Example usage for android.app Person toString

List of usage examples for android.app Person toString

Introduction

In this page you can find the example usage for android.app Person toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.apptentive.android.sdk.module.messagecenter.ApptentiveMessageCenter.java

static void showIntroDialog(final Activity activity, boolean emailRequired) {
    final MessageCenterIntroDialog dialog = new MessageCenterIntroDialog(activity);
    dialog.setEmailRequired(emailRequired);

    String personEnteredEmail = PersonManager.loadPersonEmail(activity);
    String personInitialEmail = PersonManager.loadInitialPersonEmail(activity);
    if (Util.isEmpty(personEnteredEmail)) {
        if (!Util.isEmpty(personInitialEmail)) {
            dialog.setEmailFieldHidden(false);
            dialog.prePopulateEmail(personInitialEmail);
        }//from w w w. j  ava 2s.c o m
    } else {
        dialog.setEmailFieldHidden(true);
    }
    dialog.setCanceledOnTouchOutside(false);

    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialogInterface) {
            MetricModule.sendMetric(activity, Event.EventLabel.message_center__intro__cancel);
            dialog.dismiss();
        }
    });

    dialog.setOnSendListener(new MessageCenterIntroDialog.OnSendListener() {
        @Override
        public void onSend(String email, String message) {
            SharedPreferences prefs = activity.getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE);
            prefs.edit().putBoolean(Constants.PREF_KEY_MESSAGE_CENTER_SHOULD_SHOW_INTRO_DIALOG, false).commit();
            // Save the email.
            if (dialog.isEmailFieldVisible()) {
                if (email != null && email.length() != 0) {
                    PersonManager.storePersonEmail(activity, email);
                    Person person = PersonManager.storePersonAndReturnDiff(activity);
                    if (person != null) {
                        Log.d("Person was updated.");
                        Log.v(person.toString());
                        ApptentiveDatabase.getInstance(activity).addPayload(person);
                    } else {
                        Log.d("Person was not updated.");
                    }
                }
            }
            // Send the message.
            final TextMessage textMessage = new TextMessage();
            textMessage.setBody(message);
            textMessage.setRead(true);
            textMessage.setCustomData(customData);
            customData = null;
            MessageManager.sendMessage(activity, textMessage);
            MetricModule.sendMetric(activity, Event.EventLabel.message_center__intro__send);
            dialog.dismiss();

            final MessageCenterThankYouDialog messageCenterThankYouDialog = new MessageCenterThankYouDialog(
                    activity);
            messageCenterThankYouDialog.setValidEmailProvided(email != null && Util.isEmailValid(email));
            messageCenterThankYouDialog
                    .setOnChoiceMadeListener(new MessageCenterThankYouDialog.OnChoiceMadeListener() {
                        @Override
                        public void onNo() {
                            MetricModule.sendMetric(activity,
                                    Event.EventLabel.message_center__thank_you__close);
                        }

                        @Override
                        public void onYes() {
                            MetricModule.sendMetric(activity,
                                    Event.EventLabel.message_center__thank_you__messages);
                            show(activity);
                        }
                    });
            MetricModule.sendMetric(activity, Event.EventLabel.message_center__thank_you__launch);
            messageCenterThankYouDialog.show();
        }
    });

    String appDisplayName = Configuration.load(activity).getAppDisplayName();
    switch (trigger) {
    case enjoyment_dialog:
        dialog.setTitle(R.string.apptentive_intro_dialog_title_no_love);
        dialog.setBody(
                activity.getResources().getString(R.string.apptentive_intro_dialog_body, appDisplayName));
        break;
    case message_center:
        dialog.setTitle(R.string.apptentive_intro_dialog_title_default);
        dialog.setBody(
                activity.getResources().getString(R.string.apptentive_intro_dialog_body, appDisplayName));
        break;
    default:
        return;
    }
    MetricModule.sendMetric(activity, Event.EventLabel.message_center__intro__launch, trigger.name());
    dialog.show();
}

From source file:com.apptentive.android.sdk.Apptentive.java

/**
 * Sends current Person to the server if it differs from the last time it was sent.
 *
 * @param context/*w  w  w  .j  a  va  2  s.c  o  m*/
 */
private static void syncPerson(Context context) {
    Person person = PersonManager.storePersonAndReturnDiff(context);
    if (person != null) {
        Log.d("Person was updated.");
        Log.v(person.toString());
        ApptentiveDatabase.getInstance(context).addPayload(person);
    } else {
        Log.d("Person was not updated.");
    }
}