mirror of
https://github.com/Julow/Unexpected-Keyboard.git
synced 2024-11-26 01:03:24 +01:00
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.
This commit is contained in:
parent
ddceb69d4e
commit
613aa283bd
@ -14,6 +14,7 @@
|
|||||||
<string name="pref_layout_e_custom">Vlastní rozvržení</string>
|
<string name="pref_layout_e_custom">Vlastní rozvržení</string>
|
||||||
<string name="pref_layouts_add">Přidat alternativní rozložení</string>
|
<string name="pref_layouts_add">Přidat alternativní rozložení</string>
|
||||||
<string name="pref_layouts_item">Rozložení %1$d: %2$s</string>
|
<string name="pref_layouts_item">Rozložení %1$d: %2$s</string>
|
||||||
|
<!-- <string name="pref_layouts_remove_custom">Remove layout</string> -->
|
||||||
<string name="pref_custom_layout_title">Vlastní rozvržení</string>
|
<string name="pref_custom_layout_title">Vlastní rozvržení</string>
|
||||||
<string name="pref_show_numpad_title">Zobrazit NumPad</string>
|
<string name="pref_show_numpad_title">Zobrazit NumPad</string>
|
||||||
<string name="pref_show_numpad_never">Nikdy</string>
|
<string name="pref_show_numpad_never">Nikdy</string>
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<string name="pref_layout_e_custom">Eigenes Layout</string>
|
<string name="pref_layout_e_custom">Eigenes Layout</string>
|
||||||
<string name="pref_layouts_add">Alternatives Layout hinzufügen</string>
|
<string name="pref_layouts_add">Alternatives Layout hinzufügen</string>
|
||||||
<string name="pref_layouts_item">Layout %1$d: %2$s</string>
|
<string name="pref_layouts_item">Layout %1$d: %2$s</string>
|
||||||
|
<!-- <string name="pref_layouts_remove_custom">Remove layout</string> -->
|
||||||
<string name="pref_custom_layout_title">Eigenes Layout</string>
|
<string name="pref_custom_layout_title">Eigenes Layout</string>
|
||||||
<string name="pref_show_numpad_title">Ziffernblock anzeigen</string>
|
<string name="pref_show_numpad_title">Ziffernblock anzeigen</string>
|
||||||
<string name="pref_show_numpad_never">Nie</string>
|
<string name="pref_show_numpad_never">Nie</string>
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<string name="pref_layout_e_custom">Formato personalizado</string>
|
<string name="pref_layout_e_custom">Formato personalizado</string>
|
||||||
<!-- <string name="pref_layouts_add">Add an alternate layout</string> -->
|
<!-- <string name="pref_layouts_add">Add an alternate layout</string> -->
|
||||||
<!-- <string name="pref_layouts_item">Layout %1$d: %2$s</string> -->
|
<!-- <string name="pref_layouts_item">Layout %1$d: %2$s</string> -->
|
||||||
|
<!-- <string name="pref_layouts_remove_custom">Remove layout</string> -->
|
||||||
<string name="pref_custom_layout_title">Formato personalizado</string>
|
<string name="pref_custom_layout_title">Formato personalizado</string>
|
||||||
<string name="pref_show_numpad_title">Mostrar pad numérico</string>
|
<string name="pref_show_numpad_title">Mostrar pad numérico</string>
|
||||||
<string name="pref_show_numpad_never">Nunca</string>
|
<string name="pref_show_numpad_never">Nunca</string>
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<string name="pref_layout_e_custom">طرح صفارشی</string>
|
<string name="pref_layout_e_custom">طرح صفارشی</string>
|
||||||
<!-- <string name="pref_layouts_add">Add an alternate layout</string> -->
|
<!-- <string name="pref_layouts_add">Add an alternate layout</string> -->
|
||||||
<!-- <string name="pref_layouts_item">Layout %1$d: %2$s</string> -->
|
<!-- <string name="pref_layouts_item">Layout %1$d: %2$s</string> -->
|
||||||
|
<!-- <string name="pref_layouts_remove_custom">Remove layout</string> -->
|
||||||
<string name="pref_custom_layout_title">طرح شخصی</string>
|
<string name="pref_custom_layout_title">طرح شخصی</string>
|
||||||
<string name="pref_show_numpad_title">نمایش پد شمارهها</string>
|
<string name="pref_show_numpad_title">نمایش پد شمارهها</string>
|
||||||
<string name="pref_show_numpad_never">هرگز</string>
|
<string name="pref_show_numpad_never">هرگز</string>
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<string name="pref_layout_e_custom">Disposition personnalisée</string>
|
<string name="pref_layout_e_custom">Disposition personnalisée</string>
|
||||||
<string name="pref_layouts_add">Ajouter un clavier alternatif</string>
|
<string name="pref_layouts_add">Ajouter un clavier alternatif</string>
|
||||||
<string name="pref_layouts_item">Disposition %1$d: %2$s</string>
|
<string name="pref_layouts_item">Disposition %1$d: %2$s</string>
|
||||||
|
<!-- <string name="pref_layouts_remove_custom">Remove layout</string> -->
|
||||||
<string name="pref_custom_layout_title">Disposition personnalisée</string>
|
<string name="pref_custom_layout_title">Disposition personnalisée</string>
|
||||||
<string name="pref_show_numpad_title">Afficher le pavé numérique</string>
|
<string name="pref_show_numpad_title">Afficher le pavé numérique</string>
|
||||||
<string name="pref_show_numpad_never">Jamais</string>
|
<string name="pref_show_numpad_never">Jamais</string>
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<!-- <string name="pref_layout_e_custom">Custom layout</string> -->
|
<!-- <string name="pref_layout_e_custom">Custom layout</string> -->
|
||||||
<!-- <string name="pref_layouts_add">Add an alternate layout</string> -->
|
<!-- <string name="pref_layouts_add">Add an alternate layout</string> -->
|
||||||
<!-- <string name="pref_layouts_item">Layout %1$d: %2$s</string> -->
|
<!-- <string name="pref_layouts_item">Layout %1$d: %2$s</string> -->
|
||||||
|
<!-- <string name="pref_layouts_remove_custom">Remove layout</string> -->
|
||||||
<!-- <string name="pref_custom_layout_title">Custom layout</string> -->
|
<!-- <string name="pref_custom_layout_title">Custom layout</string> -->
|
||||||
<!-- <string name="pref_show_numpad_title">Show NumPad</string> -->
|
<!-- <string name="pref_show_numpad_title">Show NumPad</string> -->
|
||||||
<!-- <string name="pref_show_numpad_never">Never</string> -->
|
<!-- <string name="pref_show_numpad_never">Never</string> -->
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<!-- <string name="pref_layout_e_custom">Custom layout</string> -->
|
<!-- <string name="pref_layout_e_custom">Custom layout</string> -->
|
||||||
<!-- <string name="pref_layouts_add">Add an alternate layout</string> -->
|
<!-- <string name="pref_layouts_add">Add an alternate layout</string> -->
|
||||||
<!-- <string name="pref_layouts_item">Layout %1$d: %2$s</string> -->
|
<!-- <string name="pref_layouts_item">Layout %1$d: %2$s</string> -->
|
||||||
|
<!-- <string name="pref_layouts_remove_custom">Remove layout</string> -->
|
||||||
<!-- <string name="pref_custom_layout_title">Custom layout</string> -->
|
<!-- <string name="pref_custom_layout_title">Custom layout</string> -->
|
||||||
<!-- <string name="pref_show_numpad_title">Show NumPad</string> -->
|
<!-- <string name="pref_show_numpad_title">Show NumPad</string> -->
|
||||||
<!-- <string name="pref_show_numpad_never">Never</string> -->
|
<!-- <string name="pref_show_numpad_never">Never</string> -->
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<string name="pref_layout_e_custom">Pielāgots izkārtojums</string>
|
<string name="pref_layout_e_custom">Pielāgots izkārtojums</string>
|
||||||
<string name="pref_layouts_add">Pievienot aizstājējizkārtojumu</string>
|
<string name="pref_layouts_add">Pievienot aizstājējizkārtojumu</string>
|
||||||
<string name="pref_layouts_item">Izkārtojums %1$d: %2$s</string>
|
<string name="pref_layouts_item">Izkārtojums %1$d: %2$s</string>
|
||||||
|
<!-- <string name="pref_layouts_remove_custom">Remove layout</string> -->
|
||||||
<string name="pref_custom_layout_title">Pielāgots izkārtojums</string>
|
<string name="pref_custom_layout_title">Pielāgots izkārtojums</string>
|
||||||
<string name="pref_show_numpad_title">Rādīt ciparnīcu</string>
|
<string name="pref_show_numpad_title">Rādīt ciparnīcu</string>
|
||||||
<string name="pref_show_numpad_never">Nekad</string>
|
<string name="pref_show_numpad_never">Nekad</string>
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<string name="pref_layout_e_custom">Własny układ</string>
|
<string name="pref_layout_e_custom">Własny układ</string>
|
||||||
<string name="pref_layouts_add">Dodaj dodatkowy układ</string>
|
<string name="pref_layouts_add">Dodaj dodatkowy układ</string>
|
||||||
<string name="pref_layouts_item">Układ %1$d: %2$s</string>
|
<string name="pref_layouts_item">Układ %1$d: %2$s</string>
|
||||||
|
<!-- <string name="pref_layouts_remove_custom">Remove layout</string> -->
|
||||||
<string name="pref_custom_layout_title">Własny układ</string>
|
<string name="pref_custom_layout_title">Własny układ</string>
|
||||||
<string name="pref_show_numpad_title">Pokaż klawiaturę numeryczną</string>
|
<string name="pref_show_numpad_title">Pokaż klawiaturę numeryczną</string>
|
||||||
<string name="pref_show_numpad_never">Nigdy</string>
|
<string name="pref_show_numpad_never">Nigdy</string>
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<string name="pref_layout_e_custom">Layout personalizado</string>
|
<string name="pref_layout_e_custom">Layout personalizado</string>
|
||||||
<string name="pref_layouts_add">Adicione um layout alternativo</string>
|
<string name="pref_layouts_add">Adicione um layout alternativo</string>
|
||||||
<string name="pref_layouts_item">Layout %1$d: %2$s</string>
|
<string name="pref_layouts_item">Layout %1$d: %2$s</string>
|
||||||
|
<!-- <string name="pref_layouts_remove_custom">Remove layout</string> -->
|
||||||
<string name="pref_custom_layout_title">Layout personalizado</string>
|
<string name="pref_custom_layout_title">Layout personalizado</string>
|
||||||
<string name="pref_show_numpad_title">Mostrar Teclado Numérico</string>
|
<string name="pref_show_numpad_title">Mostrar Teclado Numérico</string>
|
||||||
<string name="pref_show_numpad_never">Nunca</string>
|
<string name="pref_show_numpad_never">Nunca</string>
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<string name="pref_layout_e_custom">Aranjament personalizat</string>
|
<string name="pref_layout_e_custom">Aranjament personalizat</string>
|
||||||
<!-- <string name="pref_layouts_add">Add an alternate layout</string> -->
|
<!-- <string name="pref_layouts_add">Add an alternate layout</string> -->
|
||||||
<!-- <string name="pref_layouts_item">Layout %1$d: %2$s</string> -->
|
<!-- <string name="pref_layouts_item">Layout %1$d: %2$s</string> -->
|
||||||
|
<!-- <string name="pref_layouts_remove_custom">Remove layout</string> -->
|
||||||
<string name="pref_custom_layout_title">Aranjament personalizat</string>
|
<string name="pref_custom_layout_title">Aranjament personalizat</string>
|
||||||
<string name="pref_show_numpad_title">Arată NumPad</string>
|
<string name="pref_show_numpad_title">Arată NumPad</string>
|
||||||
<string name="pref_show_numpad_never">Niciodată</string>
|
<string name="pref_show_numpad_never">Niciodată</string>
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<string name="pref_layout_e_custom">Пользовательская раскладка</string>
|
<string name="pref_layout_e_custom">Пользовательская раскладка</string>
|
||||||
<!-- <string name="pref_layouts_add">Add an alternate layout</string> -->
|
<!-- <string name="pref_layouts_add">Add an alternate layout</string> -->
|
||||||
<!-- <string name="pref_layouts_item">Layout %1$d: %2$s</string> -->
|
<!-- <string name="pref_layouts_item">Layout %1$d: %2$s</string> -->
|
||||||
|
<!-- <string name="pref_layouts_remove_custom">Remove layout</string> -->
|
||||||
<string name="pref_custom_layout_title">Пользовательская раскладка</string>
|
<string name="pref_custom_layout_title">Пользовательская раскладка</string>
|
||||||
<string name="pref_show_numpad_title">Показывать NumPad</string>
|
<string name="pref_show_numpad_title">Показывать NumPad</string>
|
||||||
<string name="pref_show_numpad_never">Никогда</string>
|
<string name="pref_show_numpad_never">Никогда</string>
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<!-- <string name="pref_layout_e_custom">Custom layout</string> -->
|
<!-- <string name="pref_layout_e_custom">Custom layout</string> -->
|
||||||
<!-- <string name="pref_layouts_add">Add an alternate layout</string> -->
|
<!-- <string name="pref_layouts_add">Add an alternate layout</string> -->
|
||||||
<!-- <string name="pref_layouts_item">Layout %1$d: %2$s</string> -->
|
<!-- <string name="pref_layouts_item">Layout %1$d: %2$s</string> -->
|
||||||
|
<!-- <string name="pref_layouts_remove_custom">Remove layout</string> -->
|
||||||
<!-- <string name="pref_custom_layout_title">Custom layout</string> -->
|
<!-- <string name="pref_custom_layout_title">Custom layout</string> -->
|
||||||
<!-- <string name="pref_show_numpad_title">Show NumPad</string> -->
|
<!-- <string name="pref_show_numpad_title">Show NumPad</string> -->
|
||||||
<!-- <string name="pref_show_numpad_never">Never</string> -->
|
<!-- <string name="pref_show_numpad_never">Never</string> -->
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<string name="pref_layout_e_custom">Tùy chỉnh bố cục</string>
|
<string name="pref_layout_e_custom">Tùy chỉnh bố cục</string>
|
||||||
<!-- <string name="pref_layouts_add">Add an alternate layout</string> -->
|
<!-- <string name="pref_layouts_add">Add an alternate layout</string> -->
|
||||||
<!-- <string name="pref_layouts_item">Layout %1$d: %2$s</string> -->
|
<!-- <string name="pref_layouts_item">Layout %1$d: %2$s</string> -->
|
||||||
|
<!-- <string name="pref_layouts_remove_custom">Remove layout</string> -->
|
||||||
<string name="pref_custom_layout_title">Tùy chỉnh bố cục</string>
|
<string name="pref_custom_layout_title">Tùy chỉnh bố cục</string>
|
||||||
<string name="pref_show_numpad_title">Hiện NumPad</string>
|
<string name="pref_show_numpad_title">Hiện NumPad</string>
|
||||||
<string name="pref_show_numpad_never">Không bao giờ</string>
|
<string name="pref_show_numpad_never">Không bao giờ</string>
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<string name="pref_layout_e_custom">自定义布局</string>
|
<string name="pref_layout_e_custom">自定义布局</string>
|
||||||
<!-- <string name="pref_layouts_add">Add an alternate layout</string> -->
|
<!-- <string name="pref_layouts_add">Add an alternate layout</string> -->
|
||||||
<!-- <string name="pref_layouts_item">Layout %1$d: %2$s</string> -->
|
<!-- <string name="pref_layouts_item">Layout %1$d: %2$s</string> -->
|
||||||
|
<!-- <string name="pref_layouts_remove_custom">Remove layout</string> -->
|
||||||
<string name="pref_custom_layout_title">自定义布局</string>
|
<string name="pref_custom_layout_title">自定义布局</string>
|
||||||
<string name="pref_show_numpad_title">显示数字小键盘</string>
|
<string name="pref_show_numpad_title">显示数字小键盘</string>
|
||||||
<string name="pref_show_numpad_never">从不</string>
|
<string name="pref_show_numpad_never">从不</string>
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<string name="pref_layout_e_custom">Custom layout</string>
|
<string name="pref_layout_e_custom">Custom layout</string>
|
||||||
<string name="pref_layouts_add">Add an alternate layout</string>
|
<string name="pref_layouts_add">Add an alternate layout</string>
|
||||||
<string name="pref_layouts_item">Layout %1$d: %2$s</string>
|
<string name="pref_layouts_item">Layout %1$d: %2$s</string>
|
||||||
|
<string name="pref_layouts_remove_custom">Remove layout</string>
|
||||||
<string name="pref_custom_layout_title">Custom layout</string>
|
<string name="pref_custom_layout_title">Custom layout</string>
|
||||||
<string name="pref_show_numpad_title">Show NumPad</string>
|
<string name="pref_show_numpad_title">Show NumPad</string>
|
||||||
<string name="pref_show_numpad_never">Never</string>
|
<string name="pref_show_numpad_never">Never</string>
|
||||||
|
@ -122,9 +122,9 @@ public class LayoutsPreference extends ListGroupPreference<LayoutsPreference.Lay
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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
|
@Override
|
||||||
@ -163,7 +163,7 @@ public class LayoutsPreference extends ListGroupPreference<LayoutsPreference.Lay
|
|||||||
{
|
{
|
||||||
final EditText input = new EditText(getContext());
|
final EditText input = new EditText(getContext());
|
||||||
input.setText(initial_text);
|
input.setText(initial_text);
|
||||||
new AlertDialog.Builder(getContext())
|
AlertDialog.Builder dialog = new AlertDialog.Builder(getContext())
|
||||||
.setView(input)
|
.setView(input)
|
||||||
.setTitle(R.string.pref_custom_layout_title)
|
.setTitle(R.string.pref_custom_layout_title)
|
||||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
|
.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()));
|
callback.select(new CustomLayout(input.getText().toString()));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null);
|
||||||
.show();
|
// 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. */
|
/** Called when modifying a layout. Custom layouts behave differently. */
|
||||||
|
@ -48,7 +48,7 @@ public abstract class ListGroupPreference<E> extends PreferenceGroup
|
|||||||
/** Called every time the list changes and allows to disable the "Remove"
|
/** Called every time the list changes and allows to disable the "Remove"
|
||||||
buttons on every items. Might be used to enforce a minimum number of
|
buttons on every items. Might be used to enforce a minimum number of
|
||||||
items. */
|
items. */
|
||||||
boolean should_allow_remove_item()
|
boolean should_allow_remove_item(E _value)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -170,11 +170,10 @@ public abstract class ListGroupPreference<E> extends PreferenceGroup
|
|||||||
if (!_attached)
|
if (!_attached)
|
||||||
return;
|
return;
|
||||||
removeAll();
|
removeAll();
|
||||||
boolean allow_remove_item = should_allow_remove_item();
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (E v : _values)
|
for (E v : _values)
|
||||||
{
|
{
|
||||||
addPreference(this.new Item(getContext(), i, v, allow_remove_item));
|
addPreference(this.new Item(getContext(), i, v));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
_add_button = on_attach_add_button(_add_button);
|
_add_button = on_attach_add_button(_add_button);
|
||||||
@ -187,14 +186,14 @@ public abstract class ListGroupPreference<E> extends PreferenceGroup
|
|||||||
final E _value;
|
final E _value;
|
||||||
final int _index;
|
final int _index;
|
||||||
|
|
||||||
public Item(Context ctx, int index, E value, boolean allow_remove)
|
public Item(Context ctx, int index, E value)
|
||||||
{
|
{
|
||||||
super(ctx);
|
super(ctx);
|
||||||
_value = value;
|
_value = value;
|
||||||
_index = index;
|
_index = index;
|
||||||
setPersistent(false);
|
setPersistent(false);
|
||||||
setTitle(label_of_value(value, index));
|
setTitle(label_of_value(value, index));
|
||||||
if (allow_remove)
|
if (should_allow_remove_item(value))
|
||||||
setWidgetLayoutResource(R.layout.pref_listgroup_item_widget);
|
setWidgetLayoutResource(R.layout.pref_listgroup_item_widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,9 +217,14 @@ public abstract class ListGroupPreference<E> extends PreferenceGroup
|
|||||||
select(new SelectionCallback<E>() {
|
select(new SelectionCallback<E>() {
|
||||||
public void select(E value)
|
public void select(E value)
|
||||||
{
|
{
|
||||||
change_item(_index, value);
|
if (value == null)
|
||||||
|
remove_item(_index);
|
||||||
|
else
|
||||||
|
change_item(_index, value);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
public boolean allow_remove() { return true; }
|
||||||
|
}, _value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return v;
|
return v;
|
||||||
@ -244,6 +248,8 @@ public abstract class ListGroupPreference<E> extends PreferenceGroup
|
|||||||
{
|
{
|
||||||
add_item(value);
|
add_item(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean allow_remove() { return false; }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,6 +257,10 @@ public abstract class ListGroupPreference<E> extends PreferenceGroup
|
|||||||
public interface SelectionCallback<E>
|
public interface SelectionCallback<E>
|
||||||
{
|
{
|
||||||
public void select(E value);
|
public void select(E value);
|
||||||
|
|
||||||
|
/** If this method returns [true], [null] might be passed to [select] to
|
||||||
|
remove the item. */
|
||||||
|
public boolean allow_remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Methods for serializing and deserializing abstract items.
|
/** Methods for serializing and deserializing abstract items.
|
||||||
|
Loading…
Reference in New Issue
Block a user