Compare commits

..
5 Commits
Author SHA1 Message Date
EddyVerbruggen 55856bcb44 bump 2021-11-10 15:59:03 +01:00
Eddy VerbruggenandGitHub 28cc48357c Merge pull request #142 from tomburger/fix/api-30-crashing
fix the crash for API 30
2021-11-10 14:48:38 +01:00
Tom Burger 4399bed9e1 fix the crash for API 30 2021-11-09 15:12:20 +01:00
Eddy VerbruggenandGitHub 09d536b9ec Merge pull request #132 from cherouvim/patch-2
docs: Typo.
2019-10-14 22:08:52 +02:00
Ioannis CherouvimandGitHub 653aed37a3 docs: Typo. 2019-10-13 22:58:56 +03:00
4 changed files with 15 additions and 8 deletions
+1 -1
View File
@@ -231,7 +231,7 @@ called again. You can distinguish between those events of course:
);
```
The success callback is useful when your toast is binded to a notification id in your backend and you have to mark it as `read` when the toast is done, or to update the notifications counter for iOS. The usage of this will be defined by your application logic. Use the `result.data` object to support your specific logic.
The success callback is useful when your toast is bound to a notification id in your backend and you have to mark it as `read` when the toast is done, or to update the notifications counter for iOS. The usage of this will be defined by your application logic. Use the `result.data` object to support your specific logic.
### Styling
Since version 2.4.0 you can pass an optional `styling` object to the plugin.
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-x-toast",
"version": "2.7.2",
"version": "2.7.3",
"description": "This plugin allows you to show a Toast. A Toast is a little non intrusive buttonless popup which automatically disappears.",
"cordova": {
"id": "cordova-plugin-x-toast",
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-plugin-x-toast"
version="2.7.2">
version="2.7.3">
<name>Toast</name>
+12 -5
View File
@@ -35,8 +35,10 @@ public class Toast extends CordovaPlugin {
private android.widget.Toast mostRecentToast;
private ViewGroup viewGroup;
private static final boolean IS_AT_LEAST_JELLY_BEAN = Build.VERSION.SDK_INT >= 16;
private static final boolean IS_AT_LEAST_LOLLIPOP = Build.VERSION.SDK_INT >= 21;
private static final boolean IS_AT_LEAST_PIE = Build.VERSION.SDK_INT >= 28;
private static final boolean IS_AT_LEAST_R = Build.VERSION.SDK_INT >= 30;
// note that webView.isPaused() is not Xwalk compatible, so tracking it poor-man style
private boolean isPaused;
@@ -105,7 +107,8 @@ public class Toast extends CordovaPlugin {
}
// if one of the custom layout options have been passed in, draw our own shape
if (styling != null && Build.VERSION.SDK_INT >= 16) {
// (but disabled on Android >= 11 since custom toast views are deprecated)
if (styling != null && IS_AT_LEAST_JELLY_BEAN && !IS_AT_LEAST_R) {
// the defaults mimic the default toast as close as possible
final String backgroundColor = styling.optString("backgroundColor", "#333333");
@@ -132,14 +135,18 @@ public class Toast extends CordovaPlugin {
toast.getView().setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding);
// this gives the toast a very subtle shadow on newer devices
if (Build.VERSION.SDK_INT >= 21) {
if (IS_AT_LEAST_LOLLIPOP) {
toast.getView().setElevation(6);
}
}
// On Android >= 5 you can no longer rely on the 'toast.getView().setOnTouchListener',
// so created something funky that compares the Toast position to the tap coordinates.
if (IS_AT_LEAST_LOLLIPOP) {
if (IS_AT_LEAST_R) {
// On Android >= 11 the 'toast.getView()' will always return null
// so no touchListener can be used or mocked
// DO NOTHING
} else if (IS_AT_LEAST_LOLLIPOP) {
// On Android >= 5 you can no longer rely on the 'toast.getView().setOnTouchListener',
// so created something funky that compares the Toast position to the tap coordinates.
getViewGroup().setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {