// [START handleSignInResult] private void handleSignInResult(GoogleSignInResult result) { Log.d(TAG, "handleSignInResult:" + result.isSuccess()); if (result.isSuccess()) { // Signed in successfully, show authenticated UI. GoogleSignInAccount acct = result.getSignInAccount(); String emailPref = acct.getEmail(); Log.d(TAG, " Handle signIn email of user" + emailPref); PrefUtils.setEmail(this, emailPref); // save Acct Name String namePref = acct.getDisplayName(); PrefUtils.setPersonKey(this, namePref); Uri mPhoto = acct.getPhotoUrl(); if (mPhoto != null) { // personPhotoUrl = acct.getPhotoUrl().toString(); personPhotoUrl = mPhoto.toString(); Log.e(TAG, "Profile Image" + personPhotoUrl); personPhotoUrl = personPhotoUrl.substring(0, personPhotoUrl.length() - 2) + PROFILE_PIC_SIZE; new LoadProfileImage().execute(personPhotoUrl); } else { Bitmap def = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher); PrefUtils.setPhoto(this, def); Log.e(TAG, "Converted Launcher ICOn " + def); Toast.makeText(this, "Profile Loaded, Registering User", Toast.LENGTH_SHORT).show(); registerUser(); } } else { // Signed out, show unauthenticated UI. Toast.makeText( this, "Ensure you are connected to a Network to be able to Sign In", Toast.LENGTH_SHORT) .show(); // signOutUser(); RC_SIGN_IN++; // btEnter.setVisibility(View.GONE); // btnSignIn.setVisibility(View.VISIBLE); /*signOutUser(); Toast.makeText(this, "An Error Occured, Check your Network Connection Settings",Toast.LENGTH_SHORT).show(); btEnter.setVisibility(View.GONE); btnSignIn.setVisibility(View.VISIBLE);*/ // updateUI(false); } }
private void registerUser() { String name = etName.getText().toString().trim().toLowerCase(); String phone = etPhone.getText().toString().trim().toLowerCase(); String email = PrefUtils.getEmail(this); String mName = PrefUtils.getPersonal(this); String rName = ""; try { rName = URLEncoder.encode(mName, "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } String uuid = UUID.randomUUID().toString(); Log.e(TAG, "REGISTERING EMAIL " + email); register(name, phone, email, uuid, rName); }
protected void onPostExecute(Bitmap result) { this.bitmap = result; Log.e(TAG, "ONPOSTEXECUTE result " + result); bmImage.setImageBitmap(result); // buttonContainer.setBackgroundResource(R.drawable.transparent_button); // btnSignIn.setProgress(0); // Toast.makeText(Login.this,"Profile Loaded", Toast.LENGTH_SHORT).show(); if (result != null) { PrefUtils.setPhoto(Login.this, result); String m = PrefUtils.encodeTobase64(result); Log.e(TAG, "Encoded Profile image " + m); registerUser(); } else { /*Bitmap def = BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher); PrefUtils.setPhoto(context,def); Log.e(TAG, "Converted Launcher ICOn " + def); Toast.makeText(Login.this, "Invalid image", Toast.LENGTH_SHORT).show();*/ } // registerUser(); }
@Override protected void onPostExecute(String s) { super.onPostExecute(s); ; Toast.makeText(Login.this, s, Toast.LENGTH_SHORT).show(); hidepDialog(); Log.e(TAG, "isSignedIn before Subject combination " + isSignedIn); if (s.contains("success")) { try { JSONObject json = new JSONObject(s); String id = json.getString("id"); Log.e(TAG, "Printed ID " + id); PrefUtils.setUniqueId(Login.this, id); } catch (JSONException e) { e.printStackTrace(); } subjectCombination(); } else Log.e(TAG, "Signed out in doIn background " + isSignedIn); signOutUser(); }