From 71bd8507ade8297bc4e6ffb423357c753d92350f Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Thu, 25 Jul 2024 17:28:30 +0530 Subject: [PATCH] Minor code improvement --- .../kotlin/org/fossify/keyboard/extensions/View.kt | 2 +- .../org/fossify/keyboard/views/MyKeyboardView.kt | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/keyboard/extensions/View.kt b/app/src/main/kotlin/org/fossify/keyboard/extensions/View.kt index 9e7443bb..3beb6877 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/extensions/View.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/extensions/View.kt @@ -4,7 +4,7 @@ import android.content.Context import android.view.View import androidx.recyclerview.widget.RecyclerView -val View.safeContext: Context +val View.safeStorageContext: Context get() = context.safeStorageContext fun RecyclerView.onScroll(scroll: (Int) -> Unit) { diff --git a/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt b/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt index a26c623e..a9e3a986 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt @@ -206,7 +206,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut mPreviewHeight = resources.getDimension(R.dimen.key_height).toInt() mSpaceMoveThreshold = resources.getDimension(R.dimen.medium_margin).toInt() - with(safeContext) { + with(safeStorageContext) { mTextColor = getProperTextColor() mBackgroundColor = getProperBackgroundColor() mKeyboardBackgroundColor = getKeyboardBackgroundColor() @@ -380,7 +380,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut } fun setupKeyboard(changedView: View? = null) { - with(safeContext) { + with(safeStorageContext) { mTextColor = getProperTextColor() mBackgroundColor = getProperBackgroundColor() mKeyboardBackgroundColor = getKeyboardBackgroundColor() @@ -1471,7 +1471,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut } } - val adapter = ClipsKeyboardAdapter(safeContext, clips, refreshClipsListener) { clip -> + val adapter = ClipsKeyboardAdapter(safeStorageContext, clips, refreshClipsListener) { clip -> mOnKeyboardActionListener!!.onText(clip.value) vibrateIfNeeded() } @@ -1635,7 +1635,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut keyboardViewBinding?.emojisList?.apply { layoutManager = emojiLayoutManager - adapter = EmojisAdapter(context = safeContext, items = emojiItems) { emoji -> + adapter = EmojisAdapter(context = safeStorageContext, items = emojiItems) { emoji -> mOnKeyboardActionListener!!.onText(emoji.emoji) vibrateIfNeeded() @@ -1700,7 +1700,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut } private fun getKeyColor(): Int { - val backgroundColor = safeContext.getKeyboardBackgroundColor() + val backgroundColor = safeStorageContext.getKeyboardBackgroundColor() val lighterColor = backgroundColor.lightenColor() val keyColor = if (context.config.isUsingSystemTheme) { lighterColor