adding the dialog for inserting new clips
This commit is contained in:
parent
8191ad7017
commit
565a149d6d
|
@ -64,7 +64,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:1db5d21d3e'
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:8921e5c41c'
|
||||
|
||||
kapt 'androidx.room:room-compiler:2.3.0'
|
||||
implementation 'androidx.room:room-runtime:2.3.0'
|
||||
|
|
|
@ -3,10 +3,14 @@ package com.simplemobiletools.keyboard.activities
|
|||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
|
||||
import com.simplemobiletools.commons.extensions.underlineText
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.keyboard.R
|
||||
import com.simplemobiletools.keyboard.dialogs.AddClipDialog
|
||||
import com.simplemobiletools.keyboard.extensions.clipsDB
|
||||
import kotlinx.android.synthetic.main.activity_manage_clipboard_items.*
|
||||
|
||||
class ManageClipboardItemsActivity : SimpleActivity() {
|
||||
|
@ -15,7 +19,9 @@ class ManageClipboardItemsActivity : SimpleActivity() {
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_manage_clipboard_items)
|
||||
updateTextColors(clipboard_items_wrapper)
|
||||
updateClips()
|
||||
|
||||
clipboard_items_placeholder.text = "${getText(R.string.manage_clipboard_empty)}\n\n${getText(R.string.manage_clips)}"
|
||||
clipboard_items_placeholder_2.apply {
|
||||
underlineText()
|
||||
setTextColor(getAdjustedPrimaryColor())
|
||||
|
@ -40,7 +46,20 @@ class ManageClipboardItemsActivity : SimpleActivity() {
|
|||
return true
|
||||
}
|
||||
|
||||
private fun addNewClip() {
|
||||
private fun updateClips() {
|
||||
ensureBackgroundThread {
|
||||
val clips = clipsDB.getClips()
|
||||
runOnUiThread {
|
||||
clipboard_items_list.beVisibleIf(clips.isNotEmpty())
|
||||
clipboard_items_placeholder.beVisibleIf(clips.isEmpty())
|
||||
clipboard_items_placeholder_2.beVisibleIf(clips.isEmpty())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun addNewClip() {
|
||||
AddClipDialog(this) {
|
||||
updateClips()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package com.simplemobiletools.keyboard.dialogs
|
||||
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.extensions.showKeyboard
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.extensions.value
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.keyboard.R
|
||||
import com.simplemobiletools.keyboard.extensions.clipsDB
|
||||
import com.simplemobiletools.keyboard.models.Clip
|
||||
import kotlinx.android.synthetic.main.dialog_add_clip.view.*
|
||||
|
||||
class AddClipDialog(val activity: BaseSimpleActivity, val callback: () -> Unit) {
|
||||
init {
|
||||
val view = activity.layoutInflater.inflate(R.layout.dialog_add_clip, null)
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this) {
|
||||
showKeyboard(view.add_clip_value)
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
val clipValue = view.add_clip_value.value
|
||||
if (clipValue.isEmpty()) {
|
||||
activity.toast(R.string.value_cannot_be_empty)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
val clip = Clip(null, clipValue)
|
||||
ensureBackgroundThread {
|
||||
activity.clipsDB.insertOrUpdate(clip)
|
||||
activity.runOnUiThread {
|
||||
callback()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/dialog_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingTop="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyEditText
|
||||
android:id="@+id/add_clip_value"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/activity_margin"
|
||||
android:layout_marginEnd="@dimen/activity_margin"
|
||||
android:hint="@string/clip_text"
|
||||
android:inputType="textCapSentences"
|
||||
android:textCursorDrawable="@null"
|
||||
android:textSize="@dimen/bigger_text_size" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -6,7 +6,7 @@
|
|||
<string name="change_keyboard">Canvia el teclat</string>
|
||||
<!-- Clipboard -->
|
||||
<string name="manage_clipboard_items">Manage clipboard items</string>
|
||||
<string name="manage_clipboard_empty">Your clipboard is empty</string>
|
||||
<string name="manage_clipboard_empty">Your clipboard is empty.</string>
|
||||
<string name="manage_clipboard_label">Once you copy some text, it will show up here. You can also pin clips so they won\'t disappear later.</string>
|
||||
<string name="clear_clipboard_data">Neteja les dades del porta-retalls</string>
|
||||
<string name="clear_clipboard_data_confirmation">Esteu segur que voleu netejar les dades del porta-retalls\?</string>
|
||||
|
@ -15,6 +15,7 @@
|
|||
<string name="clipboard_pinned">Fixat</string>
|
||||
<string name="add_new_item">Add a new item</string>
|
||||
<string name="manage_clips">You can manage or add clips here for quick access.</string>
|
||||
<string name="clip_text">Clip text</string>
|
||||
<!-- Accessibility -->
|
||||
<string name="keycode_delete">Suprimeix</string>
|
||||
<string name="keycode_mode_change">Canvia el tipus de teclat</string>
|
||||
|
@ -34,4 +35,4 @@
|
|||
Haven't found some strings? There's more at
|
||||
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
|
||||
-->
|
||||
</resources>
|
||||
</resources>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<string name="change_keyboard">Skift tastatur</string>
|
||||
<!-- Clipboard -->
|
||||
<string name="manage_clipboard_items">Manage clipboard items</string>
|
||||
<string name="manage_clipboard_empty">Your clipboard is empty</string>
|
||||
<string name="manage_clipboard_empty">Your clipboard is empty.</string>
|
||||
<string name="manage_clipboard_label">Once you copy some text, it will show up here. You can also pin clips so they won\'t disappear later.</string>
|
||||
<string name="clear_clipboard_data">Ryd data i udklipsholder</string>
|
||||
<string name="clear_clipboard_data_confirmation">Er du sikker på, at du vil slette data i udklipsholderen\?</string>
|
||||
|
@ -15,6 +15,7 @@
|
|||
<string name="clipboard_pinned">Pinned</string>
|
||||
<string name="add_new_item">Add a new item</string>
|
||||
<string name="manage_clips">You can manage or add clips here for quick access.</string>
|
||||
<string name="clip_text">Clip text</string>
|
||||
<!-- Accessibility -->
|
||||
<string name="keycode_delete">Slet</string>
|
||||
<string name="keycode_mode_change">Skift tastaturtype</string>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<string name="change_keyboard">Tastatur wechseln</string>
|
||||
<!-- Clipboard -->
|
||||
<string name="manage_clipboard_items">Manage clipboard items</string>
|
||||
<string name="manage_clipboard_empty">Your clipboard is empty</string>
|
||||
<string name="manage_clipboard_empty">Your clipboard is empty.</string>
|
||||
<string name="manage_clipboard_label">Once you copy some text, it will show up here. You can also pin clips so they won\'t disappear later.</string>
|
||||
<string name="clear_clipboard_data">Daten in der Zwischenablage löschen</string>
|
||||
<string name="clear_clipboard_data_confirmation">Sind Sie sicher, dass Sie die Daten in der Zwischenablage löschen wollen\?</string>
|
||||
|
@ -15,6 +15,7 @@
|
|||
<string name="clipboard_pinned">Pinned</string>
|
||||
<string name="add_new_item">Add a new item</string>
|
||||
<string name="manage_clips">You can manage or add clips here for quick access.</string>
|
||||
<string name="clip_text">Clip text</string>
|
||||
<!-- Accessibility -->
|
||||
<string name="keycode_delete">Löschen</string>
|
||||
<string name="keycode_mode_change">Tastaturtyp ändern</string>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<string name="change_keyboard">Αλλαγή πληκτρολογίου</string>
|
||||
<!-- Clipboard -->
|
||||
<string name="manage_clipboard_items">Manage clipboard items</string>
|
||||
<string name="manage_clipboard_empty">Your clipboard is empty</string>
|
||||
<string name="manage_clipboard_empty">Your clipboard is empty.</string>
|
||||
<string name="manage_clipboard_label">Once you copy some text, it will show up here. You can also pin clips so they won\'t disappear later.</string>
|
||||
<string name="clear_clipboard_data">Καθαρισμός δεδομένων πρόχειρου</string>
|
||||
<string name="clear_clipboard_data_confirmation">Είστε σίγουροι ότι θέλετε να διαγράψετε τα δεδομένα του πρόχειρου;</string>
|
||||
|
@ -15,6 +15,7 @@
|
|||
<string name="clipboard_pinned">Καρφιτσωμένα</string>
|
||||
<string name="add_new_item">Add a new item</string>
|
||||
<string name="manage_clips">You can manage or add clips here for quick access.</string>
|
||||
<string name="clip_text">Clip text</string>
|
||||
<!-- Accessibility -->
|
||||
<string name="keycode_delete">Διαγραφή</string>
|
||||
<string name="keycode_mode_change">Αλλαγή τύπου πληκτρολογίου</string>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<string name="change_keyboard">Changer de clavier</string>
|
||||
<!-- Clipboard -->
|
||||
<string name="manage_clipboard_items">Manage clipboard items</string>
|
||||
<string name="manage_clipboard_empty">Your clipboard is empty</string>
|
||||
<string name="manage_clipboard_empty">Your clipboard is empty.</string>
|
||||
<string name="manage_clipboard_label">Once you copy some text, it will show up here. You can also pin clips so they won\'t disappear later.</string>
|
||||
<string name="clear_clipboard_data">Effacer les données du presse-papiers</string>
|
||||
<string name="clear_clipboard_data_confirmation">Voulez-vous vraiment effacer les données du presse-papiers \?</string>
|
||||
|
@ -15,6 +15,7 @@
|
|||
<string name="clipboard_pinned">Épinglé</string>
|
||||
<string name="add_new_item">Add a new item</string>
|
||||
<string name="manage_clips">You can manage or add clips here for quick access.</string>
|
||||
<string name="clip_text">Clip text</string>
|
||||
<!-- Accessibility -->
|
||||
<string name="keycode_delete">Supprimer</string>
|
||||
<string name="keycode_mode_change">Changer de type de clavier</string>
|
||||
|
@ -34,4 +35,4 @@
|
|||
Haven't found some strings? There's more at
|
||||
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
|
||||
-->
|
||||
</resources>
|
||||
</resources>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<string name="change_keyboard">Promijeni tipkovnicu</string>
|
||||
<!-- Clipboard -->
|
||||
<string name="manage_clipboard_items">Manage clipboard items</string>
|
||||
<string name="manage_clipboard_empty">Your clipboard is empty</string>
|
||||
<string name="manage_clipboard_empty">Your clipboard is empty.</string>
|
||||
<string name="manage_clipboard_label">Once you copy some text, it will show up here. You can also pin clips so they won\'t disappear later.</string>
|
||||
<string name="clear_clipboard_data">Izbriši podatke međuspremnika</string>
|
||||
<string name="clear_clipboard_data_confirmation">Stvarno želiš izbrisati podatke međuspremnika\?</string>
|
||||
|
@ -15,6 +15,7 @@
|
|||
<string name="clipboard_pinned">Pinned</string>
|
||||
<string name="add_new_item">Add a new item</string>
|
||||
<string name="manage_clips">You can manage or add clips here for quick access.</string>
|
||||
<string name="clip_text">Clip text</string>
|
||||
<!-- Accessibility -->
|
||||
<string name="keycode_delete">Izbriži</string>
|
||||
<string name="keycode_mode_change">Promijeni vrstu tipkovnice</string>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<string name="change_keyboard">Cambia la tastiera</string>
|
||||
<!-- Clipboard -->
|
||||
<string name="manage_clipboard_items">Manage clipboard items</string>
|
||||
<string name="manage_clipboard_empty">Your clipboard is empty</string>
|
||||
<string name="manage_clipboard_empty">Your clipboard is empty.</string>
|
||||
<string name="manage_clipboard_label">Once you copy some text, it will show up here. You can also pin clips so they won\'t disappear later.</string>
|
||||
<string name="clear_clipboard_data">Elimina i dati degli appunti</string>
|
||||
<string name="clear_clipboard_data_confirmation">Vuoi davvero eliminare i dati degli appunti\?</string>
|
||||
|
@ -15,6 +15,7 @@
|
|||
<string name="clipboard_pinned">Pinned</string>
|
||||
<string name="add_new_item">Add a new item</string>
|
||||
<string name="manage_clips">You can manage or add clips here for quick access.</string>
|
||||
<string name="clip_text">Clip text</string>
|
||||
<!-- Accessibility -->
|
||||
<string name="keycode_delete">Elimina</string>
|
||||
<string name="keycode_mode_change">Cambia il tipo di tastiera</string>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<string name="change_keyboard">Keisti klaviatūrą</string>
|
||||
<!-- Clipboard -->
|
||||
<string name="manage_clipboard_items">Manage clipboard items</string>
|
||||
<string name="manage_clipboard_empty">Your clipboard is empty</string>
|
||||
<string name="manage_clipboard_empty">Your clipboard is empty.</string>
|
||||
<string name="manage_clipboard_label">Once you copy some text, it will show up here. You can also pin clips so they won\'t disappear later.</string>
|
||||
<string name="clear_clipboard_data">Išvalyti iškarpinės duomenis</string>
|
||||
<string name="clear_clipboard_data_confirmation">Ar tikrai norite išvalyti iškarpinės duomenis\?</string>
|
||||
|
@ -15,6 +15,7 @@
|
|||
<string name="clipboard_pinned">Pinned</string>
|
||||
<string name="add_new_item">Add a new item</string>
|
||||
<string name="manage_clips">You can manage or add clips here for quick access.</string>
|
||||
<string name="clip_text">Clip text</string>
|
||||
<!-- Accessibility -->
|
||||
<string name="keycode_delete">Delete</string>
|
||||
<string name="keycode_mode_change">Keisti klaviatūros tipą</string>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<string name="change_keyboard">Zmień klawiaturę</string>
|
||||
<!-- Clipboard -->
|
||||
<string name="manage_clipboard_items">Zarządzaj elementami schowka</string>
|
||||
<string name="manage_clipboard_empty">Twój schowek jest pusty</string>
|
||||
<string name="manage_clipboard_empty">Twój schowek jest pusty.</string>
|
||||
<string name="manage_clipboard_label">Gdy skopiujesz jakiś tekst, pojawi się on tutaj. Możesz także przypinać wpisy, aby później nie zniknęły.</string>
|
||||
<string name="clear_clipboard_data">Wyczyść dane schowka</string>
|
||||
<string name="clear_clipboard_data_confirmation">Czy wyczyścić dane schowka\?</string>
|
||||
|
@ -15,6 +15,7 @@
|
|||
<string name="clipboard_pinned">Przypięte</string>
|
||||
<string name="add_new_item">Add a new item</string>
|
||||
<string name="manage_clips">You can manage or add clips here for quick access.</string>
|
||||
<string name="clip_text">Clip text</string>
|
||||
<!-- Accessibility -->
|
||||
<string name="keycode_delete">Usuń</string>
|
||||
<string name="keycode_mode_change">Zmień typ klawiatury</string>
|
||||
|
@ -34,4 +35,4 @@
|
|||
Haven't found some strings? There's more at
|
||||
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
|
||||
-->
|
||||
</resources>
|
||||
</resources>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<string name="change_keyboard">Zmeniť klávesnicu</string>
|
||||
<!-- Clipboard -->
|
||||
<string name="manage_clipboard_items">Spravovať položky v schránke</string>
|
||||
<string name="manage_clipboard_empty">Schránka je prázdna</string>
|
||||
<string name="manage_clipboard_empty">Vaša schránka je prázdna.</string>
|
||||
<string name="manage_clipboard_label">Akonáhle skopírujete nejaký text, objaví sa tu. Budete ho aj môcť pripnúť, aby sa časom nestratil.</string>
|
||||
<string name="clear_clipboard_data">Vyčistič schránku</string>
|
||||
<string name="clear_clipboard_data_confirmation">Ste si istý, že chcete vyčistiť schránku?</string>
|
||||
|
@ -15,6 +15,7 @@
|
|||
<string name="clipboard_pinned">Pripnuté</string>
|
||||
<string name="add_new_item">Pridať novú položku</string>
|
||||
<string name="manage_clips">Na tomto mieste viete spravovať a pridávať nové pripnutia do schránky pre rýchly prístup.</string>
|
||||
<string name="clip_text">Text položky</string>
|
||||
<!-- Accessibility -->
|
||||
<string name="keycode_delete">Odstrániť</string>
|
||||
<string name="keycode_mode_change">Zmeniť typ klávesnice</string>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<string name="change_keyboard">Klavye Değiştir</string>
|
||||
<!-- Clipboard -->
|
||||
<string name="manage_clipboard_items">Manage clipboard items</string>
|
||||
<string name="manage_clipboard_empty">Your clipboard is empty</string>
|
||||
<string name="manage_clipboard_empty">Your clipboard is empty.</string>
|
||||
<string name="manage_clipboard_label">Once you copy some text, it will show up here. You can also pin clips so they won\'t disappear later.</string>
|
||||
<string name="clear_clipboard_data">Pano verilerini temizle</string>
|
||||
<string name="clear_clipboard_data_confirmation">Pano verilerini silmek istediğinizden emin misiniz\?</string>
|
||||
|
@ -15,6 +15,7 @@
|
|||
<string name="clipboard_pinned">Sabitlendi</string>
|
||||
<string name="add_new_item">Add a new item</string>
|
||||
<string name="manage_clips">You can manage or add clips here for quick access.</string>
|
||||
<string name="clip_text">Clip text</string>
|
||||
<!-- Accessibility -->
|
||||
<string name="keycode_delete">Sil</string>
|
||||
<string name="keycode_mode_change">Klavye türünü değiştir</string>
|
||||
|
@ -34,4 +35,4 @@
|
|||
Haven't found some strings? There's more at
|
||||
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
|
||||
-->
|
||||
</resources>
|
||||
</resources>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<string name="change_keyboard">Change Keyboard</string>
|
||||
<!-- Clipboard -->
|
||||
<string name="manage_clipboard_items">Manage clipboard items</string>
|
||||
<string name="manage_clipboard_empty">Your clipboard is empty</string>
|
||||
<string name="manage_clipboard_empty">Your clipboard is empty.</string>
|
||||
<string name="manage_clipboard_label">Once you copy some text, it will show up here. You can also pin clips so they won\'t disappear later.</string>
|
||||
<string name="clear_clipboard_data">Clear clipboard data</string>
|
||||
<string name="clear_clipboard_data_confirmation">Are you sure you want to clear the clipboard data?</string>
|
||||
|
@ -15,6 +15,7 @@
|
|||
<string name="clipboard_pinned">Pinned</string>
|
||||
<string name="add_new_item">Add a new item</string>
|
||||
<string name="manage_clips">You can manage or add clips here for quick access.</string>
|
||||
<string name="clip_text">Clip text</string>
|
||||
<!-- Accessibility -->
|
||||
<string name="keycode_delete">Delete</string>
|
||||
<string name="keycode_mode_change">Change keyboard type</string>
|
||||
|
|
Loading…
Reference in New Issue