Refactor: New namespace for preference classes

This commit is contained in:
Jules Aguillon 2024-01-13 20:59:05 +01:00
parent 148f3dfc05
commit eddf9c6c11
16 changed files with 46 additions and 38 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory android:title="@string/pref_category_layout"> <PreferenceCategory android:title="@string/pref_category_layout">
<juloo.keyboard2.LayoutsPreference/> <juloo.keyboard2.prefs.LayoutsPreference/>
<PreferenceScreen android:title="@string/pref_extra_keys_title"> <PreferenceScreen android:title="@string/pref_extra_keys_title">
<PreferenceCategory android:title="@string/pref_extra_keys_custom"> <PreferenceCategory android:title="@string/pref_extra_keys_custom">
<juloo.keyboard2.CustomExtraKeysPreference/> <juloo.keyboard2.prefs.CustomExtraKeysPreference/>
</PreferenceCategory> </PreferenceCategory>
<juloo.keyboard2.ExtraKeysPreference android:title="@string/pref_extra_keys_internal"/> <juloo.keyboard2.prefs.ExtraKeysPreference android:title="@string/pref_extra_keys_internal"/>
</PreferenceScreen> </PreferenceScreen>
<CheckBoxPreference android:key="number_row" android:title="@string/pref_number_row_title" android:summary="@string/pref_number_row_summary" android:defaultValue="false"/> <CheckBoxPreference android:key="number_row" android:title="@string/pref_number_row_title" android:summary="@string/pref_number_row_summary" android:defaultValue="false"/>
<ListPreference android:key="show_numpad" android:title="@string/pref_show_numpad_title" android:summary="%s" android:defaultValue="1" android:entries="@array/pref_show_numpad_entries" android:entryValues="@array/pref_show_numpad_values"/> <ListPreference android:key="show_numpad" android:title="@string/pref_show_numpad_title" android:summary="%s" android:defaultValue="1" android:entries="@array/pref_show_numpad_entries" android:entryValues="@array/pref_show_numpad_values"/>
@ -14,37 +14,37 @@
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/pref_category_typing"> <PreferenceCategory android:title="@string/pref_category_typing">
<ListPreference android:key="swipe_dist" android:title="@string/pref_swipe_dist_title" android:summary="@string/pref_swipe_dist_summary" android:defaultValue="15" android:entries="@array/pref_swipe_dist_entries" android:entryValues="@array/pref_swipe_dist_values"/> <ListPreference android:key="swipe_dist" android:title="@string/pref_swipe_dist_title" android:summary="@string/pref_swipe_dist_summary" android:defaultValue="15" android:entries="@array/pref_swipe_dist_entries" android:entryValues="@array/pref_swipe_dist_values"/>
<juloo.common.IntSlideBarPreference android:key="longpress_timeout" android:title="@string/pref_long_timeout_title" android:summary="%sms" android:defaultValue="600" min="50" max="2000"/> <juloo.keyboard2.prefs.IntSlideBarPreference android:key="longpress_timeout" android:title="@string/pref_long_timeout_title" android:summary="%sms" android:defaultValue="600" min="50" max="2000"/>
<juloo.common.IntSlideBarPreference android:key="longpress_interval" android:title="@string/pref_long_interval_title" android:summary="%sms" android:defaultValue="25" min="5" max="100"/> <juloo.keyboard2.prefs.IntSlideBarPreference android:key="longpress_interval" android:title="@string/pref_long_interval_title" android:summary="%sms" android:defaultValue="25" min="5" max="100"/>
<CheckBoxPreference android:key="lock_double_tap" android:title="@string/pref_lock_double_tap_title" android:summary="@string/pref_lock_double_tap_summary" android:defaultValue="false"/> <CheckBoxPreference android:key="lock_double_tap" android:title="@string/pref_lock_double_tap_title" android:summary="@string/pref_lock_double_tap_summary" android:defaultValue="false"/>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/pref_category_behavior"> <PreferenceCategory android:title="@string/pref_category_behavior">
<CheckBoxPreference android:key="autocapitalisation" android:title="@string/pref_autocapitalisation_title" android:summary="@string/pref_autocapitalisation_summary" android:defaultValue="true"/> <CheckBoxPreference android:key="autocapitalisation" android:title="@string/pref_autocapitalisation_title" android:summary="@string/pref_autocapitalisation_summary" android:defaultValue="true"/>
<CheckBoxPreference android:key="switch_input_immediate" android:title="@string/pref_switch_input_immediate_title" android:summary="@string/pref_switch_input_immediate_summary" android:defaultValue="false"/> <CheckBoxPreference android:key="switch_input_immediate" android:title="@string/pref_switch_input_immediate_title" android:summary="@string/pref_switch_input_immediate_summary" android:defaultValue="false"/>
<CheckBoxPreference android:key="vibrate_custom" android:title="@string/pref_vibrate_custom" android:defaultValue="false"/> <CheckBoxPreference android:key="vibrate_custom" android:title="@string/pref_vibrate_custom" android:defaultValue="false"/>
<juloo.common.IntSlideBarPreference android:dependency="vibrate_custom" android:key="vibrate_duration" android:title="@string/pref_vibrate_duration_title" android:summary="%sms" android:defaultValue="20" min="0" max="100"/> <juloo.keyboard2.prefs.IntSlideBarPreference android:dependency="vibrate_custom" android:key="vibrate_duration" android:title="@string/pref_vibrate_duration_title" android:summary="%sms" android:defaultValue="20" min="0" max="100"/>
<CheckBoxPreference android:key="pin_entry_enabled" android:title="@string/pref_pin_entry_enabled_title" android:summary="@string/pref_pin_entry_enabled_summary" android:defaultValue="true"/> <CheckBoxPreference android:key="pin_entry_enabled" android:title="@string/pref_pin_entry_enabled_title" android:summary="@string/pref_pin_entry_enabled_summary" android:defaultValue="true"/>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/pref_category_style"> <PreferenceCategory android:title="@string/pref_category_style">
<ListPreference android:key="theme" android:title="@string/pref_theme" android:summary="%s" android:defaultValue="system" android:entries="@array/pref_theme_entries" android:entryValues="@array/pref_theme_values"/> <ListPreference android:key="theme" android:title="@string/pref_theme" android:summary="%s" android:defaultValue="system" android:entries="@array/pref_theme_entries" android:entryValues="@array/pref_theme_values"/>
<juloo.common.IntSlideBarPreference android:key="label_brightness" android:title="@string/pref_label_brightness" android:summary="%s%%" android:defaultValue="100" min="50" max="100"/> <juloo.keyboard2.prefs.IntSlideBarPreference android:key="label_brightness" android:title="@string/pref_label_brightness" android:summary="%s%%" android:defaultValue="100" min="50" max="100"/>
<juloo.common.IntSlideBarPreference android:key="keyboard_opacity" android:title="@string/pref_keyboard_opacity" android:summary="%s%%" android:defaultValue="100" min="0" max="100"/> <juloo.keyboard2.prefs.IntSlideBarPreference android:key="keyboard_opacity" android:title="@string/pref_keyboard_opacity" android:summary="%s%%" android:defaultValue="100" min="0" max="100"/>
<juloo.common.IntSlideBarPreference android:key="key_opacity" android:title="@string/pref_key_opacity" android:summary="%s%%" android:defaultValue="100" min="0" max="100"/> <juloo.keyboard2.prefs.IntSlideBarPreference android:key="key_opacity" android:title="@string/pref_key_opacity" android:summary="%s%%" android:defaultValue="100" min="0" max="100"/>
<juloo.common.IntSlideBarPreference android:key="key_activated_opacity" android:title="@string/pref_key_activated_opacity" android:summary="%s%%" android:defaultValue="100" min="0" max="100"/> <juloo.keyboard2.prefs.IntSlideBarPreference android:key="key_activated_opacity" android:title="@string/pref_key_activated_opacity" android:summary="%s%%" android:defaultValue="100" min="0" max="100"/>
<PreferenceScreen android:title="@string/pref_margin_bottom_title"> <PreferenceScreen android:title="@string/pref_margin_bottom_title">
<juloo.common.IntSlideBarPreference android:key="margin_bottom_portrait" android:title="@string/pref_portrait" android:summary="%sdp" android:defaultValue="7" min="0" max="100"/> <juloo.keyboard2.prefs.IntSlideBarPreference android:key="margin_bottom_portrait" android:title="@string/pref_portrait" android:summary="%sdp" android:defaultValue="7" min="0" max="100"/>
<juloo.common.IntSlideBarPreference android:key="margin_bottom_landscape" android:title="@string/pref_landscape" android:summary="%sdp" android:defaultValue="3" min="0" max="100"/> <juloo.keyboard2.prefs.IntSlideBarPreference android:key="margin_bottom_landscape" android:title="@string/pref_landscape" android:summary="%sdp" android:defaultValue="3" min="0" max="100"/>
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen android:title="@string/pref_keyboard_height_title"> <PreferenceScreen android:title="@string/pref_keyboard_height_title">
<juloo.common.IntSlideBarPreference android:key="keyboard_height" android:title="@string/pref_portrait" android:summary="%s%%" android:defaultValue="35" min="10" max="50"/> <juloo.keyboard2.prefs.IntSlideBarPreference android:key="keyboard_height" android:title="@string/pref_portrait" android:summary="%s%%" android:defaultValue="35" min="10" max="50"/>
<juloo.common.IntSlideBarPreference android:key="keyboard_height_landscape" android:title="@string/pref_landscape" android:summary="%s%%" android:defaultValue="50" min="20" max="65"/> <juloo.keyboard2.prefs.IntSlideBarPreference android:key="keyboard_height_landscape" android:title="@string/pref_landscape" android:summary="%s%%" android:defaultValue="50" min="20" max="65"/>
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen android:title="@string/pref_horizontal_margin_title"> <PreferenceScreen android:title="@string/pref_horizontal_margin_title">
<juloo.common.IntSlideBarPreference android:key="horizontal_margin_portrait" android:title="@string/pref_portrait" android:summary="%sdp" android:defaultValue="3" min="0" max="30"/> <juloo.keyboard2.prefs.IntSlideBarPreference android:key="horizontal_margin_portrait" android:title="@string/pref_portrait" android:summary="%sdp" android:defaultValue="3" min="0" max="30"/>
<juloo.common.IntSlideBarPreference android:key="horizontal_margin_landscape" android:title="@string/pref_landscape" android:summary="%sdp" android:defaultValue="28" min="0" max="200"/> <juloo.keyboard2.prefs.IntSlideBarPreference android:key="horizontal_margin_landscape" android:title="@string/pref_landscape" android:summary="%sdp" android:defaultValue="28" min="0" max="200"/>
</PreferenceScreen> </PreferenceScreen>
<juloo.common.SlideBarPreference android:key="character_size" android:title="@string/pref_character_size_title" android:summary="@string/pref_character_size_summary" android:defaultValue="1.0" min="0.75" max="1.5"/> <juloo.keyboard2.prefs.SlideBarPreference android:key="character_size" android:title="@string/pref_character_size_title" android:summary="@string/pref_character_size_summary" android:defaultValue="1.0" min="0.75" max="1.5"/>
<juloo.common.IntSlideBarPreference android:key="key_vertical_space" android:title="@string/pref_key_vertical_space" android:summary="%sdp" android:defaultValue="2" min="0" max="8"/> <juloo.keyboard2.prefs.IntSlideBarPreference android:key="key_vertical_space" android:title="@string/pref_key_vertical_space" android:summary="%sdp" android:defaultValue="2" min="0" max="8"/>
<juloo.common.IntSlideBarPreference android:key="key_horizontal_space" android:title="@string/pref_key_horizontal_space" android:summary="%sdp" android:defaultValue="2" min="0" max="8"/> <juloo.keyboard2.prefs.IntSlideBarPreference android:key="key_horizontal_space" android:title="@string/pref_key_horizontal_space" android:summary="%sdp" android:defaultValue="2" min="0" max="8"/>
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View File

@ -8,7 +8,7 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputConnection;
import android.view.KeyEvent; import android.view.KeyEvent;
final class Autocapitalisation public final class Autocapitalisation
{ {
boolean _enabled = false; boolean _enabled = false;
boolean _should_enable_shift = false; boolean _should_enable_shift = false;

View File

@ -14,8 +14,11 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import juloo.keyboard2.prefs.CustomExtraKeysPreference;
import juloo.keyboard2.prefs.ExtraKeysPreference;
import juloo.keyboard2.prefs.LayoutsPreference;
final class Config public final class Config
{ {
private final SharedPreferences _prefs; private final SharedPreferences _prefs;

View File

@ -9,7 +9,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
class ExtraKeys public final class ExtraKeys
{ {
public static final ExtraKeys EMPTY = new ExtraKeys(Collections.EMPTY_LIST); public static final ExtraKeys EMPTY = new ExtraKeys(Collections.EMPTY_LIST);

View File

@ -7,7 +7,7 @@ import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.ExtractedTextRequest; import android.view.inputmethod.ExtractedTextRequest;
import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputConnection;
class KeyEventHandler implements Config.IKeyEventHandler public final class KeyEventHandler implements Config.IKeyEventHandler
{ {
IReceiver _recv; IReceiver _recv;
Autocapitalisation _autocap; Autocapitalisation _autocap;

View File

@ -4,7 +4,7 @@ import android.view.KeyCharacterMap;
import android.view.KeyEvent; import android.view.KeyEvent;
import java.util.HashMap; import java.util.HashMap;
class KeyModifier public final class KeyModifier
{ {
/** Cache key is KeyValue's name */ /** Cache key is KeyValue's name */
private static HashMap<KeyValue, HashMap<Pointers.Modifiers, KeyValue>> _cache = private static HashMap<KeyValue, HashMap<Pointers.Modifiers, KeyValue>> _cache =

View File

@ -3,7 +3,7 @@ package juloo.keyboard2;
import android.view.KeyEvent; import android.view.KeyEvent;
import java.util.HashMap; import java.util.HashMap;
final class KeyValue public final class KeyValue
{ {
public static enum Event public static enum Event
{ {

View File

@ -23,6 +23,7 @@ import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import juloo.keyboard2.prefs.LayoutsPreference;
public class Keyboard2 extends InputMethodService public class Keyboard2 extends InputMethodService
implements SharedPreferences.OnSharedPreferenceChangeListener implements SharedPreferences.OnSharedPreferenceChangeListener

View File

@ -14,7 +14,7 @@ import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
class KeyboardData public final class KeyboardData
{ {
public final List<Row> rows; public final List<Row> rows;
/** Total width of the keyboard. */ /** Total width of the keyboard. */

View File

@ -7,7 +7,7 @@ import android.view.WindowManager;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
class Utils public final class Utils
{ {
/** Turn the first letter of a string uppercase. */ /** Turn the first letter of a string uppercase. */
public static String capitalize_string(String s) public static String capitalize_string(String s)

View File

@ -1,4 +1,4 @@
package juloo.keyboard2; package juloo.keyboard2.prefs;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
@ -13,6 +13,7 @@ import android.widget.EditText;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import juloo.keyboard2.*;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;

View File

@ -1,4 +1,4 @@
package juloo.keyboard2; package juloo.keyboard2.prefs;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -11,6 +11,7 @@ import android.widget.TextView;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import juloo.keyboard2.*;
/** This class implements the "extra keys" preference but also defines the /** This class implements the "extra keys" preference but also defines the
possible extra keys. */ possible extra keys. */

View File

@ -1,4 +1,4 @@
package juloo.common; package juloo.keyboard2.prefs;
import android.content.Context; import android.content.Context;
import android.content.res.TypedArray; import android.content.res.TypedArray;

View File

@ -1,4 +1,4 @@
package juloo.keyboard2; package juloo.keyboard2.prefs;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
@ -12,6 +12,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import juloo.keyboard2.*;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -237,22 +238,22 @@ public class LayoutsPreference extends ListGroupPreference<LayoutsPreference.Lay
/** A layout selected by the user. The only implementations are /** A layout selected by the user. The only implementations are
[NamedLayout], [SystemLayout] and [CustomLayout]. */ [NamedLayout], [SystemLayout] and [CustomLayout]. */
interface Layout {} public interface Layout {}
static final class SystemLayout implements Layout public static final class SystemLayout implements Layout
{ {
public SystemLayout() {} public SystemLayout() {}
} }
/** The name of a layout defined in [res/xml]. */ /** The name of a layout defined in [res/xml]. */
static final class NamedLayout implements Layout public static final class NamedLayout implements Layout
{ {
public final String name; public final String name;
public NamedLayout(String n) { name = n; } public NamedLayout(String n) { name = n; }
} }
/** The XML description of a custom layout. */ /** The XML description of a custom layout. */
static final class CustomLayout implements Layout public static final class CustomLayout implements Layout
{ {
public final String xml; public final String xml;
/** Might be null. */ /** Might be null. */
@ -269,7 +270,7 @@ public class LayoutsPreference extends ListGroupPreference<LayoutsPreference.Lay
/** Named layouts are serialized to strings and custom layouts to JSON /** Named layouts are serialized to strings and custom layouts to JSON
objects with a [kind] field. */ objects with a [kind] field. */
static class Serializer implements ListGroupPreference.Serializer<Layout> public static class Serializer implements ListGroupPreference.Serializer<Layout>
{ {
public Layout load_item(Object obj) throws JSONException public Layout load_item(Object obj) throws JSONException
{ {

View File

@ -1,4 +1,4 @@
package juloo.keyboard2; package juloo.keyboard2.prefs;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -9,6 +9,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import juloo.keyboard2.*;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;

View File

@ -1,4 +1,4 @@
package juloo.common; package juloo.keyboard2.prefs;
import android.content.Context; import android.content.Context;
import android.content.res.TypedArray; import android.content.res.TypedArray;