Esempio n. 1
0
  @Override
  public void onConnected(Bundle bundle) {
    if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
      Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
      String personName = currentPerson.getDisplayName();
      String personPhoto = currentPerson.getImage().getUrl();
      String firstName = currentPerson.getName().getGivenName();
      String lastName = currentPerson.getName().getFamilyName();
      String personGooglePlusProfile = currentPerson.getUrl();
      String date = currentPerson.getBirthday();
      if (date == null) {
        date = "";
      }
      int gender = currentPerson.getGender();
      String email = Plus.AccountApi.getAccountName(mGoogleApiClient);

      Intent mIntent = new Intent(getActivity(), LoginUserDetails.class);
      mIntent.putExtra("login_method", "google");
      mIntent.putExtra("email", email);
      mIntent.putExtra("first_name", firstName);
      mIntent.putExtra("gender", gender);
      mIntent.putExtra("last_name", lastName);
      mIntent.putExtra("photo", personPhoto);

      mixpanel.track("Login - Google");
      startActivity(mIntent);
    } else {
      Toast.makeText(getContext(), "You do not have a google+ account", Toast.LENGTH_SHORT).show();
      showSocialLoginDialog();
    }

    Log.d(TAG, "onConnected:" + bundle);
    mShouldResolve = false;
  }
  /** Fetching user's information name, email, profile pic */
  private void getProfileInformation() {
    try {
      if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
        Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
        personName = currentPerson.getDisplayName();
        String personPhotoUrl = currentPerson.getImage().getUrl();
        String personGooglePlusProfile = currentPerson.getUrl();
        email = Plus.AccountApi.getAccountName(mGoogleApiClient);

        Log.e(
            TAG,
            "Name: "
                + personName
                + ", plusProfile: "
                + personGooglePlusProfile
                + ", email: "
                + email
                + ", Image: "
                + personPhotoUrl);

      } else {
        Toast.makeText(getApplicationContext(), "Person information is null", Toast.LENGTH_LONG)
            .show();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  /** * Fetching user's information name, email, profile pic * */
  private void getProfileInformation() {
    try {
      if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
        Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
        String personName = currentPerson.getDisplayName();
        String personPhotoUrl = currentPerson.getImage().getUrl();
        String personGooglePlusProfile = currentPerson.getUrl();
        String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
        Log.e(
            TAG,
            "Name: "
                + personName
                + ", plusProfile: "
                + personGooglePlusProfile
                + ", email: "
                + email
                + ", Image: "
                + personPhotoUrl);

        Toast.makeText(
                getApplicationContext(),
                "Signed In as:" + currentPerson.getDisplayName(),
                Toast.LENGTH_LONG)
            .show();
        if (!sharedPref.contains("UID")) {
          int Applicationid = getUID();
          saveSharedint("UID", Applicationid);
        }

        long DS = getDataValue(context);
        long DC = getFolderSize() + DS;
        String DataS = l2bytes(DS, false);
        String DataC = l2bytes(DC, false);

        long hours = CommonUtils.totaltime / 3600;
        long minutes = (CommonUtils.totaltime % 3600) / 60;
        long seconds = (long) ((CommonUtils.totaltime % 3600) % 60);

        txtDatasent.setText("Data Sent :" + DataS);
        txtDatasent.setAnimation(null);

      } else {
        Toast.makeText(getApplicationContext(), "Person information is null", Toast.LENGTH_LONG)
            .show();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  // Implements ConnectionCallbacks
  @Override
  public void onConnected(Bundle arg0) {
    // TODO Auto-generated method stub
    Person user = mPlusClient.getCurrentPerson();

    // show The Image
    new DownloadImageTask(imageView).execute(user.getImage().getUrl());

    textViewName.setText(user.getDisplayName());
    textViewUrl.setText(user.getUrl());
    textViewBday.setText(user.getBirthday());
    textViewEmail.setText(user.getEmails() != null ? user.getEmails().get(0).getValue() : "");
    textViewGender.setText(user.getGender() == 0 ? "Male" : "Female");

    buttonSignIn.setVisibility(View.GONE);
    relativeLayout.setVisibility(View.VISIBLE);

    mPlusClient.loadPeople(this, Person.Collection.VISIBLE);
  }
  @Override
  public void onConnected(Bundle bundle) {
    if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
      BrewSharedPrefs.setIsUserLoggedIn(true);
      Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
      BrewSharedPrefs.setFullName(currentPerson.getDisplayName());
      String personPhoto = currentPerson.getImage().getUrl();

      try {
        URL url = new URL(personPhoto);
        personPhoto = personPhoto.replace(url.getQuery(), "");
      } catch (MalformedURLException e) {
        e.printStackTrace();
      }

      BrewSharedPrefs.setGoolgePlusProfileUrl(currentPerson.getUrl());
      BrewSharedPrefs.setUserProfileImageUrl(personPhoto);
      BrewSharedPrefs.setEmailAddress(Plus.AccountApi.getAccountName(mGoogleApiClient));
      PlusAccountSetup();
    }
  }
Esempio n. 6
0
  public void getProfileInformation() {
    try {
      if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
        Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
        String personName = currentPerson.getDisplayName();
        String personPhotoUrl = currentPerson.getImage().getUrl();
        String personGooglePlusProfile = currentPerson.getUrl();
        String email = Plus.AccountApi.getAccountName(mGoogleApiClient);

        Log.e(
            TAG,
            "Name: "
                + personName
                + ", plusProfile: "
                + personGooglePlusProfile
                + ", email: "
                + email
                + ", Image: "
                + personPhotoUrl);

        profileName.setText(personName);
        profileEmail.setText(email);

        // by default the profile url gives 50x50 px image only
        // we can replace the value with whatever dimension we want by
        // replacing sz=X
        personPhotoUrl =
            personPhotoUrl.substring(0, personPhotoUrl.length() - 2) + PROFILE_PIC_SIZE;

        new LoadProfileImage(imgProfilePic).execute(personPhotoUrl);

      } else {
        Toast.makeText(getApplicationContext(), "Person information is null", Toast.LENGTH_LONG)
            .show();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  /** Fetching user's information name, email, profile picture */
  private void getGGProfileInformation() {
    Log.e(tag, "getGGProfileInformation");
    try {
      if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
        Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
        String personGooglePlusProfile = currentPerson.getUrl();

        Log.e(tag, currentPerson.toString());

        String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
        String id = currentPerson.getId();
        String name = new String(currentPerson.getDisplayName().getBytes("UTF-8"), "UTF-8");
        String birthday = "";
        if (currentPerson.getBirthday() != null) {
          birthday = currentPerson.getBirthday();
        }
        String gender = currentPerson.getGender() == 1 ? "men" : "women";
        String avatar = currentPerson.getImage().getUrl();
        Log.e(
            tag,
            "Name: "
                + name
                + ", plusProfile: "
                + personGooglePlusProfile
                + ", email: "
                + email
                + ", Image: "
                + avatar
                + ", birthday: "
                + birthday);

        new GGLoginTask().execute(name, email, avatar, gender, birthday, id);
      } else {
        Log.e(tag, "Person information is null");
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }