Merge pull request #192 from Merkost/direct_boot_aware
Direct boot aware fixes
This commit is contained in:
commit
603f7033c5
|
@ -4,12 +4,12 @@ import android.app.Application
|
||||||
import androidx.emoji2.bundled.BundledEmojiCompatConfig
|
import androidx.emoji2.bundled.BundledEmojiCompatConfig
|
||||||
import androidx.emoji2.text.EmojiCompat
|
import androidx.emoji2.text.EmojiCompat
|
||||||
import com.simplemobiletools.commons.extensions.checkUseEnglish
|
import com.simplemobiletools.commons.extensions.checkUseEnglish
|
||||||
import com.simplemobiletools.keyboard.extensions.isDeviceLocked
|
import com.simplemobiletools.keyboard.extensions.isDeviceInDirectBootMode
|
||||||
|
|
||||||
class App : Application() {
|
class App : Application() {
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
if (!isDeviceLocked) {
|
if (!isDeviceInDirectBootMode) {
|
||||||
checkUseEnglish()
|
checkUseEnglish()
|
||||||
}
|
}
|
||||||
setupEmojiCompat()
|
setupEmojiCompat()
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
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
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
|
import android.os.UserManager
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
@ -22,14 +22,17 @@ import com.simplemobiletools.keyboard.interfaces.ClipsDao
|
||||||
val Context.config: Config get() = Config.newInstance(applicationContext.safeStorageContext)
|
val Context.config: Config get() = Config.newInstance(applicationContext.safeStorageContext)
|
||||||
|
|
||||||
val Context.safeStorageContext: Context
|
val Context.safeStorageContext: Context
|
||||||
get() = if (isNougatPlus() && isDeviceLocked) {
|
get() = if (isNougatPlus() && isDeviceInDirectBootMode) {
|
||||||
createDeviceProtectedStorageContext()
|
createDeviceProtectedStorageContext()
|
||||||
} else {
|
} else {
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
val Context.isDeviceLocked: Boolean
|
val Context.isDeviceInDirectBootMode: Boolean
|
||||||
get() = (getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager).isDeviceLocked
|
get() {
|
||||||
|
val userManager = getSystemService(Context.USER_SERVICE) as UserManager
|
||||||
|
return isNougatPlus() && !userManager.isUserUnlocked
|
||||||
|
}
|
||||||
|
|
||||||
val Context.clipsDB: ClipsDao
|
val Context.clipsDB: ClipsDao
|
||||||
get() = ClipsDatabase.getInstance(applicationContext.safeStorageContext).ClipsDao()
|
get() = ClipsDatabase.getInstance(applicationContext.safeStorageContext).ClipsDao()
|
||||||
|
|
|
@ -2,9 +2,9 @@ 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.isDeviceLocked
|
import com.simplemobiletools.keyboard.extensions.isDeviceInDirectBootMode
|
||||||
import com.simplemobiletools.keyboard.extensions.safeStorageContext
|
import com.simplemobiletools.keyboard.extensions.safeStorageContext
|
||||||
import java.util.*
|
import java.util.Locale
|
||||||
|
|
||||||
class Config(context: Context) : BaseConfig(context) {
|
class Config(context: Context) : BaseConfig(context) {
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -44,7 +44,7 @@ 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.isDeviceLocked) {
|
get() = if (!context.isDeviceInDirectBootMode) {
|
||||||
prefs.getBoolean(SHOW_NUMBERS_ROW, false)
|
prefs.getBoolean(SHOW_NUMBERS_ROW, false)
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
|
|
|
@ -192,7 +192,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||||
mPreviewHeight = resources.getDimension(R.dimen.key_height).toInt()
|
mPreviewHeight = resources.getDimension(R.dimen.key_height).toInt()
|
||||||
mSpaceMoveThreshold = resources.getDimension(R.dimen.medium_margin).toInt()
|
mSpaceMoveThreshold = resources.getDimension(R.dimen.medium_margin).toInt()
|
||||||
|
|
||||||
with (context.safeStorageContext) {
|
with(context.safeStorageContext) {
|
||||||
mTextColor = getProperTextColor()
|
mTextColor = getProperTextColor()
|
||||||
mBackgroundColor = getProperBackgroundColor()
|
mBackgroundColor = getProperBackgroundColor()
|
||||||
mPrimaryColor = getProperPrimaryColor()
|
mPrimaryColor = getProperPrimaryColor()
|
||||||
|
@ -400,7 +400,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.isDeviceLocked)
|
toolbar_holder.beInvisibleIf(context.isDeviceInDirectBootMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
mClipboardManagerHolder?.apply {
|
mClipboardManagerHolder?.apply {
|
||||||
|
|
Loading…
Reference in New Issue