@capacitor/status-bar 7.0.0-nightly-20241126T150542.0 → 7.0.0-nightly-20241127T150538.0
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.
|
@@ -15,19 +15,27 @@ import androidx.core.view.WindowInsetsControllerCompat;
|
|
|
15
15
|
|
|
16
16
|
public class StatusBar {
|
|
17
17
|
|
|
18
|
+
public static final String statusBarVisibilityChanged = "statusBarVisibilityChanged";
|
|
19
|
+
public static final String statusBarOverlayChanged = "statusBarOverlayChanged";
|
|
20
|
+
|
|
18
21
|
private int currentStatusBarColor;
|
|
22
|
+
private final ChangeListener listener;
|
|
19
23
|
private final AppCompatActivity activity;
|
|
20
24
|
private final String defaultStyle;
|
|
21
25
|
|
|
22
|
-
public StatusBar(AppCompatActivity activity, StatusBarConfig config) {
|
|
26
|
+
public StatusBar(AppCompatActivity activity, StatusBarConfig config, ChangeListener listener) {
|
|
23
27
|
// save initial color of the status bar
|
|
24
28
|
this.activity = activity;
|
|
25
29
|
this.currentStatusBarColor = activity.getWindow().getStatusBarColor();
|
|
30
|
+
this.listener = listener;
|
|
26
31
|
this.defaultStyle = getStyle();
|
|
27
32
|
|
|
28
33
|
setBackgroundColor(config.getBackgroundColor());
|
|
29
34
|
setStyle(config.getStyle());
|
|
30
35
|
setOverlaysWebView(config.isOverlaysWebView());
|
|
36
|
+
StatusBarInfo info = getInfo();
|
|
37
|
+
info.setVisible(true);
|
|
38
|
+
listener.onChange(statusBarOverlayChanged, info);
|
|
31
39
|
}
|
|
32
40
|
|
|
33
41
|
public void setStyle(String style) {
|
|
@@ -56,12 +64,18 @@ public class StatusBar {
|
|
|
56
64
|
View decorView = activity.getWindow().getDecorView();
|
|
57
65
|
WindowInsetsControllerCompat windowInsetsControllerCompat = WindowCompat.getInsetsController(activity.getWindow(), decorView);
|
|
58
66
|
windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.statusBars());
|
|
67
|
+
StatusBarInfo info = getInfo();
|
|
68
|
+
info.setVisible(false);
|
|
69
|
+
listener.onChange(statusBarVisibilityChanged, info);
|
|
59
70
|
}
|
|
60
71
|
|
|
61
72
|
public void show() {
|
|
62
73
|
View decorView = activity.getWindow().getDecorView();
|
|
63
74
|
WindowInsetsControllerCompat windowInsetsControllerCompat = WindowCompat.getInsetsController(activity.getWindow(), decorView);
|
|
64
75
|
windowInsetsControllerCompat.show(WindowInsetsCompat.Type.statusBars());
|
|
76
|
+
StatusBarInfo info = getInfo();
|
|
77
|
+
info.setVisible(true);
|
|
78
|
+
listener.onChange(statusBarVisibilityChanged, info);
|
|
65
79
|
}
|
|
66
80
|
|
|
67
81
|
@SuppressWarnings("deprecation")
|
|
@@ -81,6 +95,7 @@ public class StatusBar {
|
|
|
81
95
|
// recover the previous color of the status bar
|
|
82
96
|
activity.getWindow().setStatusBarColor(currentStatusBarColor);
|
|
83
97
|
}
|
|
98
|
+
listener.onChange(statusBarOverlayChanged, getInfo());
|
|
84
99
|
}
|
|
85
100
|
|
|
86
101
|
@SuppressWarnings("deprecation")
|
|
@@ -130,4 +145,8 @@ public class StatusBar {
|
|
|
130
145
|
// Fallback if the insets are not available
|
|
131
146
|
return 0;
|
|
132
147
|
}
|
|
148
|
+
|
|
149
|
+
public interface ChangeListener {
|
|
150
|
+
void onChange(String eventName, StatusBarInfo info);
|
|
151
|
+
}
|
|
133
152
|
}
|
|
@@ -12,15 +12,12 @@ import java.util.Locale;
|
|
|
12
12
|
@CapacitorPlugin(name = "StatusBar")
|
|
13
13
|
public class StatusBarPlugin extends Plugin {
|
|
14
14
|
|
|
15
|
-
public static final String statusBarVisibilityChanged = "statusBarVisibilityChanged";
|
|
16
|
-
public static final String statusBarOverlayChanged = "statusBarOverlayChanged";
|
|
17
|
-
|
|
18
15
|
private StatusBar implementation;
|
|
19
16
|
|
|
20
17
|
@Override
|
|
21
18
|
public void load() {
|
|
22
19
|
StatusBarConfig config = getStatusBarConfig();
|
|
23
|
-
implementation = new StatusBar(getActivity(), config);
|
|
20
|
+
implementation = new StatusBar(getActivity(), config, (eventName, info) -> notifyListeners(eventName, toJSObject(info), true));
|
|
24
21
|
}
|
|
25
22
|
|
|
26
23
|
private StatusBarConfig getStatusBarConfig() {
|
|
@@ -98,8 +95,6 @@ public class StatusBarPlugin extends Plugin {
|
|
|
98
95
|
.executeOnMainThread(
|
|
99
96
|
() -> {
|
|
100
97
|
implementation.hide();
|
|
101
|
-
StatusBarInfo info = implementation.getInfo();
|
|
102
|
-
notifyListeners(statusBarVisibilityChanged, toJSObject(info));
|
|
103
98
|
call.resolve();
|
|
104
99
|
}
|
|
105
100
|
);
|
|
@@ -112,8 +107,6 @@ public class StatusBarPlugin extends Plugin {
|
|
|
112
107
|
.executeOnMainThread(
|
|
113
108
|
() -> {
|
|
114
109
|
implementation.show();
|
|
115
|
-
StatusBarInfo info = implementation.getInfo();
|
|
116
|
-
notifyListeners(statusBarVisibilityChanged, toJSObject(info));
|
|
117
110
|
call.resolve();
|
|
118
111
|
}
|
|
119
112
|
);
|
|
@@ -127,13 +120,11 @@ public class StatusBarPlugin extends Plugin {
|
|
|
127
120
|
|
|
128
121
|
@PluginMethod
|
|
129
122
|
public void setOverlaysWebView(final PluginCall call) {
|
|
130
|
-
final Boolean
|
|
123
|
+
final Boolean overlay = call.getBoolean("overlay", true);
|
|
131
124
|
getBridge()
|
|
132
125
|
.executeOnMainThread(
|
|
133
126
|
() -> {
|
|
134
|
-
implementation.setOverlaysWebView(
|
|
135
|
-
StatusBarInfo info = implementation.getInfo();
|
|
136
|
-
notifyListeners(statusBarOverlayChanged, toJSObject(info));
|
|
127
|
+
implementation.setOverlaysWebView(overlay);
|
|
137
128
|
call.resolve();
|
|
138
129
|
}
|
|
139
130
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/status-bar",
|
|
3
|
-
"version": "7.0.0-nightly-
|
|
3
|
+
"version": "7.0.0-nightly-20241127T150538.0",
|
|
4
4
|
"description": "The StatusBar API Provides methods for configuring the style of the Status Bar, along with showing or hiding it.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "af2317f75f72d80308fac83ae65b7196cca98371"
|
|
85
85
|
}
|