@capacitor/status-bar 4.0.0-nightly-44c040f.0 → 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,25 @@
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
+
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)
18
+
19
+ **Note:** Version bump only for package @capacitor/status-bar
20
+
21
+
22
+
23
+
24
+
6
25
  # 4.0.0-beta.0 (2022-06-27)
7
26
 
8
27
 
@@ -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 final String logTag = "Capacitor-StatusBar";
16
- private int currentStatusbarColor;
17
- private AppCompatActivity activity;
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.currentStatusbarColor = activity.getWindow().getStatusBarColor();
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 = ViewCompat.getWindowInsetsController(decorView);
36
- if (windowInsetsControllerCompat != null) {
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
- currentStatusbarColor = color;
45
+ currentStatusBarColor = color;
51
46
  }
52
47
 
53
48
  public void hide() {
54
49
  View decorView = activity.getWindow().getDecorView();
55
- WindowInsetsControllerCompat windowInsetsControllerCompat = ViewCompat.getWindowInsetsController(decorView);
56
- if (windowInsetsControllerCompat != null) {
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 = ViewCompat.getWindowInsetsController(decorView);
66
- if (windowInsetsControllerCompat != null) {
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 webview is displayed behind it.
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
- currentStatusbarColor = activity.getWindow().getStatusBarColor();
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 webview below the status bar.
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(currentStatusbarColor);
75
+ activity.getWindow().setStatusBarColor(currentStatusBarColor);
89
76
  }
90
77
  }
91
78
 
92
79
  @SuppressWarnings("deprecation")
93
- private boolean getIsOverlayed() {
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(getIsOverlayed());
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 = ViewCompat.getWindowInsetsController(decorView);
116
- if (windowInsetsControllerCompat != null) {
117
- if (windowInsetsControllerCompat.isAppearanceLightStatusBars()) {
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-nightly-44c040f.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": "44c040f725a76414eaf5d922ffd64aa9d0c32ec6"
82
+ "gitHead": "27bd016fc57850ae151ae06017bb1e9ee0d62975"
83
83
  }