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

Commit 5d93b1c9 authored by tibbi's avatar tibbi
Browse files

make sure getSharedTheme is always called

parent 460e996a
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 = '3.1.1'
        propVersionName = '3.1.2'
        kotlin_version = '1.2.0'
        support_libs = '27.0.2'
    }
+1 −2
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@ import android.content.Intent
import android.graphics.drawable.ColorDrawable
import android.media.MediaScannerConnection
import android.net.Uri
import android.os.Build
import android.os.Looper
import android.os.TransactionTooLargeException
import android.provider.DocumentsContract
@@ -591,7 +590,7 @@ fun BaseSimpleActivity.restartActivity() {
    startActivity(intent)
}

fun Activity.isActivityDestroyed() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && isDestroyed
fun Activity.isActivityDestroyed() = isJellyBean1Plus() && isDestroyed

fun Activity.updateSharedTheme(sharedTheme: SharedTheme): Int {
    try {
+6 −2
Original line number Diff line number Diff line
@@ -271,6 +271,7 @@ fun Context.getFilenameFromContentUri(uri: Uri): String? {
}

fun Context.getSharedTheme(callback: (sharedTheme: SharedTheme?) -> Unit) {
    var wasSharedThemeReturned = false
    val cursorLoader = CursorLoader(this, MyContentProvider.CONTENT_URI, null, null, null, null)
    Thread {
        val cursor = cursorLoader.loadInBackground()
@@ -283,9 +284,12 @@ fun Context.getSharedTheme(callback: (sharedTheme: SharedTheme?) -> Unit) {
                val lastUpdatedTS = cursor.getIntValue(COL_LAST_UPDATED_TS)
                val sharedTheme = SharedTheme(textColor, backgroundColor, primaryColor, lastUpdatedTS)
                callback(sharedTheme)
            } else {
                callback(null)
                wasSharedThemeReturned = true
            }
        }

        if (!wasSharedThemeReturned) {
            callback(null)
        }
    }.start()
}