diff options
Diffstat (limited to 'library/src/main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt')
-rw-r--r-- | library/src/main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/library/src/main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt b/library/src/main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt deleted file mode 100644 index 837c209..0000000 --- a/library/src/main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt +++ /dev/null @@ -1,48 +0,0 @@ -package ca.allanwang.kau.utils - -import android.content.Context -import android.content.pm.PackageManager -import android.os.Build -import android.support.annotation.RequiresApi - -/** - * Created by Allan Wang on 2017-06-23. - */ - -/** - * Checks if a given package is installed - * @param packageName packageId - * @return true if installed with activity, false otherwise - */ -@KauUtils fun Context.isAppInstalled(packageName: String): Boolean { - val pm = packageManager - var installed: Boolean - try { - pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES) - installed = true - } catch (e: PackageManager.NameNotFoundException) { - installed = false - } - return installed -} - -val buildIsLollipopAndUp: Boolean - get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP - -val buildIsMarshmallowAndUp: Boolean - get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M - -val buildIsNougatAndUp: Boolean - get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N - -const val INSTALLER_GOOGLE_PLAY_VENDING = "com.android.vending" -const val INSTALLER_GOOGLE_PLAY_FEEDBACK = "com.google.android.feedback" - -val Context.installerPackageName: String? - get() = packageManager.getInstallerPackageName(packageName) - -val Context.isFromGooglePlay: Boolean - get() { - val installer = installerPackageName - return arrayOf(INSTALLER_GOOGLE_PLAY_FEEDBACK, INSTALLER_GOOGLE_PLAY_VENDING).any { it == installer } - }
\ No newline at end of file |