Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
IT-MikeS authored Jan 30, 2024
2 parents de2ed04 + 5cc0e65 commit 6e68f11
Show file tree
Hide file tree
Showing 42 changed files with 243 additions and 162 deletions.
2 changes: 1 addition & 1 deletion action-sheet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"devDependencies": {
"@capacitor/android": "next",
"@capacitor/core": "next",
"@capacitor/docgen": "0.2.0",
"@capacitor/docgen": "0.2.2",
"@capacitor/ios": "next",
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "~1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion app-launcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"devDependencies": {
"@capacitor/android": "next",
"@capacitor/core": "next",
"@capacitor/docgen": "0.2.0",
"@capacitor/docgen": "0.2.2",
"@capacitor/ios": "next",
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "~1.0.1",
Expand Down
12 changes: 6 additions & 6 deletions app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ const checkAppLaunchUrl = async () => {
* [`getState()`](#getstate)
* [`getLaunchUrl()`](#getlaunchurl)
* [`minimizeApp()`](#minimizeapp)
* [`addListener('appStateChange', ...)`](#addlistenerappstatechange)
* [`addListener('pause', ...)`](#addlistenerpause)
* [`addListener('resume', ...)`](#addlistenerresume)
* [`addListener('appUrlOpen', ...)`](#addlistenerappurlopen)
* [`addListener('appRestoredResult', ...)`](#addlistenerapprestoredresult)
* [`addListener('backButton', ...)`](#addlistenerbackbutton)
* [`addListener('appStateChange', ...)`](#addlistenerappstatechange-)
* [`addListener('pause', ...)`](#addlistenerpause-)
* [`addListener('resume', ...)`](#addlistenerresume-)
* [`addListener('appUrlOpen', ...)`](#addlistenerappurlopen-)
* [`addListener('appRestoredResult', ...)`](#addlistenerapprestoredresult-)
* [`addListener('backButton', ...)`](#addlistenerbackbutton-)
* [`removeAllListeners()`](#removealllisteners)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"devDependencies": {
"@capacitor/android": "next",
"@capacitor/core": "next",
"@capacitor/docgen": "0.2.0",
"@capacitor/docgen": "0.2.2",
"@capacitor/ios": "next",
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "~1.0.1",
Expand Down
4 changes: 2 additions & 2 deletions browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const openCapacitorSite = async () => {

* [`open(...)`](#open)
* [`close()`](#close)
* [`addListener('browserFinished', ...)`](#addlistenerbrowserfinished)
* [`addListener('browserPageLoaded', ...)`](#addlistenerbrowserpageloaded)
* [`addListener('browserFinished', ...)`](#addlistenerbrowserfinished-)
* [`addListener('browserPageLoaded', ...)`](#addlistenerbrowserpageloaded-)
* [`removeAllListeners()`](#removealllisteners)
* [Interfaces](#interfaces)

Expand Down
6 changes: 6 additions & 0 deletions browser/android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<activity android:name=".BrowserControllerActivity"
android:exported="false"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:launchMode="singleTask"/>
</application>
<queries>
<intent>
<action android:name="android.support.customtabs.action.CustomTabsService" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.capacitorjs.plugins.browser;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import androidx.annotation.Nullable;

public class BrowserControllerActivity extends Activity {

private boolean isCustomTabsOpen = false;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
isCustomTabsOpen = false;

if (BrowserPlugin.browserControllerListener != null) {
BrowserPlugin.browserControllerListener.onControllerReady(this);
}
}

@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (intent.hasExtra("close")) {
finish();
}
}

@Override
protected void onResume() {
super.onResume();
if (isCustomTabsOpen) {
isCustomTabsOpen = false;
finish();
} else {
isCustomTabsOpen = true;
}
}

public void open(Browser implementation, Uri url, Integer toolbarColor) {
implementation.open(url, toolbarColor);
}

@Override
protected void onDestroy() {
super.onDestroy();
isCustomTabsOpen = false;
BrowserPlugin.setBrowserControllerListener(null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.capacitorjs.plugins.browser;

public interface BrowserControllerListener {
void onControllerReady(BrowserControllerActivity activity);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.capacitorjs.plugins.browser;

import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import com.getcapacitor.Logger;
import com.getcapacitor.Plugin;
Expand All @@ -14,6 +15,16 @@ public class BrowserPlugin extends Plugin {

private Browser implementation;

public static BrowserControllerListener browserControllerListener;
private static BrowserControllerActivity browserControllerActivityInstance;

public static void setBrowserControllerListener(BrowserControllerListener listener) {
browserControllerListener = listener;
if (listener == null) {
browserControllerActivityInstance = null;
}
}

public void load() {
implementation = new Browser(getContext());
implementation.setBrowserEventListener(this::onBrowserEvent);
Expand Down Expand Up @@ -50,18 +61,35 @@ public void open(PluginCall call) {

// open the browser and finish
try {
implementation.open(url, toolbarColor);
Intent intent = new Intent(getContext(), BrowserControllerActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getContext().startActivity(intent);

Integer finalToolbarColor = toolbarColor;
setBrowserControllerListener(
activity -> {
activity.open(implementation, url, finalToolbarColor);
browserControllerActivityInstance = activity;
call.resolve();
}
);
} catch (ActivityNotFoundException ex) {
Logger.error(getLogTag(), ex.getLocalizedMessage(), null);
call.reject("Unable to display URL");
return;
}
call.resolve();
}

@PluginMethod
public void close(PluginCall call) {
call.unimplemented();
if (browserControllerActivityInstance != null) {
browserControllerActivityInstance = null;
Intent intent = new Intent(getContext(), BrowserControllerActivity.class);
intent.putExtra("close", true);
getContext().startActivity(intent);
}
call.resolve();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"devDependencies": {
"@capacitor/android": "next",
"@capacitor/core": "next",
"@capacitor/docgen": "0.2.0",
"@capacitor/docgen": "0.2.2",
"@capacitor/ios": "next",
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "~1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion camera/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"devDependencies": {
"@capacitor/android": "next",
"@capacitor/core": "next",
"@capacitor/docgen": "0.2.0",
"@capacitor/docgen": "0.2.2",
"@capacitor/ios": "next",
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "~1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion clipboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"devDependencies": {
"@capacitor/android": "next",
"@capacitor/core": "next",
"@capacitor/docgen": "0.2.0",
"@capacitor/docgen": "0.2.2",
"@capacitor/ios": "next",
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "~1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion device/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"devDependencies": {
"@capacitor/android": "next",
"@capacitor/core": "next",
"@capacitor/docgen": "0.2.0",
"@capacitor/docgen": "0.2.2",
"@capacitor/ios": "next",
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "~1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion dialog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"devDependencies": {
"@capacitor/android": "next",
"@capacitor/core": "next",
"@capacitor/docgen": "0.2.0",
"@capacitor/docgen": "0.2.2",
"@capacitor/ios": "next",
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "~1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion filesystem/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const readFilePath = async () => {
* [`checkPermissions()`](#checkpermissions)
* [`requestPermissions()`](#requestpermissions)
* [`downloadFile(...)`](#downloadfile)
* [`addListener('progress', ...)`](#addlistenerprogress)
* [`addListener('progress', ...)`](#addlistenerprogress-)
* [`removeAllListeners()`](#removealllisteners)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)
Expand Down
2 changes: 1 addition & 1 deletion filesystem/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"devDependencies": {
"@capacitor/android": "next",
"@capacitor/core": "next",
"@capacitor/docgen": "0.2.0",
"@capacitor/docgen": "0.2.2",
"@capacitor/ios": "next",
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "~1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion geolocation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"devDependencies": {
"@capacitor/android": "next",
"@capacitor/core": "next",
"@capacitor/docgen": "0.2.0",
"@capacitor/docgen": "0.2.2",
"@capacitor/ios": "next",
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "~1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion google-maps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"devDependencies": {
"@capacitor/android": "next",
"@capacitor/core": "next",
"@capacitor/docgen": "0.2.0",
"@capacitor/docgen": "0.2.2",
"@capacitor/ios": "next",
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion haptics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"devDependencies": {
"@capacitor/android": "next",
"@capacitor/core": "next",
"@capacitor/docgen": "0.2.0",
"@capacitor/docgen": "0.2.2",
"@capacitor/ios": "next",
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "~1.0.1",
Expand Down
8 changes: 4 additions & 4 deletions keyboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ the following events also work with `window.addEventListener`:
* [`setStyle(...)`](#setstyle)
* [`setResizeMode(...)`](#setresizemode)
* [`getResizeMode()`](#getresizemode)
* [`addListener('keyboardWillShow', ...)`](#addlistenerkeyboardwillshow)
* [`addListener('keyboardDidShow', ...)`](#addlistenerkeyboarddidshow)
* [`addListener('keyboardWillHide', ...)`](#addlistenerkeyboardwillhide)
* [`addListener('keyboardDidHide', ...)`](#addlistenerkeyboarddidhide)
* [`addListener('keyboardWillShow', ...)`](#addlistenerkeyboardwillshow-)
* [`addListener('keyboardDidShow', ...)`](#addlistenerkeyboarddidshow-)
* [`addListener('keyboardWillHide', ...)`](#addlistenerkeyboardwillhide-)
* [`addListener('keyboardDidHide', ...)`](#addlistenerkeyboarddidhide-)
* [`removeAllListeners()`](#removealllisteners)
* [Interfaces](#interfaces)
* [Enums](#enums)
Expand Down
Loading

0 comments on commit 6e68f11

Please sign in to comment.