From 4645e425e60c75e97b6beb4b4e08540b6fb10e2d Mon Sep 17 00:00:00 2001 From: Helium314 Date: Sun, 4 Feb 2024 09:31:45 +0100 Subject: [PATCH] remove or add info to some todos --- .../keyboard/keyboard/emoji/EmojiPageKeyboardView.java | 1 - .../keyboard/keyboard/internal/KeyVisualAttributes.java | 7 +++++-- .../keyboard/internal/keyboard_parser/KeyboardParser.kt | 2 +- .../keyboard/latin/DictionaryFacilitatorImpl.java | 2 -- .../latin/DictionaryPackInstallBroadcastReceiver.java | 3 --- app/src/main/java/helium314/keyboard/latin/LatinIME.java | 3 +-- .../helium314/keyboard/latin/RichInputMethodSubtype.java | 4 ++++ .../helium314/keyboard/latin/makedict/DictionaryHeader.kt | 4 ---- .../keyboard/latin/setup/SetupWizardActivity.java | 1 - .../keyboard/latin/suggestions/MoreSuggestions.java | 1 + .../keyboard/latin/utils/AutoCorrectionUtils.java | 1 - .../helium314/keyboard/latin/utils/SubtypeLocaleUtils.java | 6 +----- 12 files changed, 13 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/helium314/keyboard/keyboard/emoji/EmojiPageKeyboardView.java b/app/src/main/java/helium314/keyboard/keyboard/emoji/EmojiPageKeyboardView.java index e005daf7c..6721a46a1 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/emoji/EmojiPageKeyboardView.java +++ b/app/src/main/java/helium314/keyboard/keyboard/emoji/EmojiPageKeyboardView.java @@ -46,7 +46,6 @@ import java.util.WeakHashMap; * This is an extended {@link KeyboardView} class that hosts an emoji page keyboard. * Multi-touch unsupported. No gesture support. */ -// TODO: Implement key popup preview. public final class EmojiPageKeyboardView extends KeyboardView implements MoreKeysPanel.Controller { private static final String TAG = "EmojiPageKeyboardView"; diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/KeyVisualAttributes.java b/app/src/main/java/helium314/keyboard/keyboard/internal/KeyVisualAttributes.java index 8b9910978..2aebc1429 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/KeyVisualAttributes.java +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/KeyVisualAttributes.java @@ -47,8 +47,6 @@ public final class KeyVisualAttributes { public final float mLabelOffCenterRatio; public final float mHintLabelOffCenterRatio; - // todo: replace the remaining colors with something from new colors instead of theme - // but first check which colors are actually used private static final int[] VISUAL_ATTRIBUTE_IDS = { R.styleable.Keyboard_Key_keyTypeface, R.styleable.Keyboard_Key_keyLetterSize, @@ -115,15 +113,20 @@ public final class KeyVisualAttributes { mPreviewTextRatio = ResourceUtils.getFraction(keyAttr, R.styleable.Keyboard_Key_keyPreviewTextRatio); + // todo: check what colors do, and if irrelevant and no plan to use -> remove here and from attr final Colors colors = Settings.getInstance().getCurrent().mColors; mTextColor = colors.get(ColorType.KEY_TEXT); + // when? -> isShiftedLetterActivated, which is a label flag mTextInactivatedColor = keyAttr.getColor(R.styleable.Keyboard_Key_keyTextInactivatedColor, 0); + // when? -> mKeyTextShadowRadius > 0, but it's always set to -1 (in theme) -> maybe play with this? mTextShadowColor = keyAttr.getColor(R.styleable.Keyboard_Key_keyTextShadowColor, 0); mFunctionalTextColor = colors.get(ColorType.FUNCTIONAL_KEY_TEXT); mHintLetterColor = colors.get(ColorType.KEY_HINT_TEXT); mHintLabelColor = colors.get(ColorType.KEY_TEXT); + // when? -> hasShiftedLetterHint and not isShiftedLetterActivated -> both are label flags mShiftedLetterHintInactivatedColor = keyAttr.getColor( R.styleable.Keyboard_Key_keyShiftedLetterHintInactivatedColor, 0); + // when? -> hasShiftedLetterHint and isShiftedLetterActivated -> both are label flags mShiftedLetterHintActivatedColor = keyAttr.getColor( R.styleable.Keyboard_Key_keyShiftedLetterHintActivatedColor, 0); mPreviewTextColor = colors.get(ColorType.KEY_TEXT); diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt index 92182f2f4..a1546c1ae 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt @@ -651,7 +651,7 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co if (params.mIconsSet.getIconDrawable(KeyboardIconsSet.getIconId(this)) != null) return this if (params.mId.mWidth == AndroidSpellCheckerService.SPELLCHECKER_DUMMY_KEYBOARD_WIDTH && params.mId.mHeight == AndroidSpellCheckerService.SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT - && !params.mId.mSubtype.rawSubtype.extraValue.contains(Constants.Subtype.ExtraValue.EMOJI_CAPABLE) + && !params.mId.mSubtype.hasExtraValue(Constants.Subtype.ExtraValue.EMOJI_CAPABLE) ) // fake keyboard that is used by spell checker (for key coordinates), but not shown to the user // often this doesn't have any icons loaded, and there is no need to bother with this diff --git a/app/src/main/java/helium314/keyboard/latin/DictionaryFacilitatorImpl.java b/app/src/main/java/helium314/keyboard/latin/DictionaryFacilitatorImpl.java index b0e4aef13..149c95c5d 100644 --- a/app/src/main/java/helium314/keyboard/latin/DictionaryFacilitatorImpl.java +++ b/app/src/main/java/helium314/keyboard/latin/DictionaryFacilitatorImpl.java @@ -58,7 +58,6 @@ import java.util.concurrent.TimeUnit; * a client for interacting with dictionaries. */ public class DictionaryFacilitatorImpl implements DictionaryFacilitator { - // TODO: Consolidate dictionaries in native code. public static final String TAG = DictionaryFacilitatorImpl.class.getSimpleName(); // HACK: This threshold is being used when adding a capitalized entry in the User History @@ -333,7 +332,6 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator { final String dictNamePrefix, @Nullable final DictionaryInitializationListener listener) { final HashMap> existingDictionariesToCleanup = new HashMap<>(); - // TODO: Make subDictTypesToUse configurable by resource or a static final list. final HashSet subDictTypesToUse = new HashSet<>(); subDictTypesToUse.add(Dictionary.TYPE_USER); final List allLocales = new ArrayList<>() {{ diff --git a/app/src/main/java/helium314/keyboard/latin/DictionaryPackInstallBroadcastReceiver.java b/app/src/main/java/helium314/keyboard/latin/DictionaryPackInstallBroadcastReceiver.java index abd1c1ce2..9289ec1b3 100644 --- a/app/src/main/java/helium314/keyboard/latin/DictionaryPackInstallBroadcastReceiver.java +++ b/app/src/main/java/helium314/keyboard/latin/DictionaryPackInstallBroadcastReceiver.java @@ -95,9 +95,6 @@ public final class DictionaryPackInstallBroadcastReceiver extends BroadcastRecei // If we are replacing the package, we will receive ADDED right away so no need to // remove the dictionary at the moment, since we will do it when we receive the // ADDED broadcast. - - // TODO: Only reload dictionary on REMOVED when the removed package is the one we - // read dictionary from? mService.resetSuggestMainDict(); } else if (DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION.equals(action)) { if (null == mService) { diff --git a/app/src/main/java/helium314/keyboard/latin/LatinIME.java b/app/src/main/java/helium314/keyboard/latin/LatinIME.java index ba00e6104..40ab5734e 100644 --- a/app/src/main/java/helium314/keyboard/latin/LatinIME.java +++ b/app/src/main/java/helium314/keyboard/latin/LatinIME.java @@ -1995,8 +1995,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen p.println(" Keyboard mode = " + keyboardMode); final SettingsValues settingsValues = mSettings.getCurrent(); p.println(settingsValues.dump()); - p.println(mDictionaryFacilitator.dump(this /* context */)); - // TODO: Dump all settings values + p.println(mDictionaryFacilitator.dump(this)); } // slightly modified from Simple Keyboard: https://github.com/rkkr/simple-keyboard/blob/master/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/LatinIME.java diff --git a/app/src/main/java/helium314/keyboard/latin/RichInputMethodSubtype.java b/app/src/main/java/helium314/keyboard/latin/RichInputMethodSubtype.java index afcf1ef59..66b30d419 100644 --- a/app/src/main/java/helium314/keyboard/latin/RichInputMethodSubtype.java +++ b/app/src/main/java/helium314/keyboard/latin/RichInputMethodSubtype.java @@ -51,6 +51,10 @@ public class RichInputMethodSubtype { return mSubtype.getExtraValueOf(key); } + public boolean hasExtraValue(@NonNull final String key) { + return mSubtype.containsExtraValueKey(key); + } + // The mode is also determined by the primary subtype. public String getMode() { return mSubtype.getMode(); diff --git a/app/src/main/java/helium314/keyboard/latin/makedict/DictionaryHeader.kt b/app/src/main/java/helium314/keyboard/latin/makedict/DictionaryHeader.kt index 3923814f8..a57600fdf 100644 --- a/app/src/main/java/helium314/keyboard/latin/makedict/DictionaryHeader.kt +++ b/app/src/main/java/helium314/keyboard/latin/makedict/DictionaryHeader.kt @@ -38,8 +38,6 @@ class DictionaryHeader( val description: String? // Helper method to get the description - // TODO: Right now each dictionary file comes with a description in its own language. - // It will display as is no matter the device's locale. It should be internationalized. get() = mDictionaryOptions.mAttributes[DICTIONARY_DESCRIPTION_KEY] fun info(locale: Locale): String { @@ -52,8 +50,6 @@ class DictionaryHeader( companion object { // Note that these are corresponding definitions in native code in latinime::HeaderPolicy // and latinime::HeaderReadWriteUtils. - // TODO: Standardize the key names and bump up the format version, taking care not to - // break format version 2 dictionaries. const val DICTIONARY_VERSION_KEY = "version" const val DICTIONARY_LOCALE_KEY = "locale" const val DICTIONARY_ID_KEY = "dictionary" diff --git a/app/src/main/java/helium314/keyboard/latin/setup/SetupWizardActivity.java b/app/src/main/java/helium314/keyboard/latin/setup/SetupWizardActivity.java index 9f8ee1f4d..73351d414 100644 --- a/app/src/main/java/helium314/keyboard/latin/setup/SetupWizardActivity.java +++ b/app/src/main/java/helium314/keyboard/latin/setup/SetupWizardActivity.java @@ -37,7 +37,6 @@ import helium314.keyboard.latin.utils.UncachedInputMethodManagerUtils; import java.util.ArrayList; -// TODO: Use Fragment to implement welcome screen and setup steps. public final class SetupWizardActivity extends AppCompatActivity implements View.OnClickListener { // For debugging purpose. private static final boolean FORCE_TO_SHOW_WELCOME_SCREEN = false; diff --git a/app/src/main/java/helium314/keyboard/latin/suggestions/MoreSuggestions.java b/app/src/main/java/helium314/keyboard/latin/suggestions/MoreSuggestions.java index e51f55e84..433b8f1a5 100644 --- a/app/src/main/java/helium314/keyboard/latin/suggestions/MoreSuggestions.java +++ b/app/src/main/java/helium314/keyboard/latin/suggestions/MoreSuggestions.java @@ -252,6 +252,7 @@ public final class MoreSuggestions extends Keyboard { // KeyboardIconsSet and alpha are unused. Use the icon that has been passed to the // constructor. // TODO: Drawable itself should have an alpha value. + // todo: replace with shape or vector, or maybe remove it completely mIcon.setAlpha(128); return mIcon; } diff --git a/app/src/main/java/helium314/keyboard/latin/utils/AutoCorrectionUtils.java b/app/src/main/java/helium314/keyboard/latin/utils/AutoCorrectionUtils.java index d95b4cf95..8ebee14ec 100644 --- a/app/src/main/java/helium314/keyboard/latin/utils/AutoCorrectionUtils.java +++ b/app/src/main/java/helium314/keyboard/latin/utils/AutoCorrectionUtils.java @@ -25,7 +25,6 @@ public final class AutoCorrectionUtils { if (suggestion.isKindOf(SuggestedWordInfo.KIND_WHITELIST)) { return true; } - // TODO: return suggestion.isAppropriateForAutoCorrection(); if (!suggestion.isAppropriateForAutoCorrection()) { return false; } diff --git a/app/src/main/java/helium314/keyboard/latin/utils/SubtypeLocaleUtils.java b/app/src/main/java/helium314/keyboard/latin/utils/SubtypeLocaleUtils.java index e62cbd967..771bf21b2 100644 --- a/app/src/main/java/helium314/keyboard/latin/utils/SubtypeLocaleUtils.java +++ b/app/src/main/java/helium314/keyboard/latin/utils/SubtypeLocaleUtils.java @@ -242,15 +242,12 @@ public final class SubtypeLocaleUtils { private static String getSubtypeDisplayNameInternal(@NonNull final InputMethodSubtype subtype, @NonNull final Locale displayLocale) { final String replacementString = getReplacementString(subtype, displayLocale); - // TODO: rework this for multi-lingual subtypes final int nameResId = subtype.getNameResId(); return RunInLocaleKt.runInLocale(sResources, displayLocale, res -> { try { return StringUtils.capitalizeFirstCodePoint(res.getString(nameResId, replacementString), displayLocale); } catch (Resources.NotFoundException e) { - // TODO: Remove this catch when InputMethodManager.getCurrentInputMethodSubtype - // is fixed. Log.w(TAG, "Unknown subtype: mode=" + subtype.getMode() + " nameResId=" + subtype.getNameResId() + " locale=" + subtype.getLocale() @@ -280,8 +277,7 @@ public final class SubtypeLocaleUtils { if (keyboardLayoutSet == null && subtype.isAsciiCapable()) { keyboardLayoutSet = QWERTY; } - // TODO: Remove this null check when InputMethodManager.getCurrentInputMethodSubtype is fixed. - if (keyboardLayoutSet == null) { + if (keyboardLayoutSet == null) { // we could search for a subtype with the correct script, but this is a bug anyway... Log.w(TAG, "KeyboardLayoutSet not found, use QWERTY: " + "locale=" + subtype.getLocale() + " extraValue=" + subtype.getExtraValue()); return QWERTY;