@capawesome/capacitor-android-edge-to-edge-support 7.0.0 → 7.1.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/README.md +44 -1
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidedgetoedgesupport/EdgeToEdge.java +20 -3
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidedgetoedgesupport/EdgeToEdgeConfig.java +16 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidedgetoedgesupport/EdgeToEdgePlugin.java +13 -1
- package/dist/docs.json +25 -1
- package/dist/esm/definitions.d.ts +13 -0
- package/dist/esm/definitions.js +1 -0
- package/dist/esm/definitions.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @capawesome/capacitor-android-edge-to-edge-support
|
|
2
2
|
|
|
3
|
-
Capacitor plugin to support edge-to-edge display on Android.
|
|
3
|
+
Capacitor plugin to support [edge-to-edge](https://developer.android.com/develop/ui/views/layout/edge-to-edge) display on Android.
|
|
4
4
|
|
|
5
5
|
| Before | After | Before | After |
|
|
6
6
|
| ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
|
|
@@ -13,6 +13,49 @@ npm install @capawesome/capacitor-android-edge-to-edge-support
|
|
|
13
13
|
npx cap sync
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
## Configuration
|
|
17
|
+
|
|
18
|
+
<docgen-config>
|
|
19
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
20
|
+
|
|
21
|
+
| Prop | Type | Description | Since |
|
|
22
|
+
| --------------------- | ------------------- | ------------------------------------------------------------------------------------------ | ----- |
|
|
23
|
+
| **`backgroundColor`** | <code>string</code> | The hexadecimal color to set as the background color of the status bar and navigation bar. | 7.1.0 |
|
|
24
|
+
|
|
25
|
+
### Examples
|
|
26
|
+
|
|
27
|
+
In `capacitor.config.json`:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"plugins": {
|
|
32
|
+
"EdgeToEdge": {
|
|
33
|
+
"backgroundColor": "#ffffff"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
In `capacitor.config.ts`:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
/// <reference types="@capawesome/capacitor-android-edge-to-edge-support" />
|
|
43
|
+
|
|
44
|
+
import { CapacitorConfig } from '@capacitor/cli';
|
|
45
|
+
|
|
46
|
+
const config: CapacitorConfig = {
|
|
47
|
+
plugins: {
|
|
48
|
+
EdgeToEdge: {
|
|
49
|
+
backgroundColor: "#ffffff",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default config;
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
</docgen-config>
|
|
58
|
+
|
|
16
59
|
## Usage
|
|
17
60
|
|
|
18
61
|
The plugin **only needs to be installed**. It applies insets to the web view to support edge-to-edge display on Android. The plugin also provides a method to set the background color of the status bar and navigation bar. It's recommended to use this method in combination with the [Status Bar](https://capacitorjs.com/docs/apis/status-bar) plugin.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package io.capawesome.capacitorjs.plugins.androidedgetoedgesupport;
|
|
2
2
|
|
|
3
3
|
import android.graphics.Color;
|
|
4
|
+
import android.os.Build;
|
|
4
5
|
import android.view.View;
|
|
5
6
|
import android.view.ViewGroup;
|
|
6
7
|
import androidx.annotation.NonNull;
|
|
@@ -10,10 +11,14 @@ import androidx.core.view.WindowInsetsCompat;
|
|
|
10
11
|
|
|
11
12
|
public class EdgeToEdge {
|
|
12
13
|
|
|
14
|
+
@NonNull
|
|
15
|
+
private final EdgeToEdgeConfig config;
|
|
16
|
+
|
|
13
17
|
@NonNull
|
|
14
18
|
private final EdgeToEdgePlugin plugin;
|
|
15
19
|
|
|
16
|
-
public EdgeToEdge(@NonNull EdgeToEdgePlugin plugin) {
|
|
20
|
+
public EdgeToEdge(@NonNull EdgeToEdgePlugin plugin, @NonNull EdgeToEdgeConfig config) {
|
|
21
|
+
this.config = config;
|
|
17
22
|
this.plugin = plugin;
|
|
18
23
|
// Apply insets to disable the edge-to-edge feature
|
|
19
24
|
applyInsets();
|
|
@@ -38,12 +43,24 @@ public class EdgeToEdge {
|
|
|
38
43
|
// Get parent view
|
|
39
44
|
ViewGroup parent = (ViewGroup) view.getParent();
|
|
40
45
|
// Set background color to black
|
|
41
|
-
parent.setBackgroundColor(
|
|
46
|
+
parent.setBackgroundColor(this.config.getBackgroundColor());
|
|
42
47
|
// Apply insets to disable the edge-to-edge feature
|
|
43
48
|
ViewCompat.setOnApplyWindowInsetsListener(view, (v, windowInsets) -> {
|
|
44
49
|
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
|
|
50
|
+
Boolean keyboardVisible = windowInsets.isVisible(WindowInsetsCompat.Type.ime());
|
|
51
|
+
|
|
45
52
|
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
|
|
46
|
-
|
|
53
|
+
|
|
54
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
|
55
|
+
if (keyboardVisible) {
|
|
56
|
+
mlp.bottomMargin = 0;
|
|
57
|
+
} else {
|
|
58
|
+
mlp.bottomMargin = insets.bottom;
|
|
59
|
+
}
|
|
60
|
+
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
61
|
+
mlp.bottomMargin = insets.bottom;
|
|
62
|
+
}
|
|
63
|
+
|
|
47
64
|
mlp.leftMargin = insets.left;
|
|
48
65
|
mlp.rightMargin = insets.right;
|
|
49
66
|
mlp.topMargin = insets.top;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.androidedgetoedgesupport;
|
|
2
|
+
|
|
3
|
+
import android.graphics.Color;
|
|
4
|
+
|
|
5
|
+
public class EdgeToEdgeConfig {
|
|
6
|
+
|
|
7
|
+
private int backgroundColor = Color.WHITE;
|
|
8
|
+
|
|
9
|
+
public int getBackgroundColor() {
|
|
10
|
+
return this.backgroundColor;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public void setBackgroundColor(int backgroundColor) {
|
|
14
|
+
this.backgroundColor = backgroundColor;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package io.capawesome.capacitorjs.plugins.androidedgetoedgesupport;
|
|
2
2
|
|
|
3
|
+
import android.graphics.Color;
|
|
3
4
|
import androidx.annotation.Nullable;
|
|
4
5
|
import com.getcapacitor.Plugin;
|
|
5
6
|
import com.getcapacitor.PluginCall;
|
|
@@ -17,7 +18,8 @@ public class EdgeToEdgePlugin extends Plugin {
|
|
|
17
18
|
|
|
18
19
|
@Override
|
|
19
20
|
public void load() {
|
|
20
|
-
|
|
21
|
+
EdgeToEdgeConfig config = getEdgeToEdgeConfig();
|
|
22
|
+
implementation = new EdgeToEdge(this, config);
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
@PluginMethod
|
|
@@ -30,4 +32,14 @@ public class EdgeToEdgePlugin extends Plugin {
|
|
|
30
32
|
implementation.setBackgroundColor(color);
|
|
31
33
|
call.resolve();
|
|
32
34
|
}
|
|
35
|
+
|
|
36
|
+
private EdgeToEdgeConfig getEdgeToEdgeConfig() {
|
|
37
|
+
EdgeToEdgeConfig config = new EdgeToEdgeConfig();
|
|
38
|
+
|
|
39
|
+
String backgroundColor = getConfig().getString("backgroundColor");
|
|
40
|
+
if (backgroundColor != null) {
|
|
41
|
+
config.setBackgroundColor(Color.parseColor(backgroundColor));
|
|
42
|
+
}
|
|
43
|
+
return config;
|
|
44
|
+
}
|
|
33
45
|
}
|
package/dist/docs.json
CHANGED
|
@@ -69,5 +69,29 @@
|
|
|
69
69
|
],
|
|
70
70
|
"enums": [],
|
|
71
71
|
"typeAliases": [],
|
|
72
|
-
"pluginConfigs": [
|
|
72
|
+
"pluginConfigs": [
|
|
73
|
+
{
|
|
74
|
+
"name": "EdgeToEdge",
|
|
75
|
+
"slug": "edgetoedge",
|
|
76
|
+
"properties": [
|
|
77
|
+
{
|
|
78
|
+
"name": "backgroundColor",
|
|
79
|
+
"tags": [
|
|
80
|
+
{
|
|
81
|
+
"text": "7.1.0",
|
|
82
|
+
"name": "since"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"text": "\"#ffffff\"",
|
|
86
|
+
"name": "example"
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
"docs": "The hexadecimal color to set as the background color of the status bar and navigation bar.",
|
|
90
|
+
"complexTypes": [],
|
|
91
|
+
"type": "string | undefined"
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
"docs": ""
|
|
95
|
+
}
|
|
96
|
+
]
|
|
73
97
|
}
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
declare module '@capacitor/cli' {
|
|
2
|
+
interface PluginsConfig {
|
|
3
|
+
EdgeToEdge?: {
|
|
4
|
+
/**
|
|
5
|
+
* The hexadecimal color to set as the background color of the status bar and navigation bar.
|
|
6
|
+
*
|
|
7
|
+
* @since 7.1.0
|
|
8
|
+
* @example "#ffffff"
|
|
9
|
+
*/
|
|
10
|
+
backgroundColor?: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
1
14
|
export interface EdgeToEdgePlugin {
|
|
2
15
|
/**
|
|
3
16
|
* Set the background color of the status bar and navigation bar.
|
package/dist/esm/definitions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface EdgeToEdgePlugin {\n /**\n * Set the background color of the status bar and navigation bar.\n *\n * Only available on Android.\n *\n * @since 7.0.0\n */\n setBackgroundColor(options: SetBackgroundColorOptions): Promise<void>;\n}\n\n/**\n * @since 7.0.0\n */\nexport interface SetBackgroundColorOptions {\n /**\n * The hexadecimal color to set as the background color of the status bar and navigation bar.\n *\n * @since 7.0.0\n * @example \"#ffffff\"\n * @example \"#000000\"\n */\n color: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n EdgeToEdge?: {\n /**\n * The hexadecimal color to set as the background color of the status bar and navigation bar.\n *\n * @since 7.1.0\n * @example \"#ffffff\"\n */\n backgroundColor?: string;\n };\n }\n}\n\nexport interface EdgeToEdgePlugin {\n /**\n * Set the background color of the status bar and navigation bar.\n *\n * Only available on Android.\n *\n * @since 7.0.0\n */\n setBackgroundColor(options: SetBackgroundColorOptions): Promise<void>;\n}\n\n/**\n * @since 7.0.0\n */\nexport interface SetBackgroundColorOptions {\n /**\n * The hexadecimal color to set as the background color of the status bar and navigation bar.\n *\n * @since 7.0.0\n * @example \"#ffffff\"\n * @example \"#000000\"\n */\n color: string;\n}\n"]}
|
package/package.json
CHANGED