work off some "todo"s, mostly related to colors

make threshold score for autocorrect depedent on autocorrect threshold
This commit is contained in:
Helium314 2023-09-10 19:45:03 +02:00
parent eebaa2881b
commit bc9150b007
17 changed files with 75 additions and 140 deletions

View file

@ -150,8 +150,8 @@ public class KeyboardView extends View {
mKeyBackground.getPadding(mKeyBackgroundPadding);
mFunctionalKeyBackground = mColors.getDrawable(BackgroundType.FUNCTIONAL, keyboardViewAttr);
mSpacebarBackground = mColors.getDrawable(BackgroundType.SPACE, keyboardViewAttr);
if (this instanceof MoreKeysKeyboardView && mColors.getThemeStyle().equals(KeyboardTheme.THEME_STYLE_HOLO)) // todo: this logic should be in Colors
mActionKeyBackground = mColors.getDrawable(BackgroundType.ADJUSTED_BACKGROUND, keyboardViewAttr);
if (this instanceof MoreKeysKeyboardView)
mActionKeyBackground = mColors.getDrawable(BackgroundType.ACTION_MORE_KEYS, keyboardViewAttr);
else
mActionKeyBackground = mColors.getDrawable(BackgroundType.ACTION, keyboardViewAttr);
@ -598,11 +598,10 @@ public class KeyboardView extends View {
}
private void setKeyIconColor(Key key, Drawable icon, Keyboard keyboard) {
if (key.isAccentColored() && !(mColors.getThemeStyle().equals(KeyboardTheme.THEME_STYLE_HOLO))) { // todo: this logic should not be here
if (key.isAccentColored()) {
icon.setColorFilter(mColors.getActionKeyIconColorFilter());
} else if (key.isShift() && keyboard != null) {
// todo (idea): replace shift icon with white one and use the normal multiply filters
// this could allow different shift icon with nicer coloring
// todo: switch to multiply after changing keyboard symbols to white icons
if (keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED
|| keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED
|| keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED

View file

@ -164,7 +164,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
// Gesture floating preview text
// TODO: Make this parameter customizable by user via settings.
private int mGestureFloatingPreviewTextLingerTimeout;
private final int mGestureFloatingPreviewTextLingerTimeout;
private final KeyDetector mKeyDetector;
private final NonDistinctMultitouchHelper mNonDistinctMultitouchHelper;
@ -218,10 +218,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
mLanguageOnSpacebarTextRatio = mainKeyboardViewAttr.getFraction(
R.styleable.MainKeyboardView_languageOnSpacebarTextRatio, 1, 1, 1.0f);
final Colors colors = Settings.getInstance().getCurrent().mColors;
if (colors.getThemeStyle().equals(KeyboardTheme.THEME_STYLE_HOLO)) // todo: this logic should be in Colors
mLanguageOnSpacebarTextColor = colors.getKeyText();
else
mLanguageOnSpacebarTextColor = colors.getKeyHintText(); //mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_languageOnSpacebarTextColor, 0);
mLanguageOnSpacebarTextColor = colors.getSpaceBarText(); //mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_languageOnSpacebarTextColor, 0);
mLanguageOnSpacebarTextShadowRadius = mainKeyboardViewAttr.getFloat(
R.styleable.MainKeyboardView_languageOnSpacebarTextShadowRadius,
LANGUAGE_ON_SPACEBAR_TEXT_SHADOW_RADIUS_DISABLED);
@ -541,9 +538,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
public void showGestureFloatingPreviewText(@NonNull final SuggestedWords suggestedWords,
final boolean dismissDelayed) {
locatePreviewPlacerView();
final GestureFloatingTextDrawingPreview gestureFloatingTextDrawingPreview =
mGestureFloatingTextDrawingPreview;
gestureFloatingTextDrawingPreview.setSuggestedWords(suggestedWords);
mGestureFloatingTextDrawingPreview.setSuggestedWords(suggestedWords);
if (dismissDelayed) {
mTimerHandler.postDismissGestureFloatingPreviewText(
mGestureFloatingPreviewTextLingerTimeout);
@ -919,7 +914,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
// Draw language text with shadow
final float descent = paint.descent();
final float textHeight = -paint.ascent() + descent;
final float baseline = height / 2 + textHeight / 2;
final float baseline = height / 2f + textHeight / 2;
if (mLanguageOnSpacebarTextShadowRadius > 0.0f) {
paint.setShadowLayer(mLanguageOnSpacebarTextShadowRadius, 0, 0,
mLanguageOnSpacebarTextShadowColor);
@ -928,7 +923,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
}
paint.setColor(mLanguageOnSpacebarTextColor);
paint.setAlpha(mLanguageOnSpacebarAnimAlpha);
canvas.drawText(language, width / 2, baseline - descent, paint);
canvas.drawText(language, width / 2f, baseline - descent, paint);
paint.clearShadowLayer();
paint.setTextScaleX(1.0f);
}

View file

@ -9,7 +9,6 @@ import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme
import org.dslul.openboard.inputmethod.latin.ClipboardHistoryEntry
import org.dslul.openboard.inputmethod.latin.ClipboardHistoryManager
import org.dslul.openboard.inputmethod.latin.R
@ -69,8 +68,7 @@ class ClipboardAdapter(
}
clipboardLayoutParams.setItemProperties(view)
val colors = Settings.getInstance().current.mColors
if (colors.themeStyle == KeyboardTheme.THEME_STYLE_HOLO) // todo: this logic should be in Colors, not here
pinnedIconView.colorFilter = colors.accentColorFilter
pinnedIconView.colorFilter = colors.clipboardPinFilter
}
fun setContent(historyEntry: ClipboardHistoryEntry?) {

View file

@ -1,12 +1,9 @@
package org.dslul.openboard.inputmethod.keyboard.clipboard
import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.util.AttributeSet
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import org.dslul.openboard.inputmethod.latin.settings.Settings
class ClipboardHistoryRecyclerView @JvmOverloads constructor(
context: Context,
@ -56,25 +53,4 @@ class ClipboardHistoryRecyclerView @JvmOverloads constructor(
adapter?.registerAdapterDataObserver(adapterDataObserver)
}
class BottomDividerItemDecoration(dividerHeight: Int, dividerColor: Int) : RecyclerView.ItemDecoration() {
private val paint = Paint()
init {
paint.color = dividerColor
paint.strokeWidth = dividerHeight.toFloat()
paint.colorFilter = Settings.getInstance().current.mColors.getThatBackgroundFilter()
}
override fun onDrawOver(canvas: Canvas, parent: RecyclerView, state: State) {
super.onDrawOver(canvas, parent, state)
canvas.drawLine(parent.paddingLeft.toFloat(),
parent.height - paint.strokeWidth / 2,
parent.width.toFloat() - parent.paddingRight.toFloat(),
parent.height - paint.strokeWidth / 2 ,
paint
)
}
}
}

View file

@ -1,7 +1,6 @@
package org.dslul.openboard.inputmethod.keyboard.clipboard
import android.content.Context
import android.graphics.Color
import android.util.AttributeSet
import android.util.TypedValue
import android.view.MotionEvent
@ -31,7 +30,6 @@ class ClipboardHistoryView @JvmOverloads constructor(
private val clipboardLayoutParams = ClipboardLayoutParams(context.resources)
private val pinIconId: Int
private val dividerColor: Int
private val functionalKeyBackgroundId: Int
private val keyBackgroundId: Int
@ -47,15 +45,10 @@ class ClipboardHistoryView @JvmOverloads constructor(
init {
val clipboardViewAttr = context.obtainStyledAttributes(attrs,
R.styleable.ClipboardHistoryView, defStyle, R.style.ClipboardHistoryView)
pinIconId = clipboardViewAttr.getResourceId(
R.styleable.ClipboardHistoryView_iconPinnedClip, 0)
// todo: remove the divider completely?
dividerColor = Color.TRANSPARENT //clipboardViewAttr.getColor(R.styleable.ClipboardHistoryView_dividerBackground, 0)
pinIconId = clipboardViewAttr.getResourceId(R.styleable.ClipboardHistoryView_iconPinnedClip, 0)
clipboardViewAttr.recycle()
val keyboardViewAttr = context.obtainStyledAttributes(attrs,
R.styleable.KeyboardView, defStyle, R.style.KeyboardView)
keyBackgroundId = keyboardViewAttr.getResourceId(
R.styleable.KeyboardView_keyBackground, 0)
val keyboardViewAttr = context.obtainStyledAttributes(attrs, R.styleable.KeyboardView, defStyle, R.style.KeyboardView)
keyBackgroundId = keyboardViewAttr.getResourceId(R.styleable.KeyboardView_keyBackground, 0)
functionalKeyBackgroundId = keyboardViewAttr.getResourceId(
R.styleable.KeyboardView_functionalKeyBackground, keyBackgroundId)
keyboardViewAttr.recycle()
@ -65,8 +58,7 @@ class ClipboardHistoryView @JvmOverloads constructor(
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
val res = context.resources
// The main keyboard expands to the entire this {@link KeyboardView}.
val width = (ResourceUtils.getDefaultKeyboardWidth(res)
+ paddingLeft + paddingRight)
val width = (ResourceUtils.getDefaultKeyboardWidth(res) + paddingLeft + paddingRight)
val height = (ResourceUtils.getDefaultKeyboardHeight(res)
+ res.getDimensionPixelSize(R.dimen.config_suggestions_strip_height)
+ paddingTop + paddingBottom)
@ -85,9 +77,7 @@ class ClipboardHistoryView @JvmOverloads constructor(
clipboardRecyclerView = findViewById<ClipboardHistoryRecyclerView>(R.id.clipboard_list).apply {
val colCount = resources.getInteger(R.integer.config_clipboard_keyboard_col_count)
layoutManager = StaggeredGridLayoutManager(colCount, StaggeredGridLayoutManager.VERTICAL)
val dividerHeight = resources.getDimensionPixelSize(R.dimen.config_clipboard_divider_height)
addItemDecoration(ClipboardHistoryRecyclerView.BottomDividerItemDecoration(dividerHeight, dividerColor))
@Suppress("deprecation") // no cache should be fine according to warning in https://developer.android.com/reference/android/view/ViewGroup#setPersistentDrawingCache(int)
@Suppress("deprecation") // "no cache" should be fine according to warning in https://developer.android.com/reference/android/view/ViewGroup#setPersistentDrawingCache(int)
persistentDrawingCache = PERSISTENT_NO_CACHE
clipboardLayoutParams.setListProperties(this)
placeholderView = this@ClipboardHistoryView.placeholderView

View file

@ -211,7 +211,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
final RestartAfterDeviceUnlockReceiver mRestartAfterDeviceUnlockReceiver = new RestartAfterDeviceUnlockReceiver();
private AlertDialog mOptionsDialog; // todo: this is always null -> remove?
private AlertDialog mOptionsDialog;
private final boolean mIsHardwareAcceleratedDrawingEnabled;
@ -1419,8 +1419,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (isShowingOptionDialog()) return false;
if (requestCode == Constants.CUSTOM_CODE_SHOW_INPUT_METHOD_PICKER) {
if (mRichImm.hasMultipleEnabledIMEsOrSubtypes(true /* include aux subtypes */)) {
InputMethodPickerKt.showInputMethodPicker(this, mRichImm, mKeyboardSwitcher.getMainKeyboardView().getWindowToken());
return true; // todo: don't show and return if dialog already shown? but how can this happen?
mOptionsDialog = InputMethodPickerKt.createInputMethodPickerDialog(this, mRichImm, mKeyboardSwitcher.getMainKeyboardView().getWindowToken());
mOptionsDialog.show();
return true;
}
return false;
}

View file

@ -35,11 +35,9 @@ import org.dslul.openboard.inputmethod.latin.utils.SubtypeLocaleUtils;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import static org.dslul.openboard.inputmethod.latin.common.Constants.Subtype.KEYBOARD_MODE;
@ -392,38 +390,13 @@ public class RichInputMethodManager {
updateShortcutIme();
}
// todo: remove?
public boolean isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes() {
final Locale systemLocale = mContext.getResources().getConfiguration().locale;
final Set<InputMethodSubtype> enabledSubtypesOfEnabledImes = new HashSet<>();
final InputMethodManager inputMethodManager = getInputMethodManager();
final List<InputMethodInfo> enabledInputMethodInfoList =
inputMethodManager.getEnabledInputMethodList();
for (final InputMethodInfo info : enabledInputMethodInfoList) {
final List<InputMethodSubtype> enabledSubtypes =
inputMethodManager.getEnabledInputMethodSubtypeList(
info, true /* allowsImplicitlySelectedSubtypes */);
if (enabledSubtypes.isEmpty()) {
// An IME with no subtypes is found.
return false;
}
enabledSubtypesOfEnabledImes.addAll(enabledSubtypes);
}
for (final InputMethodSubtype subtype : enabledSubtypesOfEnabledImes) {
if (!subtype.isAuxiliary() && !subtype.getLocale().isEmpty()
&& !systemLocale.equals(SubtypeLocaleUtils.getSubtypeLocale(subtype))) {
return false;
}
}
return true;
}
private void updateCurrentSubtype(final InputMethodSubtype subtype) {
SubtypeSettingsKt.setSelectedSubtype(DeviceProtectedUtils.getSharedPreferences(mContext), subtype);
mCurrentRichInputMethodSubtype = RichInputMethodSubtype.getRichInputMethodSubtype(subtype);
}
// todo: what is shortcutIme? the voice input? if yes, rename it and other things like mHasShortcutKey
// todo: is shortcutIme only voice input, or can it be something else?
// if always voice input, rename it and other things like mHasShortcutKey
private void updateShortcutIme() {
if (DEBUG) {
Log.d(TAG, "Update shortcut IME from : "
@ -495,12 +468,6 @@ public class RichInputMethodManager {
}
public boolean isShortcutImeReady() {
if (mShortcutInputMethodInfo == null) {
return false;
}
if (mShortcutSubtype == null) {
return true;
}
return true;
return mShortcutInputMethodInfo != null;
}
}

View file

@ -26,6 +26,7 @@ import org.dslul.openboard.inputmethod.latin.common.Constants;
import org.dslul.openboard.inputmethod.latin.common.InputPointers;
import org.dslul.openboard.inputmethod.latin.common.StringUtils;
import org.dslul.openboard.inputmethod.latin.define.DebugFlags;
import org.dslul.openboard.inputmethod.latin.settings.Settings;
import org.dslul.openboard.inputmethod.latin.settings.SettingsValuesForSuggestion;
import org.dslul.openboard.inputmethod.latin.utils.AutoCorrectionUtils;
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
@ -306,9 +307,6 @@ public final class Suggest {
final int firstOccurrenceOfTypedWordInSuggestions,
final SuggestedWordInfo typedWordFirstOccurrenceWordInfo
) {
// todo:
// tune the suggestion score thresholds (currently 900k, maybe should depend on autocorrect)
// maybe tune the empty word suggestion min difference (currently 20, seems quite ok)
final String consideredWord = trailingSingleQuotesCount > 0
? typedWordString.substring(0, typedWordString.length() - trailingSingleQuotesCount)
: typedWordString;
@ -322,6 +320,7 @@ public final class Suggest {
// We allow auto-correction if whitelisting is not required or the word is whitelisted,
// or if the word had more than one char and was not suggested.
final boolean allowsToBeAutoCorrected;
final int scoreLimit = Settings.getInstance().getCurrent().mScoreLimitForAutocorrect;
if ((SHOULD_AUTO_CORRECT_USING_NON_WHITE_LISTED_SUGGESTION || whitelistedWord != null)
|| (consideredWord.length() > 1 && (sourceDictionaryOfRemovedWord == null)) // more than 1 letter and not in dictionary
) {
@ -331,7 +330,7 @@ public final class Suggest {
putEmptyWordSuggestions.run();
final SuggestedWordInfo first = firstAndTypedWordEmptyInfos.get(0);
final SuggestedWordInfo typed = firstAndTypedWordEmptyInfos.get(1);
if (firstSuggestionInContainer.mScore > 900000) {
if (firstSuggestionInContainer.mScore > scoreLimit) {
allowsToBeAutoCorrected = true; // suggestion has good score, allow
} else if (first == null) {
allowsToBeAutoCorrected = false; // no autocorrect if first suggestion unknown in this context
@ -396,23 +395,21 @@ public final class Suggest {
// is determined, see #isAllowedByAutoCorrectionWithSpaceFilter.
// TODO: this should not have its own logic here but be handled by the dictionary.
final boolean allowed = isAllowedByAutoCorrectionWithSpaceFilter(firstSuggestion);
if (allowed && typedWordFirstOccurrenceWordInfo != null && typedWordFirstOccurrenceWordInfo.mScore > 900000) {
if (allowed && typedWordFirstOccurrenceWordInfo != null && typedWordFirstOccurrenceWordInfo.mScore > scoreLimit) {
// typed word is valid and has good score
// do not auto-correct if typed word is better match than first suggestion
final SuggestedWordInfo first = firstSuggestionInContainer != null ? firstSuggestionInContainer : firstSuggestion;
final Locale dictLocale = dictionaryFacilitator.getCurrentLocale();
if (first.mScore < 900000) {
if (first.mScore < scoreLimit) {
// don't allow if suggestion has too low score
// todo: maybe lower this to ~600k? 500k will be too aggressive
// or make it depend on autocorrect threshold
return new boolean[]{ true, false };
}
if (first.mSourceDict.mLocale != typedWordFirstOccurrenceWordInfo.mSourceDict.mLocale) {
// dict locale different -> return the better match
return new boolean[]{ true, dictLocale == first.mSourceDict.mLocale };
}
// todo: this may need tuning, especially the score difference thing
// the score difference may need tuning, but so far it seems alright
final int firstWordBonusScore = (first.isKindOf(SuggestedWordInfo.KIND_WHITELIST) ? 20 : 0) // large bonus because it's wanted by dictionary
+ (StringUtils.isLowerCaseAscii(typedWordString) ? 5 : 0) // small bonus because typically only ascii is typed (applies to latin keyboards only)
+ (first.mScore > typedWordFirstOccurrenceWordInfo.mScore ? 5 : 0); // small bonus if score is higher

View file

@ -11,7 +11,8 @@ import android.view.View
import androidx.core.graphics.BlendModeColorFilterCompat
import androidx.core.graphics.BlendModeCompat
import androidx.core.graphics.drawable.DrawableCompat
import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme
import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme.THEME_STYLE_HOLO
import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme.THEME_STYLE_MATERIAL
import org.dslul.openboard.inputmethod.keyboard.MoreKeysKeyboardView
import org.dslul.openboard.inputmethod.keyboard.emoji.EmojiPageKeyboardView
import org.dslul.openboard.inputmethod.latin.R
@ -33,6 +34,7 @@ class Colors (
val navBar: Int
val adjustedBackground: Int
val adjustedKeyText: 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
@ -48,6 +50,7 @@ class Colors (
val keyTextFilter: ColorFilter
val accentColorFilter: ColorFilter
val actionKeyIconColorFilter: ColorFilter?
val clipboardPinFilter: ColorFilter?
private val backgroundStateList: ColorStateList
private val keyStateList: ColorStateList
@ -59,13 +62,18 @@ class Colors (
val keyboardBackground: Drawable?
init {
if (themeStyle == KeyboardTheme.THEME_STYLE_HOLO) {
accentColorFilter = colorFilter(accent)
if (themeStyle == THEME_STYLE_HOLO) {
val darkerBackground = adjustLuminosityAndKeepAlpha(background, -0.2f)
navBar = darkerBackground
keyboardBackground = GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, intArrayOf(background, darkerBackground))
spaceBarText = keyText
clipboardPinFilter = accentColorFilter
} else {
navBar = background
keyboardBackground = null
spaceBarText = keyHintText
clipboardPinFilter = null
}
// create color filters, todo: maybe better / simplify
@ -92,12 +100,12 @@ class Colors (
functionalKeyBackgroundFilter = colorFilter(functionalKey)
spaceBarFilter = colorFilter(spaceBar)
backgroundStateList = stateList(brightenOrDarken(background, true), background)
keyStateList = if (themeStyle == KeyboardTheme.THEME_STYLE_HOLO) stateList(keyBackground, keyBackground)
keyStateList = if (themeStyle == THEME_STYLE_HOLO) stateList(keyBackground, keyBackground)
else stateList(brightenOrDarken(keyBackground, true), keyBackground)
functionalKeyStateList = stateList(brightenOrDarken(functionalKey, true), functionalKey)
actionKeyStateList = if (themeStyle == KeyboardTheme.THEME_STYLE_HOLO) functionalKeyStateList
actionKeyStateList = if (themeStyle == THEME_STYLE_HOLO) functionalKeyStateList
else stateList(brightenOrDarken(accent, true), accent)
spaceBarStateList = if (themeStyle == KeyboardTheme.THEME_STYLE_HOLO) stateList(spaceBar, spaceBar)
spaceBarStateList = if (themeStyle == THEME_STYLE_HOLO) stateList(spaceBar, spaceBar)
else stateList(brightenOrDarken(spaceBar, true), spaceBar)
} else {
// need to set color to background if key borders are disabled, or there will be ugly keys
@ -107,16 +115,17 @@ class Colors (
backgroundStateList = stateList(brightenOrDarken(background, true), background)
keyStateList = backgroundStateList
functionalKeyStateList = backgroundStateList
actionKeyStateList = if (themeStyle == KeyboardTheme.THEME_STYLE_HOLO) functionalKeyStateList
actionKeyStateList = if (themeStyle == THEME_STYLE_HOLO) functionalKeyStateList
else stateList(brightenOrDarken(accent, true), accent)
spaceBarStateList = stateList(brightenOrDarken(spaceBar, true), spaceBar)
}
keyTextFilter = colorFilter(keyText, BlendModeCompat.SRC_ATOP)
accentColorFilter = colorFilter(accent)
actionKeyIconColorFilter =
if (isBrightColor(accent)) // the white icon may not have enough contrast, and can't be adjusted by the user
colorFilter(Color.DKGRAY, BlendModeCompat.SRC_ATOP)
else null
actionKeyIconColorFilter = when {
themeStyle == THEME_STYLE_HOLO -> keyTextFilter
// the white icon may not have enough contrast, and can't be adjusted by the user
isBrightColor(accent) -> colorFilter(Color.DKGRAY, BlendModeCompat.SRC_ATOP)
else -> null
}
}
/** set background colors including state list to the drawable */
@ -128,9 +137,12 @@ class Colors (
BackgroundType.ACTION -> actionKeyStateList
BackgroundType.SPACE -> spaceBarStateList
BackgroundType.ADJUSTED_BACKGROUND -> adjustedBackgroundStateList
BackgroundType.SUGGESTION -> if (!hasKeyBorders && themeStyle == KeyboardTheme.THEME_STYLE_MATERIAL)
BackgroundType.SUGGESTION -> if (!hasKeyBorders && themeStyle == THEME_STYLE_MATERIAL)
adjustedBackgroundStateList
else backgroundStateList
BackgroundType.ACTION_MORE_KEYS -> if (themeStyle == THEME_STYLE_HOLO)
adjustedBackgroundStateList
else actionKeyStateList
}
DrawableCompat.setTintMode(background, PorterDuff.Mode.MULTIPLY)
DrawableCompat.setTintList(background, colorStateList)
@ -142,14 +154,18 @@ class Colors (
fun getDrawable(type: BackgroundType, attr: TypedArray): Drawable {
val drawable = when (type) {
BackgroundType.KEY, BackgroundType.ADJUSTED_BACKGROUND, BackgroundType.BACKGROUND, BackgroundType.SUGGESTION ->
attr.getDrawable(R.styleable.KeyboardView_keyBackground)?.mutate()
BackgroundType.FUNCTIONAL -> attr.getDrawable(R.styleable.KeyboardView_functionalKeyBackground)?.mutate()
BackgroundType.SPACE -> attr.getDrawable(R.styleable.KeyboardView_spacebarBackground)?.mutate()
BackgroundType.ACTION -> if (themeStyle == KeyboardTheme.THEME_STYLE_HOLO && hasKeyBorders) // no borders has a very small pressed drawable otherwise
attr.getDrawable(R.styleable.KeyboardView_functionalKeyBackground)?.mutate()
else attr.getDrawable(R.styleable.KeyboardView_keyBackground)?.mutate()
} ?: attr.getDrawable(R.styleable.KeyboardView_keyBackground)?.mutate()!! // keyBackground always exists
BackgroundType.KEY, BackgroundType.ADJUSTED_BACKGROUND, BackgroundType.BACKGROUND,
BackgroundType.SUGGESTION, BackgroundType.ACTION_MORE_KEYS ->
attr.getDrawable(R.styleable.KeyboardView_keyBackground)
BackgroundType.FUNCTIONAL -> attr.getDrawable(R.styleable.KeyboardView_functionalKeyBackground)
BackgroundType.SPACE -> attr.getDrawable(R.styleable.KeyboardView_spacebarBackground)
BackgroundType.ACTION -> {
if (themeStyle == THEME_STYLE_HOLO && hasKeyBorders) // no borders has a very small pressed drawable otherwise
attr.getDrawable(R.styleable.KeyboardView_functionalKeyBackground)
else
attr.getDrawable(R.styleable.KeyboardView_keyBackground)
}
}?.mutate() ?: attr.getDrawable(R.styleable.KeyboardView_keyBackground)?.mutate()!! // keyBackground always exists
setBackgroundColor(drawable, type)
return drawable
@ -169,5 +185,5 @@ class Colors (
}
enum class BackgroundType {
BACKGROUND, KEY, FUNCTIONAL, ACTION, SPACE, ADJUSTED_BACKGROUND, SUGGESTION
BACKGROUND, KEY, FUNCTIONAL, ACTION, ACTION_MORE_KEYS, SPACE, ADJUSTED_BACKGROUND, SUGGESTION
}

View file

@ -81,12 +81,11 @@ class LanguageFakeSettingsFragment : Fragment(R.layout.language_fake_settings) {
sortedSubtypes.clear()
// list of all subtypes, any subtype added to sortedSubtypes will be removed to avoid duplicates
val allSubtypes = getAllAvailableSubtypes().toMutableList()
// maybe make use of the map used by SubtypeSettings for performance reasons?
// todo: re-write this, it's hard to understand
// also consider that more _ZZ languages might be added
fun List<Locale>.sortedAddToSubtypesAndRemoveFromAllSubtypes() {
val subtypesToAdd = mutableListOf<SubtypeInfo>()
forEach { locale ->
// this could be rather slow with looping multiple times over all ~100 subtypes,
// but usually there aren't many locales to be checked, and usually the first loop already finds a match
val localeString = locale.toString()
val iterator = allSubtypes.iterator()
var added = false
@ -112,8 +111,6 @@ class LanguageFakeSettingsFragment : Fragment(R.layout.language_fake_settings) {
}
}
// special treatment for the known languages with _ZZ types
// todo: later: make it a bit less weird... and probably faster
// consider that more _ZZ languages might be added
if (!added && (locale.language == "sr" || locale.language == "hi")) {
val languageString = locale.language
val iter = allSubtypes.iterator()

View file

@ -94,9 +94,9 @@ public final class SettingsFragment extends PreferenceFragmentCompat {
}
}
// todo: got a crash because it wasn't initialized...
// but sometimes wrong languages are returned when not initializing on creation of LatinIME
// maybe wait until some user actually encounters this bug, initializing here is really rare
// sometimes wrong languages are returned when not initializing on creation of LatinIME
// this might be a bug, at least it's not documented
// but anyway, here is really rare (LatinIme should be loaded when the settings are opened)
SubtypeSettingsKt.init(getActivity());
findPreference("screen_languages").setSummary(getEnabledSubtypesLabel());

View file

@ -120,6 +120,7 @@ public class SettingsValues {
public final float mKeypressSoundVolume;
private final boolean mAutoCorrectEnabled;
public final float mAutoCorrectionThreshold;
public final int mScoreLimitForAutocorrect;
public final float mPlausibilityThreshold;
public final boolean mAutoCorrectionEnabledPerUserSettings;
private final boolean mSuggestionsEnabledPerUserSettings;
@ -179,6 +180,8 @@ public class SettingsValues {
mAutoCorrectionThreshold = mAutoCorrectEnabled
? readAutoCorrectionThreshold(res, prefs)
: AUTO_CORRECTION_DISABLED_THRESHOLD;
mScoreLimitForAutocorrect = (mAutoCorrectionThreshold < 0) ? 600000 // very aggressive
: (mAutoCorrectionThreshold < 0.07 ? 800000 : 950000); // aggressive or modest
mBigramPredictionEnabled = readBigramPredictionEnabled(prefs, res);
mDoubleSpacePeriodTimeout = res.getInteger(R.integer.config_double_space_period_timeout);
mHasHardwareKeyboard = Settings.readHasHardwareKeyboard(res.getConfiguration());

View file

@ -14,7 +14,7 @@ import org.dslul.openboard.inputmethod.latin.R
import org.dslul.openboard.inputmethod.latin.RichInputMethodManager
// similar to what showSubtypePicker does in https://github.com/rkkr/simple-keyboard/blob/master/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/RichInputMethodManager.java
fun showInputMethodPicker(latinIme: LatinIME, richImm: RichInputMethodManager, windowToken: IBinder) {
fun createInputMethodPickerDialog(latinIme: LatinIME, richImm: RichInputMethodManager, windowToken: IBinder): AlertDialog {
val pm = latinIme.packageManager
val thisImi = richImm.inputMethodInfoOfThisIme
val currentSubtype = richImm.currentSubtype.rawSubtype
@ -76,5 +76,5 @@ fun showInputMethodPicker(latinIme: LatinIME, richImm: RichInputMethodManager, w
layoutParams?.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG
window?.attributes = layoutParams
window?.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM)
dialog.show()
return dialog
}

View file

@ -208,7 +208,6 @@
</declare-styleable>
<declare-styleable name="ClipboardHistoryView">
<attr name="dividerBackground" format="color" />
<attr name="iconPinnedClip" format="reference" />
</declare-styleable>

View file

@ -140,7 +140,6 @@
<dimen name="config_emoji_category_page_id_height">2dp</dimen>
<!-- Common configuration of clipboard keyboard -->
<dimen name="config_clipboard_divider_height">1.5dp</dimen>
<dimen name="config_clipboard_pinned_icon_size">18dp</dimen>
<!-- Inset used in Accessibility mode to avoid accidental key presses when a finger slides off the screen. -->

View file

@ -104,7 +104,6 @@
parent="MainKeyboardView.HoloBase"
>
<item name="iconPinnedClip">@drawable/ic_clipboard_pin_holo_dark</item>
<item name="dividerBackground">@color/emoji_tab_page_indicator_background_holo</item>
</style>
<style
name="MoreKeysKeyboard.HoloBase"

View file

@ -84,7 +84,6 @@
parent="MainKeyboardView.LXX_Base"
>
<item name="iconPinnedClip">@drawable/ic_clipboard_pin_lxx_light</item>
<item name="dividerBackground">@color/emoji_tab_page_indicator_background_lxx_base</item>
</style>
<style
name="MoreKeysKeyboard.LXX_Base"