From 7c85870352c93cc7f73f28c26effc37e4f5bfc9b Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sun, 8 Dec 2024 11:43:40 +0100 Subject: [PATCH] Fix empty text box when editing custom extra keys --- .../prefs/CustomExtraKeysPreference.java | 7 +++++-- srcs/juloo.keyboard2/prefs/LayoutsPreference.java | 7 +++---- srcs/juloo.keyboard2/prefs/ListGroupPreference.java | 13 ++++--------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/srcs/juloo.keyboard2/prefs/CustomExtraKeysPreference.java b/srcs/juloo.keyboard2/prefs/CustomExtraKeysPreference.java index fda07ec..6f4cf41 100644 --- a/srcs/juloo.keyboard2/prefs/CustomExtraKeysPreference.java +++ b/srcs/juloo.keyboard2/prefs/CustomExtraKeysPreference.java @@ -10,6 +10,7 @@ import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.widget.EditText; +import android.widget.TextView; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -48,10 +49,12 @@ public class CustomExtraKeysPreference extends ListGroupPreference String label_of_value(String value, int i) { return value; } @Override - void select(final SelectionCallback callback) + void select(final SelectionCallback callback, String old_value) { + View content = View.inflate(getContext(), R.layout.dialog_edit_text, null); + ((TextView)content.findViewById(R.id.text)).setText(old_value); new AlertDialog.Builder(getContext()) - .setView(View.inflate(getContext(), R.layout.dialog_edit_text, null)) + .setView(content) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialog, int which) { diff --git a/srcs/juloo.keyboard2/prefs/LayoutsPreference.java b/srcs/juloo.keyboard2/prefs/LayoutsPreference.java index c1a863f..1798f8d 100644 --- a/srcs/juloo.keyboard2/prefs/LayoutsPreference.java +++ b/srcs/juloo.keyboard2/prefs/LayoutsPreference.java @@ -145,8 +145,7 @@ public class LayoutsPreference extends ListGroupPreference get_serializer() { return SERIALIZER; } - @Override - void select(final SelectionCallback callback) + void select_dialog(final SelectionCallback callback) { ArrayAdapter layouts = new ArrayAdapter(getContext(), android.R.layout.simple_list_item_1, _layout_display_names); new AlertDialog.Builder(getContext()) @@ -207,10 +206,10 @@ public class LayoutsPreference extends ListGroupPreference extends PreferenceGroup return true; } - /** Called when an item is added or modified. */ - abstract void select(SelectionCallback callback); - - /** Called when an item is modified. */ - void select(SelectionCallback callback, E _old_value) - { - select(callback); - } + /** Called when an item is added or modified. [old_value] is [null] if the + item is being added. */ + abstract void select(SelectionCallback callback, E old_value); /** A separate class is used as the same serializer must be used in the static context. See [Serializer] below. */ @@ -261,7 +256,7 @@ public abstract class ListGroupPreference extends PreferenceGroup } public boolean allow_remove() { return false; } - }); + }, null); } }