-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
toast notifications #752
toast notifications #752
Conversation
app/src/main/java/helium314/keyboard/keyboard/KeyboardSwitcher.java
Outdated
Show resolved
Hide resolved
Not sure whether it works, but having the fake toast in default device style is worth trying. Could you try making a |
I don't think this still works, I tried to get the view and got:
The comment here may be the reason for it |
Shouldn't this notification be a little lower? 🤔 Most often I saw them just above the spacebar. |
I think you might be right, but there may be a better placement for this notification: In OneUI 6 (android 14) the toast notification when copying something to the clipboard are actually above the keyboard, right in the middle of the screen: That makes the toast less intrusive as it does not hide keys on the keyboard |
It looks better than on the keyboard, but I think that for some people such a notification in the middle of the screen can be annoying. Maybe it's better to place it just above the keyboard? |
I find the position somewhat awkward comparing to normal toast messages, but showing some amount above the keyboard definitely is a good idea, as this is a. not covering the text field (assuming it's a single line), and b. not at a place that might be covered with fingers. The inability to copy the system toast style is unfortunate. Though maybe we could derive toast colors from the keyboard colors... |
@codokie do you plan to move the notification to the place above the input field, or do you consider this PR done? |
I think such change would make the toast notifications less obstructive for the user, so it may be worth trying to implement it. I'm a newbie still when it comes to xml layouts, I tried to change things around in main_keyboard_frame.xml to no avail, perhaps you are aware of another approach that might work? The idea is to place the toast's TextView directly in the middle of the screen, I don't think it's possible to tell where the input field is actually placed |
I think it might work when you do it in |
You could try something like |
This is highly dependent on the Android version though, device manufacturers may style the toast, and some custom roms also do this, or let the user tune the toast. |
Having the message centered may be a (minor) issue in some cases. E.g. in landscape mode it will be on the keyboard, or when height scale is very low it will be far above the keyboard. But handling the window insets is probably too much, at least in scope of this PR. |
final PopupMenu uglyWorkaround = new PopupMenu(DialogUtilsKt.getPlatformDialogThemeContext(getContext()), wordView); | ||
uglyWorkaround.getMenu().add(Menu.NONE, 1, Menu.NONE, text); | ||
uglyWorkaround.show(); | ||
mListener.showToast(text, true, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me, the toast is hidden behind the more suggestions panel. Is it the same for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just checked and it is also hidden for me
There should be some way to make the toast view appear on top
Alternatively another 'ugly workaround' would be to dismiss the more suggestions panel just before the toast would get shown
In landscape mode the fake toast isn't shown even when the panel is dismissed, but mFakeToast.bringToFront() seems to solve that
I don't really like the way how some parts of the toast are being handled though.
|
app/src/main/res/anim/fade_in.xml
Outdated
<alpha xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:fromAlpha="0.0" | ||
android:toAlpha="1.0" | ||
android:duration="300" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that reproduce the toast on your system? For me the default toast is much faster than that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean that the animation of the system toast is faster? because in terms of timing I haven't noticed a real difference
|
This PR adds toast notifications.
In Android 12L and below, there is no need for notification permission (which Heliboard currently does not have), so the toasts will be displayed natively.
For newer Android versions, a "fake" toast will be shown instead. Here's how it would look (inspired by OneUI):
It has a 300ms fade in/out animation to make the transition smoother. The view does not prevent pressing the keys it covers.
In Android versions older than 13, a toast notification will now be shown for 2 seconds when content is copied to the clipboard (can be triggered by pressing the copy/cut toolbar keys).
In Android 13+, most devices already show some kind of notification whenever the clipboard is set, so there is no need to display another one.
However, it will be possible to use it for other purposes like indicating an image URI could not be pasted to an input field (#722), or that the clipboard history has been cleared (#679). If you have any other ideas please let me know.
Fixes #545