@capgo/capacitor-navigation-bar 8.0.3 → 8.0.5

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,7 +15,7 @@ import java.util.Locale;
15
15
  @CapacitorPlugin(name = "NavigationBar")
16
16
  public class CapgoNavigationBarPlugin extends Plugin {
17
17
 
18
- private final String pluginVersion = "8.0.3";
18
+ private final String pluginVersion = "8.0.5";
19
19
 
20
20
  @PluginMethod
21
21
  public void setNavigationBarColor(PluginCall call) {
@@ -29,45 +29,40 @@ public class CapgoNavigationBarPlugin extends Plugin {
29
29
 
30
30
  getBridge().executeOnMainThread(() -> {
31
31
  try {
32
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
33
- if ("transparent".equalsIgnoreCase(color)) {
34
- int flags = getActivity().getWindow().getDecorView().getSystemUiVisibility();
35
- flags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
36
- getActivity().getWindow().getDecorView().setSystemUiVisibility(flags);
37
- getActivity().getWindow().setNavigationBarColor(Color.TRANSPARENT);
38
- } else {
39
- final int parsedColor = WebColor.parseColor(color);
40
- View decor = getActivity().getWindow().getDecorView();
41
- int flags = decor.getSystemUiVisibility();
42
- flags &= ~View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION & ~View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
43
- decor.setSystemUiVisibility(flags);
44
- getActivity().getWindow().setNavigationBarColor(parsedColor);
45
- }
32
+ if ("transparent".equalsIgnoreCase(color)) {
33
+ int flags = getActivity().getWindow().getDecorView().getSystemUiVisibility();
34
+ flags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
35
+ getActivity().getWindow().getDecorView().setSystemUiVisibility(flags);
36
+ getActivity().getWindow().setNavigationBarColor(Color.TRANSPARENT);
37
+ } else {
38
+ final int parsedColor = WebColor.parseColor(color);
39
+ View decor = getActivity().getWindow().getDecorView();
40
+ int flags = decor.getSystemUiVisibility();
41
+ flags &= ~View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION & ~View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
42
+ decor.setSystemUiVisibility(flags);
43
+ getActivity().getWindow().setNavigationBarColor(parsedColor);
44
+ }
46
45
 
47
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
48
- WindowInsetsController insetsController = getActivity().getWindow().getInsetsController();
49
- if (insetsController != null) {
50
- if (darkButtons) {
51
- insetsController.setSystemBarsAppearance(
52
- WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS,
53
- WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
54
- );
55
- } else {
56
- insetsController.setSystemBarsAppearance(0, WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS);
57
- }
58
- }
59
- } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
60
- int flags = getActivity().getWindow().getDecorView().getSystemUiVisibility();
46
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
47
+ WindowInsetsController insetsController = getActivity().getWindow().getInsetsController();
48
+ if (insetsController != null) {
61
49
  if (darkButtons) {
62
- flags |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
50
+ insetsController.setSystemBarsAppearance(
51
+ WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS,
52
+ WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
53
+ );
63
54
  } else {
64
- flags &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
55
+ insetsController.setSystemBarsAppearance(0, WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS);
65
56
  }
66
- getActivity().getWindow().getDecorView().setSystemUiVisibility(flags);
67
57
  }
68
- } else {
69
- call.reject("Navigation bar color customization is not supported on this Android version.");
70
- return;
58
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
59
+ int flags = getActivity().getWindow().getDecorView().getSystemUiVisibility();
60
+ if (darkButtons) {
61
+ flags |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
62
+ } else {
63
+ flags &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
64
+ }
65
+ getActivity().getWindow().getDecorView().setSystemUiVisibility(flags);
71
66
  }
72
67
  call.resolve();
73
68
  } catch (IllegalArgumentException ex) {
@@ -81,34 +76,28 @@ public class CapgoNavigationBarPlugin extends Plugin {
81
76
  getBridge().executeOnMainThread(() -> {
82
77
  try {
83
78
  JSObject ret = new JSObject();
84
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
85
- int intColor = getActivity().getWindow().getNavigationBarColor();
86
- String hexColor = String.format("#%06X", (0xFFFFFF & intColor));
87
- ret.put("color", hexColor);
79
+ int intColor = getActivity().getWindow().getNavigationBarColor();
80
+ String hexColor = String.format("#%06X", (0xFFFFFF & intColor));
81
+ ret.put("color", hexColor);
88
82
 
89
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
90
- WindowInsetsController insetsController = getActivity().getWindow().getInsetsController();
91
- if (insetsController != null) {
92
- int appearance = insetsController.getSystemBarsAppearance();
93
- boolean isLight = (appearance & WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS) != 0;
94
- ret.put("darkButtons", !isLight);
95
- } else {
96
- ret.put("darkButtons", true);
97
- }
98
- } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
99
- int flags = getActivity().getWindow().getDecorView().getSystemUiVisibility();
100
- boolean isLight = (flags & View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR) != 0;
83
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
84
+ WindowInsetsController insetsController = getActivity().getWindow().getInsetsController();
85
+ if (insetsController != null) {
86
+ int appearance = insetsController.getSystemBarsAppearance();
87
+ boolean isLight = (appearance & WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS) != 0;
101
88
  ret.put("darkButtons", !isLight);
102
89
  } else {
103
90
  ret.put("darkButtons", true);
104
91
  }
105
-
106
- call.resolve(ret);
92
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
93
+ int flags = getActivity().getWindow().getDecorView().getSystemUiVisibility();
94
+ boolean isLight = (flags & View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR) != 0;
95
+ ret.put("darkButtons", !isLight);
107
96
  } else {
108
- ret.put("color", "#000000");
109
97
  ret.put("darkButtons", true);
110
- call.resolve(ret);
111
98
  }
99
+
100
+ call.resolve(ret);
112
101
  } catch (Exception ex) {
113
102
  call.reject("Failed to get navigation bar color or button style", ex);
114
103
  }
@@ -7,7 +7,7 @@ import Capacitor
7
7
  */
8
8
  @objc(CapgoNavigationBarPlugin)
9
9
  public class CapgoNavigationBarPlugin: CAPPlugin, CAPBridgedPlugin {
10
- private let pluginVersion: String = "8.0.3"
10
+ private let pluginVersion: String = "8.0.5"
11
11
  public let identifier = "CapgoNavigationBarPlugin"
12
12
  public let jsName = "NavigationBar"
13
13
  public let pluginMethods: [CAPPluginMethod] = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-navigation-bar",
3
- "version": "8.0.3",
3
+ "version": "8.0.5",
4
4
  "description": "Capacitor plugin Set navigation bar color for android lollipop and higher",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",