@capgo/capacitor-home-indicator 8.0.18 → 8.0.20
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/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @capgo/home-indicator
|
|
1
|
+
# @capgo/capacitor-home-indicator
|
|
2
2
|
<a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
|
|
3
3
|
|
|
4
4
|
<div align="center">
|
|
@@ -77,8 +77,8 @@ The most complete doc is available here: https://capgo.app/docs/plugins/home-ind
|
|
|
77
77
|
## Install
|
|
78
78
|
|
|
79
79
|
```bash
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
bun add @capgo/capacitor-home-indicator
|
|
81
|
+
bunx cap sync
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
## API
|
package/android/build.gradle
CHANGED
|
@@ -30,7 +30,7 @@ android {
|
|
|
30
30
|
buildTypes {
|
|
31
31
|
release {
|
|
32
32
|
minifyEnabled false
|
|
33
|
-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
lintOptions {
|
|
@@ -7,6 +7,7 @@ import android.util.Log;
|
|
|
7
7
|
import android.view.OrientationEventListener;
|
|
8
8
|
import android.view.View;
|
|
9
9
|
import android.view.WindowInsets;
|
|
10
|
+
import android.view.WindowInsetsController;
|
|
10
11
|
import com.getcapacitor.JSObject;
|
|
11
12
|
import com.getcapacitor.Plugin;
|
|
12
13
|
import com.getcapacitor.PluginCall;
|
|
@@ -16,21 +17,41 @@ import com.getcapacitor.annotation.CapacitorPlugin;
|
|
|
16
17
|
@CapacitorPlugin(name = "HomeIndicator")
|
|
17
18
|
public class HomeIndicatorPlugin extends Plugin {
|
|
18
19
|
|
|
19
|
-
public final String pluginVersion = "
|
|
20
|
+
public final String pluginVersion = "8.0.19";
|
|
20
21
|
private OrientationEventListener orientationEventListener;
|
|
21
22
|
private int previousOrientation = Configuration.ORIENTATION_UNDEFINED;
|
|
22
23
|
|
|
23
24
|
public void UiChangeListener() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
26
|
+
// Use WindowInsetsController listener for Android 11+
|
|
27
|
+
final WindowInsetsController insetsController = this.getBridge().getActivity().getWindow().getInsetsController();
|
|
28
|
+
if (insetsController != null) {
|
|
29
|
+
this.getBridge()
|
|
30
|
+
.getActivity()
|
|
31
|
+
.getWindow()
|
|
32
|
+
.getDecorView()
|
|
33
|
+
.setOnSystemUiVisibilityChangeListener(
|
|
34
|
+
new View.OnSystemUiVisibilityChangeListener() {
|
|
35
|
+
@Override
|
|
36
|
+
public void onSystemUiVisibilityChange(int visibility) {
|
|
37
|
+
Log.i("HomeIndicator", "onSystemUiVisibilityChange");
|
|
38
|
+
HomeIndicatorPlugin.this.setCssVar();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
);
|
|
32
42
|
}
|
|
33
|
-
|
|
43
|
+
} else {
|
|
44
|
+
final View decorView = this.getBridge().getActivity().getWindow().getDecorView();
|
|
45
|
+
decorView.setOnSystemUiVisibilityChangeListener(
|
|
46
|
+
new View.OnSystemUiVisibilityChangeListener() {
|
|
47
|
+
@Override
|
|
48
|
+
public void onSystemUiVisibilityChange(int visibility) {
|
|
49
|
+
Log.i("HomeIndicator", "onSystemUiVisibilityChange");
|
|
50
|
+
HomeIndicatorPlugin.this.setCssVar();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
}
|
|
34
55
|
}
|
|
35
56
|
|
|
36
57
|
private void setCssVar() {
|
|
@@ -126,9 +147,17 @@ public class HomeIndicatorPlugin extends Plugin {
|
|
|
126
147
|
new Runnable() {
|
|
127
148
|
@Override
|
|
128
149
|
public void run() {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
150
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
151
|
+
WindowInsetsController insetsController = getActivity().getWindow().getInsetsController();
|
|
152
|
+
if (insetsController != null) {
|
|
153
|
+
insetsController.hide(WindowInsets.Type.navigationBars());
|
|
154
|
+
insetsController.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
View decorView = getActivity().getWindow().getDecorView();
|
|
158
|
+
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
|
159
|
+
decorView.setSystemUiVisibility(uiOptions);
|
|
160
|
+
}
|
|
132
161
|
HomeIndicatorPlugin.this.setCssVar();
|
|
133
162
|
JSObject ret = new JSObject();
|
|
134
163
|
call.resolve(ret);
|
|
@@ -143,11 +172,17 @@ public class HomeIndicatorPlugin extends Plugin {
|
|
|
143
172
|
new Runnable() {
|
|
144
173
|
@Override
|
|
145
174
|
public void run() {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
175
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
176
|
+
WindowInsetsController insetsController = getActivity().getWindow().getInsetsController();
|
|
177
|
+
if (insetsController != null) {
|
|
178
|
+
insetsController.show(WindowInsets.Type.navigationBars());
|
|
179
|
+
}
|
|
180
|
+
} else {
|
|
181
|
+
View decorView = getActivity().getWindow().getDecorView();
|
|
182
|
+
int currentFlags = decorView.getSystemUiVisibility();
|
|
183
|
+
int newFlags = currentFlags & ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
|
184
|
+
decorView.setSystemUiVisibility(newFlags);
|
|
185
|
+
}
|
|
151
186
|
HomeIndicatorPlugin.this.setCssVar();
|
|
152
187
|
JSObject ret = new JSObject();
|
|
153
188
|
call.resolve(ret);
|
|
@@ -162,11 +197,20 @@ public class HomeIndicatorPlugin extends Plugin {
|
|
|
162
197
|
new Runnable() {
|
|
163
198
|
@Override
|
|
164
199
|
public void run() {
|
|
165
|
-
|
|
166
|
-
|
|
200
|
+
boolean hidden = false;
|
|
201
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
202
|
+
WindowInsets insets = getActivity().getWindow().getDecorView().getRootWindowInsets();
|
|
203
|
+
if (insets != null) {
|
|
204
|
+
hidden = !insets.isVisible(WindowInsets.Type.navigationBars());
|
|
205
|
+
}
|
|
206
|
+
} else {
|
|
207
|
+
View decorView = getActivity().getWindow().getDecorView();
|
|
208
|
+
int uiOptions = decorView.getSystemUiVisibility();
|
|
209
|
+
hidden = (uiOptions & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
|
210
|
+
}
|
|
167
211
|
HomeIndicatorPlugin.this.setCssVar();
|
|
168
212
|
JSObject ret = new JSObject();
|
|
169
|
-
ret.put("hidden",
|
|
213
|
+
ret.put("hidden", hidden);
|
|
170
214
|
call.resolve(ret);
|
|
171
215
|
}
|
|
172
216
|
}
|
|
@@ -35,7 +35,7 @@ public class CapgoHomeIndicatorPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
35
35
|
CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise)
|
|
36
36
|
]
|
|
37
37
|
|
|
38
|
-
private let pluginVersion: String = "8.0.
|
|
38
|
+
private let pluginVersion: String = "8.0.20"
|
|
39
39
|
|
|
40
40
|
@objc func getPluginVersion(_ call: CAPPluginCall) {
|
|
41
41
|
call.resolve(["version": self.pluginVersion])
|