Skip to content

Commit 974a966

Browse files
committed
Merge branch 'master' into develop
# Conflicts: # package.json # yarn.lock
2 parents bb2b1fc + 6ebc3e7 commit 974a966

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+4849
-4006
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extends": "@react-native-community",
33
"rules": {
4-
"comma-dangle": ["error", {
4+
"comma-dangle": ["error", "always-multiline", {
55
"arrays": "never",
66
"objects": "never",
77
"imports": "never",

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ in case of vulnerabilities.
2222

2323
## [Unreleased]
2424

25+
## [3.4.0] - 2020-04-08
26+
27+
### Added
28+
- Added `ephemeralWebSession` option to supports `ephemeralWebBrowserSession` on iOS 13 by [@avenner](https://github.com/avenner) ([#141](https://github.com/proyecto26/react-native-inappbrowser/pull/141)).
29+
- Add `@ReactModule` annotation by [@janicduplessis](https://github.com/janicduplessis) ([#94](https://github.com/proyecto26/react-native-inappbrowser/pull/94)).
30+
31+
### Fixed
32+
- Remove listener of `openAuth` when `closeAuth` is called.
33+
2534
## [3.3.4] - 2020-01-07
2635

2736
### Fixed
@@ -145,7 +154,8 @@ Missing tags for previous versions 🤷‍♂
145154
- Fix `EventBusException` on **Android** by [@Almouro](https://github.com/Almouro) ([9cf4cbb](https://github.com/proyecto26/react-native-inappbrowser/commit/9cf4cbb58d55c8b534dabac6791e6a2a5428253f)).
146155

147156

148-
[Unreleased]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.3.4...HEAD
157+
[Unreleased]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.4.0...HEAD
158+
[3.4.0]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.3.4...v3.4.0
149159
[3.3.4]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.3.3...v3.3.4
150160
[3.3.3]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.3.2...v3.3.3
151161
[3.3.2]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.3.1...v3.3.2

README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,13 @@ Property | Description
144144
`modalTransitionStyle` (String) | The transition style to use when presenting the view controller. [`coverVertical`/`flipHorizontal`/`crossDissolve`/`partialCurl`]
145145
`modalEnabled` (Boolean) | Present the **SafariViewController** modally or as push instead. [`true`/`false`]
146146
`enableBarCollapsing` (Boolean) | Determines whether the browser's tool bars will collapse or not. [`true`/`false`]
147+
`ephemeralWebSession` (Boolean) | Prevent re-use cookies of previous session (openAuth only) [`true`/`false`]
147148
148149
### Android Options
149150
Property | Description
150151
-------------- | ------
151152
`showTitle` (Boolean) | Sets whether the title should be shown in the custom tab. [`true`/`false`]
153+
`hasBackButton` (Boolean) | Sets a back arrow instead of the default X icon to close the custom tab. [`true`/`false`]
152154
`toolbarColor` (String) | Sets the toolbar color. [`gray`/`#808080`]
153155
`secondaryToolbarColor` (String) | Sets the color of the secondary toolbar. [`white`/`#FFFFFF`]
154156
`enableUrlBarHiding` (Boolean) | Enables the url bar to hide as the user scrolls down on the page. [`true`/`false`]
@@ -175,7 +177,7 @@ import InAppBrowser from 'react-native-inappbrowser-reborn'
175177
preferredControlTintColor: 'white',
176178
readerMode: false,
177179
animated: true,
178-
modalPresentationStyle: 'overFullScreen',
180+
modalPresentationStyle: 'fullScreen',
179181
modalTransitionStyle: 'partialCurl',
180182
modalEnabled: true,
181183
enableBarCollapsing: false,
@@ -295,14 +297,16 @@ import { getDeepLink } from './utilities'
295297
if (await InAppBrowser.isAvailable()) {
296298
InAppBrowser.openAuth(url, deepLink, {
297299
// iOS Properties
298-
dismissButtonStyle: 'cancel',
300+
ephemeralWebSession: false,
299301
// Android Properties
300302
showTitle: false,
301303
enableUrlBarHiding: true,
302-
enableDefaultShare: true
304+
enableDefaultShare: false
303305
}).then((response) => {
304-
if (response.type === 'success' &&
305-
response.url) {
306+
if (
307+
response.type === 'success' &&
308+
response.url
309+
) {
306310
Linking.openURL(response.url)
307311
}
308312
})
@@ -319,7 +323,7 @@ import { getDeepLink } from './utilities'
319323
...
320324
async componentDidMount() {
321325
// Play Lottie Animation :)
322-
326+
323327
// Validate the stored access token (Maybe with a request)
324328
// Redirect the user to the Home page if the token is still valid
325329
// Otherwise redirect to the Login page
@@ -339,7 +343,7 @@ import { getDeepLink } from './utilities'
339343
// Show error and redirect the user to the Login page
340344
}
341345
}
342-
346+
343347
async loadUserInfo() {
344348
const { navigation } = this.props
345349
const { state: { params } } = navigation
@@ -456,7 +460,12 @@ Support this project with your organization. Your logo will show up here with a
456460
## Supporting 🍻
457461
I believe in Unicorns 🦄
458462
Support [me](http://www.paypal.me/jdnichollsc/2), if you do too.
459-
[Professionally supported react-native-inappbrowser-reborn is coming soon](https://tidelift.com/subscription/pkg/npm-react-native-inappbrowser-reborn?utm_source=npm-react-native-inappbrowser-reborn&utm_medium=referral&utm_campaign=readme)
463+
464+
## Enterprise 💼
465+
466+
Available as part of the Tidelift Subscription.
467+
468+
The maintainers of InAppBrowser for React Native and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-react-native-inappbrowser-reborn?utm_source=npm-react-native-inappbrowser-reborn&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
460469

461470
## Security contact information 🚨
462471
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.

android/src/main/java/com/proyecto26/inappbrowser/RNInAppBrowser.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
import android.app.Activity;
77
import android.content.Context;
88
import android.content.Intent;
9+
import android.content.pm.ResolveInfo;
910
import android.graphics.Color;
11+
import android.graphics.BitmapFactory;
1012
import android.provider.Browser;
1113
import androidx.annotation.Nullable;
1214
import androidx.browser.customtabs.CustomTabsIntent;
15+
import androidx.core.graphics.ColorUtils;
1316

1417
import com.facebook.react.bridge.Arguments;
1518
import com.facebook.react.bridge.Promise;
@@ -23,6 +26,7 @@
2326
import org.greenrobot.eventbus.Subscribe;
2427

2528
import java.util.regex.Pattern;
29+
import java.util.List;
2630

2731
public class RNInAppBrowser {
2832
private final static String ERROR_CODE = "InAppBrowser";
@@ -38,8 +42,10 @@ public class RNInAppBrowser {
3842
private static final String KEY_ANIMATION_START_EXIT = "startExit";
3943
private static final String KEY_ANIMATION_END_ENTER = "endEnter";
4044
private static final String KEY_ANIMATION_END_EXIT = "endExit";
45+
private static final String HASBACKBUTTON = "hasBackButton";
4146

4247
private @Nullable Promise mOpenBrowserPromise;
48+
private Boolean isLightTheme;
4349
private Activity currentActivity;
4450
private static final Pattern animationIdentifierPattern = Pattern.compile("^.+:.+/");
4551

@@ -66,6 +72,7 @@ public void open(Context context, final ReadableMap options, final Promise promi
6672
final String colorString = options.getString(KEY_TOOLBAR_COLOR);
6773
try {
6874
builder.setToolbarColor(Color.parseColor(colorString));
75+
isLightTheme = toolbarIsLight(colorString);
6976
} catch (IllegalArgumentException e) {
7077
throw new JSApplicationIllegalArgumentException(
7178
"Invalid toolbar color '" + colorString + "': " + e.getMessage());
@@ -92,6 +99,11 @@ public void open(Context context, final ReadableMap options, final Promise promi
9299
final ReadableMap animations = options.getMap(KEY_ANIMATIONS);
93100
applyAnimation(context, builder, animations);
94101
}
102+
if (options.hasKey(HASBACKBUTTON) &&
103+
options.getBoolean(HASBACKBUTTON)) {
104+
builder.setCloseButtonIcon(BitmapFactory.decodeResource(
105+
context.getResources(), isLightTheme ? R.drawable.ic_arrow_back_black : R.drawable.ic_arrow_back_white));
106+
}
95107

96108
CustomTabsIntent customTabsIntent = builder.build();
97109

@@ -162,6 +174,12 @@ public void close() {
162174
ChromeTabsManagerActivity.createDismissIntent(currentActivity));
163175
}
164176

177+
public void isAvailable(Context context, final Promise promise) {
178+
Intent serviceIntent = new Intent("android.support.customtabs.action.CustomTabsService");
179+
List<ResolveInfo> resolveInfos = context.getPackageManager().queryIntentServices(serviceIntent, 0);
180+
promise.resolve(!(resolveInfos == null || resolveInfos.isEmpty()));
181+
}
182+
165183
@Subscribe
166184
public void onEvent(ChromeTabsDismissedEvent event) {
167185
unRegisterEventBus();
@@ -218,4 +236,8 @@ private void unRegisterEventBus() {
218236
EventBus.getDefault().unregister(this);
219237
}
220238
}
239+
240+
private Boolean toolbarIsLight(String themeColor) {
241+
return ColorUtils.calculateLuminance(Color.parseColor(themeColor)) > 0.5;
242+
}
221243
}

android/src/main/java/com/proyecto26/inappbrowser/RNInAppBrowserModule.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77
import com.facebook.react.bridge.ReactContextBaseJavaModule;
88
import com.facebook.react.bridge.ReactMethod;
99
import com.facebook.react.bridge.ReadableMap;
10+
import com.facebook.react.module.annotations.ReactModule;
1011

12+
@ReactModule(name = RNInAppBrowserModule.NAME)
1113
public class RNInAppBrowserModule extends ReactContextBaseJavaModule {
14+
public final static String NAME = "RNInAppBrowser";
15+
1216
private final RNInAppBrowser inAppBrowser;
1317
private final ReactApplicationContext reactContext;
1418

@@ -20,7 +24,7 @@ public RNInAppBrowserModule(ReactApplicationContext reactContext) {
2024

2125
@Override
2226
public String getName() {
23-
return "RNInAppBrowser";
27+
return NAME;
2428
}
2529

2630
@ReactMethod
@@ -33,4 +37,9 @@ public void open(final ReadableMap options, final Promise promise) {
3337
public void close() {
3438
inAppBrowser.close();
3539
}
36-
}
40+
41+
@ReactMethod
42+
public void isAvailable(final Promise promise) {
43+
inAppBrowser.isAvailable(this.reactContext, promise);
44+
}
45+
}
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

example/.eslintrc.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11
module.exports = {
22
root: true,
33
extends: '@react-native-community',
4-
rules: {
5-
"comma-dangle": ["error", {
6-
"arrays": "never",
7-
"objects": "never",
8-
"imports": "never",
9-
"exports": "never",
10-
"functions": "never"
11-
}],
12-
"prettier/prettier": ["error", {
13-
"endOfLine": "auto",
14-
"singleQuote": true
15-
}]
16-
}
174
};

example/.flowconfig

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
; Ignore "BUCK" generated dirs
66
<PROJECT_ROOT>/\.buckd/
77

8-
; Ignore unexpected extra "@providesModule"
9-
.*/node_modules/.*/node_modules/fbjs/.*
10-
11-
; Ignore duplicate module providers
12-
; For RN Apps installed via npm, "Libraries" folder is inside
13-
; "node_modules/react-native" but in the source repo it is in the root
14-
node_modules/react-native/Libraries/react-native/React.js
15-
168
; Ignore polyfills
179
node_modules/react-native/Libraries/polyfills/.*
1810

@@ -21,15 +13,15 @@ node_modules/react-native/Libraries/polyfills/.*
2113
node_modules/warning/.*
2214

2315
; Flow doesn't support platforms
24-
.*/Libraries/Utilities/HMRLoadingView.js
16+
.*/Libraries/Utilities/LoadingView.js
2517

2618
[untyped]
2719
.*/node_modules/@react-native-community/cli/.*/.*
2820

2921
[include]
3022

3123
[libs]
32-
node_modules/react-native/Libraries/react-native/react-native-interface.js
24+
node_modules/react-native/interface.js
3325
node_modules/react-native/flow/
3426

3527
[options]
@@ -42,27 +34,10 @@ module.file_ext=.js
4234
module.file_ext=.json
4335
module.file_ext=.ios.js
4436

45-
module.system=haste
46-
module.system.haste.use_name_reducers=true
47-
# get basename
48-
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
49-
# strip .js or .js.flow suffix
50-
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
51-
# strip .ios suffix
52-
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
53-
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
54-
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
55-
module.system.haste.paths.blacklist=.*/__tests__/.*
56-
module.system.haste.paths.blacklist=.*/__mocks__/.*
57-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
58-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/RNTester/.*
59-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/IntegrationTests/.*
60-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation.js
61-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
62-
6337
munge_underscores=true
6438

65-
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
39+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
40+
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
6641

6742
suppress_type=$FlowIssue
6843
suppress_type=$FlowFixMe
@@ -96,4 +71,4 @@ untyped-import
9671
untyped-type-import
9772

9873
[version]
99-
^0.98.0
74+
^0.113.0

example/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ DerivedData
2020
*.hmap
2121
*.ipa
2222
*.xcuserstate
23-
project.xcworkspace
2423

2524
# Android/IntelliJ
2625
#
@@ -40,6 +39,7 @@ yarn-error.log
4039
buck-out/
4140
\.buckd/
4241
*.keystore
42+
!debug.keystore
4343

4444
# fastlane
4545
#

example/.prettierrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
bracketSpacing: false,
3+
jsxBracketSameLine: true,
4+
singleQuote: true,
5+
trailingComma: 'all',
6+
};

0 commit comments

Comments
 (0)