Search in sources :

Example 1 with UserProfile

use of com.zendesk.rememberthedate.model.UserProfile in project sdk_demo_app_android by zendesk.

the class CreateProfileActivity method showStoredProfile.

private void showStoredProfile() {
    UserProfile userProfile = storage.getUserProfile();
    imageView.setOnClickListener(v -> Belvedere.from(getApplicationContext()).document().contentType("image/*").allowMultiple(false).open(CreateProfileActivity.this));
    if (userProfile.getUri() != null) {
        ImageUtils.loadProfilePicture(getApplicationContext(), userProfile.getUri(), imageView);
    }
    if (!StringUtils.hasLength(nameText.getText().toString())) {
        nameText.setText(userProfile.getName());
    }
    if (!StringUtils.hasLength(emailText.getText().toString())) {
        emailText.setText(userProfile.getEmail());
    }
}
Also used : UserProfile(com.zendesk.rememberthedate.model.UserProfile)

Example 2 with UserProfile

use of com.zendesk.rememberthedate.model.UserProfile in project sdk_demo_app_android by zendesk.

the class CreateProfileActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case android.R.id.home:
            onBackPressed();
            return true;
        case R.id.action_edit:
            final String email = emailText.getText().toString();
            final String name = nameText.getText().toString();
            if (isProfileSettable) {
                final UserProfile user = new UserProfile(name, email, uri);
                storage.storeUserProfile(user);
                updateIdentityInSdks(user);
                finish();
            }
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
Also used : UserProfile(com.zendesk.rememberthedate.model.UserProfile)

Example 3 with UserProfile

use of com.zendesk.rememberthedate.model.UserProfile in project sdk_demo_app_android by zendesk.

the class MainActivity method initialiseChatSdk.

private void initialiseChatSdk() {
    final UserProfile profile = storage.getUserProfile();
    if (StringUtils.hasLength(profile.getEmail())) {
        // Init Zopim Visitor info
        final VisitorInfo.Builder build = VisitorInfo.builder().withEmail(profile.getEmail());
        if (StringUtils.hasLength(profile.getName())) {
            build.withName(profile.getName());
        }
        Chat.INSTANCE.providers().profileProvider().setVisitorInfo(build.build(), null);
    }
}
Also used : UserProfile(com.zendesk.rememberthedate.model.UserProfile) VisitorInfo(zendesk.chat.VisitorInfo)

Example 4 with UserProfile

use of com.zendesk.rememberthedate.model.UserProfile in project sdk_demo_app_android by zendesk.

the class AppStorage method getUserProfile.

public UserProfile getUserProfile() {
    final String name = storage.getString(NAME_KEY, "");
    final String email = storage.getString(EMAIL_KEY, "");
    final String avatarUri = storage.getString(IMAGE_DATA_KEY, "");
    Uri uri = null;
    if (StringUtils.hasLength(avatarUri)) {
        uri = Uri.parse(avatarUri);
    }
    return new UserProfile(name, email, uri);
}
Also used : UserProfile(com.zendesk.rememberthedate.model.UserProfile) Uri(android.net.Uri)

Example 5 with UserProfile

use of com.zendesk.rememberthedate.model.UserProfile in project sdk_demo_app_android by zendesk.

the class ProfileFragment method onStart.

@Override
public void onStart() {
    super.onStart();
    AppStorage storage = Global.getStorage(getContext());
    UserProfile userProfile = storage.getUserProfile();
    if (userProfile.getUri() != null) {
        ImageUtils.loadProfilePicture(getContext(), userProfile.getUri(), imageView);
    }
    userName.setText(userProfile.getName());
    email.setText(userProfile.getEmail());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        userName.setTextColor(getResources().getColor(R.color.primaryTextColor, getActivity().getTheme()));
        email.setTextColor(getResources().getColor(R.color.primaryTextColor, getActivity().getTheme()));
    }
}
Also used : UserProfile(com.zendesk.rememberthedate.model.UserProfile) AppStorage(com.zendesk.rememberthedate.storage.AppStorage)

Aggregations

UserProfile (com.zendesk.rememberthedate.model.UserProfile)5 Uri (android.net.Uri)1 AppStorage (com.zendesk.rememberthedate.storage.AppStorage)1 VisitorInfo (zendesk.chat.VisitorInfo)1