Search in sources :

Example 6 with ESMFactory

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();
    }
}
Also used : ESMFactory(com.aware.ui.esms.ESMFactory) JSONException(org.json.JSONException) ESM_Number(com.aware.ui.esms.ESM_Number)

Example 7 with ESMFactory

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();
    }
}
Also used : ESMFactory(com.aware.ui.esms.ESMFactory) ESM_PAM(com.aware.ui.esms.ESM_PAM) Scheduler(com.aware.utils.Scheduler) JSONException(org.json.JSONException)

Example 8 with ESMFactory

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();
    }
}
Also used : ESMFactory(com.aware.ui.esms.ESMFactory) JSONObject(org.json.JSONObject) ESM_Question(com.aware.ui.esms.ESM_Question) JSONException(org.json.JSONException) PendingIntent(android.app.PendingIntent) Cursor(android.database.Cursor)

Example 9 with ESMFactory

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();
    }
}
Also used : ESMFactory(com.aware.ui.esms.ESMFactory) JSONException(org.json.JSONException) ESM_Checkbox(com.aware.ui.esms.ESM_Checkbox) ESM_Radio(com.aware.ui.esms.ESM_Radio)

Example 10 with ESMFactory

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();
    }
}
Also used : ESMFactory(com.aware.ui.esms.ESMFactory) JSONException(org.json.JSONException) ESM_Web(com.aware.ui.esms.ESM_Web)

Aggregations

ESMFactory (com.aware.ui.esms.ESMFactory)14 JSONException (org.json.JSONException)14 ESM_Radio (com.aware.ui.esms.ESM_Radio)5 ESM_Checkbox (com.aware.ui.esms.ESM_Checkbox)4 ESM_PAM (com.aware.ui.esms.ESM_PAM)4 ESM_QuickAnswer (com.aware.ui.esms.ESM_QuickAnswer)4 ESM_Freetext (com.aware.ui.esms.ESM_Freetext)3 ESM_Likert (com.aware.ui.esms.ESM_Likert)3 ESM_Scale (com.aware.ui.esms.ESM_Scale)3 Cursor (android.database.Cursor)2 ESM_DateTime (com.aware.ui.esms.ESM_DateTime)2 ESM_Number (com.aware.ui.esms.ESM_Number)2 ESM_Question (com.aware.ui.esms.ESM_Question)2 JSONObject (org.json.JSONObject)2 PendingIntent (android.app.PendingIntent)1 ESM_Date (com.aware.ui.esms.ESM_Date)1 ESM_Web (com.aware.ui.esms.ESM_Web)1 Scheduler (com.aware.utils.Scheduler)1 JSONArray (org.json.JSONArray)1