@totalpave/cordova-plugin-insets 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<plugin
|
|
3
3
|
xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
4
4
|
id="@totalpave/cordova-plugin-insets"
|
|
5
|
-
version="0.3.
|
|
5
|
+
version="0.3.1"
|
|
6
6
|
>
|
|
7
7
|
<name>cordova-plugin-insets</name>
|
|
8
8
|
<description>Cordova Android Plugin to receive native information regarding the unsafe area insets</description>
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
package com.totalpave.cordova.inset;
|
|
18
18
|
|
|
19
|
+
import android.content.res.Configuration;
|
|
19
20
|
import android.content.Context;
|
|
20
21
|
import android.os.Build;
|
|
21
22
|
import android.view.RoundedCorner;
|
|
@@ -136,16 +137,42 @@ public class Inset extends CordovaPlugin {
|
|
|
136
137
|
double bottom = insets.bottom / density;
|
|
137
138
|
double left = insets.left / density;
|
|
138
139
|
|
|
140
|
+
// First we will get the screen orientation. This may be locked by the user, so it
|
|
141
|
+
// may not match the physical orientation. If the orientation cannot be determined,
|
|
142
|
+
// we will assume PORTRAIT
|
|
143
|
+
int orientation = Configuration.ORIENTATION_UNDEFINED;
|
|
144
|
+
|
|
145
|
+
// There are other orientation types, albeit deprecated and supposedly no longer
|
|
146
|
+
// used, but this limits us from handling only portrait and landscape.
|
|
147
|
+
switch ($context.getResources().getConfiguration().orientation) {
|
|
148
|
+
case Configuration.ORIENTATION_LANDSCAPE:
|
|
149
|
+
case Configuration.ORIENTATION_PORTRAIT:
|
|
150
|
+
orientation = $context.getResources().getConfiguration().orientation;
|
|
151
|
+
break;
|
|
152
|
+
case Configuration.ORIENTATION_SQUARE:
|
|
153
|
+
case Configuration.ORIENTATION_UNDEFINED:
|
|
154
|
+
// SQUARE is not used anymore since API 16, but included just to satisfy
|
|
155
|
+
// lint warnings. If undefined, then fallback to PORTRAIT
|
|
156
|
+
orientation = Configuration.ORIENTATION_PORTRAIT;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
|
|
139
160
|
// Insets do not include rounded corner radius. If an inset is present, it
|
|
140
161
|
// generally will be big enough to cover the rounded corner. This is a coincidence,
|
|
141
162
|
// not a designed thing. In either case, we need to determine how much space is
|
|
142
163
|
// required to cover the rounded corner and take the higher between the inset and
|
|
143
164
|
// the rounded corner.
|
|
144
165
|
|
|
145
|
-
top
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
166
|
+
// If portrait, then top-left & top-right is applied to the top inset,
|
|
167
|
+
// and bot-left & bot-right is applied to the bottom inset
|
|
168
|
+
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
|
169
|
+
top = Math.max(Math.max(top, topLeftRadius), topRightRadius);
|
|
170
|
+
bottom = Math.max(Math.max(bottom, botLeftRadius), botRightRadius);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
left = Math.max(Math.max(left, topLeftRadius), botLeftRadius);
|
|
174
|
+
right = Math.max(Math.max(right, topRightRadius), botRightRadius);
|
|
175
|
+
}
|
|
149
176
|
|
|
150
177
|
result.put("top", top);
|
|
151
178
|
result.put("right", right);
|
package/www/Insets.d.ts
CHANGED
package/www/InsetType.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* An enumeration of Inset Types.
|
|
3
|
-
* These are mapped to android's native WindowInsetsCompat.TYPE
|
|
4
|
-
*
|
|
5
|
-
* See https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Type
|
|
6
|
-
* for more information.
|
|
7
|
-
*
|
|
8
|
-
* Note that the native constant values is an implementation detail,
|
|
9
|
-
* therefore the values here isn't a direct mapping, but will be resolved
|
|
10
|
-
* appropriately.
|
|
11
|
-
*/
|
|
12
|
-
export declare enum InsetType {
|
|
13
|
-
CAPTION_BAR = 1,
|
|
14
|
-
DISPLAY_CUTOUT = 2,
|
|
15
|
-
IME = 4,
|
|
16
|
-
MANDATORY_SYSTEM_GESTURES = 8,
|
|
17
|
-
NAVIGATION_BARS = 16,
|
|
18
|
-
STATUS_BARS = 32,
|
|
19
|
-
SYSTEM_BARS = 64,
|
|
20
|
-
SYSTEM_GESTURES = 128,
|
|
21
|
-
TAPPABLE_ELEMENT = 256
|
|
22
|
-
}
|