Пример #1
0
 public static void showAlert(final ForgeTask task, @ForgeParam("text") final String text) {
   if (text.length() == 0) {
     // Error if there is no text to show
     task.error("No text entered");
     return;
   }
   task.performUI(
       new Runnable() {
         public void run() {
           AlertDialog.Builder builder = new AlertDialog.Builder(ForgeApp.getActivity());
           builder
               .setMessage(text)
               .setCancelable(false)
               .setPositiveButton(
                   "Ok",
                   new DialogInterface.OnClickListener() {
                     public void onClick(DialogInterface dialog, int which) {
                       task.success();
                     }
                   });
           AlertDialog alert = builder.create();
           alert.show();
         }
       });
 }
Пример #2
0
 public static void showSurvey(
     final ForgeTask task, @ForgeParam("tags") final JsonArray surveyTags) {
   Log.e("Tags: " + surveyTags.toString());
   // Remove duplicates and empty string tags.
   Set<String> tagSet = new HashSet<String>();
   for (int i = 0; i < surveyTags.size(); i++) {
     String tag = surveyTags.get(i).getAsString();
     if (tag.length() > 0) {
       tagSet.add(tag);
     }
   }
   final String[] tags = tagSet.toArray(new String[] {});
   task.performUI(
       new Runnable() {
         public void run() {
           Apptentive.showSurvey(
               ForgeApp.getActivity(),
               new OnSurveyFinishedListener() {
                 @Override
                 public void onSurveyFinished(boolean completed) {
                   Log.d(
                       "Firing apptentive.surveyFinishedsurvey event with parameter {%b}",
                       completed);
                   ForgeApp.event("apptentive.surveyFinished", new JsonPrimitive(completed));
                 }
               },
               tags);
         }
       });
 }
Пример #3
0
 public static void showRatingFlowIfConditionsAreMet(final ForgeTask task) {
   task.performUI(
       new Runnable() {
         public void run() {
           Apptentive.showRatingFlowIfConditionsAreMet(ForgeApp.getActivity());
         }
       });
 }
Пример #4
0
 public static void showMessageCenter(final ForgeTask task) {
   task.performUI(
       new Runnable() {
         public void run() {
           Apptentive.showMessageCenter(ForgeApp.getActivity());
           task.success();
         }
       });
 }
Пример #5
0
 public static void isSurveyAvailable(
     final ForgeTask task, @ForgeParam("tags") final JsonArray surveyTags) {
   Log.e("Tags: " + surveyTags.toString());
   String[] tags = new String[surveyTags.size()];
   for (int i = 0; i < surveyTags.size(); i++) {
     tags[i] = surveyTags.get(i).getAsString();
   }
   boolean available = Apptentive.isSurveyAvailable(ForgeApp.getActivity(), tags);
   task.success(available);
 }
Пример #6
0
 public static void getUnreadMessageCount(final ForgeTask task) {
   int count = Apptentive.getUnreadMessageCount(ForgeApp.getActivity());
   task.success(new JsonPrimitive(count));
 }
Пример #7
0
 public static void setInitialUserEmailAddress(
     final ForgeTask task,
     @ForgeParam("initialUserEmailAddress") final String initialUserEmailAddress) {
   Apptentive.setInitialUserEmail(ForgeApp.getActivity(), initialUserEmailAddress);
   task.success();
 }