use of com.aware.ui.esms.ESMFactory in project aware-client by denzilferreira.
the class TestESM method testNumeric.
private void testNumeric(Context context) {
ESMFactory factory = new ESMFactory();
try {
ESM_Number q1 = new ESM_Number();
q1.setTitle("Number").setInstructions("We only accept a number!").setSubmitButton("OK").setTrigger("AWARE Test");
factory.addESM(q1);
ESM.queueESM(context, factory.build());
} catch (JSONException e) {
e.printStackTrace();
}
}
use of com.aware.ui.esms.ESMFactory in project aware-client by denzilferreira.
the class TestScheduler method testESMTrigger.
private void testESMTrigger(Context c) {
try {
ESM_PAM esmPAM = new ESM_PAM();
esmPAM.setTitle("PAM").setInstructions("Pick the closest to how you feel right now.").setSubmitButton("OK").setNotificationTimeout(10).setTrigger("AWARE Test");
ESMFactory factory = new ESMFactory();
factory.addESM(esmPAM);
Scheduler.Schedule contextual = new Scheduler.Schedule("test_contextual");
contextual.addContext(Screen.ACTION_AWARE_SCREEN_ON);
contextual.setActionType(Scheduler.ACTION_TYPE_BROADCAST);
contextual.setActionIntentAction(ESM.ACTION_AWARE_QUEUE_ESM);
contextual.addActionExtra(ESM.EXTRA_ESM, factory.build());
Scheduler.saveSchedule(c, contextual);
} catch (JSONException e) {
e.printStackTrace();
}
}
use of com.aware.ui.esms.ESMFactory in project aware-client by denzilferreira.
the class ESM method processAppIntegration.
private static void processAppIntegration(Context context) {
try {
ESM_Question esm = null;
Cursor last_esm = context.getContentResolver().query(ESM_Data.CONTENT_URI, null, ESM_Data.STATUS + "=" + ESM.STATUS_ANSWERED, null, ESM_Data.TIMESTAMP + " DESC LIMIT 1");
if (last_esm != null && last_esm.moveToFirst()) {
JSONObject esm_question = new JSONObject(last_esm.getString(last_esm.getColumnIndex(ESM_Data.JSON)));
esm = new ESMFactory().getESM(esm_question.getInt(ESM_Question.esm_type), esm_question, last_esm.getInt(last_esm.getColumnIndex(ESM_Data._ID)));
}
if (last_esm != null && !last_esm.isClosed())
last_esm.close();
if (esm != null && esm.getAppIntegration().length() > 0) {
try {
Intent integration = new Intent(Intent.ACTION_VIEW);
integration.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
integration.setData(Uri.parse(esm.getAppIntegration()));
context.startActivity(integration);
} catch (ActivityNotFoundException e) {
Toast.makeText(context, "No application to handle: " + esm.getAppIntegration(), Toast.LENGTH_LONG).show();
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
use of com.aware.ui.esms.ESMFactory in project aware-client by denzilferreira.
the class TestESM method testOptionsOverflow.
private void testOptionsOverflow(Context context) {
ESMFactory factory = new ESMFactory();
try {
ESM_Radio q2 = new ESM_Radio();
q2.addRadio("1").addRadio("2").addRadio("3").addRadio("4").addRadio("5").addRadio("6").addRadio("7").addRadio("8").addRadio("9").addRadio("10").addRadio("11").addRadio("12").addRadio("13").addRadio("14").addRadio("15").addRadio("16").addRadio("17").addRadio("18").addRadio("19").setTitle("Too many options!!!").setSubmitButton("Visible?");
ESM_Checkbox q3 = new ESM_Checkbox();
q3.addCheck("1").addCheck("2").addCheck("3").addCheck("4").addCheck("5").addCheck("6").addCheck("7").addCheck("8").addCheck("9").addCheck("10").addCheck("11").addCheck("12").addCheck("13").addCheck("14").addCheck("15").addCheck("16").addCheck("17").addCheck("18").addCheck("19").setTitle("Too many options!!!").setSubmitButton("Visible?");
factory.addESM(q2);
factory.addESM(q3);
ESM.queueESM(context, factory.build());
} catch (JSONException e) {
e.printStackTrace();
}
}
use of com.aware.ui.esms.ESMFactory in project aware-client by denzilferreira.
the class TestESM method testESMWeb.
private void testESMWeb(Context context) {
try {
ESMFactory factory = new ESMFactory();
ESM_Web web = new ESM_Web();
web.setURL("https://www.google.com");
web.setTitle("Web survey");
web.setInstructions("Fill out this survey. Press OK when finished");
web.setSubmitButton("OK");
factory.addESM(web);
ESM.queueESM(context, factory.build());
} catch (JSONException e) {
e.printStackTrace();
}
}
Aggregations