@Override public void show(Activity activity) { super.show(activity); activity.setContentView(R.layout.apptentive_upgrade_message_interaction); EngagementModule.engageInternal(activity, interaction.getType().name(), CODE_POINT_LAUNCH); ImageView iconView = (ImageView) activity.findViewById(R.id.icon); Drawable icon = getIconDrawableResourceId(activity); if (icon != null) { iconView.setImageDrawable(icon); } else { iconView.setVisibility(View.GONE); } WebView webview = (WebView) activity.findViewById(R.id.webview); webview.loadData(interaction.getBody(), "text/html", "UTF-8"); webview.setBackgroundColor( Color.TRANSPARENT); // Hack to keep webview background from being colored after load. // If branding is not desired, turn the view off. if (!interaction.isShowPoweredBy()) { activity.findViewById(R.id.apptentive_branding_view).setVisibility(View.GONE); } }
@Override public void show(final Activity activity) { super.show(activity); activity.setContentView(R.layout.apptentive_feedback_dialog_interaction); // Legacy support: We can remove this when we switch over to 100% interaction based Message // Center. SharedPreferences prefs = activity.getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE); prefs .edit() .putBoolean(Constants.PREF_KEY_MESSAGE_CENTER_SHOULD_SHOW_INTRO_DIALOG, false) .commit(); if (!thankYouDialogVisible) { if (!feedbackDialogVisible) { EngagementModule.engageInternal(activity, interaction.getType().name(), CODE_POINT_LAUNCH); } String title = interaction.getTitle(); final AutoCompleteTextView emailView = (AutoCompleteTextView) activity.findViewById(R.id.email); EditText messageView = (EditText) activity.findViewById(R.id.message); Button noButton = (Button) activity.findViewById(R.id.decline); final Button sendButton = (Button) activity.findViewById(R.id.submit); // Title if (title != null) { TextView titleView = (TextView) activity.findViewById(R.id.title); titleView.setText(title); } // Body String body = interaction.getBody(activity); TextView bodyView = (TextView) activity.findViewById(R.id.body); bodyView.setText(body); // Email String personEnteredEmail = PersonManager.loadPersonEmail(activity); if (!interaction.isAskForEmail()) { emailView.setVisibility(View.GONE); } else if (!Util.isEmpty(personEnteredEmail)) { emailView.setVisibility(View.GONE); email = personEnteredEmail; } else { String personInitialEmail = PersonManager.loadInitialPersonEmail(activity); if (!Util.isEmpty(personInitialEmail)) { emailView.setText(personInitialEmail); email = personInitialEmail; } String emailHintText = interaction.getEmailHintText(); if (emailHintText != null) { emailView.setHint(emailHintText); } else if (interaction.isEmailRequired()) { emailView.setHint(R.string.apptentive_edittext_hint_email_required); } // Pre-populate a list of possible emails based on those pulled from the phone. ArrayAdapter<String> emailAdapter = new ArrayAdapter<String>( activity, android.R.layout.simple_dropdown_item_1line, Util.getAllUserAccountEmailAddresses(activity)); emailView.setAdapter(emailAdapter); emailView.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { emailView.showDropDown(); return false; } }); emailView.addTextChangedListener( new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {} @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { email = charSequence; validateForm(sendButton); } @Override public void afterTextChanged(Editable editable) {} }); } // Message String messageHintText = interaction.getMessageHintText(); if (messageHintText != null) { messageView.setHint(messageHintText); } messageView.addTextChangedListener( new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {} @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { message = charSequence; validateForm(sendButton); } @Override public void afterTextChanged(Editable editable) {} }); // No String no = interaction.getDeclineText(); if (no != null) { noButton.setText(no); } noButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { cleanup(); EngagementModule.engageInternal( activity, interaction.getType().name(), CODE_POINT_DECLINE); activity.finish(); } }); // Send String send = interaction.getSubmitText(); if (send != null) { sendButton.setText(send); } sendButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { if (email != null && email.length() != 0 && !Util.isEmailValid(email.toString())) { EmailValidationFailedDialog dialog = new EmailValidationFailedDialog(activity); dialog.show(); return; } // Before we send this message, send an auto message. createMessageCenterAutoMessage(activity); sendMessage(activity); EngagementModule.engageInternal( activity, interaction.getType().name(), CODE_POINT_SUBMIT); thankYouDialogVisible = true; feedbackDialogVisible = false; activity.findViewById(R.id.feedback_dialog).setVisibility(View.GONE); activity.findViewById(R.id.thank_you_dialog).setVisibility(View.VISIBLE); } }); } else { activity.findViewById(R.id.feedback_dialog).setVisibility(View.GONE); activity.findViewById(R.id.thank_you_dialog).setVisibility(View.VISIBLE); } // Thank You Title TextView thankYouTitleView = (TextView) activity.findViewById(R.id.thank_you_title); String thankYouTitle = interaction.getThankYouTitle(); if (thankYouTitle != null) { thankYouTitleView.setText(thankYouTitle); } // Thank You Body TextView thankYouBodyView = (TextView) activity.findViewById(R.id.thank_you_body); String thankYouBody = interaction.getThankYouBody(); if (thankYouBody != null) { thankYouBodyView.setText(thankYouBody); } // Thank You Close Button Button thankYouCloseButton = (Button) activity.findViewById(R.id.thank_you_close); String thankYouCloseText = interaction.getThankYouCloseText(); if (thankYouCloseText != null) { thankYouCloseButton.setText(thankYouCloseText); } thankYouCloseButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { cleanup(); EngagementModule.engageInternal( activity, interaction.getType().name(), CODE_POINT_SKIP_VIEW_MESSAGES); activity.finish(); } }); // Thank You View Messages Button Button thankYouViewMessagesButton = (Button) activity.findViewById(R.id.thank_you_view_messages); String thankYouViewMessages = interaction.getThankYouViewMessagesText(); if (thankYouViewMessages != null) { thankYouViewMessagesButton.setText(thankYouViewMessages); } thankYouViewMessagesButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { cleanup(); EngagementModule.engageInternal( activity, interaction.getType().name(), CODE_POINT_VIEW_MESSAGES); activity.finish(); } }); feedbackDialogVisible = true; }