@capawesome/capacitor-android-edge-to-edge-support 7.2.0 → 7.2.2
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/README.md
CHANGED
|
@@ -80,6 +80,19 @@ The plugin **only needs to be installed**. It applies insets to the web view to
|
|
|
80
80
|
import { EdgeToEdge } from '@capawesome/capacitor-android-edge-to-edge-support';
|
|
81
81
|
import { StatusBar, Style } from '@capacitor/status-bar';
|
|
82
82
|
|
|
83
|
+
const enable = async () => {
|
|
84
|
+
await EdgeToEdge.enable();
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const disable = async () => {
|
|
88
|
+
await EdgeToEdge.disable();
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const getInsets = async () => {
|
|
92
|
+
const result = await EdgeToEdge.getInsets();
|
|
93
|
+
console.log('Insets:', result);
|
|
94
|
+
};
|
|
95
|
+
|
|
83
96
|
const setBackgroundColor = async () => {
|
|
84
97
|
await EdgeToEdge.setBackgroundColor({ color: '#ffffff' });
|
|
85
98
|
await StatusBar.setStyle({ style: Style.Light });
|
|
@@ -2,8 +2,8 @@ package io.capawesome.capacitorjs.plugins.androidedgetoedgesupport;
|
|
|
2
2
|
|
|
3
3
|
import android.graphics.Color;
|
|
4
4
|
import android.view.ViewGroup;
|
|
5
|
-
import androidx.annotation.Nullable;
|
|
6
5
|
import com.getcapacitor.JSObject;
|
|
6
|
+
import com.getcapacitor.Logger;
|
|
7
7
|
import com.getcapacitor.Plugin;
|
|
8
8
|
import com.getcapacitor.PluginCall;
|
|
9
9
|
import com.getcapacitor.PluginMethod;
|
|
@@ -27,8 +27,12 @@ public class EdgeToEdgePlugin extends Plugin {
|
|
|
27
27
|
public void enable(PluginCall call) {
|
|
28
28
|
getActivity()
|
|
29
29
|
.runOnUiThread(() -> {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
try {
|
|
31
|
+
implementation.enable();
|
|
32
|
+
call.resolve();
|
|
33
|
+
} catch (Exception exception) {
|
|
34
|
+
call.reject(exception.getMessage());
|
|
35
|
+
}
|
|
32
36
|
});
|
|
33
37
|
}
|
|
34
38
|
|
|
@@ -36,20 +40,28 @@ public class EdgeToEdgePlugin extends Plugin {
|
|
|
36
40
|
public void disable(PluginCall call) {
|
|
37
41
|
getActivity()
|
|
38
42
|
.runOnUiThread(() -> {
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
try {
|
|
44
|
+
implementation.disable();
|
|
45
|
+
call.resolve();
|
|
46
|
+
} catch (Exception exception) {
|
|
47
|
+
call.reject(exception.getMessage());
|
|
48
|
+
}
|
|
41
49
|
});
|
|
42
50
|
}
|
|
43
51
|
|
|
44
52
|
@PluginMethod
|
|
45
53
|
public void getInsets(PluginCall call) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
try {
|
|
55
|
+
ViewGroup.MarginLayoutParams insets = implementation.getInsets();
|
|
56
|
+
JSObject result = new JSObject();
|
|
57
|
+
result.put("bottom", insets.bottomMargin);
|
|
58
|
+
result.put("left", insets.leftMargin);
|
|
59
|
+
result.put("right", insets.rightMargin);
|
|
60
|
+
result.put("top", insets.topMargin);
|
|
61
|
+
call.resolve(result);
|
|
62
|
+
} catch (Exception exception) {
|
|
63
|
+
call.reject(exception.getMessage());
|
|
64
|
+
}
|
|
53
65
|
}
|
|
54
66
|
|
|
55
67
|
@PluginMethod
|
|
@@ -59,16 +71,27 @@ public class EdgeToEdgePlugin extends Plugin {
|
|
|
59
71
|
call.reject(ERROR_COLOR_MISSING);
|
|
60
72
|
return;
|
|
61
73
|
}
|
|
62
|
-
|
|
63
|
-
|
|
74
|
+
getActivity()
|
|
75
|
+
.runOnUiThread(() -> {
|
|
76
|
+
try {
|
|
77
|
+
implementation.setBackgroundColor(color);
|
|
78
|
+
call.resolve();
|
|
79
|
+
} catch (Exception exception) {
|
|
80
|
+
call.reject(exception.getMessage());
|
|
81
|
+
}
|
|
82
|
+
});
|
|
64
83
|
}
|
|
65
84
|
|
|
66
85
|
private EdgeToEdgeConfig getEdgeToEdgeConfig() {
|
|
67
86
|
EdgeToEdgeConfig config = new EdgeToEdgeConfig();
|
|
68
87
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
88
|
+
try {
|
|
89
|
+
String backgroundColor = getConfig().getString("backgroundColor");
|
|
90
|
+
if (backgroundColor != null) {
|
|
91
|
+
config.setBackgroundColor(Color.parseColor(backgroundColor));
|
|
92
|
+
}
|
|
93
|
+
} catch (Exception exception) {
|
|
94
|
+
Logger.error(TAG, "Set config failed.", exception);
|
|
72
95
|
}
|
|
73
96
|
return config;
|
|
74
97
|
}
|
package/package.json
CHANGED