From f9b29acd8200a1121a7e8956a01e79537f55e55f Mon Sep 17 00:00:00 2001 From: Mygod Date: Sun, 14 Jan 2018 06:22:58 +0800 Subject: [PATCH] Update notification channels on configuration change --- .../src/main/java/com/github/shadowsocks/App.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/mobile/src/main/java/com/github/shadowsocks/App.kt b/mobile/src/main/java/com/github/shadowsocks/App.kt index a59306f5..78b6da6f 100644 --- a/mobile/src/main/java/com/github/shadowsocks/App.kt +++ b/mobile/src/main/java/com/github/shadowsocks/App.kt @@ -203,6 +203,16 @@ class App : Application() { DataStore.publicStore.putLong(Key.assetUpdateTime, info.lastUpdateTime) } + updateNotificationChannels() + } + + override fun onConfigurationChanged(newConfig: Configuration) { + super.onConfigurationChanged(newConfig) + checkChineseLocale(newConfig) + updateNotificationChannels() + } + + private fun updateNotificationChannels() { if (Build.VERSION.SDK_INT >= 26) @RequiresApi(26) { val nm = getSystemService(NotificationManager::class.java) nm.createNotificationChannels(listOf( @@ -216,11 +226,6 @@ class App : Application() { } } - override fun onConfigurationChanged(newConfig: Configuration) { - super.onConfigurationChanged(newConfig) - checkChineseLocale(newConfig) - } - fun listenForPackageChanges(callback: () -> Unit): BroadcastReceiver { val filter = IntentFilter(Intent.ACTION_PACKAGE_ADDED) filter.addAction(Intent.ACTION_PACKAGE_REMOVED)