@capawesome/capacitor-android-edge-to-edge-support 7.2.1 → 7.2.3

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
@@ -1,11 +1,17 @@
1
1
  # @capawesome/capacitor-android-edge-to-edge-support
2
2
 
3
- Capacitor plugin to support [edge-to-edge](https://developer.android.com/develop/ui/views/layout/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 with advanced features like setting the background color of the status bar and navigation bar.
4
4
 
5
5
  | Before | After | Before | After |
6
6
  | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
7
7
  | <image src="https://github.com/user-attachments/assets/1c42aa63-1191-4b9b-860f-ffc47881d815" width="200" /> | <image src="https://github.com/user-attachments/assets/a4df4e58-0c21-45b5-aadd-ca197308016a" width="200" /> | <image src="https://github.com/user-attachments/assets/22c94f95-a0c4-4ace-8a3b-3a0feabf9191" width="200" /> | <image src="https://github.com/user-attachments/assets/21ece022-fb74-4067-889b-6922ecd0e2a5" width="200" /> |
8
8
 
9
+ <div class="capawesome-z29o10a">
10
+ <a href="https://cloud.capawesome.io/" target="_blank">
11
+ <img alt="Deliver Live Updates to your Capacitor app with Capawesome Cloud" src="https://cloud.capawesome.io/assets/banners/cloud-deploy-real-time-app-updates.png?t=1" />
12
+ </a>
13
+ </div>
14
+
9
15
  ## Installation
10
16
 
11
17
  ```bash
@@ -50,7 +50,9 @@ public class EdgeToEdge {
50
50
  // Set insets
51
51
  WindowInsetsCompat currentInsets = ViewCompat.getRootWindowInsets(view);
52
52
  if (currentInsets != null) {
53
- Insets systemBarsInsets = currentInsets.getInsets(WindowInsetsCompat.Type.systemBars());
53
+ Insets systemBarsInsets = currentInsets.getInsets(
54
+ WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout()
55
+ );
54
56
  Insets imeInsets = currentInsets.getInsets(WindowInsetsCompat.Type.ime());
55
57
  boolean keyboardVisible = currentInsets.isVisible(WindowInsetsCompat.Type.ime());
56
58
 
@@ -66,7 +68,9 @@ public class EdgeToEdge {
66
68
  // Set listener
67
69
  ViewCompat.setOnApplyWindowInsetsListener(view, (v, windowInsets) -> {
68
70
  // Retrieve system bars insets (for status/navigation bars)
69
- Insets systemBarsInsets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
71
+ Insets systemBarsInsets = windowInsets.getInsets(
72
+ WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout()
73
+ );
70
74
  // Retrieve keyboard (IME) insets
71
75
  Insets imeInsets = windowInsets.getInsets(WindowInsetsCompat.Type.ime());
72
76
  boolean keyboardVisible = windowInsets.isVisible(WindowInsetsCompat.Type.ime());
@@ -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
- implementation.enable();
31
- call.resolve();
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
- implementation.disable();
40
- call.resolve();
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
- ViewGroup.MarginLayoutParams insets = implementation.getInsets();
47
- JSObject result = new JSObject();
48
- result.put("bottom", insets.bottomMargin);
49
- result.put("left", insets.leftMargin);
50
- result.put("right", insets.rightMargin);
51
- result.put("top", insets.topMargin);
52
- call.resolve(result);
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
@@ -61,17 +73,25 @@ public class EdgeToEdgePlugin extends Plugin {
61
73
  }
62
74
  getActivity()
63
75
  .runOnUiThread(() -> {
64
- implementation.setBackgroundColor(color);
65
- call.resolve();
76
+ try {
77
+ implementation.setBackgroundColor(color);
78
+ call.resolve();
79
+ } catch (Exception exception) {
80
+ call.reject(exception.getMessage());
81
+ }
66
82
  });
67
83
  }
68
84
 
69
85
  private EdgeToEdgeConfig getEdgeToEdgeConfig() {
70
86
  EdgeToEdgeConfig config = new EdgeToEdgeConfig();
71
87
 
72
- String backgroundColor = getConfig().getString("backgroundColor");
73
- if (backgroundColor != null) {
74
- config.setBackgroundColor(Color.parseColor(backgroundColor));
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);
75
95
  }
76
96
  return config;
77
97
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capawesome/capacitor-android-edge-to-edge-support",
3
- "version": "7.2.1",
3
+ "version": "7.2.3",
4
4
  "description": "Capacitor plugin to support edge-to-edge display on Android.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",