Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 492b592d authored by tibbi's avatar tibbi
Browse files

add an extension function for checking if a package is installed

parent 28e25a6c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ buildscript {
        propMinSdkVersion = 16
        propTargetSdkVersion = propCompileSdkVersion
        propVersionCode = 1
        propVersionName = '3.14.6'
        propVersionName = '3.14.7'
        kotlin_version = '1.2.30'
        support_libs = '27.1.0'
    }
+11 −9
Original line number Diff line number Diff line
@@ -103,15 +103,6 @@ val Context.baseConfig: BaseConfig get() = BaseConfig.newInstance(this)
val Context.sdCardPath: String get() = baseConfig.sdCardPath
val Context.internalStoragePath: String get() = baseConfig.internalStoragePath

fun Context.isThankYouInstalled(): Boolean {
    return try {
        packageManager.getPackageInfo("com.simplemobiletools.thankyou", 0)
        true
    } catch (e: Exception) {
        false
    }
}

@SuppressLint("InlinedApi", "NewApi")
fun Context.isFingerPrintSensorAvailable() = isMarshmallowPlus() && Reprint.isHardwarePresent()

@@ -351,3 +342,14 @@ fun Context.getUriMimeType(path: String, newUri: Uri): String {
    }
    return mimeType
}

fun Context.isThankYouInstalled() = isPackageInstalled("com.simplemobiletools.thankyou")

fun Context.isPackageInstalled(pkgName: String): Boolean {
    return try {
        packageManager.getPackageInfo(pkgName, 0)
        true
    } catch (e: Exception) {
        false
    }
}