-
-
Notifications
You must be signed in to change notification settings - Fork 195
Display emoji descriptions in popups #1542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
44e2b0e
Display emoji descriptions in popups
eranl 428c41a
Merge branch 'refs/heads/main' into emoji-descriptions
eranl 698f9f9
New implementation: take descriptions from dictionary, display them u…
eranl b995fb6
Merge branch 'main' into emoji-descriptions
eranl 099ea9a
Use `SingleDictionaryFacilitator`.
eranl 56b36df
Avoid loading emoji dictionary in every emoji view, and when the sett…
eranl abea2bd
Minor fixes
eranl 304aa3d
Make description text smaller.
eranl 7bcd0f6
Merge branch 'main' into emoji-descriptions
eranl ca60aa9
Justify popup to close edge.
eranl 4577807
Minor fix
eranl 51df37f
Use `BinaryDictionary.getWordProperty` to load descriptions.
eranl d59f4ee
Cosmetics
eranl 721b63e
Address comments.
eranl 932bbe8
Move setting down from between sound settings
eranl a30b989
Address comments
eranl 21faa2b
Merge branch 'refs/heads/main' into emoji-descriptions
eranl a7bc60b
Address comments
eranl 8256854
Address comments
eranl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
app/src/main/java/helium314/keyboard/keyboard/PopupTextView.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| /* | ||
| * Copyright (C) 2011 The Android Open Source Project | ||
| * modified | ||
| * SPDX-License-Identifier: Apache-2.0 AND GPL-3.0-only | ||
| */ | ||
|
|
||
| package helium314.keyboard.keyboard; | ||
|
|
||
| import android.content.Context; | ||
| import android.graphics.Typeface; | ||
| import android.util.AttributeSet; | ||
| import android.util.TypedValue; | ||
| import android.view.Gravity; | ||
| import android.view.View; | ||
| import android.widget.TextView; | ||
| import helium314.keyboard.keyboard.emoji.EmojiViewCallback; | ||
| import helium314.keyboard.keyboard.internal.KeyDrawParams; | ||
| import helium314.keyboard.latin.R; | ||
| import helium314.keyboard.latin.common.ColorType; | ||
| import helium314.keyboard.latin.common.CoordinateUtils; | ||
| import helium314.keyboard.latin.settings.Settings; | ||
|
|
||
|
|
||
| /** | ||
| * A view that displays popup text. | ||
| */ | ||
| public class PopupTextView extends TextView implements PopupKeysPanel { | ||
| private final int[] mCoordinates = CoordinateUtils.newInstance(); | ||
| private final Typeface mTypeface; | ||
| private Controller mController = EMPTY_CONTROLLER; | ||
| private int mOriginX; | ||
| private int mOriginY; | ||
| private Key mKey; | ||
| private EmojiViewCallback mEmojiViewCallback; | ||
|
|
||
| public PopupTextView(final Context context, final AttributeSet attrs) { | ||
| this(context, attrs, R.attr.popupKeysKeyboardViewStyle); | ||
| } | ||
|
|
||
| public PopupTextView(final Context context, final AttributeSet attrs, | ||
| final int defStyle) { | ||
| super(context, attrs, defStyle); | ||
| mTypeface = Settings.getInstance().getCustomTypeface(); | ||
| } | ||
|
|
||
| public void setKeyDrawParams(Key key, KeyDrawParams drawParams) { | ||
| mKey = key; | ||
| Settings.getValues().mColors.setBackground(this, ColorType.KEY_PREVIEW_BACKGROUND); | ||
| setTextColor(drawParams.mPreviewTextColor); | ||
| setTextSize(TypedValue.COMPLEX_UNIT_PX, key.selectHintTextSize(drawParams) << 1); | ||
| setTypeface(mTypeface == null ? key.selectTypeface(drawParams) : mTypeface); | ||
| } | ||
|
|
||
| @Override | ||
| public void showPopupKeysPanel(final View parentView, final Controller controller, | ||
| final int pointX, final int pointY, final KeyboardActionListener listener) { | ||
| showPopupKeysPanelInternal(parentView, controller, pointX, pointY); | ||
| } | ||
|
|
||
| @Override | ||
| public void showPopupKeysPanel(final View parentView, final Controller controller, | ||
| final int pointX, final int pointY, final EmojiViewCallback emojiViewCallback) { | ||
| mEmojiViewCallback = emojiViewCallback; | ||
| showPopupKeysPanelInternal(parentView, controller, pointX, pointY); | ||
| } | ||
|
|
||
| private void showPopupKeysPanelInternal(final View parentView, final Controller controller, | ||
| final int pointX, final int pointY) { | ||
| mController = controller; | ||
| final View container = getContainerView(); | ||
| // The coordinates of panel's left-top corner in parentView's coordinate system. | ||
| // We need to consider background drawable paddings. | ||
| final int x = pointX - getMeasuredWidth() / 2 - container.getPaddingLeft() - getPaddingLeft(); | ||
| final int y = pointY - container.getMeasuredHeight() + container.getPaddingBottom() | ||
| + getPaddingBottom(); | ||
|
|
||
| parentView.getLocationInWindow(mCoordinates); | ||
| // Ensure the horizontal position of the panel does not extend past the parentView edges. | ||
| final int maxX = parentView.getMeasuredWidth() - container.getMeasuredWidth(); | ||
| final int panelX = Math.max(0, Math.min(maxX, x)) + CoordinateUtils.x(mCoordinates); | ||
| final int panelY = y + CoordinateUtils.y(mCoordinates); | ||
| container.setX(panelX); | ||
| container.setY(panelY); | ||
|
|
||
| mOriginX = x + container.getPaddingLeft(); | ||
| mOriginY = y + container.getPaddingTop(); | ||
| controller.setLayoutGravity(Gravity.NO_GRAVITY); | ||
| controller.onShowPopupKeysPanel(this); | ||
| } | ||
|
|
||
| @Override | ||
| public void onDownEvent(final int x, final int y, final int pointerId, final long eventTime) { | ||
| } | ||
|
|
||
| @Override | ||
| public void onMoveEvent(final int x, final int y, final int pointerId, final long eventTime) { | ||
| } | ||
|
|
||
| @Override | ||
| public void onUpEvent(final int x, final int y, final int pointerId, final long eventTime) { | ||
| mEmojiViewCallback.onReleaseKey(mKey); | ||
| } | ||
|
|
||
| @Override | ||
| public void dismissPopupKeysPanel() { | ||
| if (!isShowingInParent()) { | ||
| return; | ||
| } | ||
| mController.onDismissPopupKeysPanel(); | ||
| } | ||
|
|
||
| @Override | ||
| public int translateX(final int x) { | ||
| return x - mOriginX; | ||
| } | ||
|
|
||
| @Override | ||
| public int translateY(final int y) { | ||
| return y - mOriginY; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.