Skip to content

Commit 8485de8

Browse files
only support versionCode
would love to support version name but it's not going to work out very well Signed-off-by: androidacy-user <opensource@androidacy.com>
1 parent 159454b commit 8485de8

5 files changed

Lines changed: 25 additions & 4 deletions

File tree

app/build.gradle.kts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ plugins {
1212
id("com.mikepenz.aboutlibraries.plugin")
1313
kotlin("android")
1414
kotlin("kapt")
15+
id("androidx.baselineprofile")
1516
}
1617

1718
// apply realm-android
@@ -39,12 +40,12 @@ android {
3940
minSdk = 24
4041
targetSdk = 33
4142
versionCode = 70
42-
versionName = "2.0.2"
43+
versionName = "2.1.0"
4344
vectorDrawables {
4445
useSupportLibrary = true
4546
}
4647
multiDexEnabled = true
47-
resourceConfigurations.addAll(listOf("ar", "bs", "cs", "de", "es-rMX", "fr", "hu", "id", "ja", "nl", "pl", "pt", "pt-rBR", "ro", "ru", "tr", "uk", "zh", "zh-rTW", "en"))
48+
resourceConfigurations.addAll(listOf("ar", "bs", "cs", "de", "es-rMX", "fr", "hu", "id", "ja", "hu", "nl", "pl", "pt", "pt-rBR", "ro", "ru", "tr", "uk", "zh", "zh-rTW", "en"))
4849
}
4950

5051
splits {
@@ -426,6 +427,8 @@ dependencies {
426427

427428
// google guava, maybe fix a bug
428429
implementation("com.google.guava:guava:31.1-android")
430+
implementation("androidx.profileinstaller:profileinstaller:1.3.0")
431+
"baselineProfile"(project(mapOf("path" to ":baselineprofile")))
429432

430433

431434
val libsuVersion = "5.0.5"

app/src/main/java/com/fox2code/mmm/MainActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
8686
private SearchView searchView;
8787
private boolean initMode;
8888
private RuntimeUtils runtimeUtils;
89+
public static Boolean isShowingWeblateSb = false; // race condition
8990

9091
public MainActivity() {
9192
this.moduleViewListBuilder = new ModuleViewListBuilder(this);

app/src/main/java/com/fox2code/mmm/MainApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ public synchronized Tracker getTracker() {
383383

384384
@Override
385385
public void onCreate() {
386-
supportedLocales.addAll(Arrays.asList("ar", "bs", "cs", "de", "es-rMX", "fr", "hu", "id", "ja", "nl", "pl", "pt", "pt-rBR", "ro", "ru", "tr", "uk", "zh", "zh-rTW", "en"));
386+
supportedLocales.addAll(Arrays.asList("ar", "bs", "cs", "de", "es-rMX", "fr", "hu", "id", "ja", "hu", "nl", "pl", "pt", "pt-rBR", "ro", "ru", "tr", "uk", "zh", "zh-rTW", "en"));
387387
if (INSTANCE == null) INSTANCE = this;
388388
relPackageName = this.getPackageName();
389389
super.onCreate();

app/src/main/java/com/fox2code/mmm/utils/RuntimeUtils.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import android.content.Intent
77
import android.content.pm.PackageManager
88
import android.net.Uri
99
import android.os.Build
10+
import android.os.Handler
11+
import android.os.Looper
1012
import android.provider.Settings
1113
import android.view.View
1214
import android.widget.CheckBox
@@ -203,20 +205,25 @@ class RuntimeUtils {
203205
fun showWeblateSnackbar(
204206
context: Context, activity: MainActivity, language: String, languageName: String
205207
) {
208+
MainActivity.isShowingWeblateSb = true
206209
// if we haven't shown context snackbar for context version yet
207210
val prefs = MainApplication.getSharedPreferences("mmm")
208211
if (prefs.getInt("weblate_snackbar_shown", 0) == BuildConfig.VERSION_CODE) return
209212
val snackbar: Snackbar = Snackbar.make(
210213
activity.findViewById(R.id.root_container),
211214
activity.getString(R.string.language_not_available, languageName),
212-
Snackbar.LENGTH_LONG
215+
4000
213216
)
214217
snackbar.setAction(R.string.ok) {
215218
val intent = Intent(Intent.ACTION_VIEW)
216219
intent.data = Uri.parse("https://translate.nift4.org/engage/foxmmm/?language=$language")
217220
activity.startActivity(intent)
218221
}
219222
snackbar.show()
223+
// after four seconds, set isShowingWeblateSb to false
224+
Handler(Looper.getMainLooper()).postDelayed({
225+
MainActivity.isShowingWeblateSb = false
226+
}, 4000)
220227
prefs.edit().putInt("weblate_snackbar_shown", BuildConfig.VERSION_CODE).apply()
221228
}
222229

@@ -230,6 +237,13 @@ class RuntimeUtils {
230237
@SuppressLint("RestrictedApi")
231238
fun showUpgradeSnackbar(context: Context, activity: MainActivity) {
232239
Timber.i("showUpgradeSnackbar start")
240+
// if sb is already showing, wait 4 seconds and try again
241+
if (MainActivity.isShowingWeblateSb) {
242+
Handler(Looper.getMainLooper()).postDelayed({
243+
showUpgradeSnackbar(context, activity)
244+
}, 4500)
245+
return
246+
}
233247
val prefs = MainApplication.getSharedPreferences("mmm")
234248
// if last shown < 7 days ago
235249
if (prefs.getLong("ugsns4", 0) > System.currentTimeMillis() - 604800000) return

settings.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
@file:Suppress("UnstableApiUsage")
2+
3+
include(":baselineprofile")
4+
25
plugins {
36
id("com.gradle.enterprise") version("3.13")
47
}

0 commit comments

Comments
 (0)