diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index f47ec213a..79353351c 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -2,7 +2,6 @@ package io.legado.app.help import android.annotation.SuppressLint import android.content.Context -import android.content.pm.PackageManager import io.legado.app.App import io.legado.app.R import io.legado.app.constant.PreferKey @@ -139,15 +138,3 @@ object AppConfig { val isGooglePlay: Boolean get() = App.INSTANCE.channel == "google" } -val Context.channel: String - get() { - try { - val pm = packageManager - val appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); - return appInfo.metaData.getString("channel") ?: "" - } catch (e: Exception) { - e.printStackTrace(); - } - return "" - } - diff --git a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt index bc3f6f9fa..7a9d1e275 100644 --- a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt @@ -3,6 +3,7 @@ package io.legado.app.utils import android.annotation.SuppressLint import android.content.* +import android.content.pm.PackageManager import android.content.res.ColorStateList import android.content.res.Configuration import android.graphics.Bitmap @@ -178,4 +179,16 @@ fun Context.openUrl(uri: Uri) { toast(e.localizedMessage ?: "open url error") } } -} \ No newline at end of file +} + +val Context.channel: String + get() { + try { + val pm = packageManager + val appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); + return appInfo.metaData.getString("channel") ?: "" + } catch (e: Exception) { + e.printStackTrace(); + } + return "" + }