Skip to content

Commit 68514b5

Browse files
author
Daniil Efremov
authored
Merge pull request #52 from dividiti/issue-final
final pre release issues
2 parents 69d61df + ff3b67e commit 68514b5

File tree

4 files changed

+84
-8
lines changed

4 files changed

+84
-8
lines changed

app/src/main/java/openscience/crowdsource/video/experiments/AppConfigService.java

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public Thread newThread(Runnable r) {
8080
public static final Executor THREAD_POOL_EXECUTOR
8181
= new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE,
8282
TimeUnit.SECONDS, sPoolWorkQueue, sThreadFactory);
83+
public static final String OLD_VERSION_FILE_NAME = "email.txt";
8384

8485
private static Updater previewRecognitionTextUpdater;
8586

@@ -324,18 +325,45 @@ synchronized public static void updateState(AppConfig.State state) {
324325
saveAppConfig(appConfig);
325326
}
326327

328+
private static String tryGetOldEmail() {
329+
String oldEmail = Utils.readOneStringFile(APP_CONFIG_DIR + File.separator + OLD_VERSION_FILE_NAME);
330+
if (oldEmail != null) {
331+
updateEmail(oldEmail);
332+
return oldEmail;
333+
} else {
334+
return "";
335+
}
336+
}
337+
327338
synchronized public static String getEmail() {
328339
AppConfig appConfig = loadAppConfig();
329340
if (appConfig == null) {
330-
return "";
341+
return tryGetOldEmail();
331342
}
332343
String email = appConfig.getEmail();
333344
if (email == null) {
334-
return "";
345+
return tryGetOldEmail();
335346
}
336347
return email;
337348
}
338349

350+
synchronized public static void updateResultURL(String value) {
351+
AppConfig appConfig = loadAppConfig();
352+
if (appConfig == null) {
353+
appConfig = new AppConfig();
354+
}
355+
appConfig.setResultURL(value);
356+
saveAppConfig(appConfig);
357+
}
358+
359+
synchronized public static String getResultURL() {
360+
AppConfig appConfig = loadAppConfig();
361+
if (appConfig == null) {
362+
return null;
363+
}
364+
return appConfig.getResultURL();
365+
}
366+
339367
public static void saveAppConfig(AppConfig appConfig) {
340368
try {
341369
JSONObject scenariosJSON = appConfig.toJSONObject();
@@ -380,6 +408,7 @@ public enum State {
380408
public static final String BEHAVIOR_UID = "behavior_uid";
381409
public static final String STATE_PARAM = "state";
382410
public static final String LOCAL_APP_PATH = "local_app_path";
411+
public static final String RESULT_URL = "result_url";
383412

384413
private String email;
385414
private String actualImagePath;
@@ -393,6 +422,7 @@ public enum State {
393422
private State state;
394423
private String localAppPath;
395424
private String previewRecognitionText;
425+
private String resultURL;
396426

397427
public String getEmail() {
398428
return email;
@@ -482,6 +512,14 @@ public void setPreviewRecognitionText(String previewRecognitionText) {
482512
this.previewRecognitionText = previewRecognitionText;
483513
}
484514

515+
public String getResultURL() {
516+
return resultURL;
517+
}
518+
519+
public void setResultURL(String resultURL) {
520+
this.resultURL = resultURL;
521+
}
522+
485523
public JSONObject toJSONObject() {
486524
JSONObject jsonObject = new JSONObject();
487525
try {
@@ -496,6 +534,7 @@ public JSONObject toJSONObject() {
496534
jsonObject.put(STATE_PARAM, getState() == null? null : getState().name());
497535
jsonObject.put(LOCAL_APP_PATH, getLocalAppPath());
498536
jsonObject.put(PREVIEW_RECOGNITION_TEXT, getPreviewRecognitionText());
537+
jsonObject.put(RESULT_URL, getResultURL());
499538
} catch (JSONException e) {
500539
AppLogger.logMessage("ERROR could not serialize app config to json format");
501540
}
@@ -574,6 +613,12 @@ public static AppConfig fromJSONObject(JSONObject jsonObject) {
574613
} catch (JSONException e) {
575614
// optional param
576615
}
616+
617+
try {
618+
appConfig.setResultURL(jsonObject.getString(RESULT_URL));
619+
} catch (JSONException e) {
620+
// optional param
621+
}
577622
return appConfig;
578623
}
579624
}

app/src/main/java/openscience/crowdsource/video/experiments/MainActivity.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,15 +1058,18 @@ public void run() {
10581058
String status = "";
10591059
String data_uid = "";
10601060
String behavior_uid = "";
1061+
String resultURL = AppConfigService.URL_CROWD_RESULTS;
10611062

10621063
try {
10631064
status = (String) response.get("status");
10641065
data_uid = (String) response.get("data_uid");
10651066
behavior_uid = (String) response.get("behavior_uid");
1067+
resultURL = (String) response.get("result_url");
10661068
} catch (JSONException e) {
10671069
publishProgress("\nError obtaining key 'status' from OpenME output (" + e.getMessage() + ") ...");
10681070
}
10691071

1072+
AppConfigService.updateResultURL(resultURL);
10701073
publishProgress('\n' + status + '\n');
10711074

10721075
showIsThatCorrectDialog(recognitionResultText, actualImageFilePath, data_uid, behavior_uid, dataUID);

app/src/main/java/openscience/crowdsource/video/experiments/ResultActivity.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void onClick(View v) {
8181
}
8282

8383
final TextView crowdResultURL = (TextView) findViewById(R.id.crowdResultURL);
84-
crowdResultURL.setText(Html.fromHtml("<a href=\"" + AppConfigService.URL_CROWD_RESULTS + "\">View your results in the public repositor</a>"));
84+
crowdResultURL.setText(Html.fromHtml("<a href=\"" + AppConfigService.getResultURL() + "\">View your results in the public repository</a>"));
8585
crowdResultURL.setOnClickListener(new View.OnClickListener() {
8686
@SuppressWarnings({"unused", "unchecked"})
8787
@Override
@@ -114,10 +114,12 @@ public void onClick(View arg0) {
114114
Spanned spanned;
115115
final EditText edittext = new EditText(ResultActivity.this);
116116
edittext.setEnabled(false);
117-
int skipIndex = 0; // 0 - mean do not skip
117+
int skipIndex = 1; // 0 - mean do not skip
118118
if (p == skipIndex) {
119119
spanned = Html.fromHtml("<font color='red'><b>" + predictions[p] + "</b></font>");
120-
edittext.setText(predictions[p]);
120+
TextView correctResultvalue = (TextView) findViewById(R.id.predictedResultValue);
121+
correctResultvalue.setText(spanned);
122+
continue;
121123
} else if (p == predictions.length){
122124
spanned = Html.fromHtml("<font color='#ffffff'><b>Other: _____________________________</b></font>");
123125
edittext.setText("");

app/src/main/res/layout/activity_result.xml

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,44 @@
7979
/>
8080

8181
<TextView
82-
android:id="@+id/selectResultText"
83-
android:text="Select correct result or suggest your own:"
82+
android:id="@+id/predictedResultLabel"
83+
android:text="The most likely prediction:"
8484
android:textColor="@color/colorTextGreen"
8585
android:layout_width="wrap_content"
8686
android:layout_height="wrap_content"
87-
android:layout_marginTop="30dp"
87+
android:layout_marginTop="10dp"
8888
android:layout_marginLeft="0dp"
8989
android:layout_below="@+id/crowdResultURL"
9090
android:minHeight="28dp"
9191
android:textSize="14sp"
9292
/>
9393

94+
<TextView
95+
android:id="@+id/predictedResultValue"
96+
android:text="predictedResultValue"
97+
android:textColor="@color/colorTextWhite"
98+
android:layout_width="wrap_content"
99+
android:layout_height="wrap_content"
100+
android:layout_marginTop="0dp"
101+
android:layout_marginLeft="0dp"
102+
android:layout_below="@+id/predictedResultLabel"
103+
android:minHeight="28dp"
104+
android:textSize="14sp"
105+
/>
106+
107+
<TextView
108+
android:id="@+id/selectResultText"
109+
android:text="If it's wrong answer, select correct result or suggest your own:"
110+
android:textColor="@color/colorTextGreen"
111+
android:layout_width="wrap_content"
112+
android:layout_height="wrap_content"
113+
android:layout_marginTop="10dp"
114+
android:layout_marginLeft="0dp"
115+
android:layout_below="@+id/predictedResultValue"
116+
android:minHeight="28dp"
117+
android:textSize="14sp"
118+
/>
119+
94120
<RadioGroup
95121
android:id="@+id/rgSelectResultList"
96122
android:orientation="vertical"

0 commit comments

Comments
 (0)