Skip to content

Commit 4348cff

Browse files
committed
Add toggle to hide clipboard
1 parent d8f39bd commit 4348cff

File tree

5 files changed

+30
-1
lines changed

5 files changed

+30
-1
lines changed

app/src/main/kotlin/com/simplemobiletools/keyboard/activities/SettingsActivity.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class SettingsActivity : SimpleActivity() {
4242
setupShowPopupOnKeypress()
4343
setupKeyboardLanguage()
4444
setupKeyboardHeightMultiplier()
45+
setupShowClipboardContent()
4546

4647
updateTextColors(settings_nested_scrollview)
4748

@@ -141,4 +142,12 @@ class SettingsActivity : SimpleActivity() {
141142
else -> getString(R.string.small)
142143
}
143144
}
145+
146+
private fun setupShowClipboardContent() {
147+
settings_show_clipboard_content.isChecked = config.showClipboardContent
148+
settings_show_clipboard_content_holder.setOnClickListener {
149+
settings_show_clipboard_content.toggle()
150+
config.showClipboardContent = settings_show_clipboard_content.isChecked
151+
}
152+
}
144153
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ class Config(context: Context) : BaseConfig(context) {
2929
get() = prefs.getInt(HEIGHT_MULTIPLIER, 1)
3030
set(keyboardHeightMultiplier) = prefs.edit().putInt(HEIGHT_MULTIPLIER, keyboardHeightMultiplier).apply()
3131

32+
var showClipboardContent: Boolean
33+
get() = prefs.getBoolean(SHOW_CLIPBOARD_CONTENT, true)
34+
set(showClipboardContent) = prefs.edit().putBoolean(SHOW_CLIPBOARD_CONTENT, showClipboardContent).apply()
35+
3236

3337
private fun getDefaultLanguage(): Int {
3438
val conf = context.resources.configuration

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const val SHOW_POPUP_ON_KEYPRESS = "show_popup_on_keypress"
1313
const val LAST_EXPORTED_CLIPS_FOLDER = "last_exported_clips_folder"
1414
const val KEYBOARD_LANGUAGE = "keyboard_language"
1515
const val HEIGHT_MULTIPLIER = "height_multiplier"
16+
const val SHOW_CLIPBOARD_CONTENT = "show_clipboard_content"
1617

1718
// differentiate current and pinned clips at the keyboards' Clipboard section
1819
const val ITEM_SECTION_LABEL = 0

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
657657
}
658658

659659
private fun handleClipboard() {
660-
if (mToolbarHolder != null && mPopupParent.id != R.id.mini_keyboard_view) {
660+
if (mToolbarHolder != null && mPopupParent.id != R.id.mini_keyboard_view && context.config.showClipboardContent) {
661661
val clipboardContent = context.getCurrentClip()
662662
if (clipboardContent?.isNotEmpty() == true) {
663663
mToolbarHolder?.apply {

app/src/main/res/layout/activity_settings.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,21 @@
206206
tools:text="@string/small" />
207207

208208
</RelativeLayout>
209+
210+
<RelativeLayout
211+
android:id="@+id/settings_show_clipboard_content_holder"
212+
style="@style/SettingsHolderCheckboxStyle"
213+
android:layout_width="match_parent"
214+
android:layout_height="wrap_content">
215+
216+
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
217+
android:id="@+id/settings_show_clipboard_content"
218+
style="@style/SettingsCheckboxStyle"
219+
android:layout_width="match_parent"
220+
android:layout_height="wrap_content"
221+
android:text="@string/show_clipboard_content" />
222+
223+
</RelativeLayout>
209224
</LinearLayout>
210225
</androidx.core.widget.NestedScrollView>
211226
</androidx.coordinatorlayout.widget.CoordinatorLayout>

0 commit comments

Comments
 (0)