Skip to content
This repository was archived by the owner on Oct 23, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions app/src/main/java/org/adl/roses/ContentActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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){
Expand All @@ -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,
Expand Down Expand Up @@ -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<String, String> verb_lang = new HashMap<>();
verb_lang.put("en-US", "completed");
Verb verb = new Verb(getString(R.string.read_verb), verb_lang);
Expand All @@ -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();

Expand All @@ -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
Expand Down Expand Up @@ -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<Statement, Void, Pair<Boolean, String>> {
protected Pair<Boolean, String> doInBackground(Statement... params){
Expand Down
32 changes: 10 additions & 22 deletions app/src/main/java/org/adl/roses/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/org/adl/roses/SlideFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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){
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<ListView
android:id="@+id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content"
android:layout_above="@+id/img1" />

<ImageView
android:id="@+id/img1"
Expand All @@ -33,4 +34,5 @@
android:layout_marginRight="50dp"
/>


</RelativeLayout>
32 changes: 7 additions & 25 deletions app/src/main/res/layout/dialog_actor.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
Expand All @@ -9,32 +8,23 @@
android:inputType="text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="4dp"

android:text="Name" />

<EditText
android:id="@+id/account_name"
android:inputType="text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="4dp"

android:text="Account Name" />

<EditText
android:id="@+id/account_homepage"
android:inputType="textUri"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="16dp"

android:text="Account Homepage" />

<TextView android:id="@+id/lrs_endpoint_text"
Expand All @@ -47,31 +37,23 @@
android:inputType="textUri"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="16dp"

android:text="LRS Endpoint" />

<EditText
android:id="@+id/lrs_username"
android:inputType="text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="16dp"

android:text="LRS Username" />

<EditText
android:id="@+id/lrs_password"
android:inputType="textPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="16dp"

android:visibility="visible"
android:hint="LRS Password"/>
</LinearLayout>
83 changes: 57 additions & 26 deletions app/src/main/res/layout/fragment_buttons.xml
Original file line number Diff line number Diff line change
@@ -1,49 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">

<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<RelativeLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:id="@+id/img1"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="bottom"
android:paddingBottom="16dp"
android:paddingRight="16dp"
android:scaleType="centerCrop"
android:src="@drawable/corner" />



</RelativeLayout>
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/img1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="16dp"
android:layout_gravity="center_horizontal"
android:orientation="horizontal">

<Button
android:id="@+id/prev"
android:layout_gravity="center_horizontal"
android:id="@+id/prev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/previous_button"
android:textColor="#FFFFFF"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="16dp"
android:background="#33B5E5"
/>
android:text="@string/previous_button"
android:textColor="#FFFFFF" />

<Button
android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/next_button"
android:textColor="#FFFFFF"
android:layout_marginLeft="8dp"
android:background="#33B5E5"
/>
android:text="@string/next_button"
android:textColor="#FFFFFF" />

<Button
android:id="@+id/suspend"
android:layout_marginLeft="@dimen/suspend_button_margin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/suspend_button"
android:textColor="#FFFFFF"
android:layout_marginLeft="@dimen/suspend_button_margin"
android:background="#1395C5"
/>
android:text="@string/suspend_button"
android:textColor="#FFFFFF" />

</LinearLayout>

<ImageView
android:id="@+id/img1"
android:src="@drawable/corner"
<Button
android:id="@+id/exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
/>
</LinearLayout>
android:layout_gravity="bottom"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="#1395C5"
android:text="Exit"
android:textColor="#FFFFFF"
android:layout_alignParentBottom="true" />
</FrameLayout>
9 changes: 6 additions & 3 deletions app/src/main/res/layout/fragment_slide.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
tools:context="org.adl.roses.SlideFragment">

<TextView android:id="@+id/fragText"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
android:scrollbars = "vertical"
android:lines="7"
/>

</FrameLayout>
</ScrollView>