mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2025-01-30 12:37:33 +01:00
Do not use application context when requesting resources
Application context is not properly themed, resulting in ugly UI on some devices
This commit is contained in:
parent
a7b2b7e3f8
commit
05d18bb8d2
@ -52,7 +52,7 @@ class PushNotificationAllAppsFragment : PreferenceFragmentCompat() {
|
||||
}
|
||||
|
||||
private fun updateContent() {
|
||||
val context = requireContext().applicationContext
|
||||
val context = requireContext()
|
||||
lifecycleScope.launchWhenResumed {
|
||||
val apps = withContext(Dispatchers.IO) {
|
||||
val res = database.appList.map { app ->
|
||||
|
@ -46,13 +46,13 @@ class PushNotificationAppFragment : Fragment(R.layout.push_notification_fragment
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
val appContext = requireContext().applicationContext
|
||||
val context = requireContext()
|
||||
lifecycleScope.launchWhenResumed {
|
||||
val pm = appContext.packageManager
|
||||
val pm = context.packageManager
|
||||
val applicationInfo = pm.getApplicationInfoIfExists(packageName)
|
||||
binding.appName = applicationInfo?.loadLabel(pm)?.toString() ?: packageName
|
||||
binding.appIcon = applicationInfo?.loadIcon(pm)
|
||||
?: AppCompatResources.getDrawable(appContext, android.R.mipmap.sym_def_app_icon)
|
||||
?: AppCompatResources.getDrawable(context, android.R.mipmap.sym_def_app_icon)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,9 +51,9 @@ class SettingsFragment : ResourceSettingsFragment() {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
val appContext = requireContext().applicationContext
|
||||
val context = requireContext()
|
||||
lifecycleScope.launchWhenResumed {
|
||||
updateDetails(appContext)
|
||||
updateDetails(context)
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ class SettingsFragment : ResourceSettingsFragment() {
|
||||
val database = GcmDatabase(context)
|
||||
val regCount = database.registrationList.size
|
||||
database.close()
|
||||
findPreference<Preference>(PREF_GCM)!!.summary = getString(R.string.service_status_enabled_short) + " - " + resources.getQuantityString(R.plurals.gcm_registered_apps_counter, regCount, regCount)
|
||||
findPreference<Preference>(PREF_GCM)!!.summary = context.getString(R.string.service_status_enabled_short) + " - " + context.resources.getQuantityString(R.plurals.gcm_registered_apps_counter, regCount, regCount)
|
||||
} else {
|
||||
findPreference<Preference>(PREF_GCM)!!.setSummary(R.string.service_status_disabled_short)
|
||||
}
|
||||
@ -72,7 +72,7 @@ class SettingsFragment : ResourceSettingsFragment() {
|
||||
findPreference<Preference>(PREF_SNET)!!.setSummary(if (getSafetyNetServiceInfo(context).configuration.enabled) R.string.service_status_enabled_short else R.string.service_status_disabled_short)
|
||||
|
||||
val backendCount = UnifiedLocationClient[context].getLocationBackends().size + UnifiedLocationClient[context].getGeocoderBackends().size
|
||||
findPreference<Preference>(PREF_UNIFIEDNLP)!!.summary = resources.getQuantityString(R.plurals.pref_unifiednlp_summary, backendCount, backendCount)
|
||||
findPreference<Preference>(PREF_UNIFIEDNLP)!!.summary = context.resources.getQuantityString(R.plurals.pref_unifiednlp_summary, backendCount, backendCount)
|
||||
|
||||
findPreference<Preference>(PREF_EXPOSURE)?.isVisible = NearbyPreferencesIntegration.isAvailable
|
||||
findPreference<Preference>(PREF_EXPOSURE)?.icon = NearbyPreferencesIntegration.getIcon(context)
|
||||
|
@ -40,13 +40,13 @@ class ExposureNotificationsAppFragment : Fragment(R.layout.exposure_notification
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
val appContext = requireContext().applicationContext
|
||||
val context = requireContext()
|
||||
lifecycleScope.launchWhenResumed {
|
||||
val pm = appContext.packageManager
|
||||
val pm = context.packageManager
|
||||
val applicationInfo = pm.getApplicationInfoIfExists(packageName)
|
||||
binding.appName = applicationInfo?.loadLabel(pm)?.toString() ?: packageName
|
||||
binding.appIcon = applicationInfo?.loadIcon(pm)
|
||||
?: AppCompatResources.getDrawable(appContext, android.R.mipmap.sym_def_app_icon)
|
||||
?: AppCompatResources.getDrawable(context, android.R.mipmap.sym_def_app_icon)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ class ExposureNotificationsPreferencesFragment : PreferenceFragmentCompat() {
|
||||
}
|
||||
|
||||
private fun updateContent() {
|
||||
val context = requireContext().applicationContext
|
||||
val context = requireContext()
|
||||
lifecycleScope.launchWhenResumed {
|
||||
handler.postDelayed(updateContentRunnable, UPDATE_CONTENT_INTERVAL)
|
||||
val (apps, lastHourKeys, currentId) = ExposureDatabase.with(context) { database ->
|
||||
|
Loading…
x
Reference in New Issue
Block a user