mirror of
https://github.com/SimpleMobileTools/Simple-Keyboard.git
synced 2025-02-14 19:00:38 +01:00
Merge pull request #195 from Merkost/direct_boot_aware
Direct boot aware fixes
This commit is contained in:
commit
f1539bf377
@ -1,5 +1,6 @@
|
|||||||
package com.simplemobiletools.keyboard.extensions
|
package com.simplemobiletools.keyboard.extensions
|
||||||
|
|
||||||
|
import android.app.KeyguardManager
|
||||||
import android.content.ClipboardManager
|
import android.content.ClipboardManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
@ -34,6 +35,12 @@ val Context.isDeviceInDirectBootMode: Boolean
|
|||||||
return isNougatPlus() && !userManager.isUserUnlocked
|
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
|
val Context.clipsDB: ClipsDao
|
||||||
get() = ClipsDatabase.getInstance(applicationContext.safeStorageContext).ClipsDao()
|
get() = ClipsDatabase.getInstance(applicationContext.safeStorageContext).ClipsDao()
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package com.simplemobiletools.keyboard.helpers
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.simplemobiletools.commons.helpers.BaseConfig
|
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 com.simplemobiletools.keyboard.extensions.safeStorageContext
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
@ -44,10 +44,10 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
set(showClipboardContent) = prefs.edit().putBoolean(SHOW_CLIPBOARD_CONTENT, showClipboardContent).apply()
|
set(showClipboardContent) = prefs.edit().putBoolean(SHOW_CLIPBOARD_CONTENT, showClipboardContent).apply()
|
||||||
|
|
||||||
var showNumbersRow: Boolean
|
var showNumbersRow: Boolean
|
||||||
get() = if (!context.isDeviceInDirectBootMode) {
|
get() = if (context.isDeviceLocked) {
|
||||||
prefs.getBoolean(SHOW_NUMBERS_ROW, false)
|
|
||||||
} else {
|
|
||||||
true
|
true
|
||||||
|
} else {
|
||||||
|
prefs.getBoolean(SHOW_NUMBERS_ROW, false)
|
||||||
}
|
}
|
||||||
set(showNumbersRow) = prefs.edit().putBoolean(SHOW_NUMBERS_ROW, showNumbersRow).apply()
|
set(showNumbersRow) = prefs.edit().putBoolean(SHOW_NUMBERS_ROW, showNumbersRow).apply()
|
||||||
|
|
||||||
|
@ -48,8 +48,8 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared
|
|||||||
override fun onCreateInputView(): View {
|
override fun onCreateInputView(): View {
|
||||||
val keyboardHolder = layoutInflater.inflate(R.layout.keyboard_view_keyboard, null)
|
val keyboardHolder = layoutInflater.inflate(R.layout.keyboard_view_keyboard, null)
|
||||||
keyboardView = keyboardHolder.keyboard_view as MyKeyboardView
|
keyboardView = keyboardHolder.keyboard_view as MyKeyboardView
|
||||||
keyboardView!!.setKeyboard(keyboard!!)
|
|
||||||
keyboardView!!.setKeyboardHolder(keyboardHolder.keyboard_holder)
|
keyboardView!!.setKeyboardHolder(keyboardHolder.keyboard_holder)
|
||||||
|
keyboardView!!.setKeyboard(keyboard!!)
|
||||||
keyboardView!!.setEditorInfo(currentInputEditorInfo)
|
keyboardView!!.setEditorInfo(currentInputEditorInfo)
|
||||||
keyboardView!!.mOnKeyboardActionListener = this
|
keyboardView!!.mOnKeyboardActionListener = this
|
||||||
return keyboardHolder!!
|
return keyboardHolder!!
|
||||||
|
@ -269,6 +269,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
invalidateAllKeys()
|
invalidateAllKeys()
|
||||||
computeProximityThreshold(keyboard)
|
computeProximityThreshold(keyboard)
|
||||||
mMiniKeyboardCache.clear()
|
mMiniKeyboardCache.clear()
|
||||||
|
mToolbarHolder?.beInvisibleIf(context.isDeviceLocked)
|
||||||
|
|
||||||
accessHelper = AccessHelper(this, mKeyboard?.mKeys.orEmpty())
|
accessHelper = AccessHelper(this, mKeyboard?.mKeys.orEmpty())
|
||||||
ViewCompat.setAccessibilityDelegate(this, accessHelper)
|
ViewCompat.setAccessibilityDelegate(this, accessHelper)
|
||||||
@ -400,7 +401,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
pinned_clipboard_items.applyColorFilter(mTextColor)
|
pinned_clipboard_items.applyColorFilter(mTextColor)
|
||||||
clipboard_clear.applyColorFilter(mTextColor)
|
clipboard_clear.applyColorFilter(mTextColor)
|
||||||
|
|
||||||
toolbar_holder.beInvisibleIf(context.isDeviceInDirectBootMode)
|
beInvisibleIf(context.isDeviceLocked)
|
||||||
}
|
}
|
||||||
|
|
||||||
mClipboardManagerHolder?.apply {
|
mClipboardManagerHolder?.apply {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user