diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/extensions/Context.kt index e57df65..439f428 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/extensions/Context.kt @@ -1,5 +1,6 @@ package com.simplemobiletools.keyboard.extensions +import android.app.KeyguardManager import android.content.ClipboardManager import android.content.Context import android.graphics.Color @@ -34,6 +35,12 @@ val Context.isDeviceInDirectBootMode: Boolean return isNougatPlus() && !userManager.isUserUnlocked } +val Context.isDeviceLocked: Boolean + get() { + val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager + return keyguardManager.isDeviceLocked || isDeviceInDirectBootMode + } + val Context.clipsDB: ClipsDao get() = ClipsDatabase.getInstance(applicationContext.safeStorageContext).ClipsDao() diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Config.kt index 11344c5..debc97a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Config.kt @@ -2,7 +2,7 @@ package com.simplemobiletools.keyboard.helpers import android.content.Context import com.simplemobiletools.commons.helpers.BaseConfig -import com.simplemobiletools.keyboard.extensions.isDeviceInDirectBootMode +import com.simplemobiletools.keyboard.extensions.isDeviceLocked import com.simplemobiletools.keyboard.extensions.safeStorageContext import java.util.Locale @@ -44,10 +44,10 @@ class Config(context: Context) : BaseConfig(context) { set(showClipboardContent) = prefs.edit().putBoolean(SHOW_CLIPBOARD_CONTENT, showClipboardContent).apply() var showNumbersRow: Boolean - get() = if (!context.isDeviceInDirectBootMode) { - prefs.getBoolean(SHOW_NUMBERS_ROW, false) - } else { + get() = if (context.isDeviceLocked) { true + } else { + prefs.getBoolean(SHOW_NUMBERS_ROW, false) } set(showNumbersRow) = prefs.edit().putBoolean(SHOW_NUMBERS_ROW, showNumbersRow).apply() diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt index 51f1c53..6ce5c7f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt @@ -400,7 +400,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut pinned_clipboard_items.applyColorFilter(mTextColor) clipboard_clear.applyColorFilter(mTextColor) - toolbar_holder.beInvisibleIf(context.isDeviceInDirectBootMode) + beInvisibleIf(context.isDeviceLocked) } mClipboardManagerHolder?.apply {