mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2024-12-29 06:05:47 +01:00
Fix potential context crash + update deps
This commit is contained in:
parent
d3092c4579
commit
8a0361ea5e
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
#Wed Jan 26 02:00:21 CET 2022
|
#Wed Feb 09 22:14:11 CET 2022
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
@ -69,8 +69,9 @@ class PushNotificationPreferencesFragment : PreferenceFragmentCompat() {
|
|||||||
private fun updateStatus() {
|
private fun updateStatus() {
|
||||||
try {
|
try {
|
||||||
handler.postDelayed(updateRunnable, UPDATE_INTERVAL)
|
handler.postDelayed(updateRunnable, UPDATE_INTERVAL)
|
||||||
|
val appContext = requireContext().applicationContext
|
||||||
lifecycleScope.launchWhenStarted {
|
lifecycleScope.launchWhenStarted {
|
||||||
val statusInfo = getGcmServiceInfo(requireContext())
|
val statusInfo = getGcmServiceInfo(appContext)
|
||||||
pushStatusCategory.isVisible = statusInfo.configuration.enabled
|
pushStatusCategory.isVisible = statusInfo.configuration.enabled
|
||||||
pushStatus.summary = if (statusInfo.connected) {
|
pushStatus.summary = if (statusInfo.connected) {
|
||||||
getString(R.string.gcm_network_state_connected, DateUtils.getRelativeTimeSpanString(statusInfo.startTimestamp, System.currentTimeMillis(), 0))
|
getString(R.string.gcm_network_state_connected, DateUtils.getRelativeTimeSpanString(statusInfo.startTimestamp, System.currentTimeMillis(), 0))
|
||||||
@ -82,21 +83,22 @@ class PushNotificationPreferencesFragment : PreferenceFragmentCompat() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateContent() {
|
private fun updateContent() {
|
||||||
|
val appContext = requireContext().applicationContext
|
||||||
|
val context = requireContext()
|
||||||
lifecycleScope.launchWhenResumed {
|
lifecycleScope.launchWhenResumed {
|
||||||
val context = requireContext()
|
|
||||||
val (apps, showAll) = withContext(Dispatchers.IO) {
|
val (apps, showAll) = withContext(Dispatchers.IO) {
|
||||||
val apps = database.appList.sortedByDescending { it.lastMessageTimestamp }
|
val apps = database.appList.sortedByDescending { it.lastMessageTimestamp }
|
||||||
val res = apps.map { app ->
|
val res = apps.map { app ->
|
||||||
app to context.packageManager.getApplicationInfoIfExists(app.packageName)
|
app to appContext.packageManager.getApplicationInfoIfExists(app.packageName)
|
||||||
}.mapNotNull { (app, info) ->
|
}.mapNotNull { (app, info) ->
|
||||||
if (info == null) null else app to info
|
if (info == null) null else app to info
|
||||||
}.take(3).mapIndexed { idx, (app, applicationInfo) ->
|
}.take(3).mapIndexed { idx, (app, applicationInfo) ->
|
||||||
val pref = AppIconPreference(context)
|
val pref = AppIconPreference(appContext)
|
||||||
pref.order = idx
|
pref.order = idx
|
||||||
pref.title = applicationInfo.loadLabel(context.packageManager)
|
pref.title = applicationInfo.loadLabel(appContext.packageManager)
|
||||||
pref.icon = applicationInfo.loadIcon(context.packageManager)
|
pref.icon = applicationInfo.loadIcon(appContext.packageManager)
|
||||||
pref.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
pref.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||||
findNavController().navigate(requireContext(), R.id.openGcmAppDetails, bundleOf(
|
findNavController().navigate(context, R.id.openGcmAppDetails, bundleOf(
|
||||||
"package" to app.packageName
|
"package" to app.packageName
|
||||||
))
|
))
|
||||||
true
|
true
|
||||||
|
Loading…
Reference in New Issue
Block a user