Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

<!-- App discovery -->
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />
tools:ignore="PackageVisibilityPolicy,QueryAllPackagesPermission" />

<!-- Network -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

<!-- Installation & Updates -->
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"
tools:ignore="RequestInstallPackagesPolicy" />
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission android:name="android.permission.ENFORCE_UPDATE_OWNERSHIP" />

Expand Down Expand Up @@ -198,7 +199,7 @@
android:exported="false">
<meta-data
android:name="autoStoreLocales"
android:value="true" />
android:value="false" />
</service>

<provider
Expand Down
11 changes: 4 additions & 7 deletions app/src/main/java/app/morphe/manager/ManagerApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import com.topjohnwu.superuser.Shell
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import me.zhanghai.android.appiconloader.coil.AppIconFetcher
import me.zhanghai.android.appiconloader.coil.AppIconKeyer
import org.koin.android.ext.android.inject
Expand Down Expand Up @@ -73,7 +72,7 @@ class ManagerApplication : Application() {
)

// LibSuperuser: always use mount master mode
Shell.enableVerboseLogging = BuildConfig.DEBUG
Shell.enableVerboseLogging = false
Shell.setDefaultBuilder(
Shell.Builder.create()
.setFlags(Shell.FLAG_MOUNT_MASTER)
Expand Down Expand Up @@ -152,11 +151,9 @@ class ManagerApplication : Application() {
override fun attachBaseContext(base: Context?) {
super.attachBaseContext(base)

val storedLang = runCatching {
base?.let {
runBlocking { PreferencesManager(it).appLanguage.get() }.ifBlank { "system" }
}
}.getOrNull() ?: "system"
val storedLang = base?.let {
PreferencesManager.readStoredLanguage(it)
} ?: "system"

applyAppLanguage(storedLang)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,18 @@ class PreferencesManager(
fun isDevVersion(): Boolean {
return BuildConfig.VERSION_NAME.contains("-dev", ignoreCase = true)
}

/**
* Read the stored app language directly from SharedPreferences without
* instantiating [PreferencesManager] (which runs heavy init{} logic).
* Used in [app.morphe.manager.ManagerApplication.attachBaseContext] before
* Koin is available.
*/
fun readStoredLanguage(context: Context): String =
context.getSharedPreferences("settings", Context.MODE_PRIVATE)
.getString("app_language", "system")
?.ifBlank { "system" }
?: "system"
}
}

Expand Down
Loading