Merge pull request #140 from smrtrfszm/hide-clipboard

Add a toggle to hide the clipboard
This commit is contained in:
Tibor Kaputa 2023-02-07 14:16:40 +01:00 committed by GitHub
commit 308c686d1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 1 deletions

View File

@ -43,6 +43,7 @@ class SettingsActivity : SimpleActivity() {
setupShowKeyBorders() setupShowKeyBorders()
setupKeyboardLanguage() setupKeyboardLanguage()
setupKeyboardHeightMultiplier() setupKeyboardHeightMultiplier()
setupShowClipboardContent()
updateTextColors(settings_nested_scrollview) updateTextColors(settings_nested_scrollview)
@ -150,4 +151,12 @@ class SettingsActivity : SimpleActivity() {
else -> getString(R.string.small) else -> getString(R.string.small)
} }
} }
private fun setupShowClipboardContent() {
settings_show_clipboard_content.isChecked = config.showClipboardContent
settings_show_clipboard_content_holder.setOnClickListener {
settings_show_clipboard_content.toggle()
config.showClipboardContent = settings_show_clipboard_content.isChecked
}
}
} }

View File

@ -33,6 +33,10 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getInt(HEIGHT_MULTIPLIER, 1) get() = prefs.getInt(HEIGHT_MULTIPLIER, 1)
set(keyboardHeightMultiplier) = prefs.edit().putInt(HEIGHT_MULTIPLIER, keyboardHeightMultiplier).apply() set(keyboardHeightMultiplier) = prefs.edit().putInt(HEIGHT_MULTIPLIER, keyboardHeightMultiplier).apply()
var showClipboardContent: Boolean
get() = prefs.getBoolean(SHOW_CLIPBOARD_CONTENT, true)
set(showClipboardContent) = prefs.edit().putBoolean(SHOW_CLIPBOARD_CONTENT, showClipboardContent).apply()
private fun getDefaultLanguage(): Int { private fun getDefaultLanguage(): Int {
val conf = context.resources.configuration val conf = context.resources.configuration

View File

@ -14,6 +14,7 @@ const val SHOW_KEY_BORDERS = "show_key_borders"
const val LAST_EXPORTED_CLIPS_FOLDER = "last_exported_clips_folder" const val LAST_EXPORTED_CLIPS_FOLDER = "last_exported_clips_folder"
const val KEYBOARD_LANGUAGE = "keyboard_language" const val KEYBOARD_LANGUAGE = "keyboard_language"
const val HEIGHT_MULTIPLIER = "height_multiplier" const val HEIGHT_MULTIPLIER = "height_multiplier"
const val SHOW_CLIPBOARD_CONTENT = "show_clipboard_content"
// differentiate current and pinned clips at the keyboards' Clipboard section // differentiate current and pinned clips at the keyboards' Clipboard section
const val ITEM_SECTION_LABEL = 0 const val ITEM_SECTION_LABEL = 0

View File

@ -701,7 +701,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
} }
private fun handleClipboard() { private fun handleClipboard() {
if (mToolbarHolder != null && mPopupParent.id != R.id.mini_keyboard_view) { if (mToolbarHolder != null && mPopupParent.id != R.id.mini_keyboard_view && context.config.showClipboardContent) {
val clipboardContent = context.getCurrentClip() val clipboardContent = context.getCurrentClip()
if (clipboardContent?.isNotEmpty() == true) { if (clipboardContent?.isNotEmpty() == true) {
mToolbarHolder?.apply { mToolbarHolder?.apply {

View File

@ -176,6 +176,21 @@
</RelativeLayout> </RelativeLayout>
<RelativeLayout
android:id="@+id/settings_show_clipboard_content_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_show_clipboard_content"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/show_clipboard_content" />
</RelativeLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/settings_keyboard_language_holder" android:id="@+id/settings_keyboard_language_holder"
style="@style/SettingsHolderTextViewStyle" style="@style/SettingsHolderTextViewStyle"