mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 14:31:30 +01:00
fixed bug: custom labels not shown in app list
This commit is contained in:
parent
98274fbd4f
commit
2c4f5176b7
3 changed files with 16 additions and 10 deletions
|
@ -1,5 +1,6 @@
|
||||||
package de.jrpie.android.launcher
|
package de.jrpie.android.launcher
|
||||||
|
|
||||||
|
import android.content.SharedPreferences
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Build.VERSION_CODES
|
import android.os.Build.VERSION_CODES
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
|
@ -9,7 +10,13 @@ import de.jrpie.android.launcher.preferences.LauncherPreferences
|
||||||
|
|
||||||
class Application : android.app.Application() {
|
class Application : android.app.Application() {
|
||||||
var torchManager: TorchManager? = null
|
var torchManager: TorchManager? = null
|
||||||
var customAppNames: HashMap<AppInfo, String> = HashMap()
|
private var customAppNames: HashMap<AppInfo, String>? = null
|
||||||
|
private val listener = SharedPreferences.OnSharedPreferenceChangeListener { _, pref ->
|
||||||
|
if (pref == getString(R.string.settings_apps_custom_names_key)) {
|
||||||
|
customAppNames = LauncherPreferences.apps().customNames()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
|
|
||||||
|
@ -20,13 +27,12 @@ class Application : android.app.Application() {
|
||||||
val preferences = PreferenceManager.getDefaultSharedPreferences(this)
|
val preferences = PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
LauncherPreferences.init(preferences, this.resources)
|
LauncherPreferences.init(preferences, this.resources)
|
||||||
|
|
||||||
customAppNames = LauncherPreferences.apps().customNames()
|
|
||||||
|
|
||||||
LauncherPreferences.getSharedPreferences()
|
LauncherPreferences.getSharedPreferences()
|
||||||
.registerOnSharedPreferenceChangeListener { _, pref ->
|
.registerOnSharedPreferenceChangeListener(listener)
|
||||||
if (pref == getString(R.string.settings_apps_custom_names_key)) {
|
}
|
||||||
customAppNames = LauncherPreferences.apps().customNames()
|
|
||||||
}
|
fun getCustomAppNames(): HashMap<AppInfo, String> {
|
||||||
}
|
return (customAppNames ?: LauncherPreferences.apps().customNames() ?: HashMap())
|
||||||
|
.also { customAppNames = it }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ class DetailedAppInfo(
|
||||||
)
|
)
|
||||||
|
|
||||||
fun getCustomLabel(context: Context): CharSequence {
|
fun getCustomLabel(context: Context): CharSequence {
|
||||||
val map = (context.applicationContext as? Application)?.customAppNames ?: return label
|
val map = (context.applicationContext as? Application)?.getCustomAppNames() ?: return label
|
||||||
|
|
||||||
return map[app] ?: label
|
return map[app] ?: label
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ class AppsRecyclerAdapter(
|
||||||
|
|
||||||
|
|
||||||
override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) {
|
override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) {
|
||||||
var appLabel = appsListDisplayed[i].label.toString()
|
var appLabel = appsListDisplayed[i].getCustomLabel(activity)
|
||||||
|
|
||||||
if (layout.useBadgedText) {
|
if (layout.useBadgedText) {
|
||||||
appLabel = activity.packageManager.getUserBadgedLabel(
|
appLabel = activity.packageManager.getUserBadgedLabel(
|
||||||
|
|
Loading…
Add table
Reference in a new issue