From eddf9c6c117449012e2aece5776694467e3483f0 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sat, 13 Jan 2024 20:59:05 +0100 Subject: [PATCH] Refactor: New namespace for preference classes --- res/xml/settings.xml | 38 +++++++++---------- srcs/juloo.keyboard2/Autocapitalisation.java | 2 +- srcs/juloo.keyboard2/Config.java | 5 ++- srcs/juloo.keyboard2/ExtraKeys.java | 2 +- srcs/juloo.keyboard2/KeyEventHandler.java | 2 +- srcs/juloo.keyboard2/KeyModifier.java | 2 +- srcs/juloo.keyboard2/KeyValue.java | 2 +- srcs/juloo.keyboard2/Keyboard2.java | 1 + srcs/juloo.keyboard2/KeyboardData.java | 2 +- srcs/juloo.keyboard2/Utils.java | 2 +- .../CustomExtraKeysPreference.java | 3 +- .../{ => prefs}/ExtraKeysPreference.java | 3 +- .../prefs}/IntSlideBarPreference.java | 2 +- .../{ => prefs}/LayoutsPreference.java | 13 ++++--- .../{ => prefs}/ListGroupPreference.java | 3 +- .../prefs}/SlideBarPreference.java | 2 +- 16 files changed, 46 insertions(+), 38 deletions(-) rename srcs/juloo.keyboard2/{ => prefs}/CustomExtraKeysPreference.java (97%) rename srcs/juloo.keyboard2/{ => prefs}/ExtraKeysPreference.java (98%) rename srcs/{juloo.common => juloo.keyboard2/prefs}/IntSlideBarPreference.java (98%) rename srcs/juloo.keyboard2/{ => prefs}/LayoutsPreference.java (96%) rename srcs/juloo.keyboard2/{ => prefs}/ListGroupPreference.java (99%) rename srcs/{juloo.common => juloo.keyboard2/prefs}/SlideBarPreference.java (99%) diff --git a/res/xml/settings.xml b/res/xml/settings.xml index 653a3b0..f5a7eed 100644 --- a/res/xml/settings.xml +++ b/res/xml/settings.xml @@ -1,12 +1,12 @@ - + - + - + @@ -14,37 +14,37 @@ - - + + - + - - - - + + + + - - + + - - + + - - + + - - - + + + diff --git a/srcs/juloo.keyboard2/Autocapitalisation.java b/srcs/juloo.keyboard2/Autocapitalisation.java index b73f2e3..3baff48 100644 --- a/srcs/juloo.keyboard2/Autocapitalisation.java +++ b/srcs/juloo.keyboard2/Autocapitalisation.java @@ -8,7 +8,7 @@ import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputConnection; import android.view.KeyEvent; -final class Autocapitalisation +public final class Autocapitalisation { boolean _enabled = false; boolean _should_enable_shift = false; diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index cb68e80..f59bce3 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -14,8 +14,11 @@ import java.util.HashSet; import java.util.List; import java.util.Map; 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; diff --git a/srcs/juloo.keyboard2/ExtraKeys.java b/srcs/juloo.keyboard2/ExtraKeys.java index ca9e46a..416e507 100644 --- a/srcs/juloo.keyboard2/ExtraKeys.java +++ b/srcs/juloo.keyboard2/ExtraKeys.java @@ -9,7 +9,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -class ExtraKeys +public final class ExtraKeys { public static final ExtraKeys EMPTY = new ExtraKeys(Collections.EMPTY_LIST); diff --git a/srcs/juloo.keyboard2/KeyEventHandler.java b/srcs/juloo.keyboard2/KeyEventHandler.java index e903bdb..c79d002 100644 --- a/srcs/juloo.keyboard2/KeyEventHandler.java +++ b/srcs/juloo.keyboard2/KeyEventHandler.java @@ -7,7 +7,7 @@ import android.view.inputmethod.ExtractedText; import android.view.inputmethod.ExtractedTextRequest; import android.view.inputmethod.InputConnection; -class KeyEventHandler implements Config.IKeyEventHandler +public final class KeyEventHandler implements Config.IKeyEventHandler { IReceiver _recv; Autocapitalisation _autocap; diff --git a/srcs/juloo.keyboard2/KeyModifier.java b/srcs/juloo.keyboard2/KeyModifier.java index 984db2e..c0f5beb 100644 --- a/srcs/juloo.keyboard2/KeyModifier.java +++ b/srcs/juloo.keyboard2/KeyModifier.java @@ -4,7 +4,7 @@ import android.view.KeyCharacterMap; import android.view.KeyEvent; import java.util.HashMap; -class KeyModifier +public final class KeyModifier { /** Cache key is KeyValue's name */ private static HashMap> _cache = diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java index fdb1f25..24eab0b 100644 --- a/srcs/juloo.keyboard2/KeyValue.java +++ b/srcs/juloo.keyboard2/KeyValue.java @@ -3,7 +3,7 @@ package juloo.keyboard2; import android.view.KeyEvent; import java.util.HashMap; -final class KeyValue +public final class KeyValue { public static enum Event { diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java index 66380e4..daa9ea0 100644 --- a/srcs/juloo.keyboard2/Keyboard2.java +++ b/srcs/juloo.keyboard2/Keyboard2.java @@ -23,6 +23,7 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; +import juloo.keyboard2.prefs.LayoutsPreference; public class Keyboard2 extends InputMethodService implements SharedPreferences.OnSharedPreferenceChangeListener diff --git a/srcs/juloo.keyboard2/KeyboardData.java b/srcs/juloo.keyboard2/KeyboardData.java index 557e42f..3cbd4aa 100644 --- a/srcs/juloo.keyboard2/KeyboardData.java +++ b/srcs/juloo.keyboard2/KeyboardData.java @@ -14,7 +14,7 @@ import java.util.Set; import java.util.function.Function; import org.xmlpull.v1.XmlPullParser; -class KeyboardData +public final class KeyboardData { public final List rows; /** Total width of the keyboard. */ diff --git a/srcs/juloo.keyboard2/Utils.java b/srcs/juloo.keyboard2/Utils.java index 0eee945..712c83d 100644 --- a/srcs/juloo.keyboard2/Utils.java +++ b/srcs/juloo.keyboard2/Utils.java @@ -7,7 +7,7 @@ import android.view.WindowManager; import java.io.InputStream; import java.io.InputStreamReader; -class Utils +public final class Utils { /** Turn the first letter of a string uppercase. */ public static String capitalize_string(String s) diff --git a/srcs/juloo.keyboard2/CustomExtraKeysPreference.java b/srcs/juloo.keyboard2/prefs/CustomExtraKeysPreference.java similarity index 97% rename from srcs/juloo.keyboard2/CustomExtraKeysPreference.java rename to srcs/juloo.keyboard2/prefs/CustomExtraKeysPreference.java index d007bf7..9d8395f 100644 --- a/srcs/juloo.keyboard2/CustomExtraKeysPreference.java +++ b/srcs/juloo.keyboard2/prefs/CustomExtraKeysPreference.java @@ -1,4 +1,4 @@ -package juloo.keyboard2; +package juloo.keyboard2.prefs; import android.app.AlertDialog; import android.content.Context; @@ -13,6 +13,7 @@ import android.widget.EditText; import java.util.HashMap; import java.util.List; import java.util.Map; +import juloo.keyboard2.*; import org.json.JSONArray; import org.json.JSONException; diff --git a/srcs/juloo.keyboard2/ExtraKeysPreference.java b/srcs/juloo.keyboard2/prefs/ExtraKeysPreference.java similarity index 98% rename from srcs/juloo.keyboard2/ExtraKeysPreference.java rename to srcs/juloo.keyboard2/prefs/ExtraKeysPreference.java index 3e8b74b..47ca535 100644 --- a/srcs/juloo.keyboard2/ExtraKeysPreference.java +++ b/srcs/juloo.keyboard2/prefs/ExtraKeysPreference.java @@ -1,4 +1,4 @@ -package juloo.keyboard2; +package juloo.keyboard2.prefs; import android.content.Context; import android.content.SharedPreferences; @@ -11,6 +11,7 @@ import android.widget.TextView; import java.util.HashMap; import java.util.Map; import java.util.Set; +import juloo.keyboard2.*; /** This class implements the "extra keys" preference but also defines the possible extra keys. */ diff --git a/srcs/juloo.common/IntSlideBarPreference.java b/srcs/juloo.keyboard2/prefs/IntSlideBarPreference.java similarity index 98% rename from srcs/juloo.common/IntSlideBarPreference.java rename to srcs/juloo.keyboard2/prefs/IntSlideBarPreference.java index 0bdf2c7..bb6bf7d 100644 --- a/srcs/juloo.common/IntSlideBarPreference.java +++ b/srcs/juloo.keyboard2/prefs/IntSlideBarPreference.java @@ -1,4 +1,4 @@ -package juloo.common; +package juloo.keyboard2.prefs; import android.content.Context; import android.content.res.TypedArray; diff --git a/srcs/juloo.keyboard2/LayoutsPreference.java b/srcs/juloo.keyboard2/prefs/LayoutsPreference.java similarity index 96% rename from srcs/juloo.keyboard2/LayoutsPreference.java rename to srcs/juloo.keyboard2/prefs/LayoutsPreference.java index d1cffcf..787800c 100644 --- a/srcs/juloo.keyboard2/LayoutsPreference.java +++ b/srcs/juloo.keyboard2/prefs/LayoutsPreference.java @@ -1,4 +1,4 @@ -package juloo.keyboard2; +package juloo.keyboard2.prefs; import android.app.AlertDialog; import android.content.Context; @@ -12,6 +12,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import juloo.keyboard2.*; import org.json.JSONException; import org.json.JSONObject; @@ -237,22 +238,22 @@ public class LayoutsPreference extends ListGroupPreference + public static class Serializer implements ListGroupPreference.Serializer { public Layout load_item(Object obj) throws JSONException { diff --git a/srcs/juloo.keyboard2/ListGroupPreference.java b/srcs/juloo.keyboard2/prefs/ListGroupPreference.java similarity index 99% rename from srcs/juloo.keyboard2/ListGroupPreference.java rename to srcs/juloo.keyboard2/prefs/ListGroupPreference.java index 075b38c..e332764 100644 --- a/srcs/juloo.keyboard2/ListGroupPreference.java +++ b/srcs/juloo.keyboard2/prefs/ListGroupPreference.java @@ -1,4 +1,4 @@ -package juloo.keyboard2; +package juloo.keyboard2.prefs; import android.content.Context; import android.content.SharedPreferences; @@ -9,6 +9,7 @@ import android.view.View; import android.view.ViewGroup; import java.util.ArrayList; import java.util.List; +import juloo.keyboard2.*; import org.json.JSONArray; import org.json.JSONException; diff --git a/srcs/juloo.common/SlideBarPreference.java b/srcs/juloo.keyboard2/prefs/SlideBarPreference.java similarity index 99% rename from srcs/juloo.common/SlideBarPreference.java rename to srcs/juloo.keyboard2/prefs/SlideBarPreference.java index b41448b..cacf37e 100644 --- a/srcs/juloo.common/SlideBarPreference.java +++ b/srcs/juloo.keyboard2/prefs/SlideBarPreference.java @@ -1,4 +1,4 @@ -package juloo.common; +package juloo.keyboard2.prefs; import android.content.Context; import android.content.res.TypedArray;