reordered the Appearance settings a bit
This commit is contained in:
parent
5401f1e40c
commit
3f69ba4e3b
10 changed files with 46 additions and 35 deletions
|
|
@ -32,21 +32,18 @@ public class AppearanceScreen extends BaseScreenFragment {
|
||||||
ItemShowArrows showArrows = new ItemShowArrows(findPreference(ItemShowArrows.NAME), activity.getSettings());
|
ItemShowArrows showArrows = new ItemShowArrows(findPreference(ItemShowArrows.NAME), activity.getSettings());
|
||||||
ItemNumpadFnKeyScale fnKeyWidth = new ItemNumpadFnKeyScale(findPreference(ItemNumpadFnKeyScale.NAME), activity.getSettings());
|
ItemNumpadFnKeyScale fnKeyWidth = new ItemNumpadFnKeyScale(findPreference(ItemNumpadFnKeyScale.NAME), activity.getSettings());
|
||||||
|
|
||||||
|
ItemSelectLayoutType selectLayout = new ItemSelectLayoutType(findPreference(ItemSelectLayoutType.NAME), activity)
|
||||||
|
.addOnChangeItem(alignment)
|
||||||
|
.addOnChangeItem(fnKeyWidth)
|
||||||
|
.addOnChangeItem(keyboardWidth)
|
||||||
|
.addOnChangeItem(numpadKeyHeight)
|
||||||
|
.addOnChangeItem(numpadShape)
|
||||||
|
.addOnChangeItem(showArrows);
|
||||||
|
|
||||||
ItemDropDown[] items = {
|
ItemDropDown[] items = {
|
||||||
new ItemSelectTheme(findPreference(ItemSelectTheme.NAME), activity),
|
new ItemSelectTheme(findPreference(ItemSelectTheme.NAME), activity),
|
||||||
new ItemSelectLayoutType(
|
|
||||||
findPreference(ItemSelectLayoutType.NAME),
|
|
||||||
activity,
|
|
||||||
(layout) -> { // on layout change
|
|
||||||
numpadKeyHeight.onLayoutChange(layout);
|
|
||||||
alignment.onLayoutChange(layout);
|
|
||||||
keyboardWidth.onLayoutChange(layout);
|
|
||||||
numpadShape.onLayoutChange(layout);
|
|
||||||
showArrows.onLayoutChange(layout);
|
|
||||||
fnKeyWidth.onLayoutChange(layout);
|
|
||||||
}
|
|
||||||
),
|
|
||||||
new ItemSelectSettingsFontSize(findPreference(ItemSelectSettingsFontSize.NAME), this),
|
new ItemSelectSettingsFontSize(findPreference(ItemSelectSettingsFontSize.NAME), this),
|
||||||
|
selectLayout,
|
||||||
numpadKeyHeight,
|
numpadKeyHeight,
|
||||||
alignment,
|
alignment,
|
||||||
keyboardWidth,
|
keyboardWidth,
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import io.github.sspanak.tt9.R;
|
||||||
import io.github.sspanak.tt9.preferences.items.ItemDropDown;
|
import io.github.sspanak.tt9.preferences.items.ItemDropDown;
|
||||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
|
|
||||||
public class ItemAlignment extends ItemDropDown {
|
public class ItemAlignment extends ItemDropDown implements ItemLayoutChangeReactive {
|
||||||
public static final String NAME = "pref_numpad_alignment";
|
public static final String NAME = "pref_numpad_alignment";
|
||||||
|
|
||||||
private final SettingsStore settings;
|
private final SettingsStore settings;
|
||||||
|
|
@ -41,7 +41,7 @@ public class ItemAlignment extends ItemDropDown {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onLayoutChange(int mainViewLayout) {
|
public void onLayoutChange(int mainViewLayout) {
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
item.setVisible(mainViewLayout != SettingsStore.LAYOUT_STEALTH);
|
item.setVisible(mainViewLayout != SettingsStore.LAYOUT_STEALTH);
|
||||||
item.setIconSpaceReserved(false);
|
item.setIconSpaceReserved(false);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
package io.github.sspanak.tt9.preferences.screens.appearance;
|
||||||
|
|
||||||
|
public interface ItemLayoutChangeReactive {
|
||||||
|
void onLayoutChange(int mainViewLayout);
|
||||||
|
}
|
||||||
|
|
@ -7,7 +7,7 @@ import java.util.LinkedHashMap;
|
||||||
import io.github.sspanak.tt9.preferences.items.ItemDropDown;
|
import io.github.sspanak.tt9.preferences.items.ItemDropDown;
|
||||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
|
|
||||||
public class ItemNumpadFnKeyScale extends ItemDropDown {
|
public class ItemNumpadFnKeyScale extends ItemDropDown implements ItemLayoutChangeReactive {
|
||||||
public static final String NAME = "pref_numpad_fn_key_width";
|
public static final String NAME = "pref_numpad_fn_key_width";
|
||||||
|
|
||||||
private final SettingsStore settings;
|
private final SettingsStore settings;
|
||||||
|
|
@ -26,8 +26,10 @@ public class ItemNumpadFnKeyScale extends ItemDropDown {
|
||||||
LinkedHashMap<String, String> options = new LinkedHashMap<>();
|
LinkedHashMap<String, String> options = new LinkedHashMap<>();
|
||||||
options.put("1", "100 %");
|
options.put("1", "100 %");
|
||||||
options.put("0.85", "115 %");
|
options.put("0.85", "115 %");
|
||||||
|
options.put("0.75", "125 %");
|
||||||
options.put("0.675", "135 %");
|
options.put("0.675", "135 %");
|
||||||
options.put("0.477", "150 %"); // whatever...
|
options.put("0.576", "145 %");
|
||||||
|
options.put("0.477", "155 %"); // whatever...
|
||||||
|
|
||||||
super.populate(options);
|
super.populate(options);
|
||||||
super.setValue(getClosestOption(settings.getNumpadFnKeyScale(), options));
|
super.setValue(getClosestOption(settings.getNumpadFnKeyScale(), options));
|
||||||
|
|
@ -53,7 +55,7 @@ public class ItemNumpadFnKeyScale extends ItemDropDown {
|
||||||
return closest;
|
return closest;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onLayoutChange(int mainViewLayout) {
|
public void onLayoutChange(int mainViewLayout) {
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
item.setVisible(mainViewLayout == SettingsStore.LAYOUT_NUMPAD);
|
item.setVisible(mainViewLayout == SettingsStore.LAYOUT_NUMPAD);
|
||||||
item.setIconSpaceReserved(false);
|
item.setIconSpaceReserved(false);
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import java.util.LinkedHashMap;
|
||||||
import io.github.sspanak.tt9.preferences.items.ItemDropDown;
|
import io.github.sspanak.tt9.preferences.items.ItemDropDown;
|
||||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
|
|
||||||
public class ItemNumpadKeyHeight extends ItemDropDown {
|
public class ItemNumpadKeyHeight extends ItemDropDown implements ItemLayoutChangeReactive {
|
||||||
public static final String NAME = "pref_numpad_key_height";
|
public static final String NAME = "pref_numpad_key_height";
|
||||||
|
|
||||||
private final SettingsStore settings;
|
private final SettingsStore settings;
|
||||||
|
|
@ -41,7 +41,7 @@ public class ItemNumpadKeyHeight extends ItemDropDown {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onLayoutChange(int mainViewLayout) {
|
public void onLayoutChange(int mainViewLayout) {
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
item.setVisible(mainViewLayout == SettingsStore.LAYOUT_NUMPAD);
|
item.setVisible(mainViewLayout == SettingsStore.LAYOUT_NUMPAD);
|
||||||
item.setIconSpaceReserved(false);
|
item.setIconSpaceReserved(false);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import io.github.sspanak.tt9.R;
|
||||||
import io.github.sspanak.tt9.preferences.items.ItemDropDown;
|
import io.github.sspanak.tt9.preferences.items.ItemDropDown;
|
||||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
|
|
||||||
public class ItemNumpadShape extends ItemDropDown {
|
public class ItemNumpadShape extends ItemDropDown implements ItemLayoutChangeReactive {
|
||||||
static final String NAME = "pref_numpad_shape";
|
static final String NAME = "pref_numpad_shape";
|
||||||
|
|
||||||
private final SettingsStore settings;
|
private final SettingsStore settings;
|
||||||
|
|
@ -40,7 +40,7 @@ public class ItemNumpadShape extends ItemDropDown {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onLayoutChange(int mainViewLayout) {
|
public void onLayoutChange(int mainViewLayout) {
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
item.setVisible(mainViewLayout == SettingsStore.LAYOUT_NUMPAD);
|
item.setVisible(mainViewLayout == SettingsStore.LAYOUT_NUMPAD);
|
||||||
item.setIconSpaceReserved(false);
|
item.setIconSpaceReserved(false);
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,26 @@
|
||||||
package io.github.sspanak.tt9.preferences.screens.appearance;
|
package io.github.sspanak.tt9.preferences.screens.appearance;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.preference.DropDownPreference;
|
import androidx.preference.DropDownPreference;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
|
||||||
import io.github.sspanak.tt9.R;
|
import io.github.sspanak.tt9.R;
|
||||||
import io.github.sspanak.tt9.preferences.PreferencesActivity;
|
import io.github.sspanak.tt9.preferences.PreferencesActivity;
|
||||||
import io.github.sspanak.tt9.preferences.items.ItemDropDown;
|
import io.github.sspanak.tt9.preferences.items.ItemDropDown;
|
||||||
import io.github.sspanak.tt9.preferences.settings.SettingsUI;
|
import io.github.sspanak.tt9.preferences.settings.SettingsUI;
|
||||||
import io.github.sspanak.tt9.util.ConsumerCompat;
|
|
||||||
|
|
||||||
public class ItemSelectLayoutType extends ItemDropDown {
|
public class ItemSelectLayoutType extends ItemDropDown {
|
||||||
public static final String NAME = "pref_layout_type";
|
public static final String NAME = "pref_layout_type";
|
||||||
|
|
||||||
private final PreferencesActivity activity;
|
private final PreferencesActivity activity;
|
||||||
private final ConsumerCompat<Integer> onChange;
|
private final ArrayList<ItemLayoutChangeReactive> onChangeReactiveItems = new ArrayList<>();
|
||||||
|
|
||||||
public ItemSelectLayoutType(DropDownPreference item, PreferencesActivity activity, ConsumerCompat<Integer> onChange) {
|
public ItemSelectLayoutType(DropDownPreference item, PreferencesActivity activity) {
|
||||||
super(item);
|
super(item);
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
this.onChange = onChange;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemDropDown populate() {
|
public ItemDropDown populate() {
|
||||||
|
|
@ -36,11 +36,18 @@ public class ItemSelectLayoutType extends ItemDropDown {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemSelectLayoutType addOnChangeItem(@NonNull ItemLayoutChangeReactive reactiveItem) {
|
||||||
|
onChangeReactiveItems.add(reactiveItem);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onClick(Preference preference, Object newKey) {
|
protected boolean onClick(Preference preference, Object newKey) {
|
||||||
if (onChange != null) {
|
int newLayout = Integer.parseInt(newKey.toString());
|
||||||
onChange.accept(Integer.parseInt(newKey.toString()));
|
for (ItemLayoutChangeReactive item : onChangeReactiveItems) {
|
||||||
|
item.onLayoutChange(newLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onClick(preference, newKey);
|
return super.onClick(preference, newKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import androidx.preference.SwitchPreferenceCompat;
|
||||||
import io.github.sspanak.tt9.preferences.items.ItemSwitch;
|
import io.github.sspanak.tt9.preferences.items.ItemSwitch;
|
||||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
|
|
||||||
public class ItemShowArrows extends ItemSwitch {
|
public class ItemShowArrows extends ItemSwitch implements ItemLayoutChangeReactive {
|
||||||
public final static String NAME = "pref_arrow_keys_visible";
|
public final static String NAME = "pref_arrow_keys_visible";
|
||||||
private final SettingsStore settings;
|
private final SettingsStore settings;
|
||||||
|
|
||||||
|
|
@ -26,7 +26,7 @@ public class ItemShowArrows extends ItemSwitch {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void onLayoutChange(int mainViewLayout) {
|
public void onLayoutChange(int mainViewLayout) {
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
item.setVisible(mainViewLayout == SettingsStore.LAYOUT_NUMPAD);
|
item.setVisible(mainViewLayout == SettingsStore.LAYOUT_NUMPAD);
|
||||||
item.setIconSpaceReserved(false);
|
item.setIconSpaceReserved(false);
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import java.util.LinkedHashMap;
|
||||||
import io.github.sspanak.tt9.preferences.items.ItemDropDown;
|
import io.github.sspanak.tt9.preferences.items.ItemDropDown;
|
||||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
|
|
||||||
public class ItemWidth extends ItemDropDown {
|
public class ItemWidth extends ItemDropDown implements ItemLayoutChangeReactive {
|
||||||
public static final String NAME = "pref_numpad_width";
|
public static final String NAME = "pref_numpad_width";
|
||||||
|
|
||||||
private final SettingsStore settings;
|
private final SettingsStore settings;
|
||||||
|
|
@ -35,7 +35,7 @@ public class ItemWidth extends ItemDropDown {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onLayoutChange(int mainViewLayout) {
|
public void onLayoutChange(int mainViewLayout) {
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
item.setEnabled(mainViewLayout != SettingsStore.LAYOUT_STEALTH);
|
item.setEnabled(mainViewLayout != SettingsStore.LAYOUT_STEALTH);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,14 +31,14 @@
|
||||||
app:key="pref_numpad_key_height"
|
app:key="pref_numpad_key_height"
|
||||||
app:title="@string/pref_numpad_key_height" />
|
app:title="@string/pref_numpad_key_height" />
|
||||||
|
|
||||||
|
<DropDownPreference
|
||||||
|
app:key="pref_numpad_fn_key_width"
|
||||||
|
app:title="@string/pref_numpad_fn_key_width" />
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
app:key="pref_arrow_keys_visible"
|
app:key="pref_arrow_keys_visible"
|
||||||
app:title="@string/pref_arrow_keys_visible"
|
app:title="@string/pref_arrow_keys_visible"
|
||||||
app:summary="@string/pref_arrow_keys_visible_summary" />
|
app:summary="@string/pref_arrow_keys_visible_summary" />
|
||||||
|
|
||||||
<DropDownPreference
|
|
||||||
app:key="pref_numpad_fn_key_width"
|
|
||||||
app:title="@string/pref_numpad_fn_key_width" />
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory app:title="@string/pref_category_hacks">
|
<PreferenceCategory app:title="@string/pref_category_hacks">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue