diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/adapters/ClipsKeyboardAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/adapters/ClipsKeyboardAdapter.kt index 462685a..2ffd34c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/adapters/ClipsKeyboardAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/adapters/ClipsKeyboardAdapter.kt @@ -15,7 +15,6 @@ import com.simplemobiletools.keyboard.R import com.simplemobiletools.keyboard.extensions.config import com.simplemobiletools.keyboard.extensions.getCurrentClip import com.simplemobiletools.keyboard.extensions.getStrokeColor -import com.simplemobiletools.keyboard.extensions.safeStorageContext import com.simplemobiletools.keyboard.helpers.ClipsHelper import com.simplemobiletools.keyboard.helpers.ITEM_CLIP import com.simplemobiletools.keyboard.helpers.ITEM_SECTION_LABEL @@ -33,8 +32,8 @@ class ClipsKeyboardAdapter( private val layoutInflater = LayoutInflater.from(context) - private var textColor = context.safeStorageContext.getProperTextColor() - private var backgroundColor = context.safeStorageContext.getProperBackgroundColor() + private var textColor = context.getProperTextColor() + private var backgroundColor = context.getProperBackgroundColor() override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val layoutId = when (viewType) { diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/extensions/Context.kt index 3091e45..1d6f44f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/extensions/Context.kt @@ -4,7 +4,6 @@ import android.app.KeyguardManager import android.content.ClipboardManager import android.content.Context import android.graphics.Color -import android.os.Build import android.os.IBinder import android.view.* import android.widget.TextView @@ -29,9 +28,6 @@ val Context.safeStorageContext: Context this } -val Context.shouldShowKeyboardToolbar: Boolean - get() = !isDeviceLocked - val Context.isDeviceLocked: Boolean get() = (getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager).isDeviceLocked @@ -60,7 +56,7 @@ fun Context.getStrokeColor(): Int { } } -fun Context.getKeyboardDialogBuilder() = if (baseConfig.isUsingSystemTheme) { +fun Context.getKeyboardDialogBuilder() = if (safeStorageContext.baseConfig.isUsingSystemTheme) { MaterialAlertDialogBuilder(this, R.style.MyKeyboard_Alert) } else { AlertDialog.Builder(this, R.style.MyKeyboard_Alert) diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt index db5ed46..d14051e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt @@ -225,9 +225,12 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut mLabelTextSize = resources.getDimension(R.dimen.label_text_size).toInt() mPreviewHeight = resources.getDimension(R.dimen.key_height).toInt() mSpaceMoveThreshold = resources.getDimension(R.dimen.medium_margin).toInt() - mTextColor = context.safeStorageContext.getProperTextColor() - mBackgroundColor = context.safeStorageContext.getProperBackgroundColor() - mPrimaryColor = context.safeStorageContext.getProperPrimaryColor() + + with (context.safeStorageContext) { + mTextColor = getProperTextColor() + mBackgroundColor = getProperBackgroundColor() + mPrimaryColor = getProperPrimaryColor() + } mPreviewPopup = PopupWindow(context) mPreviewText = inflater.inflate(resources.getLayout(R.layout.keyboard_key_preview), null) as TextView @@ -383,7 +386,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut mUsingSystemTheme = config.isUsingSystemTheme } - val isMainKeyboard = changedView == null || changedView != mini_keyboard_view mKeyBackground = if (mShowKeyBorders && isMainKeyboard) { resources.getDrawable(R.drawable.keyboard_key_selector_outlined, context.theme) @@ -429,7 +431,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut pinned_clipboard_items.applyColorFilter(mTextColor) clipboard_clear.applyColorFilter(mTextColor) - toolbar_holder.beInvisibleIf(!context.shouldShowKeyboardToolbar) + toolbar_holder.beInvisibleIf(context.isDeviceLocked) } mClipboardManagerHolder?.apply { @@ -1492,7 +1494,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut } } - val adapter = ClipsKeyboardAdapter(context, clips, refreshClipsListener) { clip -> + val adapter = ClipsKeyboardAdapter(context.safeStorageContext, clips, refreshClipsListener) { clip -> mOnKeyboardActionListener!!.onText(clip.value) vibrateIfNeeded() }