Skip to content

Commit

Permalink
Merge pull request #16 from cmsc436/pre-demo
Browse files Browse the repository at this point in the history
Pre demo
  • Loading branch information
0queue authored May 2, 2017
2 parents fcc1894 + 3b6fc59 commit 013f3ae
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 27 deletions.
9 changes: 7 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme.ColorBlind">
<activity android:name=".IntroActivity">
<activity
android:name=".IntroActivity"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

Expand All @@ -19,10 +21,13 @@
</activity>
<activity
android:name=".ui.CoordinatorActivity"
android:screenOrientation="landscape"
android:theme="@style/AppTheme.Fullscreen">
</activity>

<activity android:name=".MainActivity"/>
<activity
android:name=".MainActivity"
android:screenOrientation="landscape"/>
</application>

</manifest>
16 changes: 9 additions & 7 deletions app/src/main/java/edu/umd/cmsc436/mstestsuite/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.Comparator;

import edu.umd.cmsc436.mstestsuite.data.ActionsAdapter;
import edu.umd.cmsc436.mstestsuite.ui.CoordinatorActivity;
import edu.umd.cmsc436.sheets.Sheets;

public class MainActivity extends AppCompatActivity implements MainContract.View, Sheets.Host {
Expand Down Expand Up @@ -308,6 +309,8 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
mPresenter.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CODE_INSTALL) {
mPresenter.onPackageInstalled();
} else if (requestCode == CoordinatorActivity.REQUEST_CODE) {
mPresenter.onCoordinatorDone();
}
}

Expand Down Expand Up @@ -341,6 +344,12 @@ public Activity getActivity() {
@Override
public void installPackage(File f) throws IOException {

if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
mInstallCache = f;
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_EXTERNAL_PERMISSION);
return;
}

FileChannel inChannel = new FileInputStream(f).getChannel();
File downloadsFolder = getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);

Expand All @@ -354,13 +363,6 @@ public void installPackage(File f) throws IOException {
FileChannel outChannel = new FileOutputStream(outFile).getChannel();


if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
mInstallCache = f;
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_EXTERNAL_PERMISSION);
return;
}


try {
inChannel.transferTo(0, inChannel.size(), outChannel);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ interface Presenter {
void onActivityResult(int requestCode, int resultCode, Intent data);
void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults);
void onPackageInstalled ();
void onCoordinatorDone ();
}
}
28 changes: 25 additions & 3 deletions app/src/main/java/edu/umd/cmsc436/mstestsuite/MainPresenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.BottomSheetBehavior;
import android.util.Log;

import java.io.File;
Expand Down Expand Up @@ -52,11 +53,19 @@ public void run() {
}
}),
new Action("Feedback", R.drawable.ic_feedback, null),
new Action("Refresh", R.drawable.ic_refresh_prescription, new Runnable() {
@Override
public void run() {
mMainAdapter.setEnabled(0, false);
mSheet.fetchPrescription(mUserManager.getCurUserID(), MainPresenter.this);
}
})
};

private MainContract.View mView;

private boolean isPractice;
private boolean isBottomSheetExpanded;
private Map<File, Float> mToInstall;

private UserManager mUserManager;
Expand All @@ -73,6 +82,7 @@ public void run() {
mView.hideBottomSheet();

isPractice = false;
isBottomSheetExpanded = false;

mUserManager = new UserManager(mView.getContext());
if (mUserManager.getCurUserID() == null) {
Expand Down Expand Up @@ -100,12 +110,13 @@ public void run() {

@Override
public void onDailyStart() {
CoordinatorActivity.start(mView.getContext(), mUserManager.getCurUserID(), mAllDifficulties, mNumTrials);
CoordinatorActivity.start(mView.getActivity(), mUserManager.getCurUserID(), mAllDifficulties, mNumTrials);
}

@Override
public void onCloseBottomSheet() {
mView.collapseBottomSheet();
isBottomSheetExpanded = false;
}

@Override
Expand All @@ -115,12 +126,16 @@ public void onBottomSheetSlide() {

@Override
public void onBottomSheetStateChange(int newState) {
// nothing
isBottomSheetExpanded = newState == BottomSheetBehavior.STATE_EXPANDED;
}

@Override
public boolean onBackPressed() {
if (isPractice) {
if (isBottomSheetExpanded) {
isBottomSheetExpanded = false;
mView.collapseBottomSheet();
return false;
} else if (isPractice) {
isPractice = false;
mView.loadActions(mMainAdapter);
return false;
Expand Down Expand Up @@ -161,6 +176,12 @@ public void onPackageInstalled() {
installFirst();
}

@Override
public void onCoordinatorDone() {
mView.hideBottomSheet();
isBottomSheetExpanded = false;
}

@Override
public void onAppSelected(TestApp app) {
try {
Expand Down Expand Up @@ -271,6 +292,7 @@ public void onCheckFinished(Map<String, Float> versionMap) {
public void run() {
mMainAdapter.setEnabled(0, true);
mView.expandBottomSheet();
isBottomSheetExpanded = true;
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package edu.umd.cmsc436.mstestsuite.ui;

import android.annotation.SuppressLint;
import android.content.Context;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
Expand All @@ -24,13 +24,14 @@ public class CoordinatorActivity extends AppCompatActivity implements Sheets.Hos
private static final String KEY_PID = "patient id";
private static final String KEY_DIFFICULTIES = "difficulties";
private static final String KEY_N_TRIALS = "number of trials";
public static final int REQUEST_CODE = 789;

public static void start(Context context, String patientId, int[] difficulties, int n_trials) {
Intent starter = new Intent(context, CoordinatorActivity.class);
public static void start(Activity activity, String patientId, int[] difficulties, int n_trials) {
Intent starter = new Intent(activity, CoordinatorActivity.class);
starter.putExtra(KEY_PID, patientId);
starter.putExtra(KEY_DIFFICULTIES, difficulties);
starter.putExtra(KEY_N_TRIALS, n_trials);
context.startActivity(starter);
activity.startActivityForResult(starter, REQUEST_CODE);
}

private String mCurPatient;
Expand Down
47 changes: 47 additions & 0 deletions app/src/main/res/drawable/ic_refresh_prescription.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="300dp"
android:height="300dp"
android:viewportWidth="300"
android:viewportHeight="300">

<path
android:strokeColor="#231F20"
android:strokeWidth="9.5101"
android:strokeMiterLimit="10"
android:pathData="M 82.5 126 H 217.8 V 226.5 H 82.5 V 126 Z" />
<path
android:strokeColor="#231F20"
android:strokeWidth="10"
android:strokeMiterLimit="10"
android:pathData="M82,228v13.1c0,11.4,9,23.9,18.2,23.9h102c9.2,0,14.8-12.6,14.8-23.9V228H82z" />
<path
android:fillColor="#231F20"
android:pathData="M89.5,121.5c-0.7-4.8,6.9-12.4,9.9-15.5c4.4-4.4,10.1-7.1,14.9-10.9c9.4-7.6,14.4-19.5,13.8-31.5
c-0.4-7.4-11.9-7.4-11.5,0c0.3,6.4-1.1,12.5-4.9,17.7c-3.8,5.4-9.7,8.2-14.9,12c-5.3,3.9-9.4,8.9-13.2,14.2
c-3.9,5.3-6.1,10.4-5.2,17.1C79.5,131.8,90.6,128.7,89.5,121.5L89.5,121.5z" />
<path
android:fillColor="#231F20"
android:pathData="M221.7,124.5c1.8-12.2-9.1-24.5-18.4-31.3c-5.2-3.8-11.1-6.6-14.9-12c-3.8-5.2-5.2-11.3-4.9-17.7
c0.4-7.4-11.1-7.4-11.5,0c-0.6,12,4.4,23.9,13.8,31.5c4.6,3.7,10.1,6.3,14.3,10.3c2.5,2.4,4.5,5.1,6.5,7.8c1.5,2.1,4.4,5.4,4,8.2
C209.6,128.7,220.7,131.8,221.7,124.5L221.7,124.5z" />
<path
android:fillColor="#231F20"
android:strokeColor="#231F20"
android:strokeWidth="2.3028"
android:strokeMiterLimit="10"
android:pathData="M153.2,208.1h-3.9c-2.5,0-4.6-2.1-4.6-4.6v-52.8c0-2.5,2.1-4.6,4.6-4.6h3.9c2.5,0,4.6,2.1,4.6,4.6v52.8
C157.8,206.1,155.7,208.1,153.2,208.1z" />
<path
android:fillColor="#231F20"
android:strokeColor="#231F20"
android:strokeWidth="2.3028"
android:strokeMiterLimit="10"
android:pathData="M119.2,179.1v-3.9c0-2.5,2.1-4.6,4.6-4.6h52.8c2.5,0,4.6,2.1,4.6,4.6v3.9c0,2.5-2.1,4.6-4.6,4.6h-52.8
C121.3,183.7,119.2,181.6,119.2,179.1z" />
<path
android:strokeColor="#231F20"
android:strokeWidth="9.2696"
android:strokeMiterLimit="10"
android:pathData="M 103.1 35.3 H 193.7 V 60.1 H 103.1 V 35.3 Z" />
</vector>
15 changes: 8 additions & 7 deletions app/src/main/res/layout/activity_intro_1.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/fab_margin">
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/fab_margin">

<TextView
android:layout_width="wrap_content"
Expand All @@ -15,13 +15,14 @@
android:textAlignment="center"
android:textColor="@android:color/black"
android:textSize="40sp"
android:textStyle="bold" />
android:textStyle="bold"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="30dp"
android:text="@string/intro_instructions"
android:textColor="@android:color/black" />
android:textAppearance="?android:textAppearanceLarge"
android:textColor="@android:color/black"/>

</LinearLayout>
5 changes: 1 addition & 4 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
<string name="main_actions_header">Welcome, %s</string>

<string name="icon_for_current_test">Icon for current test</string>
<string name="intro_instructions">This application is designed to … \n\n There will be a
number of tests that you will complete on a given day. When you do not have a selection
of tests to perform for a day, you can practice these tests through this app as well.
\n\n You also are able to track your progress among each test. </string>
<string name="intro_instructions">This application is designed to track your performance on various tests.\n\nEach time you open this application, if you have tests assigned by your doctor, there will be a pop-up asking you to complete them. If you choose not to complete them in that given moment, you can come back to them by clicking the DAILY button. You also have the option to practice the various tests prescribed. You are also able to track your progress within each test.\n\nIf there are problems when completing your test, you can go to the feedback section to report the problems, which will be sent to your doctor.</string>
<string name="introscreen_continue">ENTER</string>
<string name="introscreen_next_text">NEXT</string>
<string name="welcome">Welcome to the Test Suite</string>
Expand Down

0 comments on commit 013f3ae

Please sign in to comment.