From b37bd623cfffcb3387fdd0da501ae5f2ca12a063 Mon Sep 17 00:00:00 2001 From: jo-elimu <1451036+jo-elimu@users.noreply.github.com> Date: Wed, 25 Sep 2024 14:18:16 +0700 Subject: [PATCH] chore: upgrade to model-2.0.71 Handle renaming from `FIL` to `TGL`. Refs #156 --- app/build.gradle | 6 +++--- .../analytics/util/SharedPreferencesHelper.java | 2 +- .../ai/elimu/analytics/util/VersionHelper.java | 16 +++++++++++++--- utils/build.gradle | 6 +++--- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7e1e1f8..758c6a5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "ai.elimu.analytics" minSdkVersion 24 targetSdkVersion 33 - versionCode 3001019 - versionName "3.1.19-SNAPSHOT" + versionCode 3001020 + versionName "3.1.20-SNAPSHOT" setProperty("archivesBaseName", "${applicationId}-${versionCode}") testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" javaCompileOptions { @@ -40,7 +40,7 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.github.elimu-ai:model:model-2.0.66' // See https://jitpack.io/#elimu-ai/model + implementation 'com.github.elimu-ai:model:model-2.0.71' // See https://jitpack.io/#elimu-ai/model implementation 'com.jakewharton.timber:timber:5.0.1' implementation 'com.google.android.material:material:1.5.0' diff --git a/app/src/main/java/ai/elimu/analytics/util/SharedPreferencesHelper.java b/app/src/main/java/ai/elimu/analytics/util/SharedPreferencesHelper.java index a65379e..25ab574 100644 --- a/app/src/main/java/ai/elimu/analytics/util/SharedPreferencesHelper.java +++ b/app/src/main/java/ai/elimu/analytics/util/SharedPreferencesHelper.java @@ -9,7 +9,7 @@ public class SharedPreferencesHelper { - private static final String SHARED_PREFS = "shared_prefs"; + public static final String SHARED_PREFS = "shared_prefs"; public static final String PREF_APP_VERSION_CODE = "pref_app_version_code"; public static final String PREF_LANGUAGE = "pref_language"; diff --git a/app/src/main/java/ai/elimu/analytics/util/VersionHelper.java b/app/src/main/java/ai/elimu/analytics/util/VersionHelper.java index 5efd9cf..a54f059 100644 --- a/app/src/main/java/ai/elimu/analytics/util/VersionHelper.java +++ b/app/src/main/java/ai/elimu/analytics/util/VersionHelper.java @@ -1,11 +1,13 @@ package ai.elimu.analytics.util; import android.content.Context; +import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import java.io.File; +import ai.elimu.model.v2.enums.Language; import timber.log.Timber; /** @@ -49,6 +51,7 @@ public static void updateAppVersion(Context context) { Timber.i("Upgrading application from version " + oldVersionCode + " to " + newVersionCode + "..."); if (oldVersionCode < 3001015) { + Timber.w("oldVersionCode < 3001015"); // Delete CSV files stored under the old folder structure File filesDir = context.getFilesDir(); @@ -109,9 +112,16 @@ public static void updateAppVersion(Context context) { Timber.w("wordLearningEventsDir.delete(): " + wordLearningEventsDir.delete()); } -// if (oldVersionCode < ???) { -// ... -// } + if (oldVersionCode < 3001020) { + Timber.w("oldVersionCode < 3001020"); + // Handle renaming from "FIL" to "TGL" + SharedPreferences sharedPreferences = context.getSharedPreferences(SharedPreferencesHelper.SHARED_PREFS, Context.MODE_PRIVATE); + String languageAsString = sharedPreferences.getString(SharedPreferencesHelper.PREF_LANGUAGE, null); + Timber.w("languageAsString: " + languageAsString); + if ("FIL".equals(languageAsString)) { + SharedPreferencesHelper.storeLanguage(context, Language.TGL); + } + } // if (oldVersionCode < ???) { // ... diff --git a/utils/build.gradle b/utils/build.gradle index 562c0df..954c5ae 100644 --- a/utils/build.gradle +++ b/utils/build.gradle @@ -9,7 +9,7 @@ android { defaultConfig { minSdkVersion 24 targetSdkVersion 33 - versionName "3.1.19-SNAPSHOT" + versionName "3.1.20-SNAPSHOT" setProperty("archivesBaseName", "utils-${versionName}") } @@ -25,7 +25,7 @@ android { } dependencies { - implementation 'com.github.elimu-ai:model:model-2.0.66' // See https://jitpack.io/#elimu-ai/model + implementation 'com.github.elimu-ai:model:model-2.0.71' // See https://jitpack.io/#elimu-ai/model testImplementation 'junit:junit:4.13.2' } @@ -36,7 +36,7 @@ publishing { utils(MavenPublication) { groupId 'ai.elimu.analytics' artifactId 'utils' - version '3.1.19-SNAPSHOT' + version '3.1.20-SNAPSHOT' artifact("${buildDir}/outputs/aar/utils-${version}-release.aar") } }