@Override public void onClick(View view) { JSONObject data = new JSONObject(); try { data.put(TextModalInteraction.EVENT_KEY_ACTION_ID, buttonAction.getId()); data.put(Action.KEY_LABEL, buttonAction.getLabel()); data.put(TextModalInteraction.EVENT_KEY_ACTION_POSITION, position); } catch (JSONException e) { ApptentiveLog.e(e, "Error creating Event data object."); logException(e); } engageInternal(TextModalInteraction.EVENT_NAME_DISMISS, data.toString()); transit(); } }));
int totalChars = 0; for (Action button : actions) { totalChars += button.getLabel().length(); final int position = i; Button button = (Button) inflater.inflate(R.layout.apptentive_textmodal_interaction_button, bottomArea, false); button.setText(buttonAction.getLabel()); switch (buttonAction.getType()) { case dismiss:
try { data.put(TextModalInteraction.EVENT_KEY_ACTION_ID, action.getId()); data.put(Action.KEY_LABEL, action.getLabel()); data.put(TextModalInteraction.EVENT_KEY_ACTION_POSITION, index); data.put(TextModalInteraction.KEY_DISPLAY_TYPE, interaction.getDisplayType().name());
builder.addAction(new NotificationCompat.Action.Builder(0, action.getLabel(), pendingIntent).build());
try { data.put(TextModalInteraction.EVENT_KEY_ACTION_ID, action.getId()); data.put(Action.KEY_LABEL, action.getLabel()); data.put(TextModalInteraction.EVENT_KEY_ACTION_POSITION, index); data.put(TextModalInteraction.EVENT_KEY_INVOKED_INTERACTION_ID, invokedInteraction == null ? JSONObject.NULL : invokedInteraction.getId());
try { data.put(TextModalInteraction.EVENT_KEY_ACTION_ID, buttonAction.getId()); data.put(Action.KEY_LABEL, buttonAction.getLabel()); data.put(TextModalInteraction.EVENT_KEY_ACTION_POSITION, position); data.put(TextModalInteraction.EVENT_KEY_INVOKED_INTERACTION_ID, invokedInteraction == null ? JSONObject.NULL : invokedInteraction.getId());
@Test public void textModalInteraction() { String json = loadTextAssetAsString(TEST_DATA_DIR + "/testTextModalInteraction.json"); Interaction interaction = Interaction.Factory.parseInteraction(json); assertTrue(interaction.getType().equals(Interaction.Type.TextModal)); TextModalInteraction textModalInteraction = (TextModalInteraction) interaction; assertEquals("548cc5dd49f63bb5c2000001", textModalInteraction.getId()); assertEquals("External Deep Links", textModalInteraction.getTitle()); assertEquals("This example allow testing how external deep links are opened.", textModalInteraction.getBody()); List<Action> actions = textModalInteraction.getActions().getAsList(); { Action action = actions.get(0); assertEquals("eBay - Same Task", action.getLabel()); assertTrue(action.getType().equals(Action.Type.interaction)); } } }