mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-21 01:10:24 +00:00
make long-press toolbar pinning optional
This commit is contained in:
parent
0f503389b3
commit
388366c242
10 changed files with 98 additions and 58 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue