remove some unused code and todos

This commit is contained in:
Helium314 2023-10-20 09:43:14 +02:00
parent 6fd6113271
commit d183baf401
9 changed files with 17 additions and 101 deletions

View file

@ -46,10 +46,6 @@ android {
} }
ndkVersion '25.2.9519653' ndkVersion '25.2.9519653'
androidResources { // todo: check, probably both can be removed (together with searching dicts in res/raw)
noCompress 'main.dict'
noCompress 'empty.dict'
}
packagingOptions { packagingOptions {
jniLibs { jniLibs {

View file

@ -236,11 +236,6 @@ final class EmojiCategory {
return mCurrentCategoryPageId; return mCurrentCategoryPageId;
} }
public void saveLastTypedCategoryPage() {
Settings.writeLastTypedEmojiCategoryPageId(
mPrefs, mCurrentCategoryId, mCurrentCategoryPageId);
}
public boolean isInRecentTab() { public boolean isInRecentTab() {
return mCurrentCategoryId == EmojiCategory.ID_RECENTS; return mCurrentCategoryId == EmojiCategory.ID_RECENTS;
} }

View file

@ -353,7 +353,6 @@ public final class EmojiPalettesView extends LinearLayout
@Override @Override
public void onReleaseKey(final Key key) { public void onReleaseKey(final Key key) {
mEmojiPalettesAdapter.addRecentKey(key); mEmojiPalettesAdapter.addRecentKey(key);
mEmojiCategory.saveLastTypedCategoryPage();
final int code = key.getCode(); final int code = key.getCode();
if (code == Constants.CODE_OUTPUT_TEXT) { if (code == Constants.CODE_OUTPUT_TEXT) {
mKeyboardActionListener.onTextInput(key.getOutputText()); mKeyboardActionListener.onTextInput(key.getOutputText());

View file

@ -17,7 +17,6 @@ import org.dslul.openboard.inputmethod.latin.makedict.DictionaryHeader;
import org.dslul.openboard.inputmethod.latin.utils.DictionaryInfoUtils; import org.dslul.openboard.inputmethod.latin.utils.DictionaryInfoUtils;
import java.io.File; import java.io.File;
import java.text.Normalizer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Locale; import java.util.Locale;
@ -97,10 +96,8 @@ public final class DictionaryFactory {
public static void killDictionary(final Context context, final AssetFileAddress f) { public static void killDictionary(final Context context, final AssetFileAddress f) {
if (f.pointsToPhysicalFile()) { if (f.pointsToPhysicalFile()) {
f.deleteUnderlyingFile(); f.deleteUnderlyingFile();
// notify the user // notify the user if possible (toast not showing up on Android 13+)
// todo: use an alertDialog to avoid the toast not showing up on Android 13+ // but not that important, as the not working dictionary should be obvious
// but asyncTask doesn't work because android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
// https://stackoverflow.com/questions/7199014/show-an-alertdialog-from-a-background-thread-with-the-appcontext
final String wordlistId = DictionaryInfoUtils.getWordListIdFromFileName(new File(f.mFilename).getName()); final String wordlistId = DictionaryInfoUtils.getWordListIdFromFileName(new File(f.mFilename).getName());
new Handler(Looper.getMainLooper()).post(() -> new Handler(Looper.getMainLooper()).post(() ->
Toast.makeText(context, "dictionary "+wordlistId+" is invalid, deleting", Toast.LENGTH_LONG).show() Toast.makeText(context, "dictionary "+wordlistId+" is invalid, deleting", Toast.LENGTH_LONG).show()

View file

@ -386,14 +386,14 @@ public final class RichInputConnection implements PrivateCommandPerformer {
spacingAndPunctuations, hasSpaceBefore); spacingAndPunctuations, hasSpaceBefore);
} }
public int getCodePointBeforeCursor() { // todo: behavior still correct? also should do this to getCharBeforeBeforeCursor public int getCodePointBeforeCursor() {
final CharSequence text = mComposingText.length() == 0 ? mCommittedTextBeforeComposingText : mComposingText; final CharSequence text = mComposingText.length() == 0 ? mCommittedTextBeforeComposingText : mComposingText;
final int length = text.length(); final int length = text.length();
if (length < 1) return Constants.NOT_A_CODE; if (length < 1) return Constants.NOT_A_CODE;
return Character.codePointBefore(text, length); return Character.codePointBefore(text, length);
} }
public int getCharBeforeBeforeCursor() { // todo: behavior still correct? public int getCharBeforeBeforeCursor() {
if (mComposingText.length() >= 2) return mComposingText.charAt(mComposingText.length() - 2); if (mComposingText.length() >= 2) return mComposingText.charAt(mComposingText.length() - 2);
final int length = mCommittedTextBeforeComposingText.length(); final int length = mCommittedTextBeforeComposingText.length();
if (mComposingText.length() == 1) return mCommittedTextBeforeComposingText.charAt(length - 1); if (mComposingText.length() == 1) return mCommittedTextBeforeComposingText.charAt(length - 1);

View file

@ -47,8 +47,6 @@ class Colors (
val adjustedKeyText: Int val adjustedKeyText: Int
val spaceBarText: Int val spaceBarText: Int
// todo (later): evaluate which colors, colorFilters and colorStateLists are actually necessary
// also, ideally the color filters would be private and chosen internally depending on type
val backgroundFilter: ColorFilter val backgroundFilter: ColorFilter
val adjustedBackgroundFilter: ColorFilter val adjustedBackgroundFilter: ColorFilter
val keyBackgroundFilter: ColorFilter val keyBackgroundFilter: ColorFilter
@ -83,7 +81,7 @@ class Colors (
spaceBarText = keyHintText spaceBarText = keyHintText
} }
// create color filters, todo: maybe better / simplify // create color filters
val states = arrayOf(intArrayOf(android.R.attr.state_pressed), intArrayOf(-android.R.attr.state_pressed)) val states = arrayOf(intArrayOf(android.R.attr.state_pressed), intArrayOf(-android.R.attr.state_pressed))
fun stateList(pressed: Int, normal: Int) = ColorStateList(states, intArrayOf(pressed, normal)) fun stateList(pressed: Int, normal: Int) = ColorStateList(states, intArrayOf(pressed, normal))
// todo (idea): make better use of the states? // todo (idea): make better use of the states?

View file

@ -29,7 +29,6 @@ import org.dslul.openboard.inputmethod.latin.InputAttributes;
import org.dslul.openboard.inputmethod.latin.R; import org.dslul.openboard.inputmethod.latin.R;
import org.dslul.openboard.inputmethod.latin.common.Colors; import org.dslul.openboard.inputmethod.latin.common.Colors;
import org.dslul.openboard.inputmethod.latin.common.LocaleUtils; import org.dslul.openboard.inputmethod.latin.common.LocaleUtils;
import org.dslul.openboard.inputmethod.latin.common.StringUtils;
import org.dslul.openboard.inputmethod.latin.utils.AdditionalSubtypeUtils; import org.dslul.openboard.inputmethod.latin.utils.AdditionalSubtypeUtils;
import org.dslul.openboard.inputmethod.latin.utils.ColorUtilKt; import org.dslul.openboard.inputmethod.latin.utils.ColorUtilKt;
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils; import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils;
@ -40,11 +39,9 @@ import org.dslul.openboard.inputmethod.latin.utils.StatsUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
public final class Settings implements SharedPreferences.OnSharedPreferenceChangeListener { public final class Settings implements SharedPreferences.OnSharedPreferenceChangeListener {
@ -126,17 +123,8 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_DONT_SHOW_MISSING_DICTIONARY_DIALOG = "pref_dont_show_missing_dict_dialog"; public static final String PREF_DONT_SHOW_MISSING_DICTIONARY_DIALOG = "pref_dont_show_missing_dict_dialog";
public static final String PREF_PINNED_KEYS = "pref_pinned_keys"; public static final String PREF_PINNED_KEYS = "pref_pinned_keys";
private static final String PREF_LAST_USED_PERSONALIZATION_TOKEN =
"pref_last_used_personalization_token";
private static final String PREF_LAST_PERSONALIZATION_DICT_WIPED_TIME =
"pref_last_used_personalization_dict_wiped_time";
private static final String PREF_CORPUS_HANDLES_FOR_PERSONALIZATION =
"pref_corpus_handles_for_personalization";
// Emoji // Emoji
public static final String PREF_EMOJI_RECENT_KEYS = "emoji_recent_keys"; public static final String PREF_EMOJI_RECENT_KEYS = "emoji_recent_keys";
public static final String PREF_EMOJI_CATEGORY_LAST_TYPED_ID = "emoji_category_last_typed_id";
public static final String PREF_LAST_SHOWN_EMOJI_CATEGORY_ID = "last_shown_emoji_category_id"; public static final String PREF_LAST_SHOWN_EMOJI_CATEGORY_ID = "last_shown_emoji_category_id";
public static final String PREF_LAST_SHOWN_EMOJI_CATEGORY_PAGE_ID = "last_shown_emoji_category_page_id"; public static final String PREF_LAST_SHOWN_EMOJI_CATEGORY_PAGE_ID = "last_shown_emoji_category_page_id";
@ -334,18 +322,6 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
R.array.keypress_vibration_durations, DEFAULT_KEYPRESS_VIBRATION_DURATION)); R.array.keypress_vibration_durations, DEFAULT_KEYPRESS_VIBRATION_DURATION));
} }
public static float readKeyPreviewAnimationScale(final SharedPreferences prefs,
final String prefKey, final float defaultValue) {
final float fraction = prefs.getFloat(prefKey, UNDEFINED_PREFERENCE_VALUE_FLOAT);
return (fraction != UNDEFINED_PREFERENCE_VALUE_FLOAT) ? fraction : defaultValue;
}
public static int readKeyPreviewAnimationDuration(final SharedPreferences prefs,
final String prefKey, final int defaultValue) {
final int milliseconds = prefs.getInt(prefKey, UNDEFINED_PREFERENCE_VALUE_INT);
return (milliseconds != UNDEFINED_PREFERENCE_VALUE_INT) ? milliseconds : defaultValue;
}
public static boolean readClipboardHistoryEnabled(final SharedPreferences prefs) { public static boolean readClipboardHistoryEnabled(final SharedPreferences prefs) {
return prefs.getBoolean(PREF_ENABLE_CLIPBOARD_HISTORY, true); return prefs.getBoolean(PREF_ENABLE_CLIPBOARD_HISTORY, true);
} }
@ -423,37 +399,6 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
&& conf.hardKeyboardHidden != Configuration.HARDKEYBOARDHIDDEN_YES; && conf.hardKeyboardHidden != Configuration.HARDKEYBOARDHIDDEN_YES;
} }
public void writeLastUsedPersonalizationToken(byte[] token) {
if (token == null) {
mPrefs.edit().remove(PREF_LAST_USED_PERSONALIZATION_TOKEN).apply();
} else {
final String tokenStr = StringUtils.byteArrayToHexString(token);
mPrefs.edit().putString(PREF_LAST_USED_PERSONALIZATION_TOKEN, tokenStr).apply();
}
}
public byte[] readLastUsedPersonalizationToken() {
final String tokenStr = mPrefs.getString(PREF_LAST_USED_PERSONALIZATION_TOKEN, null);
return StringUtils.hexStringToByteArray(tokenStr);
}
public void writeLastPersonalizationDictWipedTime(final long timestamp) {
mPrefs.edit().putLong(PREF_LAST_PERSONALIZATION_DICT_WIPED_TIME, timestamp).apply();
}
public long readLastPersonalizationDictGeneratedTime() {
return mPrefs.getLong(PREF_LAST_PERSONALIZATION_DICT_WIPED_TIME, 0);
}
public void writeCorpusHandlesForPersonalization(final Set<String> corpusHandles) {
mPrefs.edit().putStringSet(PREF_CORPUS_HANDLES_FOR_PERSONALIZATION, corpusHandles).apply();
}
public Set<String> readCorpusHandlesForPersonalization() {
final Set<String> emptySet = Collections.emptySet();
return mPrefs.getStringSet(PREF_CORPUS_HANDLES_FOR_PERSONALIZATION, emptySet);
}
public static void writeEmojiRecentKeys(final SharedPreferences prefs, String str) { public static void writeEmojiRecentKeys(final SharedPreferences prefs, String str) {
prefs.edit().putString(PREF_EMOJI_RECENT_KEYS, str).apply(); prefs.edit().putString(PREF_EMOJI_RECENT_KEYS, str).apply();
} }
@ -462,18 +407,6 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
return prefs.getString(PREF_EMOJI_RECENT_KEYS, ""); return prefs.getString(PREF_EMOJI_RECENT_KEYS, "");
} }
public static void writeLastTypedEmojiCategoryPageId(
final SharedPreferences prefs, final int categoryId, final int categoryPageId) {
final String key = PREF_EMOJI_CATEGORY_LAST_TYPED_ID + categoryId;
prefs.edit().putInt(key, categoryPageId).apply();
}
public static int readLastTypedEmojiCategoryPageId(
final SharedPreferences prefs, final int categoryId) {
final String key = PREF_EMOJI_CATEGORY_LAST_TYPED_ID + categoryId;
return prefs.getInt(key, 0);
}
public static void writeLastShownEmojiCategoryId( public static void writeLastShownEmojiCategoryId(
final SharedPreferences prefs, final int categoryId) { final SharedPreferences prefs, final int categoryId) {
prefs.edit().putInt(PREF_LAST_SHOWN_EMOJI_CATEGORY_ID, categoryId).apply(); prefs.edit().putInt(PREF_LAST_SHOWN_EMOJI_CATEGORY_ID, categoryId).apply();
@ -566,7 +499,6 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
case PREF_COLOR_ACCENT_SUFFIX: case PREF_COLOR_ACCENT_SUFFIX:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && Build.VERSION.SDK_INT < Build.VERSION_CODES.S) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
// try determining accent color on Android 10 & 11, accent is not available in resources // try determining accent color on Android 10 & 11, accent is not available in resources
// todo: test whether this actually works
final Context wrapper = new ContextThemeWrapper(context, android.R.style.Theme_DeviceDefault); final Context wrapper = new ContextThemeWrapper(context, android.R.style.Theme_DeviceDefault);
final TypedValue value = new TypedValue(); final TypedValue value = new TypedValue();
if (wrapper.getTheme().resolveAttribute(android.R.attr.colorAccent, value, true)) if (wrapper.getTheme().resolveAttribute(android.R.attr.colorAccent, value, true))

View file

@ -1 +0,0 @@
<EFBFBD><EFBFBD>:<3A>

Binary file not shown.