Merge pull request #195 from Merkost/direct_boot_aware

Direct boot aware fixes
This commit is contained in:
Tibor Kaputa 2023-06-18 08:56:37 +02:00 committed by GitHub
commit f1539bf377
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 6 deletions

View file

@ -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 || keyguardManager.isKeyguardLocked || isDeviceInDirectBootMode
}
val Context.clipsDB: ClipsDao
get() = ClipsDatabase.getInstance(applicationContext.safeStorageContext).ClipsDao()

View file

@ -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()

View file

@ -48,8 +48,8 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared
override fun onCreateInputView(): View {
val keyboardHolder = layoutInflater.inflate(R.layout.keyboard_view_keyboard, null)
keyboardView = keyboardHolder.keyboard_view as MyKeyboardView
keyboardView!!.setKeyboard(keyboard!!)
keyboardView!!.setKeyboardHolder(keyboardHolder.keyboard_holder)
keyboardView!!.setKeyboard(keyboard!!)
keyboardView!!.setEditorInfo(currentInputEditorInfo)
keyboardView!!.mOnKeyboardActionListener = this
return keyboardHolder!!

View file

@ -269,6 +269,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
invalidateAllKeys()
computeProximityThreshold(keyboard)
mMiniKeyboardCache.clear()
mToolbarHolder?.beInvisibleIf(context.isDeviceLocked)
accessHelper = AccessHelper(this, mKeyboard?.mKeys.orEmpty())
ViewCompat.setAccessibilityDelegate(this, accessHelper)
@ -400,7 +401,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 {