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

Commit 451b223d authored by tibbi's avatar tibbi
Browse files

add a helper function for showing the unavailablity of widgets of SD card apps

parent 4020f861
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ buildscript {
        propMinSdkVersion = 16
        propTargetSdkVersion = propCompileSdkVersion
        propVersionCode = 1
        propVersionName = '4.4.26'
        propVersionName = '4.4.27'
        kotlin_version = '1.2.51'
        support_libs = '27.1.1'
    }
+7 −0
Original line number Diff line number Diff line
@@ -381,4 +381,11 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
            }
        }
    }

    fun checkAppOnSDCard() {
        if (!baseConfig.wasAppOnSDShown && isAppInstalledOnSDCard()) {
            baseConfig.wasAppOnSDShown = true
            ConfirmationDialog(this, "", R.string.app_on_sd_card, R.string.ok, 0) {}
        }
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ package com.simplemobiletools.commons.extensions
import android.annotation.SuppressLint
import android.app.Activity
import android.content.*
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
import android.graphics.drawable.ColorDrawable
import android.media.RingtoneManager
@@ -118,6 +119,13 @@ fun Activity.appLaunched(appId: String) {
    }
}

fun Activity.isAppInstalledOnSDCard(): Boolean = try {
    val applicationInfo = packageManager.getPackageInfo(packageName, 0).applicationInfo
    (applicationInfo.flags and ApplicationInfo.FLAG_EXTERNAL_STORAGE) == ApplicationInfo.FLAG_EXTERNAL_STORAGE
} catch (e: Exception) {
    false
}

@SuppressLint("InlinedApi")
fun Activity.isShowingSAFDialog(path: String, treeUri: String, requestCode: Int): Boolean {
    return if (needsStupidWritePermissions(path) && (treeUri.isEmpty() || !hasProperStoredTreeUri())) {
+4 −0
Original line number Diff line number Diff line
@@ -258,4 +258,8 @@ open class BaseConfig(val context: Context) {
    var wasOrangeIconChecked: Boolean
        get() = prefs.getBoolean(WAS_ORANGE_ICON_CHECKED, false)
        set(wasOrangeIconChecked) = prefs.edit().putBoolean(WAS_ORANGE_ICON_CHECKED, wasOrangeIconChecked).apply()

    var wasAppOnSDShown: Boolean
        get() = prefs.getBoolean(WAS_APP_ON_SD_SHOWN, false)
        set(wasAppOnSDShown) = prefs.edit().putBoolean(WAS_APP_ON_SD_SHOWN, wasAppOnSDShown).apply()
}
+1 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ const val IS_USING_MODIFIED_APP_ICON = "is_using_modified_app_icon"
const val INITIAL_WIDGET_HEIGHT = "initial_widget_height"
const val WIDGET_ID_TO_MEASURE = "widget_id_to_measure"
const val WAS_ORANGE_ICON_CHECKED = "was_orange_icon_checked"
const val WAS_APP_ON_SD_SHOWN = "was_app_on_sd_shown"

// licenses
internal const val LICENSE_KOTLIN = 1