1
0
Fork 0

added Compatibility sections in each screen and moved each option where it belongs, instead of keeping them all on the Initial Setup screen

This commit is contained in:
sspanak 2024-04-25 18:41:59 +03:00 committed by Dimo Karaivanov
parent 72a26c920d
commit 2760a30af2
13 changed files with 97 additions and 106 deletions

View file

@ -8,7 +8,7 @@ import java.util.LinkedHashMap;
import io.github.sspanak.tt9.util.Logger;
public class ItemDropDown {
abstract public class ItemDropDown {
private final DropDownPreference item;
private LinkedHashMap<String, String> values;
@ -27,6 +27,8 @@ public class ItemDropDown {
populate(stringifiedValues);
}
abstract public ItemDropDown populate();
protected void populate(LinkedHashMap<String, String> values) {
if (item == null) {
Logger.w("ItemDropDown.populate", "Cannot populate a NULL item. Ignoring.");

View file

@ -2,6 +2,8 @@ package io.github.sspanak.tt9.preferences.screens.appearance;
import io.github.sspanak.tt9.R;
import io.github.sspanak.tt9.preferences.PreferencesActivity;
import io.github.sspanak.tt9.preferences.items.ItemDropDown;
import io.github.sspanak.tt9.preferences.items.ItemSwitch;
import io.github.sspanak.tt9.preferences.screens.BaseScreenFragment;
public class AppearanceScreen extends BaseScreenFragment {
@ -15,32 +17,34 @@ public class AppearanceScreen extends BaseScreenFragment {
@Override
protected void onCreate() {
(new ItemSelectTheme(activity, findPreference(ItemSelectTheme.NAME)))
.populate()
.preview()
.enableClickHandler();
(new ItemSelectLayoutType(activity, findPreference(ItemSelectLayoutType.NAME)))
.populate()
.preview()
.enableClickHandler();
(new ItemStatusIcon(findPreference(ItemStatusIcon.NAME), activity.getSettings())).populate();
(new ItemSelectSettingsFontSize(findPreference(ItemSelectSettingsFontSize.NAME), this))
.populate()
.preview()
.enableClickHandler();
(new ItemCandidatesView(findPreference(ItemCandidatesView.NAME), activity.getSettings()))
.populate()
.enableClickHandler();
(new ItemClearInsets(findPreference(ItemClearInsets.NAME), activity.getSettings()))
.populate()
.enableClickHandler();
createMainSection();
createHacksSection();
resetFontSize(true);
}
private void createMainSection() {
(new ItemStatusIcon(findPreference(ItemStatusIcon.NAME), activity.getSettings())).populate();
ItemDropDown[] items = {
new ItemSelectTheme(findPreference(ItemSelectTheme.NAME), activity),
new ItemSelectLayoutType(findPreference(ItemSelectLayoutType.NAME), activity),
new ItemSelectSettingsFontSize(findPreference(ItemSelectSettingsFontSize.NAME), this)
};
for (ItemDropDown item : items) {
item.populate().preview().enableClickHandler();
}
}
private void createHacksSection() {
ItemSwitch[] items = {
new ItemAlternativeSuggestionScrolling(findPreference(ItemAlternativeSuggestionScrolling.NAME), activity.getSettings()),
new ItemCandidatesView(findPreference(ItemCandidatesView.NAME), activity.getSettings()),
new ItemClearInsets(findPreference(ItemClearInsets.NAME), activity.getSettings())
};
for (ItemSwitch item : items) {
item.populate().enableClickHandler();
}
}
}

View file

@ -0,0 +1,22 @@
package io.github.sspanak.tt9.preferences.screens.appearance;
import androidx.preference.SwitchPreferenceCompat;
import io.github.sspanak.tt9.preferences.items.ItemSwitch;
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
public class ItemAlternativeSuggestionScrolling extends ItemSwitch {
public static final String NAME = "pref_alternative_suggestion_scrolling";
private final SettingsStore settings;
public ItemAlternativeSuggestionScrolling(SwitchPreferenceCompat item, SettingsStore settings) {
super(item);
this.settings = settings;
}
@Override
protected boolean getDefaultValue() {
return settings.getSuggestionScrollingDelay() > 0;
}
}

View file

@ -14,8 +14,7 @@ public class ItemSelectLayoutType extends ItemDropDown {
private final PreferencesActivity activity;
public ItemSelectLayoutType(PreferencesActivity activity, DropDownPreference item) {
public ItemSelectLayoutType(DropDownPreference item, PreferencesActivity activity) {
super(item);
this.activity = activity;
}

View file

@ -16,7 +16,7 @@ class ItemSelectTheme extends ItemDropDown {
private final Context context;
ItemSelectTheme(Context context, DropDownPreference item) {
ItemSelectTheme(DropDownPreference item, Context context) {
super(item);
this.context = context;
}

View file

@ -1,4 +1,4 @@
package io.github.sspanak.tt9.preferences.screens.setup;
package io.github.sspanak.tt9.preferences.screens.keypad;
import android.content.Context;
@ -7,27 +7,30 @@ import androidx.preference.DropDownPreference;
import java.util.LinkedHashMap;
import io.github.sspanak.tt9.R;
import io.github.sspanak.tt9.preferences.PreferencesActivity;
import io.github.sspanak.tt9.preferences.items.ItemDropDown;
class ItemKeyPadDebounceTime extends ItemDropDown {
public static final String NAME = "pref_key_pad_debounce_time";
private final Context context;
private final PreferencesActivity activity;
ItemKeyPadDebounceTime(Context context, DropDownPreference item) {
ItemKeyPadDebounceTime(DropDownPreference item, PreferencesActivity activity) {
super(item);
this.context = context;
this.activity = activity;
}
public ItemDropDown populate() {
LinkedHashMap<String, String> dropDownOptions = new LinkedHashMap<>();
dropDownOptions.put("0", context.getString(R.string.pref_hack_key_pad_debounce_off));
dropDownOptions.put("0", activity.getString(R.string.pref_hack_key_pad_debounce_off));
String[] values = new String[] { "20", "30", "50", "75", "100", "150", "250", "350" };
for (String value : values) {
dropDownOptions.put(value, value + " ms");
}
super.populate(dropDownOptions);
super.setValue(String.valueOf(activity.getSettings().getKeyPadDebounceTime()));
return this;
}

View file

@ -2,6 +2,7 @@ package io.github.sspanak.tt9.preferences.screens.keypad;
import io.github.sspanak.tt9.R;
import io.github.sspanak.tt9.preferences.PreferencesActivity;
import io.github.sspanak.tt9.preferences.items.ItemDropDown;
import io.github.sspanak.tt9.preferences.screens.BaseScreenFragment;
public class KeyPadScreen extends BaseScreenFragment {
@ -15,15 +16,15 @@ public class KeyPadScreen extends BaseScreenFragment {
@Override
protected void onCreate() {
(new ItemSelectZeroKeyCharacter(findPreference(ItemSelectZeroKeyCharacter.NAME), activity))
.populate()
.enableClickHandler()
.preview();
ItemDropDown[] items = {
new ItemSelectZeroKeyCharacter(findPreference(ItemSelectZeroKeyCharacter.NAME), activity),
new ItemSelectABCAutoAccceptTime(findPreference(ItemSelectABCAutoAccceptTime.NAME), activity),
new ItemKeyPadDebounceTime(findPreference(ItemKeyPadDebounceTime.NAME), activity)
};
(new ItemSelectABCAutoAccceptTime(findPreference(ItemSelectABCAutoAccceptTime.NAME), activity))
.populate()
.enableClickHandler()
.preview();
for (ItemDropDown item : items) {
item.populate().enableClickHandler().preview();
}
resetFontSize(false);
}

View file

@ -1,31 +0,0 @@
package io.github.sspanak.tt9.preferences.screens.setup;
import androidx.preference.SwitchPreferenceCompat;
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
public class ItemAlternativeSuggestionScrolling {
public static final String NAME = "pref_alternative_suggestion_scrolling";
private final SwitchPreferenceCompat item;
private final SettingsStore settings;
public ItemAlternativeSuggestionScrolling(SwitchPreferenceCompat item, SettingsStore settings) {
this.item = item;
this.settings = settings;
}
public ItemAlternativeSuggestionScrolling populate() {
if (item != null) {
item.setChecked(settings.getSuggestionScrollingDelay() > 0);
}
return this;
}
public void setEnabled(boolean yes) {
if (item != null) {
item.setEnabled(yes);
}
}
}

View file

@ -48,10 +48,6 @@ public class SetupScreen extends BaseScreenFragment {
}
private void createHacksSection(boolean isTT9On) {
(new ItemAlternativeSuggestionScrolling(findPreference(ItemAlternativeSuggestionScrolling.NAME), activity.getSettings()))
.populate()
.setEnabled(isTT9On);
Preference hackGoogleChat = findPreference("pref_hack_google_chat");
if (hackGoogleChat != null) {
hackGoogleChat.setEnabled(isTT9On);
@ -61,13 +57,5 @@ public class SetupScreen extends BaseScreenFragment {
if (hackFBMessenger != null) {
hackFBMessenger.setEnabled(isTT9On);
}
ItemKeyPadDebounceTime item = new ItemKeyPadDebounceTime(activity, findPreference(ItemKeyPadDebounceTime.NAME));
item.populate().preview();
if (isTT9On) {
item.enable();
} else {
item.disable();
}
}
}

View file

@ -21,6 +21,11 @@
<PreferenceCategory app:title="@string/pref_category_hacks">
<SwitchPreferenceCompat
app:key="pref_alternative_suggestion_scrolling"
app:title="@string/pref_alternative_suggestion_scrolling"
app:summary="@string/pref_alternative_suggestion_scrolling_summary"/>
<SwitchPreferenceCompat
app:key="pref_candidates_view"
app:title="@string/pref_hack_candidate_view" />

View file

@ -15,9 +15,7 @@
app:summary="@string/pref_upside_down_keys_summary"
app:title="@string/pref_upside_down_keys" />
<PreferenceCategory
android:title="@string/pref_category_predictive_mode"
app:singleLineTitle="true">
<PreferenceCategory android:title="@string/pref_category_predictive_mode">
<SwitchPreferenceCompat
app:defaultValue="true"
@ -47,14 +45,17 @@
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_category_abc_mode"
app:singleLineTitle="true">
<PreferenceCategory android:title="@string/pref_category_abc_mode">
<DropDownPreference
app:defaultValue="800"
app:key="pref_abc_auto_accept_time"
app:title="@string/pref_abc_auto_accept" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_category_hacks">
<DropDownPreference
app:key="pref_key_pad_debounce_time"
app:title="@string/pref_hack_key_pad_debounce_time" />
</PreferenceCategory>
</PreferenceScreen>

View file

@ -9,14 +9,7 @@
app:key="global_default_keyboard"
app:title="@string/setup_default_keyboard" />
<PreferenceCategory
app:title="@string/pref_category_hacks"
app:singleLineTitle="true">
<SwitchPreferenceCompat
app:key="pref_alternative_suggestion_scrolling"
app:title="@string/pref_alternative_suggestion_scrolling"
app:summary="@string/pref_alternative_suggestion_scrolling_summary"/>
<PreferenceCategory app:title="@string/pref_category_hacks">
<SwitchPreferenceCompat
app:defaultValue="false"
@ -29,9 +22,5 @@
app:key="pref_hack_fb_messenger"
app:title="@string/pref_hack_fb_messenger"/>
<DropDownPreference
app:key="pref_key_pad_debounce_time"
app:title="@string/pref_hack_key_pad_debounce_time" />
</PreferenceCategory>
</PreferenceScreen>

View file

@ -172,16 +172,20 @@ The "Export" option allows you to export all added words, for all languages, inc
Using "Delete", you can search for and delete misspelled words or others that you don't want in the dictionary.
### Compatibility Options & Troubleshooting
For several applications or devices, it is possible to enable special options, which will make Traditional T9 work better with them. You can find them in Settings → Initial Setup, under the Compatibility section.
For several applications or devices, it is possible to enable special options, which will make Traditional T9 work better with them. You can find them at the end of each settings screen, under the Compatibility section.
#### Alternative suggestion scrolling method
On some devices, in Predictive Mode, you may not be able to see all suggestions, or may not be able to scroll the list to the end. The problem occurs sometimes on Android 9 or earlier. Enable the option, if you are experiencing this issue.
_Available in: Settings → Appearance._
#### Key repeat protection
CAT S22 Flip and Qin F21 phones are known for their low-quality keypads, which degrade quickly over time and start registering multiple clicks for a single key press. You may notice this when typing or navigating the phone menus.
For CAT phones the recommended setting is 50-75 ms. For Qin F21, try with 20-30 ms. If you are still experiencing the issue, increase the value a bit, but generally try to keep it as low as possible.
_Available in: Settings → Keypad._
_**Note:** The higher the value you set, the slower you will have to type. TT9 will ignore very quick key presses._
_**Note 2:** Besides the above, Qin phones may also fail to detect long presses. Unfortunately, in this case, nothing can be done._
@ -189,9 +193,13 @@ _**Note 2:** Besides the above, Qin phones may also fail to detect long presses.
#### Send messages with OK in Facebook Messenger
Facebook Messenger fails to recognize the OK key on some devices, making it impossible to send messages with it. If you prefer to send messages using OK, instead of Messenger's own send button, enable this option. This ensures sending is possible on any phone.
_Available in: Settings → Initial Setup._
#### Send messages with OK in Google Chat
Similar to the above, but for Google Chat.
_Available in: Settings → Initial Setup._
_This option is still experimental. It may sometimes fail to detect the "Send" button and click another one. If this starts happening, just close the chat and reopen it._
#### Telegram/Snapchat stickers and emoji panels won't open