@capacitor/status-bar 4.0.0-beta.2 → 4.0.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.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [4.0.0](https://github.com/ionic-team/capacitor-plugins/compare/4.0.0-beta.2...4.0.0) (2022-07-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **status-bar:** not working on older devices ([#1078](https://github.com/ionic-team/capacitor-plugins/issues/1078)) ([4e34977](https://github.com/ionic-team/capacitor-plugins/commit/4e349772d3d8f8e30ce52c1831a1dc9a9f9fd408))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [4.0.0-beta.2](https://github.com/ionic-team/capacitor-plugins/compare/4.0.0-beta.0...4.0.0-beta.2) (2022-07-08)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @capacitor/status-bar
|
|
@@ -6,21 +6,20 @@ import android.view.Window;
|
|
|
6
6
|
import android.view.WindowManager;
|
|
7
7
|
import androidx.appcompat.app.AppCompatActivity;
|
|
8
8
|
import androidx.core.view.ViewCompat;
|
|
9
|
+
import androidx.core.view.WindowCompat;
|
|
9
10
|
import androidx.core.view.WindowInsetsCompat;
|
|
10
11
|
import androidx.core.view.WindowInsetsControllerCompat;
|
|
11
|
-
import com.getcapacitor.Logger;
|
|
12
12
|
|
|
13
13
|
public class StatusBar {
|
|
14
14
|
|
|
15
|
-
private
|
|
16
|
-
private
|
|
17
|
-
private
|
|
18
|
-
private String defaultStyle;
|
|
15
|
+
private int currentStatusBarColor;
|
|
16
|
+
private final AppCompatActivity activity;
|
|
17
|
+
private final String defaultStyle;
|
|
19
18
|
|
|
20
19
|
public StatusBar(AppCompatActivity activity) {
|
|
21
20
|
// save initial color of the status bar
|
|
22
21
|
this.activity = activity;
|
|
23
|
-
this.
|
|
22
|
+
this.currentStatusBarColor = activity.getWindow().getStatusBarColor();
|
|
24
23
|
this.defaultStyle = getStyle();
|
|
25
24
|
}
|
|
26
25
|
|
|
@@ -32,12 +31,8 @@ public class StatusBar {
|
|
|
32
31
|
style = this.defaultStyle;
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
WindowInsetsControllerCompat windowInsetsControllerCompat =
|
|
36
|
-
|
|
37
|
-
windowInsetsControllerCompat.setAppearanceLightStatusBars(!style.equals("DARK"));
|
|
38
|
-
} else {
|
|
39
|
-
Logger.warn(logTag, "Could not get a WindowInsetsControllerCompat instance. Can not set status bar style.");
|
|
40
|
-
}
|
|
34
|
+
WindowInsetsControllerCompat windowInsetsControllerCompat = WindowCompat.getInsetsController(window, decorView);
|
|
35
|
+
windowInsetsControllerCompat.setAppearanceLightStatusBars(!style.equals("DARK"));
|
|
41
36
|
}
|
|
42
37
|
|
|
43
38
|
@SuppressWarnings("deprecation")
|
|
@@ -47,27 +42,19 @@ public class StatusBar {
|
|
|
47
42
|
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
|
48
43
|
window.setStatusBarColor(color);
|
|
49
44
|
// update the local color field as well
|
|
50
|
-
|
|
45
|
+
currentStatusBarColor = color;
|
|
51
46
|
}
|
|
52
47
|
|
|
53
48
|
public void hide() {
|
|
54
49
|
View decorView = activity.getWindow().getDecorView();
|
|
55
|
-
WindowInsetsControllerCompat windowInsetsControllerCompat =
|
|
56
|
-
|
|
57
|
-
windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.statusBars());
|
|
58
|
-
} else {
|
|
59
|
-
Logger.warn(logTag, "Could not get a WindowInsetsControllerCompat instance. Can not hide the status bar.");
|
|
60
|
-
}
|
|
50
|
+
WindowInsetsControllerCompat windowInsetsControllerCompat = WindowCompat.getInsetsController(activity.getWindow(), decorView);
|
|
51
|
+
windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.statusBars());
|
|
61
52
|
}
|
|
62
53
|
|
|
63
54
|
public void show() {
|
|
64
55
|
View decorView = activity.getWindow().getDecorView();
|
|
65
|
-
WindowInsetsControllerCompat windowInsetsControllerCompat =
|
|
66
|
-
|
|
67
|
-
windowInsetsControllerCompat.show(WindowInsetsCompat.Type.statusBars());
|
|
68
|
-
} else {
|
|
69
|
-
Logger.warn(logTag, "Could not get a WindowInsetsControllerCompat instance. Can not show the status bar.");
|
|
70
|
-
}
|
|
56
|
+
WindowInsetsControllerCompat windowInsetsControllerCompat = WindowCompat.getInsetsController(activity.getWindow(), decorView);
|
|
57
|
+
windowInsetsControllerCompat.show(WindowInsetsCompat.Type.statusBars());
|
|
71
58
|
}
|
|
72
59
|
|
|
73
60
|
@SuppressWarnings("deprecation")
|
|
@@ -75,22 +62,22 @@ public class StatusBar {
|
|
|
75
62
|
View decorView = activity.getWindow().getDecorView();
|
|
76
63
|
int uiOptions = decorView.getSystemUiVisibility();
|
|
77
64
|
if (overlays) {
|
|
78
|
-
// Sets the layout to a fullscreen one that does not hide the actual status bar, so the
|
|
65
|
+
// Sets the layout to a fullscreen one that does not hide the actual status bar, so the WebView is displayed behind it.
|
|
79
66
|
uiOptions = uiOptions | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
|
|
80
67
|
decorView.setSystemUiVisibility(uiOptions);
|
|
81
|
-
|
|
68
|
+
currentStatusBarColor = activity.getWindow().getStatusBarColor();
|
|
82
69
|
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
|
|
83
70
|
} else {
|
|
84
|
-
// Sets the layout to a normal one that displays the
|
|
71
|
+
// Sets the layout to a normal one that displays the WebView below the status bar.
|
|
85
72
|
uiOptions = uiOptions & ~View.SYSTEM_UI_FLAG_LAYOUT_STABLE & ~View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
|
|
86
73
|
decorView.setSystemUiVisibility(uiOptions);
|
|
87
74
|
// recover the previous color of the status bar
|
|
88
|
-
activity.getWindow().setStatusBarColor(
|
|
75
|
+
activity.getWindow().setStatusBarColor(currentStatusBarColor);
|
|
89
76
|
}
|
|
90
77
|
}
|
|
91
78
|
|
|
92
79
|
@SuppressWarnings("deprecation")
|
|
93
|
-
private boolean
|
|
80
|
+
private boolean getIsOverlaid() {
|
|
94
81
|
return (
|
|
95
82
|
(activity.getWindow().getDecorView().getSystemUiVisibility() & View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) ==
|
|
96
83
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
|
@@ -103,7 +90,7 @@ public class StatusBar {
|
|
|
103
90
|
boolean isVisible = windowInsetsCompat != null && windowInsetsCompat.isVisible(WindowInsetsCompat.Type.statusBars());
|
|
104
91
|
StatusBarInfo info = new StatusBarInfo();
|
|
105
92
|
info.setStyle(getStyle());
|
|
106
|
-
info.setOverlays(
|
|
93
|
+
info.setOverlays(getIsOverlaid());
|
|
107
94
|
info.setVisible(isVisible);
|
|
108
95
|
info.setColor(String.format("#%06X", (0xFFFFFF & window.getStatusBarColor())));
|
|
109
96
|
return info;
|
|
@@ -112,15 +99,9 @@ public class StatusBar {
|
|
|
112
99
|
private String getStyle() {
|
|
113
100
|
View decorView = activity.getWindow().getDecorView();
|
|
114
101
|
String style = "DARK";
|
|
115
|
-
WindowInsetsControllerCompat windowInsetsControllerCompat =
|
|
116
|
-
if (windowInsetsControllerCompat
|
|
117
|
-
|
|
118
|
-
style = "LIGHT";
|
|
119
|
-
} else {
|
|
120
|
-
style = "DARK";
|
|
121
|
-
}
|
|
122
|
-
} else {
|
|
123
|
-
Logger.warn(logTag, "Could not get a WindowInsetsControllerCompat instance. Can not get the status bar appearance.");
|
|
102
|
+
WindowInsetsControllerCompat windowInsetsControllerCompat = WindowCompat.getInsetsController(activity.getWindow(), decorView);
|
|
103
|
+
if (windowInsetsControllerCompat.isAppearanceLightStatusBars()) {
|
|
104
|
+
style = "LIGHT";
|
|
124
105
|
}
|
|
125
106
|
return style;
|
|
126
107
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/status-bar",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.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",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"publishConfig": {
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "27bd016fc57850ae151ae06017bb1e9ee0d62975"
|
|
83
83
|
}
|