@capgo/capacitor-navigation-bar 8.0.2 → 8.0.4
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/android/src/main/java/ee/forgr/capacitor_navigation_bar/CapgoNavigationBarPlugin.java
CHANGED
|
@@ -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.
|
|
18
|
+
private final String pluginVersion = "8.0.4";
|
|
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 (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
50
|
+
insetsController.setSystemBarsAppearance(
|
|
51
|
+
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS,
|
|
52
|
+
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
|
|
53
|
+
);
|
|
63
54
|
} else {
|
|
64
|
-
|
|
55
|
+
insetsController.setSystemBarsAppearance(0, WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS);
|
|
65
56
|
}
|
|
66
|
-
getActivity().getWindow().getDecorView().setSystemUiVisibility(flags);
|
|
67
57
|
}
|
|
68
|
-
} else {
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
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.
|
|
10
|
+
private let pluginVersion: String = "8.0.4"
|
|
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
|
+
"version": "8.0.4",
|
|
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",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
42
42
|
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
43
43
|
"eslint": "eslint .",
|
|
44
|
-
"prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
|
|
44
|
+
"prettier": "prettier-pretty-check \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
|
|
45
45
|
"swiftlint": "node-swiftlint",
|
|
46
46
|
"docgen": "docgen --api NavigationBarPlugin --output-readme README.md --output-json dist/docs.json",
|
|
47
47
|
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
@@ -67,7 +67,8 @@
|
|
|
67
67
|
"rimraf": "^6.1.0",
|
|
68
68
|
"rollup": "^4.53.2",
|
|
69
69
|
"swiftlint": "^2.0.0",
|
|
70
|
-
"typescript": "^5.9.3"
|
|
70
|
+
"typescript": "^5.9.3",
|
|
71
|
+
"prettier-pretty-check": "^0.2.0"
|
|
71
72
|
},
|
|
72
73
|
"peerDependencies": {
|
|
73
74
|
"@capacitor/core": ">=8.0.0"
|