correctly read pinned keys when they are not in the toolbar

This commit is contained in:
Helium314 2024-01-01 14:07:53 +01:00
parent a0e60fb9ce
commit e7d9080c49
2 changed files with 8 additions and 6 deletions

View file

@ -196,7 +196,6 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
setupKey(button, colors);
mToolbar.addView(button);
}
keyboardAttr.recycle();
final int toolbarHeight = Math.min(mToolbarExpandKey.getLayoutParams().height, (int) getResources().getDimension(R.dimen.config_suggestions_strip_height));
mToolbarExpandKey.getLayoutParams().height = toolbarHeight;
@ -216,13 +215,17 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
mToolbarExpandKey.getLayoutParams().width *= 0.82;
for (final ToolbarKey pinnedKey : Settings.readPinnedKeys(prefs)) {
final ImageButton button = createToolbarKey(context, keyboardAttr, pinnedKey);
button.setLayoutParams(toolbarKeyLayoutParams);
setupKey(button, colors);
mPinnedKeys.addView(button);
final View pinnedKeyInToolbar = mToolbar.findViewWithTag(pinnedKey);
if (pinnedKeyInToolbar == null) continue;
pinnedKeyInToolbar.setBackground(mEnabledToolKeyBackground);
addKeyToPinnedKeys(pinnedKey);
if (pinnedKeyInToolbar != null)
pinnedKeyInToolbar.setBackground(mEnabledToolKeyBackground);
}
colors.setBackground(this, ColorType.SUGGESTION_BACKGROUND);
keyboardAttr.recycle();
}
/**

View file

@ -20,7 +20,6 @@ fun createToolbarKey(context: Context, keyboardAttr: TypedArray, key: ToolbarKey
val contentDescriptionId = context.resources.getIdentifier(key.name.lowercase(), "string", context.packageName)
if (contentDescriptionId != 0)
button.contentDescription = context.getString(contentDescriptionId)
val icon = keyboardAttr.getDrawable(getStyleableIconId(key))
if (key == LEFT || key == RIGHT || key == UP || key == DOWN) {
// arrows look a little awkward when not scaled
button.scaleX = 1.2f
@ -32,7 +31,7 @@ fun createToolbarKey(context: Context, keyboardAttr: TypedArray, key: ToolbarKey
AUTOCORRECT -> Settings.getInstance().current.mAutoCorrectionEnabledPerUserSettings
else -> true
}
button.setImageDrawable(icon)
button.setImageDrawable(keyboardAttr.getDrawable(getStyleableIconId(key)))
return button
}