New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes #113

Open
wants to merge 6 commits into
base: master
from
Copy path View file
@@ -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
@@ -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),
@@ -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 @@
@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);
@@ -629,6 +639,7 @@ public void onFinish() {
chronometer.setPenalty(PuzzleUtils.PENALTY_DNF);
stopChronometer();
addNewSolve();
considerNewScramble();
inspectionText.setVisibility(View.GONE);
}
};
@@ -780,6 +791,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 +1240,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();
}
/**
@@ -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);
@@ -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) {
@@ -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();
@@ -130,6 +130,7 @@
*/
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 @@
ACTION_TOOLBAR_RESTORED,
ACTION_GENERATE_SCRAMBLE,
ACTION_SCROLLED_PAGE,
ACTION_USE_SCRAMBLE,
});
}};
@@ -3,6 +3,9 @@
<item
android:id="@+id/history_to"
android:title="@string/list_options_item_history" />
<item
android:id="@+id/use"
android:title="@string/list_options_item_use" />
<item
android:id="@+id/share"
android:title="@string/list_options_item_share" />
@@ -4,6 +4,9 @@
<item
android:id="@+id/history_from"
android:title="@string/list_options_item_from_history" />
<item
android:id="@+id/use"
android:title="@string/list_options_item_use" />
<item
android:id="@+id/share"
android:title="@string/list_options_item_share" />
@@ -139,7 +139,9 @@
<string name="import_progress_title">Importuji časy…</string>
<string name="inspection">Inspekce</string>
<string name="inspectionEnabledTitle">Inspekce</string>
<string name="inspectionTimeSummary">Výchozí čas: 15 sekund</string>
<plurals name="inspectionTimeSummary">
<item quantity="other">%d sekund</item>
</plurals>
<string name="inspectionTimeTitle">Čas inspekce (sekundy)</string>
<string name="inspection_time">Čas inspekce</string>
<string name="invalid_time">Neplatný čas</string>
@@ -83,7 +83,9 @@
<string name="inspectionEnabledTitle">Inspektion</string>
<string name="inspectionTimeTitle">Inspektionszeit (Sekunden)</string>
<string name="pref_category_title_timer">Stoppuhr</string>
<string name="inspectionTimeSummary">Standard-Zeit: 15 Sekunden</string>
<plurals name="inspectionTimeSummary">
<item quantity="other">%d sekunden</item>
</plurals>
<string name="drawer_title_reference">Referenz</string>
<string name="edit_algorithm">Algorithmen bearbeiten</string>
<string name="dialog_set_progress">Fortschritt einstellen</string>
@@ -83,7 +83,9 @@
<string name="inspectionEnabledTitle">Inspección</string>
<string name="inspectionTimeTitle">Tiempo de inspección (segundos)</string>
<string name="pref_category_title_timer">Contador</string>
<string name="inspectionTimeSummary">Tiempo por defecto: 15 segundos</string>
<plurals name="inspectionTimeSummary">
<item quantity="other">%d segundos</item>
</plurals>
<string name="drawer_title_reference">Referencia</string>
<string name="edit_algorithm">Editar algoritmos</string>
<string name="dialog_set_progress">Establecer progreso</string>
@@ -79,7 +79,9 @@
<string name="inspectionEnabledTitle">Inspection</string>
<string name="inspectionTimeTitle">Temps de l\'inspection (secondes)</string>
<string name="pref_category_title_timer">Chronomètre</string>
<string name="inspectionTimeSummary">Temps par défaut: 15 secondes</string>
<plurals name="inspectionTimeSummary">
<item quantity="other">%d secondes</item>
</plurals>
<string name="drawer_title_reference">Référence</string>
<string name="edit_algorithm">Modifier les algorithmes</string>
<string name="dialog_set_progress">Modifier la progression</string>
@@ -86,7 +86,9 @@
<string name="inspectionEnabledTitle">Apžiūra</string>
<string name="inspectionTimeTitle">Apžiūros laikas (sekundėm)</string>
<string name="pref_category_title_timer">Laikmatis</string>
<string name="inspectionTimeSummary">Numatytas laikas: 15 sekundžių</string>
<plurals name="inspectionTimeSummary">
<item quantity="other">%d sekundžių</item>
</plurals>
<string name="drawer_title_reference">Algoritmai</string>
<string name="edit_algorithm">Redaguoti algoritmus</string>
<string name="dialog_set_progress">Nustatyti progresą</string>
@@ -83,7 +83,9 @@
<string name="inspectionEnabledTitle">Inspekcja</string>
<string name="inspectionTimeTitle">Czas inspekcji (sekundy)</string>
<string name="pref_category_title_timer">Timer</string>
<string name="inspectionTimeSummary">Domyślnie</string>
<plurals name="inspectionTimeSummary">
<item quantity="other">%d sekundžių</item>
</plurals>
<string name="drawer_title_reference">Odniesienia</string>
<string name="edit_algorithm">Edytuj algorytm</string>
<string name="dialog_set_progress">Ustaw postęp</string>
@@ -82,7 +82,9 @@
<string name="inspectionTimeTitle">Tempo de inspeção (segundos)</string>
<string name="pref_category_title_inspection">Inspeção</string>
<string name="pref_category_title_timer">Cronômetro</string>
<string name="inspectionTimeSummary">Tempo padrão: 15 segundos</string>
<plurals name="inspectionTimeSummary">
<item quantity="other">%d segundos</item>
</plurals>
<string name="action_reset">Resetar</string>
<string name="action_update">Atualizar</string>
<string name="dialog_revert_content_confirmation">Resetar os algoritmos deste caso de volta para o padrão?</string>
@@ -116,7 +116,9 @@
<string name="import_progress_title">Импорт сборок...</string>
<string name="inspection">Инспекция</string>
<string name="inspectionEnabledTitle">Инспекция</string>
<string name="inspectionTimeSummary">Стандартное время: 15 секунд</string>
<plurals name="inspectionTimeSummary">
<item quantity="other">%d секунд</item>
</plurals>
<string name="inspectionTimeTitle">Время инспекции (в секундах)</string>
<string name="inspection_time">Время инспекции</string>
<string name="invalid_time">Неправильное время</string>
@@ -193,9 +193,12 @@
<string name="inspectionEnabledTitle">Inspection</string>
<string name="inspectionTimeSummary">Default duration: 15 seconds</string>
<plurals name="inspectionTimeSummary">
<item quantity="one">%d second</item>
<item quantity="other">%d seconds</item>
</plurals>
<string name="inspectionTimeTitle">Inspection duration (seconds)</string>
<string name="inspectionTimeTitle">Inspection duration</string>
<string name="inspection_time">Inspection time</string>
@@ -398,5 +401,6 @@
<string name="pref_inspection_alert_title">Alert time left</string>
<string name="pref_inspection_alert_summary">Timer will alert you once %1$d and %2$d seconds of inspection have passed</string>
<string name="list_options_item_use">Use</string>
</resources>
@@ -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" />
</PreferenceCategory>
Copy path View file
@@ -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
}
@@ -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
ProTip! Use n and p to navigate between commits in a pull request.