Skip to content

Commit 308c686

Browse files
authored
Merge pull request #140 from smrtrfszm/hide-clipboard
Add a toggle to hide the clipboard
2 parents a1dd2fd + 4b5380b commit 308c686

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
@@ -43,6 +43,7 @@ class SettingsActivity : SimpleActivity() {
4343
setupShowKeyBorders()
4444
setupKeyboardLanguage()
4545
setupKeyboardHeightMultiplier()
46+
setupShowClipboardContent()
4647

4748
updateTextColors(settings_nested_scrollview)
4849

@@ -150,4 +151,12 @@ class SettingsActivity : SimpleActivity() {
150151
else -> getString(R.string.small)
151152
}
152153
}
154+
155+
private fun setupShowClipboardContent() {
156+
settings_show_clipboard_content.isChecked = config.showClipboardContent
157+
settings_show_clipboard_content_holder.setOnClickListener {
158+
settings_show_clipboard_content.toggle()
159+
config.showClipboardContent = settings_show_clipboard_content.isChecked
160+
}
161+
}
153162
}

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

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

36+
var showClipboardContent: Boolean
37+
get() = prefs.getBoolean(SHOW_CLIPBOARD_CONTENT, true)
38+
set(showClipboardContent) = prefs.edit().putBoolean(SHOW_CLIPBOARD_CONTENT, showClipboardContent).apply()
39+
3640

3741
private fun getDefaultLanguage(): Int {
3842
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
@@ -14,6 +14,7 @@ const val SHOW_KEY_BORDERS = "show_key_borders"
1414
const val LAST_EXPORTED_CLIPS_FOLDER = "last_exported_clips_folder"
1515
const val KEYBOARD_LANGUAGE = "keyboard_language"
1616
const val HEIGHT_MULTIPLIER = "height_multiplier"
17+
const val SHOW_CLIPBOARD_CONTENT = "show_clipboard_content"
1718

1819
// differentiate current and pinned clips at the keyboards' Clipboard section
1920
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
@@ -701,7 +701,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
701701
}
702702

703703
private fun handleClipboard() {
704-
if (mToolbarHolder != null && mPopupParent.id != R.id.mini_keyboard_view) {
704+
if (mToolbarHolder != null && mPopupParent.id != R.id.mini_keyboard_view && context.config.showClipboardContent) {
705705
val clipboardContent = context.getCurrentClip()
706706
if (clipboardContent?.isNotEmpty() == true) {
707707
mToolbarHolder?.apply {

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,21 @@
176176

177177
</RelativeLayout>
178178

179+
<RelativeLayout
180+
android:id="@+id/settings_show_clipboard_content_holder"
181+
style="@style/SettingsHolderCheckboxStyle"
182+
android:layout_width="match_parent"
183+
android:layout_height="wrap_content">
184+
185+
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
186+
android:id="@+id/settings_show_clipboard_content"
187+
style="@style/SettingsCheckboxStyle"
188+
android:layout_width="match_parent"
189+
android:layout_height="wrap_content"
190+
android:text="@string/show_clipboard_content" />
191+
192+
</RelativeLayout>
193+
179194
<RelativeLayout
180195
android:id="@+id/settings_keyboard_language_holder"
181196
style="@style/SettingsHolderTextViewStyle"

0 commit comments

Comments
 (0)