make long-press toolbar pinning optional

This commit is contained in:
Helium314 2024-05-27 20:34:26 +02:00
parent 0f503389b3
commit 388366c242
10 changed files with 98 additions and 58 deletions

View file

@ -217,13 +217,13 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
mToolbarExpandKey.getLayoutParams().height *= 0.82; // shrink the whole key a little (drawable not affected)
mToolbarExpandKey.getLayoutParams().width *= 0.82;
for (final ToolbarKey pinnedKey : Settings.readPinnedKeys(prefs)) {
for (final ToolbarKey pinnedKey : ToolbarUtilsKt.getPinnedToolbarKeys(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)
if (pinnedKeyInToolbar != null && Settings.getInstance().getCurrent().mQuickPinToolbarKeys)
pinnedKeyInToolbar.setBackground(mEnabledToolKeyBackground);
}
@ -374,7 +374,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
private void onLongClickToolKey(final View view) {
if (!(view.getTag() instanceof ToolbarKey tag)) return;
if (view.getParent() == mPinnedKeys) {
if (view.getParent() == mPinnedKeys || !Settings.getInstance().getCurrent().mQuickPinToolbarKeys) {
final int longClickCode = getCodeForToolbarKeyLongClick(tag);
if (longClickCode != KeyCode.UNSPECIFIED) {
mListener.onCodeInput(longClickCode, Constants.SUGGESTION_STRIP_COORDINATE, Constants.SUGGESTION_STRIP_COORDINATE, false);
@ -384,9 +384,9 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
if (pinnedKeyView == null) {
addKeyToPinnedKeys(tag);
mToolbar.findViewWithTag(tag).setBackground(mEnabledToolKeyBackground);
Settings.addPinnedKey(DeviceProtectedUtils.getSharedPreferences(getContext()), tag);
ToolbarUtilsKt.addPinnedKey(DeviceProtectedUtils.getSharedPreferences(getContext()), tag);
} else {
Settings.removePinnedKey(DeviceProtectedUtils.getSharedPreferences(getContext()), tag);
ToolbarUtilsKt.removePinnedKey(DeviceProtectedUtils.getSharedPreferences(getContext()), tag);
mToolbar.findViewWithTag(tag).setBackground(mDefaultBackground.getConstantState().newDrawable(getResources()));
mPinnedKeys.removeView(pinnedKeyView);
}