Skip to content

Commit

Permalink
Merge branch 'main' into fix/browser-dismiss-when-finished
Browse files Browse the repository at this point in the history
  • Loading branch information
OS-martacarlos authored Sep 9, 2024
2 parents c2ec0fe + c61d011 commit b599109
Show file tree
Hide file tree
Showing 37 changed files with 571 additions and 119 deletions.
2 changes: 1 addition & 1 deletion action-sheet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/action-sheet",
"version": "6.0.2",
"version": "7.0.0-alpha.0",
"description": "The Action Sheet API provides access to native Action Sheets, which come up from the bottom of the screen and display actions a user can take.",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion app-launcher/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/app-launcher",
"version": "6.0.2",
"version": "7.0.0-alpha.0",
"description": "The AppLauncher API allows to open other apps",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/app",
"version": "6.0.1",
"version": "7.0.0-alpha.0",
"description": "The App API handles high level App state and events.For example, this API emits events when the app enters and leaves the foreground, handles deeplinks, opens other apps, and manages persisted plugin state.",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion browser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/browser",
"version": "6.0.2",
"version": "7.0.0-alpha.0",
"description": "The Browser API provides the ability to open an in-app browser and subscribe to browser events.",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion camera/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/camera",
"version": "6.0.2",
"version": "7.0.0-alpha.0",
"description": "The Camera API provides the ability to take a photo with the camera or choose an existing one from the photo album.",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion clipboard/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/clipboard",
"version": "6.0.1",
"version": "7.0.0-alpha.0",
"description": "The Clipboard API enables copy and pasting to/from the system clipboard.",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion device/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/device",
"version": "6.0.1",
"version": "7.0.0-alpha.0",
"description": "The Device API exposes internal information about the device, such as the model and operating system version, along with user information such as unique ids.",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion dialog/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/dialog",
"version": "6.0.1",
"version": "7.0.0-alpha.0",
"description": "The Dialog API provides methods for triggering native dialog windows for alerts, confirmations, and input prompts",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion filesystem/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/filesystem",
"version": "6.0.1",
"version": "7.0.0-alpha.0",
"description": "The Filesystem API provides a NodeJS-like API for working with files on the device.",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion geolocation/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/geolocation",
"version": "6.0.1",
"version": "7.0.0-alpha.0",
"description": "The Geolocation API provides simple methods for getting and tracking the current position of the device using GPS, along with altitude, heading, and speed information if available.",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion haptics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/haptics",
"version": "6.0.1",
"version": "7.0.0-alpha.0",
"description": "The Haptics API provides physical feedback to the user through touch or vibration.",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion keyboard/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/keyboard",
"version": "6.0.2",
"version": "7.0.0-alpha.0",
"description": "The Keyboard API provides keyboard display and visibility control, along with event tracking when the keyboard shows and hides.",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion local-notifications/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/local-notifications",
"version": "6.1.0",
"version": "7.0.0-alpha.0",
"description": "The Local Notifications API provides a way to schedule device notifications locally (i.e. without a server sending push notifications).",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion motion/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/motion",
"version": "6.0.1",
"version": "7.0.0-alpha.0",
"description": "The Motion API tracks accelerometer and device orientation (compass heading, etc.)",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion network/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/network",
"version": "6.0.2",
"version": "7.0.0-alpha.0",
"description": "The Network API provides network and connectivity information.",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion preferences/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/preferences",
"version": "6.0.2",
"version": "7.0.0-alpha.0",
"description": "The Preferences API provides a simple key/value persistent store for lightweight data.",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion push-notifications/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/push-notifications",
"version": "6.0.2",
"version": "7.0.0-alpha.0",
"description": "The Push Notifications API provides access to native push notifications.",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion screen-orientation/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/screen-orientation",
"version": "6.0.2",
"version": "7.0.0-alpha.0",
"description": "The Screen Orientation API provides methods to lock and unlock the screen orientation.",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion screen-reader/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/screen-reader",
"version": "6.0.2",
"version": "7.0.0-alpha.0",
"description": "The Screen Reader API provides access to TalkBack/VoiceOver/etc. and provides simple text-to-speech capabilities for visual accessibility.",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion share/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/share",
"version": "6.0.2",
"version": "7.0.0-alpha.0",
"description": "The Share API provides methods for sharing content in any sharing-enabled apps the user may have installed.",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion splash-screen/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capacitor/splash-screen",
"version": "6.0.2",
"version": "7.0.0-alpha.0",
"description": "The Splash Screen API provides methods for showing or hiding a Splash image.",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
78 changes: 61 additions & 17 deletions status-bar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ The status bar visibility defaults to visible and the style defaults to
`Style.Default`. You can change these defaults by adding
`UIStatusBarHidden` and/or `UIStatusBarStyle` in `Info.plist`.

`setBackgroundColor` and `setOverlaysWebView` are currently not supported on
iOS devices.

## Example

```typescript
Expand All @@ -33,7 +30,7 @@ window.addEventListener('statusTap', function () {
console.log('statusbar tapped');
});

// Display content under transparent status bar (Android only)
// Display content under transparent status bar
StatusBar.setOverlaysWebView({ overlay: true });

const setStatusBarStyleDark = async () => {
Expand All @@ -53,6 +50,57 @@ const showStatusBar = async () => {
};
```

## Configuration

<docgen-config>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->

These config values are available:

| Prop | Type | Description | Default | Since |
| --------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------- | -------------------- | ----- |
| **`overlaysWebView`** | <code>boolean</code> | Whether the statusbar is overlaid or not. | <code>true</code> | 1.0.0 |
| **`style`** | <code>string</code> | <a href="#style">Style</a> of the text of the status bar. | <code>default</code> | 1.0.0 |
| **`backgroundColor`** | <code>string</code> | Color of the background of the statusbar in hex format, #RRGGBB. Doesn't work if `overlaysWebView` is true. | <code>#000000</code> | 1.0.0 |

### Examples

In `capacitor.config.json`:

```json
{
"plugins": {
"StatusBar": {
"overlaysWebView": false,
"style": "DARK",
"backgroundColor": "#ffffffff"
}
}
}
```

In `capacitor.config.ts`:

```ts
/// <reference types="@capacitor/status-bar" />

import { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
plugins: {
StatusBar: {
overlaysWebView: false,
style: "DARK",
backgroundColor: "#ffffffff",
},
},
};

export default config;
```

</docgen-config>

## API

<docgen-index>
Expand Down Expand Up @@ -96,8 +144,6 @@ setBackgroundColor(options: BackgroundColorOptions) => Promise<void>

Set the background color of the status bar.

This method is only supported on Android.

| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| **`options`** | <code><a href="#backgroundcoloroptions">BackgroundColorOptions</a></code> |
Expand Down Expand Up @@ -169,8 +215,6 @@ setOverlaysWebView(options: SetOverlaysWebViewOptions) => Promise<void>
Set whether or not the status bar should overlay the webview to allow usage
of the space underneath it.

This method is only supported on Android.

| Param | Type |
| ------------- | ------------------------------------------------------------------------------- |
| **`options`** | <code><a href="#setoverlayswebviewoptions">SetOverlaysWebViewOptions</a></code> |
Expand All @@ -192,9 +236,9 @@ This method is only supported on Android.

#### BackgroundColorOptions

| Prop | Type | Description | Since |
| ----------- | ------------------- | ------------------------------------------------------------------------------------------- | ----- |
| **`color`** | <code>string</code> | A hex color to which the status bar color is set. This option is only supported on Android. | 1.0.0 |
| Prop | Type | Description | Since |
| ----------- | ------------------- | ------------------------------------------------- | ----- |
| **`color`** | <code>string</code> | A hex color to which the status bar color is set. | 1.0.0 |


#### AnimationOptions
Expand All @@ -206,12 +250,12 @@ This method is only supported on Android.

#### StatusBarInfo

| Prop | Type | Description | Since |
| -------------- | --------------------------------------- | ----------------------------------------------------------------------------------- | ----- |
| **`visible`** | <code>boolean</code> | Whether the status bar is visible or not. | 1.0.0 |
| **`style`** | <code><a href="#style">Style</a></code> | The current status bar style. | 1.0.0 |
| **`color`** | <code>string</code> | The current status bar color. This option is only supported on Android. | 1.0.0 |
| **`overlays`** | <code>boolean</code> | Whether the statusbar is overlaid or not. This option is only supported on Android. | 1.0.0 |
| Prop | Type | Description | Since |
| -------------- | --------------------------------------- | ----------------------------------------- | ----- |
| **`visible`** | <code>boolean</code> | Whether the status bar is visible or not. | 1.0.0 |
| **`style`** | <code><a href="#style">Style</a></code> | The current status bar style. | 1.0.0 |
| **`color`** | <code>string</code> | The current status bar color. | 1.0.0 |
| **`overlays`** | <code>boolean</code> | Whether the statusbar is overlaid or not. | 1.0.0 |


#### SetOverlaysWebViewOptions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.capacitorjs.plugins.statusbar;

import android.graphics.Color;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
Expand All @@ -16,11 +17,15 @@ public class StatusBar {
private final AppCompatActivity activity;
private final String defaultStyle;

public StatusBar(AppCompatActivity activity) {
public StatusBar(AppCompatActivity activity, StatusBarConfig config) {
// save initial color of the status bar
this.activity = activity;
this.currentStatusBarColor = activity.getWindow().getStatusBarColor();
this.defaultStyle = getStyle();

setBackgroundColor(config.getBackgroundColor());
setStyle(config.getStyle());
setOverlaysWebView(config.isOverlaysWebView());
}

public void setStyle(String style) {
Expand Down Expand Up @@ -93,6 +98,7 @@ public StatusBarInfo getInfo() {
info.setOverlays(getIsOverlaid());
info.setVisible(isVisible);
info.setColor(String.format("#%06X", (0xFFFFFF & window.getStatusBarColor())));
info.setHeight(getStatusBarHeight());
return info;
}

Expand All @@ -105,4 +111,17 @@ private String getStyle() {
}
return style;
}

private int getStatusBarHeight() {
int statusbarHeight = 0;
int resourceId = activity.getApplicationContext().getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
statusbarHeight = (int) activity.getApplicationContext().getResources().getDimension(resourceId);
}

DisplayMetrics metrics = activity.getApplicationContext().getResources().getDisplayMetrics();
float densityDpi = metrics.density;

return (int) (statusbarHeight / densityDpi);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.capacitorjs.plugins.statusbar;

import com.getcapacitor.util.WebColor;

public class StatusBarConfig {

private boolean overlaysWebView = true;
private Integer backgroundColor = WebColor.parseColor("#000000");
private String style = "DEFAULT";

public boolean isOverlaysWebView() {
return overlaysWebView;
}

public void setOverlaysWebView(boolean overlaysWebView) {
this.overlaysWebView = overlaysWebView;
}

public Integer getBackgroundColor() {
return backgroundColor;
}

public void setBackgroundColor(Integer backgroundColor) {
this.backgroundColor = backgroundColor;
}

public String getStyle() {
return style;
}

public void setStyle(String style) {
this.style = style;
}
}
Loading

0 comments on commit b599109

Please sign in to comment.