From c980c44fc383904641748385982c1864fd19be01 Mon Sep 17 00:00:00 2001 From: Xavier Shay Date: Fri, 22 Dec 2017 12:53:02 +1100 Subject: [PATCH 1/6] Build file updates for latest version of Android Studio. These were all suggested by build failures and warnings. --- app/build.gradle | 6 +----- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1ae01640..9d415c12 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,7 +6,6 @@ android { } } compileSdkVersion 26 - buildToolsVersion '26.0.1' defaultConfig { applicationId "com.aricneto.twistytimer" minSdkVersion 16 @@ -40,8 +39,6 @@ buildscript { } } -apply plugin: 'com.neenbedankt.android-apt' - dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile project(':TNoodle') @@ -55,9 +52,8 @@ dependencies { compile 'com.android.support:percent:26.0.1' compile 'com.android.support.constraint:constraint-layout:1.0.2' compile 'com.takisoft.fix:preference-v7:26.0.1.0' - // Butterknife ("apt" dependency is defined in root "build.gradle" script). compile 'com.jakewharton:butterknife:8.2.1' - apt 'com.jakewharton:butterknife-compiler:8.2.1' + annotationProcessor 'com.jakewharton:butterknife-compiler:8.2.1' // Observable scrollview compile 'com.github.ksoichiro:android-observablescrollview:1.5.2' // Dialogs diff --git a/build.gradle b/build.gradle index ab473866..c83ab4e7 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath ('com.android.tools.build:gradle:2.3.3') { + classpath ('com.android.tools.build:gradle:3.0.1') { force = true } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f42b9544..470209a9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Aug 15 22:02:15 BRT 2017 +#Fri Dec 22 12:39:58 AEDT 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip From ec53c427049e29b2a5796a8e8dac39e5e3c408d9 Mon Sep 17 00:00:00 2001 From: Xavier Shay Date: Fri, 22 Dec 2017 13:32:32 +1100 Subject: [PATCH 2/6] [issue-111] More intuitive summary text for inspection time setting. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is more consistent with standard presentation of settings. There's no need to call out the default value explicitly here – the default button in the dialog reveals it if needed. Instead, show the current value of the setting. --- .../aricneto/twistytimer/activity/SettingsActivity.java | 2 ++ app/src/main/res/values/strings.xml | 7 +++++-- app/src/main/res/xml/prefs.xml | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/aricneto/twistytimer/activity/SettingsActivity.java b/app/src/main/java/com/aricneto/twistytimer/activity/SettingsActivity.java index f986e1b1..f2ef41ea 100644 --- a/app/src/main/java/com/aricneto/twistytimer/activity/SettingsActivity.java +++ b/app/src/main/java/com/aricneto/twistytimer/activity/SettingsActivity.java @@ -232,6 +232,8 @@ public void onCreatePreferencesFix(Bundle bundle, String rootKey) { private void updateInspectionAlertText() { inspectionDuration = Prefs.getInt(R.string.pk_inspection_time, 15); + findPreference(getString(R.string.pk_inspection_time)) + .setSummary(getResources().getQuantityString(R.plurals.inspectionTimeSummary, inspectionDuration, inspectionDuration)); findPreference(getString(R.string.pk_inspection_alert_enabled)) .setSummary(getString(R.string.pref_inspection_alert_summary, inspectionDuration == 15 ? 8 : (int) (inspectionDuration * 0.5f), diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b887d55a..45113bfa 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -193,9 +193,12 @@ Inspection - Default duration: 15 seconds + + %d second + %d seconds + - Inspection duration (seconds) + Inspection duration Inspection time diff --git a/app/src/main/res/xml/prefs.xml b/app/src/main/res/xml/prefs.xml index 7a5e594a..bc13746b 100644 --- a/app/src/main/res/xml/prefs.xml +++ b/app/src/main/res/xml/prefs.xml @@ -34,7 +34,7 @@ android:dependency="@string/pk_inspection_enabled" android:key="@string/pk_inspection_time" - android:summary="@string/inspectionTimeSummary" + android:summary="@plurals/inspectionTimeSummary" android:title="@string/inspectionTimeTitle" /> From c0b772e37d6a5ba3973d172863ba514c96a9fc35 Mon Sep 17 00:00:00 2001 From: Xavier Shay Date: Fri, 22 Dec 2017 13:43:51 +1100 Subject: [PATCH 3/6] Convert non-EN strings.xml to plural inspectionTimeSummary. These are generated files, but I'm not sure how they are generated and wanted to ensure the build didn't crash in the meantime. Opened #112 to better document. --- app/src/main/res/values-cs/strings.xml | 4 +++- app/src/main/res/values-de/strings.xml | 4 +++- app/src/main/res/values-es/strings.xml | 4 +++- app/src/main/res/values-fr/strings.xml | 4 +++- app/src/main/res/values-lt/strings.xml | 4 +++- app/src/main/res/values-pl/strings.xml | 4 +++- app/src/main/res/values-pt-rBR/strings.xml | 4 +++- app/src/main/res/values-ru/strings.xml | 4 +++- 8 files changed, 24 insertions(+), 8 deletions(-) diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 4141f46b..0276de97 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -139,7 +139,9 @@ Importuji časy… Inspekce Inspekce - Výchozí čas: 15 sekund + + %d sekund + Čas inspekce (sekundy) Čas inspekce Neplatný čas diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index a101b2be..23b6f547 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -83,7 +83,9 @@ Inspektion Inspektionszeit (Sekunden) Stoppuhr - Standard-Zeit: 15 Sekunden + + %d sekunden + Referenz Algorithmen bearbeiten Fortschritt einstellen diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 8e55a219..6425da84 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -83,7 +83,9 @@ Inspección Tiempo de inspección (segundos) Contador - Tiempo por defecto: 15 segundos + + %d segundos + Referencia Editar algoritmos Establecer progreso diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 534d680f..07eca0b4 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -79,7 +79,9 @@ Inspection Temps de l\'inspection (secondes) Chronomètre - Temps par défaut: 15 secondes + + %d secondes + Référence Modifier les algorithmes Modifier la progression diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index 40a4e368..9171798d 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -86,7 +86,9 @@ Apžiūra Apžiūros laikas (sekundėm) Laikmatis - Numatytas laikas: 15 sekundžių + + %d sekundžių + Algoritmai Redaguoti algoritmus Nustatyti progresą diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index a16c673f..c172c08e 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -83,7 +83,9 @@ Inspekcja Czas inspekcji (sekundy) Timer - Domyślnie + + %d sekundžių + Odniesienia Edytuj algorytm Ustaw postęp diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 98f65613..46aca5bb 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -82,7 +82,9 @@ Tempo de inspeção (segundos) Inspeção Cronômetro - Tempo padrão: 15 segundos + + %d segundos + Resetar Atualizar Resetar os algoritmos deste caso de volta para o padrão? diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 748bc41f..8ad3be0b 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -116,7 +116,9 @@ Импорт сборок... Инспекция Инспекция - Стандартное время: 15 секунд + + %d секунд + Время инспекции (в секундах) Время инспекции Неправильное время From da20e47fae1c44ae9e58f7a3d41e018f4a59e3e2 Mon Sep 17 00:00:00 2001 From: Xavier Shay Date: Fri, 22 Dec 2017 14:11:33 +1100 Subject: [PATCH 4/6] [issue-108] Generate a new scramble after inspection DNF. --- .../twistytimer/fragment/TimerFragment.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/aricneto/twistytimer/fragment/TimerFragment.java b/app/src/main/java/com/aricneto/twistytimer/fragment/TimerFragment.java index 3e2706dc..bb8e4b7a 100644 --- a/app/src/main/java/com/aricneto/twistytimer/fragment/TimerFragment.java +++ b/app/src/main/java/com/aricneto/twistytimer/fragment/TimerFragment.java @@ -629,6 +629,7 @@ public void onFinish() { chronometer.setPenalty(PuzzleUtils.PENALTY_DNF); stopChronometer(); addNewSolve(); + considerNewScramble(); inspectionText.setVisibility(View.GONE); } }; @@ -780,6 +781,13 @@ public void run() { return root; } + private void considerNewScramble() { + if (scrambleEnabled) { + currentScramble = realScramble; + generateNewScramble(); + } + } + @Override public void onResume() { if (DEBUG_ME) Log.d(TAG, "onResume()"); @@ -1222,15 +1230,11 @@ private void startChronometer() { chronometer.start(); chronometer.setHighlighted(false); // Clear any start cue or hold-for-start highlight. - // isRunning should be set before generateNewScramble so the loading spinner doesn't appear - // during a solve, since generateNewScramble checks if isRunning is false before setting - // the spinner to visible. + // Generating a new scramble will show a loading spinner _unless_ the chronometer is + // running. Therefore isRunning needs to be set before generating a new scramble. isRunning = true; - if (scrambleEnabled) { - currentScramble = realScramble; - generateNewScramble(); - } + considerNewScramble(); } /** From 1ca9129a3ce7055cdd71f8c05cd2674c254aeae4 Mon Sep 17 00:00:00 2001 From: Xavier Shay Date: Fri, 22 Dec 2017 15:53:34 +1100 Subject: [PATCH 5/6] [issue-97] Can 'use' a scramble from the solves list. This adds a new menu item to the overflow button on the time dialog (from clicking on a solve in history) that switches to the main timer with that solve's scramble loaded. --- .../aricneto/twistytimer/fragment/TimerFragment.java | 10 ++++++++++ .../twistytimer/fragment/TimerFragmentMain.java | 4 ++++ .../twistytimer/fragment/dialog/TimeDialog.java | 6 ++++++ .../java/com/aricneto/twistytimer/utils/TTIntent.java | 2 ++ app/src/main/res/menu/menu_list_detail.xml | 3 +++ app/src/main/res/menu/menu_list_detail_history.xml | 3 +++ app/src/main/res/values/strings.xml | 1 + 7 files changed, 29 insertions(+) diff --git a/app/src/main/java/com/aricneto/twistytimer/fragment/TimerFragment.java b/app/src/main/java/com/aricneto/twistytimer/fragment/TimerFragment.java index bb8e4b7a..2383ad0c 100644 --- a/app/src/main/java/com/aricneto/twistytimer/fragment/TimerFragment.java +++ b/app/src/main/java/com/aricneto/twistytimer/fragment/TimerFragment.java @@ -93,11 +93,13 @@ import static com.aricneto.twistytimer.utils.TTIntent.ACTION_TIMES_MODIFIED; import static com.aricneto.twistytimer.utils.TTIntent.ACTION_TIME_ADDED; import static com.aricneto.twistytimer.utils.TTIntent.ACTION_TOOLBAR_RESTORED; +import static com.aricneto.twistytimer.utils.TTIntent.ACTION_USE_SCRAMBLE; import static com.aricneto.twistytimer.utils.TTIntent.BroadcastBuilder; import static com.aricneto.twistytimer.utils.TTIntent.CATEGORY_TIME_DATA_CHANGES; import static com.aricneto.twistytimer.utils.TTIntent.CATEGORY_UI_INTERACTIONS; import static com.aricneto.twistytimer.utils.TTIntent.TTFragmentBroadcastReceiver; import static com.aricneto.twistytimer.utils.TTIntent.broadcast; +import static com.aricneto.twistytimer.utils.TTIntent.getSolve; import static com.aricneto.twistytimer.utils.TTIntent.registerReceiver; import static com.aricneto.twistytimer.utils.TTIntent.unregisterReceiver; @@ -249,6 +251,14 @@ public class TimerFragment extends BaseFragment @Override public void onReceiveWhileAdded(Context context, Intent intent) { switch (intent.getAction()) { + case ACTION_USE_SCRAMBLE: + // Ensure that any scramble that is being generated is canceled. + // Otherwise, it will replace the scramble we set here when it completes! + scrambleGeneratorAsync.cancel(true); + + Solve solve = getSolve(intent); + setScramble(solve.getScramble()); + break; case ACTION_SCROLLED_PAGE: if (holdEnabled) { holdHandler.removeCallbacks(holdRunnable); diff --git a/app/src/main/java/com/aricneto/twistytimer/fragment/TimerFragmentMain.java b/app/src/main/java/com/aricneto/twistytimer/fragment/TimerFragmentMain.java index 5d969dba..810b83f1 100644 --- a/app/src/main/java/com/aricneto/twistytimer/fragment/TimerFragmentMain.java +++ b/app/src/main/java/com/aricneto/twistytimer/fragment/TimerFragmentMain.java @@ -77,6 +77,7 @@ import static com.aricneto.twistytimer.utils.TTIntent.ACTION_TIME_SELECTED; import static com.aricneto.twistytimer.utils.TTIntent.ACTION_TIME_UNSELECTED; import static com.aricneto.twistytimer.utils.TTIntent.ACTION_TOOLBAR_RESTORED; +import static com.aricneto.twistytimer.utils.TTIntent.ACTION_USE_SCRAMBLE; import static com.aricneto.twistytimer.utils.TTIntent.CATEGORY_TIME_DATA_CHANGES; import static com.aricneto.twistytimer.utils.TTIntent.CATEGORY_UI_INTERACTIONS; import static com.aricneto.twistytimer.utils.TTIntent.TTFragmentBroadcastReceiver; @@ -193,6 +194,9 @@ public void onDestroyActionMode(ActionMode mode) { @Override public void onReceiveWhileAdded(Context context, Intent intent) { switch (intent.getAction()) { + case ACTION_USE_SCRAMBLE: + viewPager.setCurrentItem(TIMER_PAGE); + break; case ACTION_TIMER_STARTED: // This was taken from PlusTimer (thanks :D) viewPager.setPagingEnabled(false); activateTabLayout(false); diff --git a/app/src/main/java/com/aricneto/twistytimer/fragment/dialog/TimeDialog.java b/app/src/main/java/com/aricneto/twistytimer/fragment/dialog/TimeDialog.java index 70df9867..74412b59 100644 --- a/app/src/main/java/com/aricneto/twistytimer/fragment/dialog/TimeDialog.java +++ b/app/src/main/java/com/aricneto/twistytimer/fragment/dialog/TimeDialog.java @@ -83,6 +83,12 @@ public boolean onMenuItemClick(MenuItem item) { dbHandler.deleteSolveByID(mId); updateList(); break; + case R.id.use: + new TTIntent.BroadcastBuilder(TTIntent.CATEGORY_UI_INTERACTIONS, TTIntent.ACTION_USE_SCRAMBLE) + .solve(solve) + .broadcast(); + dismiss(); + break; case R.id.history_to: solve.setHistory(true); Toast.makeText(getContext(), getString(R.string.sent_to_history), Toast.LENGTH_SHORT).show(); diff --git a/app/src/main/java/com/aricneto/twistytimer/utils/TTIntent.java b/app/src/main/java/com/aricneto/twistytimer/utils/TTIntent.java index d6aa5668..034d104f 100644 --- a/app/src/main/java/com/aricneto/twistytimer/utils/TTIntent.java +++ b/app/src/main/java/com/aricneto/twistytimer/utils/TTIntent.java @@ -130,6 +130,7 @@ public final class TTIntent { */ public static final String ACTION_GENERATE_SCRAMBLE = ACTION_PREFIX + "GENERATE_SCRAMBLE"; + public static final String ACTION_USE_SCRAMBLE = ACTION_PREFIX + "USE_SCRAMBLE"; /** * Selection mode has been turned on for the list of times. */ @@ -224,6 +225,7 @@ public final class TTIntent { ACTION_TOOLBAR_RESTORED, ACTION_GENERATE_SCRAMBLE, ACTION_SCROLLED_PAGE, + ACTION_USE_SCRAMBLE, }); }}; diff --git a/app/src/main/res/menu/menu_list_detail.xml b/app/src/main/res/menu/menu_list_detail.xml index 6b650d97..aba70089 100644 --- a/app/src/main/res/menu/menu_list_detail.xml +++ b/app/src/main/res/menu/menu_list_detail.xml @@ -3,6 +3,9 @@ + diff --git a/app/src/main/res/menu/menu_list_detail_history.xml b/app/src/main/res/menu/menu_list_detail_history.xml index db078552..4af26504 100644 --- a/app/src/main/res/menu/menu_list_detail_history.xml +++ b/app/src/main/res/menu/menu_list_detail_history.xml @@ -4,6 +4,9 @@ + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 45113bfa..3477f36c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -401,5 +401,6 @@ Alert time left Timer will alert you once %1$d and %2$d seconds of inspection have passed + Use From a72031206eb91fdac2c756b6c8a83af8a2a45bc7 Mon Sep 17 00:00:00 2001 From: Xavier Shay Date: Fri, 22 Dec 2017 16:21:44 +1100 Subject: [PATCH 6/6] [issue-94] Persist history setting correctly on device rotation. --- .../fragment/TimerListFragment.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/aricneto/twistytimer/fragment/TimerListFragment.java b/app/src/main/java/com/aricneto/twistytimer/fragment/TimerListFragment.java index e99bba1e..f89457ab 100644 --- a/app/src/main/java/com/aricneto/twistytimer/fragment/TimerListFragment.java +++ b/app/src/main/java/com/aricneto/twistytimer/fragment/TimerListFragment.java @@ -196,18 +196,32 @@ public void run() { break; case ACTION_HISTORY_TIMES_SHOWN: - history = true; + setHistory(true); reloadList(); break; case ACTION_SESSION_TIMES_SHOWN: - history = false; + setHistory(false); reloadList(); break; } } }; + private void setHistory(boolean value) { + history = value; + + // Need to persist history to fragment arguments so that it is correctly persisted on + // re-create (such as when device is rotated). + Bundle arguments = getArguments(); + + // Cargo-culted this null check from onCreate. Unsure how this could actually be null. + if (arguments != null) { + arguments.putBoolean(HISTORY, history); + setArguments(arguments); + } + } + // Receives broadcasts about UI interactions that require actions to be taken. private TTFragmentBroadcastReceiver mUIInteractionReceiver = new TTFragmentBroadcastReceiver(this, CATEGORY_UI_INTERACTIONS) {