mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-24 16:46:35 +00:00
some more todos updated, revert use of ?android:colorForeground
This commit is contained in:
parent
5d2696e725
commit
7d7d983471
10 changed files with 27 additions and 88 deletions
|
@ -601,13 +601,12 @@ public class KeyboardView extends View {
|
||||||
if (key.isAccentColored()) {
|
if (key.isAccentColored()) {
|
||||||
icon.setColorFilter(mColors.getActionKeyIconColorFilter());
|
icon.setColorFilter(mColors.getActionKeyIconColorFilter());
|
||||||
} else if (key.isShift() && keyboard != null) {
|
} else if (key.isShift() && keyboard != null) {
|
||||||
// todo: switch to multiply after changing keyboard symbols to white icons
|
|
||||||
if (keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED
|
if (keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED
|
||||||
|| keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED
|
|| keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED
|
||||||
|| keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED
|
|| keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED
|
||||||
|| keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED
|
|| keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED
|
||||||
)
|
)
|
||||||
icon.setColorFilter(mColors.getAccent(), PorterDuff.Mode.SRC_ATOP); // accent if shifted, needs SRC_ATOP because of underlying drawable
|
icon.setColorFilter(mColors.getAccent(), PorterDuff.Mode.SRC_ATOP); // todo: switch to accentColorFilter after changing keyboard symbols to white icons
|
||||||
else
|
else
|
||||||
icon.setColorFilter(mColors.getKeyTextFilter()); // key text if not shifted
|
icon.setColorFilter(mColors.getKeyTextFilter()); // key text if not shifted
|
||||||
} else if (key.getBackgroundType() != Key.BACKGROUND_TYPE_NORMAL) {
|
} else if (key.getBackgroundType() != Key.BACKGROUND_TYPE_NORMAL) {
|
||||||
|
|
|
@ -273,7 +273,7 @@ public final class EmojiPalettesView extends LinearLayout
|
||||||
colors.setBackgroundColor(mAlphabetKeyLeft.getBackground(), BackgroundType.FUNCTIONAL);
|
colors.setBackgroundColor(mAlphabetKeyLeft.getBackground(), BackgroundType.FUNCTIONAL);
|
||||||
colors.setBackgroundColor(mDeleteKey.getBackground(), BackgroundType.FUNCTIONAL);
|
colors.setBackgroundColor(mDeleteKey.getBackground(), BackgroundType.FUNCTIONAL);
|
||||||
colors.setBackgroundColor(mSpacebar.getBackground(), BackgroundType.SPACE);
|
colors.setBackgroundColor(mSpacebar.getBackground(), BackgroundType.SPACE);
|
||||||
colors.setKeyboardBackground(this); // todo: color on top appears a little darker than on normal keyboard, what is wrong?
|
colors.setKeyboardBackground(this);
|
||||||
mEmojiCategoryPageIndicatorView.setColors(colors.getAccent(), colors.getAdjustedBackground());
|
mEmojiCategoryPageIndicatorView.setColors(colors.getAccent(), colors.getAdjustedBackground());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,7 @@ final public class BinaryDictionaryGetter {
|
||||||
DictionaryInfoUtils.getCategoryFromFileName(wordList.getName());
|
DictionaryInfoUtils.getCategoryFromFileName(wordList.getName());
|
||||||
final FileAndMatchLevel currentBestMatch = cacheFiles.get(category);
|
final FileAndMatchLevel currentBestMatch = cacheFiles.get(category);
|
||||||
if (null == currentBestMatch || currentBestMatch.mMatchLevel <= matchLevel) {
|
if (null == currentBestMatch || currentBestMatch.mMatchLevel <= matchLevel) {
|
||||||
// todo: not nice, related to getDictionaryFiles todo
|
// todo: not nice, related to todo in getDictionaryFiles
|
||||||
// this is so user-added main dict has priority over internal main dict
|
// this is so user-added main dict has priority over internal main dict
|
||||||
// actually any user-added dict has priority, but there aren't any other built-in types
|
// actually any user-added dict has priority, but there aren't any other built-in types
|
||||||
if (wordList.getName().endsWith(USER_DICTIONARY_SUFFIX) || currentBestMatch == null)
|
if (wordList.getName().endsWith(USER_DICTIONARY_SUFFIX) || currentBestMatch == null)
|
||||||
|
@ -206,30 +206,6 @@ final public class BinaryDictionaryGetter {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ## HACK ## we prevent usage of a dictionary before version 18. The reason for this is, since
|
|
||||||
// those do not include whitelist entries, the new code with an old version of the dictionary
|
|
||||||
// would lose whitelist functionality.
|
|
||||||
private static boolean hackCanUseDictionaryFile(final File file) {
|
|
||||||
if (!SHOULD_USE_DICT_VERSION) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Read the version of the file
|
|
||||||
final DictionaryHeader header = BinaryDictionaryUtils.getHeader(file);
|
|
||||||
final String version = header.mDictionaryOptions.mAttributes.get(VERSION_KEY);
|
|
||||||
if (null == version) {
|
|
||||||
// No version in the options : the format is unexpected
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Version 18 is the first one to include the whitelist
|
|
||||||
// Obviously this is a big ## HACK ##
|
|
||||||
return Integer.parseInt(version) >= 18;
|
|
||||||
} catch (IOException | NumberFormatException | BufferUnderflowException | UnsupportedFormatException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of file addresses for a given locale, trying relevant methods in order.
|
* Returns a list of file addresses for a given locale, trying relevant methods in order.
|
||||||
*
|
*
|
||||||
|
@ -245,7 +221,7 @@ final public class BinaryDictionaryGetter {
|
||||||
// todo: the way of using assets and cached lists should be improved, so that the assets file
|
// todo: the way of using assets and cached lists should be improved, so that the assets file
|
||||||
// doesn't need to be in cached dir just for checking whether it's a good match
|
// doesn't need to be in cached dir just for checking whether it's a good match
|
||||||
public static ArrayList<AssetFileAddress> getDictionaryFiles(final Locale locale,
|
public static ArrayList<AssetFileAddress> getDictionaryFiles(final Locale locale,
|
||||||
final Context context, boolean notifyDictionaryPackForUpdates, final boolean weakMatchAcceptable) {
|
final Context context, final boolean weakMatchAcceptable) {
|
||||||
loadDictionaryFromAssets(locale.toString(), context, weakMatchAcceptable); // will copy dict to cached word lists if not existing
|
loadDictionaryFromAssets(locale.toString(), context, weakMatchAcceptable); // will copy dict to cached word lists if not existing
|
||||||
final File[] cachedWordLists = getCachedWordLists(locale.toString(), context, weakMatchAcceptable);
|
final File[] cachedWordLists = getCachedWordLists(locale.toString(), context, weakMatchAcceptable);
|
||||||
final String mainDictId = DictionaryInfoUtils.getMainDictId(locale);
|
final String mainDictId = DictionaryInfoUtils.getMainDictId(locale);
|
||||||
|
@ -256,10 +232,7 @@ final public class BinaryDictionaryGetter {
|
||||||
// cachedWordLists may not be null, see doc for getCachedDictionaryList
|
// cachedWordLists may not be null, see doc for getCachedDictionaryList
|
||||||
for (final File f : cachedWordLists) {
|
for (final File f : cachedWordLists) {
|
||||||
final String wordListId = DictionaryInfoUtils.getWordListIdFromFileName(f.getName());
|
final String wordListId = DictionaryInfoUtils.getWordListIdFromFileName(f.getName());
|
||||||
// remove the hack that requires version 18
|
final boolean canUse = f.canRead();
|
||||||
// danger of getting an old version is rather low, and user-added dictionaries
|
|
||||||
// will usually not work as they will likely start at version 1
|
|
||||||
final boolean canUse = f.canRead(); // && hackCanUseDictionaryFile(f);
|
|
||||||
if (canUse && DictionaryInfoUtils.isMainWordListId(wordListId)) {
|
if (canUse && DictionaryInfoUtils.isMainWordListId(wordListId)) {
|
||||||
foundMainDict = true;
|
foundMainDict = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,13 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
|
||||||
|
|
||||||
// todo: these caches are never even set, as the corresponding functions are not called...
|
// todo: these caches are never even set, as the corresponding functions are not called...
|
||||||
// and even if they were set, one is only written, but never read, and the other one
|
// and even if they were set, one is only written, but never read, and the other one
|
||||||
// is only read and thus empty and useless -> why? seems they are not needed anyway
|
// is only read and thus empty and useless -> why?
|
||||||
|
// anyway, we could just set the same cache using the set functions
|
||||||
|
// but before doing this, check the potential performance gains
|
||||||
|
// i.e. how long does a "isValidWord" check take -> on S4 mini 300 µs per dict if ok, but
|
||||||
|
// sometimes it can also be a few ms
|
||||||
|
// os if the spell checker is enabled, it's definitely reasonable to cache the results
|
||||||
|
// but this needs to be done internally, as it should be by language
|
||||||
private LruCache<String, Boolean> mValidSpellingWordReadCache;
|
private LruCache<String, Boolean> mValidSpellingWordReadCache;
|
||||||
private LruCache<String, Boolean> mValidSpellingWordWriteCache;
|
private LruCache<String, Boolean> mValidSpellingWordWriteCache;
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,11 @@ public final class DictionaryFactory {
|
||||||
* @param locale the locale for which to create the dictionary
|
* @param locale the locale for which to create the dictionary
|
||||||
* @return an initialized instance of DictionaryCollection
|
* @return an initialized instance of DictionaryCollection
|
||||||
*/
|
*/
|
||||||
|
// todo: this should be adjusted
|
||||||
|
// ONE call to getDictionaryFiles
|
||||||
|
// should return AssetFileAddress and locale (and maybe match level)
|
||||||
|
// this should consider the he/iw mess-up
|
||||||
|
// only if compressed dict needs to be used it should be extracted
|
||||||
public static DictionaryCollection createMainDictionaryFromManager(final Context context,
|
public static DictionaryCollection createMainDictionaryFromManager(final Context context,
|
||||||
final Locale locale) {
|
final Locale locale) {
|
||||||
if (null == locale) {
|
if (null == locale) {
|
||||||
|
@ -55,7 +60,7 @@ public final class DictionaryFactory {
|
||||||
|
|
||||||
final LinkedList<Dictionary> dictList = new LinkedList<>();
|
final LinkedList<Dictionary> dictList = new LinkedList<>();
|
||||||
ArrayList<AssetFileAddress> assetFileList =
|
ArrayList<AssetFileAddress> assetFileList =
|
||||||
BinaryDictionaryGetter.getDictionaryFiles(locale, context, true, false);
|
BinaryDictionaryGetter.getDictionaryFiles(locale, context, false);
|
||||||
|
|
||||||
boolean mainFound = false;
|
boolean mainFound = false;
|
||||||
for (AssetFileAddress fileAddress : assetFileList) {
|
for (AssetFileAddress fileAddress : assetFileList) {
|
||||||
|
@ -65,7 +70,7 @@ public final class DictionaryFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!mainFound) // try again and allow weaker match
|
if (!mainFound) // try again and allow weaker match
|
||||||
assetFileList = BinaryDictionaryGetter.getDictionaryFiles(locale, context, true, true);
|
assetFileList = BinaryDictionaryGetter.getDictionaryFiles(locale, context, true);
|
||||||
|
|
||||||
for (final AssetFileAddress f : assetFileList) {
|
for (final AssetFileAddress f : assetFileList) {
|
||||||
final ReadOnlyBinaryDictionary readOnlyBinaryDictionary =
|
final ReadOnlyBinaryDictionary readOnlyBinaryDictionary =
|
||||||
|
|
|
@ -116,7 +116,7 @@ public class RichInputMethodManager {
|
||||||
public @Nullable InputMethodSubtype getNextSubtypeInThisIme(final boolean onlyCurrentIme) {
|
public @Nullable InputMethodSubtype getNextSubtypeInThisIme(final boolean onlyCurrentIme) {
|
||||||
final InputMethodSubtype currentSubtype = getCurrentSubtype().getRawSubtype();
|
final InputMethodSubtype currentSubtype = getCurrentSubtype().getRawSubtype();
|
||||||
final List<InputMethodSubtype> enabledSubtypes = getMyEnabledInputMethodSubtypeList(true);
|
final List<InputMethodSubtype> enabledSubtypes = getMyEnabledInputMethodSubtypeList(true);
|
||||||
final int currentIndex = getSubtypeIndexInList(currentSubtype, enabledSubtypes);
|
final int currentIndex = enabledSubtypes.indexOf(currentSubtype);
|
||||||
if (currentIndex == INDEX_NOT_FOUND) {
|
if (currentIndex == INDEX_NOT_FOUND) {
|
||||||
Log.w(TAG, "Can't find current subtype in enabled subtypes: subtype="
|
Log.w(TAG, "Can't find current subtype in enabled subtypes: subtype="
|
||||||
+ SubtypeLocaleUtils.getSubtypeNameForLogging(currentSubtype));
|
+ SubtypeLocaleUtils.getSubtypeNameForLogging(currentSubtype));
|
||||||
|
@ -195,38 +195,17 @@ public class RichInputMethodManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkIfSubtypeBelongsToThisImeAndEnabled(final InputMethodSubtype subtype) {
|
public boolean checkIfSubtypeBelongsToThisImeAndEnabled(final InputMethodSubtype subtype) {
|
||||||
return checkIfSubtypeBelongsToList(subtype,
|
return getEnabledInputMethodSubtypeList(getInputMethodInfoOfThisIme(), true)
|
||||||
getEnabledInputMethodSubtypeList(
|
.contains(subtype);
|
||||||
getInputMethodInfoOfThisIme(),
|
|
||||||
true /* allowsImplicitlySelectedSubtypes */));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkIfSubtypeBelongsToThisImeAndImplicitlyEnabled(
|
public boolean checkIfSubtypeBelongsToThisImeAndImplicitlyEnabled(final InputMethodSubtype subtype) {
|
||||||
final InputMethodSubtype subtype) {
|
|
||||||
final boolean subtypeEnabled = checkIfSubtypeBelongsToThisImeAndEnabled(subtype);
|
final boolean subtypeEnabled = checkIfSubtypeBelongsToThisImeAndEnabled(subtype);
|
||||||
final boolean subtypeExplicitlyEnabled = checkIfSubtypeBelongsToList(subtype,
|
final boolean subtypeExplicitlyEnabled = getMyEnabledInputMethodSubtypeList(false)
|
||||||
getMyEnabledInputMethodSubtypeList(false /* allowsImplicitlySelectedSubtypes */));
|
.contains(subtype);
|
||||||
return subtypeEnabled && !subtypeExplicitlyEnabled;
|
return subtypeEnabled && !subtypeExplicitlyEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean checkIfSubtypeBelongsToList(final InputMethodSubtype subtype,
|
|
||||||
final List<InputMethodSubtype> subtypes) {
|
|
||||||
return getSubtypeIndexInList(subtype, subtypes) != INDEX_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int getSubtypeIndexInList(final InputMethodSubtype subtype,
|
|
||||||
final List<InputMethodSubtype> subtypes) {
|
|
||||||
// todo: why not simply subtypes.indexOf(subtype)? should do exactly the same, even return the same value -1 if not found
|
|
||||||
final int count = subtypes.size();
|
|
||||||
for (int index = 0; index < count; index++) {
|
|
||||||
final InputMethodSubtype ims = subtypes.get(index);
|
|
||||||
if (ims.equals(subtype)) {
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return INDEX_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onSubtypeChanged(@NonNull final InputMethodSubtype newSubtype) {
|
public void onSubtypeChanged(@NonNull final InputMethodSubtype newSubtype) {
|
||||||
updateCurrentSubtype(newSubtype);
|
updateCurrentSubtype(newSubtype);
|
||||||
updateShortcutIme();
|
updateShortcutIme();
|
||||||
|
|
|
@ -39,10 +39,6 @@ class Colors (
|
||||||
// todo (later): evaluate which colors, colorFilters and colorStateLists are actually necessary
|
// 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
|
// also, ideally the color filters would be private and chosen internally depending on type
|
||||||
val backgroundFilter: ColorFilter
|
val backgroundFilter: ColorFilter
|
||||||
// workaround for error in ClipboardHistoryRecyclerView
|
|
||||||
// java.lang.IllegalAccessError: Field 'org.dslul.openboard.inputmethod.latin.common.Colors.backgroundFilter' is inaccessible to class 'org.dslul.openboard.inputmethod.keyboard.clipboard.ClipboardHistoryRecyclerView$BottomDividerItemDecoration'
|
|
||||||
// this should not happen, maybe it's a bug in kotlin? because it also doesn't recognize if the filter is accessed there, and wants to set it private
|
|
||||||
fun getThatBackgroundFilter() = backgroundFilter
|
|
||||||
val adjustedBackgroundFilter: ColorFilter
|
val adjustedBackgroundFilter: ColorFilter
|
||||||
val keyBackgroundFilter: ColorFilter
|
val keyBackgroundFilter: ColorFilter
|
||||||
val functionalKeyBackgroundFilter: ColorFilter
|
val functionalKeyBackgroundFilter: ColorFilter
|
||||||
|
|
|
@ -62,14 +62,6 @@ public class DictionaryInfoUtils {
|
||||||
private static final int MAX_HEX_DIGITS_FOR_CODEPOINT = 6;
|
private static final int MAX_HEX_DIGITS_FOR_CODEPOINT = 6;
|
||||||
|
|
||||||
public static class DictionaryInfo {
|
public static class DictionaryInfo {
|
||||||
private static final String LOCALE_COLUMN = "locale";
|
|
||||||
private static final String WORDLISTID_COLUMN = "id";
|
|
||||||
private static final String LOCAL_FILENAME_COLUMN = "filename";
|
|
||||||
private static final String DESCRIPTION_COLUMN = "description";
|
|
||||||
private static final String DATE_COLUMN = "date";
|
|
||||||
private static final String FILESIZE_COLUMN = "filesize";
|
|
||||||
private static final String VERSION_COLUMN = "version";
|
|
||||||
|
|
||||||
@NonNull public final String mId;
|
@NonNull public final String mId;
|
||||||
@NonNull public final Locale mLocale;
|
@NonNull public final Locale mLocale;
|
||||||
@Nullable public final String mDescription;
|
@Nullable public final String mDescription;
|
||||||
|
@ -90,18 +82,6 @@ public class DictionaryInfoUtils {
|
||||||
mVersion = version;
|
mVersion = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContentValues toContentValues() {
|
|
||||||
final ContentValues values = new ContentValues();
|
|
||||||
values.put(WORDLISTID_COLUMN, mId);
|
|
||||||
values.put(LOCALE_COLUMN, mLocale.toString());
|
|
||||||
values.put(DESCRIPTION_COLUMN, mDescription);
|
|
||||||
values.put(LOCAL_FILENAME_COLUMN, mFilename != null ? mFilename : "");
|
|
||||||
values.put(DATE_COLUMN, TimeUnit.MILLISECONDS.toSeconds(mModifiedTimeMillis));
|
|
||||||
values.put(FILESIZE_COLUMN, mFilesize);
|
|
||||||
values.put(VERSION_COLUMN, mVersion);
|
|
||||||
return values;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DictionaryInfo : Id = '" + mId
|
return "DictionaryInfo : Id = '" + mId
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
|
<color name="foreground">#FFF</color>
|
||||||
<color name="foreground_weak">#BBB</color>
|
<color name="foreground_weak">#BBB</color>
|
||||||
<color name="almost_background">#666</color>
|
<color name="almost_background">#666</color>
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@
|
||||||
<color name="setup_welcome_video_margin_color">#FFCCCCCC</color>
|
<color name="setup_welcome_video_margin_color">#FFCCCCCC</color>
|
||||||
|
|
||||||
<!-- Colors that are different for night theme -->
|
<!-- Colors that are different for night theme -->
|
||||||
<color name="foreground">?android:colorForeground</color>
|
<color name="foreground">#000</color>
|
||||||
<color name="foreground_weak">#555</color>
|
<color name="foreground_weak">#555</color>
|
||||||
<color name="almost_background">#AAA</color>
|
<color name="almost_background">#AAA</color>
|
||||||
<color name="highlight_color_lxx_light">#1A73E8</color> <!-- todo: remove / replace with accent? -->
|
<color name="highlight_color_lxx_light">#1A73E8</color> <!-- todo: remove / replace with accent? -->
|
||||||
|
|
Loading…
Add table
Reference in a new issue