diff options
| author | Jules Aguillon | 2023-08-10 20:55:42 +0200 |
|---|---|---|
| committer | Jules Aguillon | 2023-08-16 12:21:38 +0200 |
| commit | 613aa283bdcab3d8d6e26fbe08aedcc49a8fe571 (patch) | |
| tree | 5760d3e69c389cc0e41f5f7a9c59b75e6f986cd3 /srcs/juloo.keyboard2/LayoutsPreference.java | |
| parent | ddceb69d4e5a8eac458b20145fe121580c0d6444 (diff) | |
| download | unexpected-keyboard-613aa283bdcab3d8d6e26fbe08aedcc49a8fe571.tar.gz unexpected-keyboard-613aa283bdcab3d8d6e26fbe08aedcc49a8fe571.zip | |
LayoutsPreference: Remove cross button for custom layouts
Remove the cross button on the right of custom layouts to reduce
accidental removal.
A remove button is added in the dialog for modifying the layout.
Diffstat (limited to 'srcs/juloo.keyboard2/LayoutsPreference.java')
| -rw-r--r-- | srcs/juloo.keyboard2/LayoutsPreference.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/srcs/juloo.keyboard2/LayoutsPreference.java b/srcs/juloo.keyboard2/LayoutsPreference.java index 87a7c3b..d6669ba 100644 --- a/srcs/juloo.keyboard2/LayoutsPreference.java +++ b/srcs/juloo.keyboard2/LayoutsPreference.java @@ -122,9 +122,9 @@ public class LayoutsPreference extends ListGroupPreference<LayoutsPreference.Lay } @Override - boolean should_allow_remove_item() + boolean should_allow_remove_item(Layout value) { - return (_values.size() > 1); + return (_values.size() > 1 && !(value instanceof CustomLayout)); } @Override @@ -163,7 +163,7 @@ public class LayoutsPreference extends ListGroupPreference<LayoutsPreference.Lay { final EditText input = new EditText(getContext()); input.setText(initial_text); - new AlertDialog.Builder(getContext()) + AlertDialog.Builder dialog = new AlertDialog.Builder(getContext()) .setView(input) .setTitle(R.string.pref_custom_layout_title) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){ @@ -172,8 +172,16 @@ public class LayoutsPreference extends ListGroupPreference<LayoutsPreference.Lay callback.select(new CustomLayout(input.getText().toString())); } }) - .setNegativeButton(android.R.string.cancel, null) - .show(); + .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(); } /** Called when modifying a layout. Custom layouts behave differently. */ |
