Added isDeviceLocked extension function to track when user is on a LockScreen
This commit is contained in:
parent
af0f05c299
commit
d8dead14ea
|
@ -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()
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue