add a widget note picker at the config screen, if more notes are available

This commit is contained in:
tibbi 2018-09-12 20:48:22 +02:00
parent f52aa7f245
commit 4743db8dc0
24 changed files with 61 additions and 3 deletions

View File

@ -4,19 +4,20 @@ import android.app.Activity
import android.appwidget.AppWidgetManager import android.appwidget.AppWidgetManager
import android.content.Intent import android.content.Intent
import android.graphics.Color import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle import android.os.Bundle
import android.util.TypedValue import android.util.TypedValue
import android.widget.RemoteViews import android.widget.RemoteViews
import android.widget.SeekBar import android.widget.SeekBar
import com.simplemobiletools.commons.dialogs.ColorPickerDialog import com.simplemobiletools.commons.dialogs.ColorPickerDialog
import com.simplemobiletools.commons.extensions.adjustAlpha import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.extensions.setBackgroundColor
import com.simplemobiletools.commons.extensions.setFillWithStroke
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
import com.simplemobiletools.notes.R import com.simplemobiletools.notes.R
import com.simplemobiletools.notes.extensions.config import com.simplemobiletools.notes.extensions.config
import com.simplemobiletools.notes.extensions.dbHelper
import com.simplemobiletools.notes.extensions.getTextSize import com.simplemobiletools.notes.extensions.getTextSize
import com.simplemobiletools.notes.helpers.MyWidgetProvider import com.simplemobiletools.notes.helpers.MyWidgetProvider
import com.simplemobiletools.notes.models.Note
import kotlinx.android.synthetic.main.widget_config.* import kotlinx.android.synthetic.main.widget_config.*
class WidgetConfigureActivity : SimpleActivity() { class WidgetConfigureActivity : SimpleActivity() {
@ -25,6 +26,7 @@ class WidgetConfigureActivity : SimpleActivity() {
private var mBgColor = 0 private var mBgColor = 0
private var mBgColorWithoutTransparency = 0 private var mBgColorWithoutTransparency = 0
private var mTextColor = 0 private var mTextColor = 0
private var mNotes = ArrayList<Note>()
public override fun onCreate(savedInstanceState: Bundle?) { public override fun onCreate(savedInstanceState: Bundle?) {
useDynamicTheme = false useDynamicTheme = false
@ -40,9 +42,12 @@ class WidgetConfigureActivity : SimpleActivity() {
finish() finish()
} }
updateTextColors(notes_picker_holder)
config_save.setOnClickListener { saveConfig() } config_save.setOnClickListener { saveConfig() }
config_bg_color.setOnClickListener { pickBackgroundColor() } config_bg_color.setOnClickListener { pickBackgroundColor() }
config_text_color.setOnClickListener { pickTextColor() } config_text_color.setOnClickListener { pickTextColor() }
notes_picker_value.setOnClickListener { showNoteSelector() }
notes_picker_holder.background = ColorDrawable(config.backgroundColor)
} }
override fun onResume() { override fun onResume() {
@ -68,6 +73,12 @@ class WidgetConfigureActivity : SimpleActivity() {
mTextColor = config.widgetTextColor mTextColor = config.widgetTextColor
updateTextColor() updateTextColor()
mNotes = dbHelper.getNotes()
notes_picker_holder.beVisibleIf(mNotes.size > 1)
}
private fun showNoteSelector() {
} }
private fun saveConfig() { private fun saveConfig() {

View File

@ -7,11 +7,36 @@
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_margin="@dimen/activity_margin"> android:layout_margin="@dimen/activity_margin">
<RelativeLayout
android:id="@+id/notes_picker_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/notes_picker_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/normal_margin"
android:text="@string/note_shown_widget"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/notes_picker_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/notes_picker_label"
android:background="@drawable/button_background"
android:padding="@dimen/normal_margin"
android:text="@string/general_note"/>
</RelativeLayout>
<TextView <TextView
android:id="@+id/notes_view" android:id="@+id/notes_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_above="@+id/config_bg_color" android:layout_above="@+id/config_bg_color"
android:layout_below="@+id/notes_picker_holder"
android:layout_marginBottom="@dimen/activity_margin" android:layout_marginBottom="@dimen/activity_margin"
android:background="@null" android:background="@null"
android:gravity="top" android:gravity="top"

View File

@ -16,6 +16,7 @@
<string name="create_new_note">Yeni qeyd yarat</string> <string name="create_new_note">Yeni qeyd yarat</string>
<string name="add_to_note">Qeydə əlavə et</string> <string name="add_to_note">Qeydə əlavə et</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">Faylı</string> <string name="open_file">Faylı</string>

View File

@ -16,6 +16,7 @@
<string name="create_new_note">Opret en ny note</string> <string name="create_new_note">Opret en ny note</string>
<string name="add_to_note">Føj til note</string> <string name="add_to_note">Føj til note</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">Åbn fil …</string> <string name="open_file">Åbn fil …</string>

View File

@ -16,6 +16,7 @@
<string name="create_new_note">Neue Notiz erstellen</string> <string name="create_new_note">Neue Notiz erstellen</string>
<string name="add_to_note">Zu Notiz hinzufügen</string> <string name="add_to_note">Zu Notiz hinzufügen</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">Datei öffnen</string> <string name="open_file">Datei öffnen</string>

View File

@ -16,6 +16,7 @@
<string name="create_new_note">Crear una nota nueva</string> <string name="create_new_note">Crear una nota nueva</string>
<string name="add_to_note">Añadir a la nota</string> <string name="add_to_note">Añadir a la nota</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">Abrir archivo</string> <string name="open_file">Abrir archivo</string>

View File

@ -16,6 +16,7 @@
<string name="create_new_note">Créer une nouvelle note</string> <string name="create_new_note">Créer une nouvelle note</string>
<string name="add_to_note">Ajouter à la note</string> <string name="add_to_note">Ajouter à la note</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">Ouvrir le fichier</string> <string name="open_file">Ouvrir le fichier</string>

View File

@ -18,6 +18,7 @@
<string name="create_new_note">Crear unha nova nota</string> <string name="create_new_note">Crear unha nova nota</string>
<string name="add_to_note">Engadir a nota</string> <string name="add_to_note">Engadir a nota</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">Abrir ficheiro</string> <string name="open_file">Abrir ficheiro</string>

View File

@ -16,6 +16,7 @@
<string name="create_new_note">Stvori novu bilješku</string> <string name="create_new_note">Stvori novu bilješku</string>
<string name="add_to_note">Dodaj u bilješku</string> <string name="add_to_note">Dodaj u bilješku</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">Otvori datoteku</string> <string name="open_file">Otvori datoteku</string>

View File

@ -16,6 +16,7 @@
<string name="create_new_note">Create a new note</string> <string name="create_new_note">Create a new note</string>
<string name="add_to_note">Add to note</string> <string name="add_to_note">Add to note</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">Fájl megnyitása</string> <string name="open_file">Fájl megnyitása</string>

View File

@ -16,6 +16,7 @@
<string name="create_new_note">Create a new note</string> <string name="create_new_note">Create a new note</string>
<string name="add_to_note">Add to note</string> <string name="add_to_note">Add to note</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">Open file</string> <string name="open_file">Open file</string>

View File

@ -16,6 +16,7 @@
<string name="create_new_note">Create a new note</string> <string name="create_new_note">Create a new note</string>
<string name="add_to_note">Add to note</string> <string name="add_to_note">Add to note</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">Open file</string> <string name="open_file">Open file</string>

View File

@ -16,6 +16,7 @@
<string name="create_new_note">Kurti naują įrašą</string> <string name="create_new_note">Kurti naują įrašą</string>
<string name="add_to_note">Papildyti įrašą</string> <string name="add_to_note">Papildyti įrašą</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">Atverti failą</string> <string name="open_file">Atverti failą</string>

View File

@ -16,6 +16,7 @@
<string name="create_new_note">Nieuwe notitie maken</string> <string name="create_new_note">Nieuwe notitie maken</string>
<string name="add_to_note">Aan notitie toevoegen</string> <string name="add_to_note">Aan notitie toevoegen</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">Bestand openen</string> <string name="open_file">Bestand openen</string>

View File

@ -16,6 +16,7 @@
<string name="create_new_note">Utwórz nową notatkę</string> <string name="create_new_note">Utwórz nową notatkę</string>
<string name="add_to_note">Dodaj do notatki</string> <string name="add_to_note">Dodaj do notatki</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">Otwórz plik</string> <string name="open_file">Otwórz plik</string>

View File

@ -16,6 +16,7 @@
<string name="create_new_note">Criar uma nova nota</string> <string name="create_new_note">Criar uma nova nota</string>
<string name="add_to_note">Adicionar à nota</string> <string name="add_to_note">Adicionar à nota</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">Abrir arquivo</string> <string name="open_file">Abrir arquivo</string>

View File

@ -16,6 +16,7 @@
<string name="create_new_note">Criar uma nota</string> <string name="create_new_note">Criar uma nota</string>
<string name="add_to_note">Adicionar a uma nota</string> <string name="add_to_note">Adicionar a uma nota</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">Abrir ficheiro</string> <string name="open_file">Abrir ficheiro</string>

View File

@ -16,6 +16,7 @@
<string name="create_new_note">Новая заметка</string> <string name="create_new_note">Новая заметка</string>
<string name="add_to_note">Добавить к заметке</string> <string name="add_to_note">Добавить к заметке</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">Открыть файл</string> <string name="open_file">Открыть файл</string>

View File

@ -16,6 +16,7 @@
<string name="create_new_note">Vytvoriť novú poznámku</string> <string name="create_new_note">Vytvoriť novú poznámku</string>
<string name="add_to_note">Pridať k poznámke</string> <string name="add_to_note">Pridať k poznámke</string>
<string name="unsaved_changes_warning">Máte nejaké neuložené zmeny. Čo s nimi chcete spraviť?</string> <string name="unsaved_changes_warning">Máte nejaké neuložené zmeny. Čo s nimi chcete spraviť?</string>
<string name="note_shown_widget">Poznámka zobrazená vo widgete:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">Otvoriť súbor</string> <string name="open_file">Otvoriť súbor</string>

View File

@ -16,6 +16,7 @@
<string name="create_new_note">Skapa en ny anteckning</string> <string name="create_new_note">Skapa en ny anteckning</string>
<string name="add_to_note">Lägg till i anteckning</string> <string name="add_to_note">Lägg till i anteckning</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">Öppna fil</string> <string name="open_file">Öppna fil</string>

View File

@ -16,6 +16,7 @@
<string name="create_new_note">Yeni not oluştur</string> <string name="create_new_note">Yeni not oluştur</string>
<string name="add_to_note">Nota ekle</string> <string name="add_to_note">Nota ekle</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">Dosya aç</string> <string name="open_file">Dosya aç</string>

View File

@ -16,6 +16,7 @@
<string name="create_new_note">创建一个新的笔记</string> <string name="create_new_note">创建一个新的笔记</string>
<string name="add_to_note">添加到笔记</string> <string name="add_to_note">添加到笔记</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">打开文件</string> <string name="open_file">打开文件</string>

View File

@ -16,6 +16,7 @@
<string name="create_new_note">建立新筆記</string> <string name="create_new_note">建立新筆記</string>
<string name="add_to_note">添加到筆記</string> <string name="add_to_note">添加到筆記</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">打開檔案</string> <string name="open_file">打開檔案</string>

View File

@ -16,6 +16,7 @@
<string name="create_new_note">Create a new note</string> <string name="create_new_note">Create a new note</string>
<string name="add_to_note">Add to note</string> <string name="add_to_note">Add to note</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string> <string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<!-- File notes --> <!-- File notes -->
<string name="open_file">Open file</string> <string name="open_file">Open file</string>