Skip to content

Offline gym log for Android. No account, no ads, no internet.

Celebrate medals won at launch and stop Android restoring old data on reinstall

InlitX7c2c89492d27
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index ebcc7ca..b6a098c 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -20,6 +20,7 @@
<application
android:label="GymMane"
android:name="${applicationName}"
+ android:allowBackup="false"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
diff --git a/lib/state/fit_state.dart b/lib/state/fit_state.dart
index eda5d2c..74694aa 100644
--- a/lib/state/fit_state.dart
+++ b/lib/state/fit_state.dart
@@ -124,6 +124,9 @@ class FitState extends FitCore
_seedCalculatorsFromProfile();
_loading = false;
refreshAwards(silent: true);
+ pendingAwards
+ ..clear()
+ ..addAll(unseenAwards);
notifyListeners();
}
diff --git a/test/profile_test.dart b/test/profile_test.dart
index 9d96334..c0f7dee 100644
--- a/test/profile_test.dart
+++ b/test/profile_test.dart
@@ -67,6 +67,29 @@ void main() {
expect(fit.unseenAwards, isEmpty);
});
+ test('a medal won while opening the app still gets its celebration', () {
+ fit.sessions.add(LoggedSession(DateTime.now(), 1800, const []));
+ fit.persistNow();
+ fit.pendingAwards.clear();
+ fit.loadFromStore();
+
+ expect(fit.hasAward(AwardId.firstWorkout), true);
+ expect(fit.pendingAwards, contains(AwardId.firstWorkout),
+ reason: 'se ganaba en silencio y aparecía en el perfil sin animación');
+ });
+
+ test('a medal already celebrated does not come back on the next launch', () {
+ fit.sessions.add(LoggedSession(DateTime.now(), 1800, const []));
+ fit.refreshAwards();
+ while (fit.nextCelebration != null) {
+ fit.celebrationShown();
+ }
+ fit.persistNow();
+ fit.loadFromStore();
+
+ expect(fit.pendingAwards, isEmpty);
+ });
+
test('a medal you have not earned reports how far along you are', () {
expect(fit.hasAward(AwardId.sets1000), false);
expect(fit.awardProgress(AwardId.sets1000), 0);