Skip to content

Commit f1539bf

Browse files
authored
Merge pull request #195 from Merkost/direct_boot_aware
Direct boot aware fixes
2 parents b89cc04 + 8f2d851 commit f1539bf

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

app/src/main/kotlin/com/simplemobiletools/keyboard/extensions/Context.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.simplemobiletools.keyboard.extensions
22

3+
import android.app.KeyguardManager
34
import android.content.ClipboardManager
45
import android.content.Context
56
import android.graphics.Color
@@ -34,6 +35,12 @@ val Context.isDeviceInDirectBootMode: Boolean
3435
return isNougatPlus() && !userManager.isUserUnlocked
3536
}
3637

38+
val Context.isDeviceLocked: Boolean
39+
get() {
40+
val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
41+
return keyguardManager.isDeviceLocked || keyguardManager.isKeyguardLocked || isDeviceInDirectBootMode
42+
}
43+
3744
val Context.clipsDB: ClipsDao
3845
get() = ClipsDatabase.getInstance(applicationContext.safeStorageContext).ClipsDao()
3946

app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Config.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.simplemobiletools.keyboard.helpers
22

33
import android.content.Context
44
import com.simplemobiletools.commons.helpers.BaseConfig
5-
import com.simplemobiletools.keyboard.extensions.isDeviceInDirectBootMode
5+
import com.simplemobiletools.keyboard.extensions.isDeviceLocked
66
import com.simplemobiletools.keyboard.extensions.safeStorageContext
77
import java.util.Locale
88

@@ -44,10 +44,10 @@ class Config(context: Context) : BaseConfig(context) {
4444
set(showClipboardContent) = prefs.edit().putBoolean(SHOW_CLIPBOARD_CONTENT, showClipboardContent).apply()
4545

4646
var showNumbersRow: Boolean
47-
get() = if (!context.isDeviceInDirectBootMode) {
48-
prefs.getBoolean(SHOW_NUMBERS_ROW, false)
49-
} else {
47+
get() = if (context.isDeviceLocked) {
5048
true
49+
} else {
50+
prefs.getBoolean(SHOW_NUMBERS_ROW, false)
5151
}
5252
set(showNumbersRow) = prefs.edit().putBoolean(SHOW_NUMBERS_ROW, showNumbersRow).apply()
5353

app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared
4848
override fun onCreateInputView(): View {
4949
val keyboardHolder = layoutInflater.inflate(R.layout.keyboard_view_keyboard, null)
5050
keyboardView = keyboardHolder.keyboard_view as MyKeyboardView
51-
keyboardView!!.setKeyboard(keyboard!!)
5251
keyboardView!!.setKeyboardHolder(keyboardHolder.keyboard_holder)
52+
keyboardView!!.setKeyboard(keyboard!!)
5353
keyboardView!!.setEditorInfo(currentInputEditorInfo)
5454
keyboardView!!.mOnKeyboardActionListener = this
5555
return keyboardHolder!!

app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
269269
invalidateAllKeys()
270270
computeProximityThreshold(keyboard)
271271
mMiniKeyboardCache.clear()
272+
mToolbarHolder?.beInvisibleIf(context.isDeviceLocked)
272273

273274
accessHelper = AccessHelper(this, mKeyboard?.mKeys.orEmpty())
274275
ViewCompat.setAccessibilityDelegate(this, accessHelper)
@@ -400,7 +401,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
400401
pinned_clipboard_items.applyColorFilter(mTextColor)
401402
clipboard_clear.applyColorFilter(mTextColor)
402403

403-
toolbar_holder.beInvisibleIf(context.isDeviceInDirectBootMode)
404+
beInvisibleIf(context.isDeviceLocked)
404405
}
405406

406407
mClipboardManagerHolder?.apply {

0 commit comments

Comments
 (0)