abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/LayoutsPreference.java
diff options
context:
space:
mode:
authorJules Aguillon2023-12-10 19:44:50 +0100
committerJules Aguillon2023-12-10 19:44:50 +0100
commitdd327cc812ccf7c37187294771b011af402b7189 (patch)
tree9c855e3628d8d0e14cef5ecc070eef47492f8e58 /srcs/juloo.keyboard2/LayoutsPreference.java
parentd073523125628ed3dcd7ef5f8a123d88c0dd3c1e (diff)
downloadunexpected-keyboard-dd327cc812ccf7c37187294771b011af402b7189.tar.gz
unexpected-keyboard-dd327cc812ccf7c37187294771b011af402b7189.zip
prefs: Render line numbers in custom layout input box
Line numbers will help reporting errors. Also, disable line breaking to improve readability.
Diffstat (limited to 'srcs/juloo.keyboard2/LayoutsPreference.java')
-rw-r--r--srcs/juloo.keyboard2/LayoutsPreference.java32
1 files changed, 11 insertions, 21 deletions
diff --git a/srcs/juloo.keyboard2/LayoutsPreference.java b/srcs/juloo.keyboard2/LayoutsPreference.java
index f15bad9..f96af80 100644
--- a/srcs/juloo.keyboard2/LayoutsPreference.java
+++ b/srcs/juloo.keyboard2/LayoutsPreference.java
@@ -8,7 +8,6 @@ import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.ArrayAdapter;
-import android.widget.EditText;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -167,27 +166,18 @@ public class LayoutsPreference extends ListGroupPreference<LayoutsPreference.Lay
description when modifying a layout. */
void select_custom(final SelectionCallback callback, String initial_text)
{
- final EditText input = new EditText(getContext());
- input.setText(initial_text);
- AlertDialog.Builder dialog = new AlertDialog.Builder(getContext())
- .setView(input)
- .setTitle(R.string.pref_custom_layout_title)
- .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
- public void onClick(DialogInterface _dialog, int _which)
+ boolean allow_remove = callback.allow_remove() && _values.size() > 1;
+ CustomLayoutEditDialog.show(getContext(), initial_text, allow_remove,
+ new CustomLayoutEditDialog.Callback()
{
- callback.select(new CustomLayout(input.getText().toString()));
- }
- })
- .setNegativeButton(android.R.string.cancel, null);
- // Might be true when modifying an existing layout
- if (callback.allow_remove() && _values.size() > 1)
- dialog.setNeutralButton(R.string.pref_layouts_remove_custom, new DialogInterface.OnClickListener(){
- public void onClick(DialogInterface _dialog, int _which)
- {
- callback.select(null);
- }
- });
- dialog.show();
+ public void select(String text)
+ {
+ if (text == null)
+ callback.select(null);
+ else
+ callback.select(new CustomLayout(text));
+ }
+ });
}
/** Called when modifying a layout. Custom layouts behave differently. */