diff --git a/app/src/main/java/org/adl/roses/ContentActivity.java b/app/src/main/java/org/adl/roses/ContentActivity.java index 71cde99..4c57a4f 100644 --- a/app/src/main/java/org/adl/roses/ContentActivity.java +++ b/app/src/main/java/org/adl/roses/ContentActivity.java @@ -69,7 +69,7 @@ protected void mOnCreate(Bundle savedInstanceState){ "Attempt for " + getName(), "Attempt for " + getDesc(), getString(R.string.scorm_profile_activity_type_attempt_id)); - Context init_con = createContext(attempt_act, null, null, true); + Context init_con = createContext(null, attempt_act, true); // send initialize statement WriteStatementTask init_stmt_task = new WriteStatementTask(); Statement stmt = new Statement(getActor(), Verbs.initialized(), init_act); @@ -140,6 +140,13 @@ public void onClick(View v){ } }); + Button ebutton = (Button) findViewById(R.id.exit); + ebutton.setOnClickListener(new View.OnClickListener(){ + public void onClick(View v){ + exit(); + } + }); + Button pbutton = (Button) findViewById(R.id.prev); pbutton.setOnClickListener(new View.OnClickListener(){ public void onClick(View v){ @@ -154,7 +161,7 @@ public void onClick(View v){ } }); - // Check that the activity is u sing he layout version with + // Check that the activity is using the layout version with // the fragment_container FameLayout if (findViewById(R.id.textFrag) != null){ // However, if we're being restored from a previous state, @@ -264,12 +271,11 @@ protected void sendSlideChangeStatement(){ getString(R.string.scorm_profile_activity_type_attempt_id)); // Create the module attempt activity - Activity parent_attempt_act = createActivity(getString(R.string.app_activity_iri) + getPath() + "?attemptId=" + getCurrentAttempt(), - "Attempt for " + getName(), "Attempt for " + getDesc(), - getString(R.string.scorm_profile_activity_type_attempt_id)); + Activity parent_attempt_act = createActivity(getString(R.string.app_activity_iri) + getPath(), getName(), getDesc(), + getString(R.string.scorm_profile_activity_type_lesson_id)); // Create context and verb for the statement, then create statement and send it - Context slide_con = createContext(lesson_attempt_act, slide_attempt_act, parent_attempt_act, false); + Context slide_con = createContext(slide_attempt_act, parent_attempt_act, false); HashMap verb_lang = new HashMap<>(); verb_lang.put("en-US", "completed"); Verb verb = new Verb(getString(R.string.read_verb), verb_lang); @@ -279,7 +285,7 @@ protected void sendSlideChangeStatement(){ slide_init_stmt_task.execute(stmt); } - protected Context createContext(Activity lesson_attempt_act, Activity slide_attempt_act, Activity parent_attempt_act, boolean init){ + protected Context createContext(Activity slide_attempt_act, Activity parent_attempt_act, boolean init){ Context con = new Context(); ContextActivities con_acts = new ContextActivities(); @@ -288,7 +294,7 @@ protected Context createContext(Activity lesson_attempt_act, Activity slide_atte con_act_list.add(createActivity(getString(R.string.app_activity_iri), getString(R.string.app_activity_name), getString(R.string.app_activity_description), getString(R.string.scorm_profile_activity_type_course_id))); - con_act_list.add(lesson_attempt_act); + // If the statement isn't init then add the slide attempt activity /// and parent attempt activity @@ -362,6 +368,13 @@ protected void returnResult(boolean suspended){ finish(); } + protected void exit(){ + // Pressing ext terminates the module, this assumes you read the current slide + // you terminated it on + sendSlideChangeStatement(); + returnResult(false); + } + // Inner class to write statements to the LRS - returns boolean success and string result private class WriteStatementTask extends AsyncTask> { protected Pair doInBackground(Statement... params){ diff --git a/app/src/main/java/org/adl/roses/MainActivity.java b/app/src/main/java/org/adl/roses/MainActivity.java index 15a3b20..44bb102 100644 --- a/app/src/main/java/org/adl/roses/MainActivity.java +++ b/app/src/main/java/org/adl/roses/MainActivity.java @@ -14,6 +14,7 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.view.WindowManager; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.EditText; @@ -66,38 +67,25 @@ protected void onCreate(Bundle savedInstanceState) { _lrs_endpoint = prefs.getString(getString(R.string.preferences_lrs_endpoint_key), getString(R.string.default_lrs_endpoint)); _lrs_username = prefs.getString(getString(R.string.preferences_lrs_username_key), getString(R.string.default_lrs_username)); - // Silly to do this but at least have to encode the password String tmpPassword; - String tmpDefaultPassword = getString(R.string.default_lrs_password); - byte[] defaultData = null; - // Try encoding default string to bytes - try { - defaultData = tmpDefaultPassword.getBytes("UTF-8"); - } catch (UnsupportedEncodingException ex) { - Toast.makeText(getApplicationContext(), "Error encoding default password", - Toast.LENGTH_LONG).show(); - } - // If encoding was successful, encode bytes to string - if (defaultData != null) { - tmpDefaultPassword = Base64.encodeToString(defaultData, Base64.DEFAULT); - } // See if there is an existing password, it should be an encoded string String tmpExistingPassword = prefs.getString(getString(R.string.preferences_lrs_password_key), null); // If there was no existing password, just set it to the encoded default password if (tmpExistingPassword == null){ - tmpPassword = tmpDefaultPassword; + launchSettings(); } else { tmpPassword = tmpExistingPassword; + byte[] tmpBytes = Base64.decode(tmpPassword, Base64.DEFAULT); + try { + _lrs_password = new String(tmpBytes, "UTF-8"); + } catch (UnsupportedEncodingException ex) { + Toast.makeText(getApplicationContext(), "Error decoding last set password, please fix", + Toast.LENGTH_LONG).show(); + } } - byte[] tmpBytes = Base64.decode(tmpPassword, Base64.DEFAULT); - try { - _lrs_password = new String(tmpBytes, "UTF-8"); - } catch (UnsupportedEncodingException ex) { - Toast.makeText(getApplicationContext(), "Error decoding last set password, please fix", - Toast.LENGTH_LONG).show(); - } + TextView endpointView = (TextView)findViewById((R.id.lrs_endpoint_view)); endpointView.setText(_lrs_endpoint); // setup the list of content options diff --git a/app/src/main/java/org/adl/roses/SlideFragment.java b/app/src/main/java/org/adl/roses/SlideFragment.java index 22fe49d..040a7f9 100644 --- a/app/src/main/java/org/adl/roses/SlideFragment.java +++ b/app/src/main/java/org/adl/roses/SlideFragment.java @@ -2,6 +2,7 @@ import android.os.Bundle; import android.app.Fragment; +import android.text.method.ScrollingMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -22,6 +23,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, int slide_id = activity.getCurrentSlide(); // Set the fragment's textview based on which module and slide is currently active TextView txt = (TextView)myInflatedView.findViewById(R.id.fragText); + txt.setMovementMethod(new ScrollingMovementMethod()); switch (android_act_id){ case 0: switch (slide_id){ diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 2bd4c59..7d1be62 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -12,7 +12,8 @@ + android:layout_height="wrap_content" + android:layout_above="@+id/img1" /> + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_actor.xml b/app/src/main/res/layout/dialog_actor.xml index 18570bd..2edc08d 100644 --- a/app/src/main/res/layout/dialog_actor.xml +++ b/app/src/main/res/layout/dialog_actor.xml @@ -1,4 +1,3 @@ - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_buttons.xml b/app/src/main/res/layout/fragment_buttons.xml index d19190b..0520ee6 100644 --- a/app/src/main/res/layout/fragment_buttons.xml +++ b/app/src/main/res/layout/fragment_buttons.xml @@ -1,49 +1,80 @@ - - + + + + + + + + + +