mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-14 05:52:47 +00:00
set correct icon when voice input key is on keyboard, but no voice input method is available
This commit is contained in:
parent
5d0341195e
commit
f7b12757ed
2 changed files with 18 additions and 3 deletions
|
@ -22,6 +22,8 @@ import helium314.keyboard.keyboard.internal.keyboard_parser.floris.PopupSet;
|
|||
import helium314.keyboard.latin.common.Constants;
|
||||
import helium314.keyboard.latin.common.StringUtils;
|
||||
import helium314.keyboard.latin.utils.PopupKeysUtilsKt;
|
||||
import helium314.keyboard.latin.utils.ToolbarKey;
|
||||
import helium314.keyboard.latin.utils.ToolbarUtilsKt;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
@ -207,10 +209,11 @@ public class Key implements Comparable<Key> {
|
|||
mPopupKeys = null;
|
||||
mPopupKeysColumnAndFlags = 0;
|
||||
mLabel = label;
|
||||
mOptionalAttributes = OptionalAttributes.newInstance(outputText, KeyCode.NOT_SPECIFIED, null, 0, 0);
|
||||
mCode = code;
|
||||
mEnabled = (code != KeyCode.NOT_SPECIFIED);
|
||||
mIconName = iconName;
|
||||
mOptionalAttributes = OptionalAttributes.newInstance(outputText, KeyCode.NOT_SPECIFIED,
|
||||
mIconName == null ? null : getDisabledIconName(mIconName), 0, 0);
|
||||
// Horizontal gap is divided equally to both sides of the key.
|
||||
mX = x + mHorizontalGap / 2;
|
||||
mY = y;
|
||||
|
@ -943,6 +946,12 @@ public class Key implements Comparable<Key> {
|
|||
|| mBackgroundType == BACKGROUND_TYPE_STICKY_ON;
|
||||
}
|
||||
|
||||
@Nullable private static String getDisabledIconName(@NonNull final String iconName) {
|
||||
if (iconName.equals(ToolbarUtilsKt.getToolbarKeyStrings().get(ToolbarKey.VOICE)))
|
||||
return KeyboardIconsSet.NAME_SHORTCUT_KEY_DISABLED;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class Spacer extends Key {
|
||||
private Spacer(KeyParams keyParams) {
|
||||
super(keyParams);
|
||||
|
@ -1180,8 +1189,8 @@ public class Key implements Comparable<Key> {
|
|||
? StringUtils.toTitleCaseOfKeyCode(altCodeInAttr, localeForUpcasing)
|
||||
: altCodeInAttr;
|
||||
mOptionalAttributes = OptionalAttributes.newInstance(outputText, altCode,
|
||||
// disabled icon only ever for old version of shortcut key, visual insets can be replaced with spacer
|
||||
null, 0, 0);
|
||||
// disabled icon only shortcut / voice key, visual insets can be replaced with spacer
|
||||
mIconName == null ? null : getDisabledIconName(mIconName), 0, 0);
|
||||
// KeyVisualAttributes for a key essentially are what the theme has, but on a per-key base
|
||||
// could be used e.g. for having a color gradient on key color
|
||||
mKeyVisualAttributes = null;
|
||||
|
|
|
@ -24,6 +24,7 @@ import helium314.keyboard.keyboard.emoji.OnKeyEventListener;
|
|||
import helium314.keyboard.keyboard.internal.KeyDrawParams;
|
||||
import helium314.keyboard.keyboard.internal.keyboard_parser.floris.KeyCode;
|
||||
import helium314.keyboard.latin.R;
|
||||
import helium314.keyboard.latin.RichInputMethodManager;
|
||||
import helium314.keyboard.latin.common.Constants;
|
||||
import helium314.keyboard.latin.common.CoordinateUtils;
|
||||
|
||||
|
@ -107,6 +108,11 @@ public class PopupKeysKeyboardView extends KeyboardView implements PopupKeysPane
|
|||
} else {
|
||||
mAccessibilityDelegate = null;
|
||||
}
|
||||
final Key shortcutKey = keyboard.getKey(KeyCode.VOICE_INPUT);
|
||||
if (shortcutKey != null) {
|
||||
shortcutKey.setEnabled(RichInputMethodManager.getInstance().isShortcutImeReady());
|
||||
invalidateKey(shortcutKey);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue