feat: 优化

pull/219/head
kunfei 5 years ago
parent e492e27fc2
commit 5f5cb39793
  1. 13
      app/src/main/java/io/legado/app/help/AppConfig.kt
  2. 15
      app/src/main/java/io/legado/app/utils/ContextExtensions.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 ""
}

@ -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")
}
}
}
}
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 ""
}

Loading…
Cancel
Save