public String getValidationError() { return getConfiguration().optString(KEY_VALIDATION_ERROR, null); }
@Override public String getTitle() { return getName(); }
final List<Question> questions = interaction.getQuestions(); answers = new LinkedHashMap<String, Object>(questions.size()); description.setText(interaction.getDescription()); String sendText = interaction.getSubmitText(); if (!TextUtils.isEmpty(sendText)) { send.setText(sendText);
boolean valid = validateAndUpdateState(); if (valid) { if (interaction.isShowSuccessMessage() && !TextUtils.isEmpty(interaction.getSuccessMessage())) { Toast toast = new Toast(getContext()); toast.setGravity(Gravity.FILL, 0, 0); toast.setView(toastView); TextView actionTV = ((TextView) toastView.findViewById(R.id.survey_sent_action_text)); actionTV.setText(interaction.getSuccessMessage()); int actionColor = Util.getThemeColor(getContext(), R.attr.apptentiveSurveySentToastActionColor); if (actionColor != 0) { View toastView = inflater.inflate(R.layout.apptentive_survey_invalid_toast, (LinearLayout) getView().findViewById(R.id.survey_invalid_toast_root)); toast.setView(toastView); String validationText = interaction.getValidationError(); if (!TextUtils.isEmpty(validationText)) { ((TextView) toastView.findViewById(R.id.survey_invalid_toast_text)).setText(validationText);
return new AppStoreRatingInteraction(interactionString); case Survey: return new SurveyInteraction(interactionString); case TextModal: return new TextModalInteraction(interactionString);
public List<Question> getQuestions() { String requiredText = getRequiredText(); try { InteractionConfiguration configuration = getConfiguration(); if (configuration != null && configuration.has(KEY_QUESTIONS)) { List<Question> questions = new ArrayList<Question>();
public SurveyResponsePayload(SurveyInteraction definition, Map<String, Object> answers) { super(PayloadType.survey); try { put(KEY_SURVEY_ID, definition.getId()); JSONObject answersJson = new JSONObject(); for (String key : answers.keySet()) { answersJson.put(key, answers.get(key)); } put(KEY_SURVEY_ANSWERS, answersJson); } catch (JSONException e) { ApptentiveLog.e(e, "Unable to construct survey payload."); logException(e); } }
@Test public void surveyParsing() { String json = loadTextAssetAsString(TEST_DATA_DIR + "testSurveyParsing.json"); Interaction survey = null; try { survey = new SurveyInteraction(json); } catch (Exception e) { ApptentiveLog.e(e, "Error loading survey."); } assertNotNull(survey); } }
public String getDescription() { return getConfiguration().optString(KEY_DESCRIPTION, null); }
public String getName() { return getConfiguration().optString(KEY_NAME, null); }
public boolean isShowSuccessMessage() { return getConfiguration().optBoolean(KEY_SHOW_SUCCESS_MESSAGE); }
public String getSubmitText() { return getConfiguration().optString(KEY_SUBMIT_TEXT, null); }
public String getSuccessMessage() { return getConfiguration().optString(KEY_SUCCESS_MESSAGE, null); }
public boolean isRequired() { return getConfiguration().optBoolean(KEY_REQUIRED); }
public String getRequiredText() { return getConfiguration().optString(KEY_REQUIRED_TEXT, null); }