Skip to content

Commit

Permalink
Merge pull request #282 from proyecto26/develop
Browse files Browse the repository at this point in the history
Release 3.6.2
  • Loading branch information
jdnichollsc committed Jul 4, 2021
2 parents 05364d3 + 214b111 commit ac8b4a2
Show file tree
Hide file tree
Showing 36 changed files with 696 additions and 1,258 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ in case of vulnerabilities.

## [Unreleased]

## [3.6.2] - 2021-07-03

### Fixed
- Fix `Build failed. Error cannot find symbol builder.setNavigationBarColor` error for Android Support by [@reberthkss](https://github.com/reberthkss) and [@jdnichollsc](https://github.com/jdnichollsc) ([#281](https://github.com/proyecto26/react-native-inappbrowser/pull/281)).

## [3.6.1] - 2021-06-27

### Added
Expand Down Expand Up @@ -192,7 +197,8 @@ Missing tags for previous versions 🤷‍♂
- Fix `EventBusException` on **Android** by [@Almouro](https://github.com/Almouro) ([9cf4cbb](https://github.com/proyecto26/react-native-inappbrowser/commit/9cf4cbb58d55c8b534dabac6791e6a2a5428253f)).


[Unreleased]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.6.1...HEAD
[Unreleased]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.6.2...HEAD
[3.6.2]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.6.1...v3.6.2
[3.6.1]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.6.0...v3.6.1
[3.6.0]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.5.1...v3.6.0
[3.5.1]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.5.0...v3.5.1
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ Linking the package manually is not required anymore with [Autolinking](https://
compileSdkVersion = 28
targetSdkVersion = 28
// Remove 'supportLibVersion' property and put specific versions for AndroidX libraries
androidXAnnotation = "1.1.0"
androidXBrowser = "1.0.0"
androidXAnnotation = "1.2.0"
androidXBrowser = "1.3.0"
// Put here other AndroidX dependencies
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.regex.Pattern;
import java.util.List;
Expand Down Expand Up @@ -62,6 +63,25 @@ public class RNInAppBrowser {
private Activity currentActivity;
private static final Pattern animationIdentifierPattern = Pattern.compile("^.+:.+/");

public Integer setColor(CustomTabsIntent.Builder builder, final ReadableMap options, String key, String method, String colorName) {
String colorString = options.getString(key);
Integer color = null;
try {
if (colorString != null) {
color = Color.parseColor(colorString);
Method findMethod = builder.getClass().getDeclaredMethod(method, int.class);
findMethod.invoke(builder, color);
}
} catch (Exception e) {
if (e instanceof IllegalArgumentException) {
throw new JSApplicationIllegalArgumentException(
"Invalid " + colorName + " color '" + colorString + "': " + e.getMessage());
}
} finally {
return color;
}
}

public void open(Context context, final ReadableMap options, final Promise promise, Activity activity) {
final String url = options.getString("url");
currentActivity = activity;
Expand All @@ -82,43 +102,14 @@ public void open(Context context, final ReadableMap options, final Promise promi

CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
isLightTheme = false;
if (options.hasKey(KEY_TOOLBAR_COLOR)) {
final String colorString = options.getString(KEY_TOOLBAR_COLOR);
try {
builder.setToolbarColor(Color.parseColor(colorString));
isLightTheme = toolbarIsLight(colorString);
} catch (IllegalArgumentException e) {
throw new JSApplicationIllegalArgumentException(
"Invalid toolbar color '" + colorString + "': " + e.getMessage());
}
}
if (options.hasKey(KEY_SECONDARY_TOOLBAR_COLOR)) {
final String colorString = options.getString(KEY_SECONDARY_TOOLBAR_COLOR);
try {
builder.setSecondaryToolbarColor(Color.parseColor(colorString));
} catch (IllegalArgumentException e) {
throw new JSApplicationIllegalArgumentException(
"Invalid secondary toolbar color '" + colorString + "': " + e.getMessage());
}
}
if (options.hasKey(KEY_NAVIGATION_BAR_COLOR)) {
final String colorString = options.getString(KEY_NAVIGATION_BAR_COLOR);
try {
builder.setNavigationBarColor(Color.parseColor(colorString));
} catch (IllegalArgumentException e) {
throw new JSApplicationIllegalArgumentException(
"Invalid navigation bar color '" + colorString + "': " + e.getMessage());
}
}
if (options.hasKey(KEY_NAVIGATION_BAR_DIVIDER_COLOR)) {
final String colorString = options.getString(KEY_NAVIGATION_BAR_DIVIDER_COLOR);
try {
builder.setNavigationBarDividerColor(Color.parseColor(colorString));
} catch (IllegalArgumentException e) {
throw new JSApplicationIllegalArgumentException(
"Invalid navigation bar divider color '" + colorString + "': " + e.getMessage());
}
final Integer toolbarColor = setColor(builder, options, KEY_TOOLBAR_COLOR, "setToolbarColor", "toolbar");
if (toolbarColor != null) {
isLightTheme = toolbarIsLight(toolbarColor);
}
setColor(builder, options, KEY_SECONDARY_TOOLBAR_COLOR, "setSecondaryToolbarColor", "secondary toolbar");
setColor(builder, options, KEY_NAVIGATION_BAR_COLOR, "setNavigationBarColor", "navigation bar");
setColor(builder, options, KEY_NAVIGATION_BAR_DIVIDER_COLOR, "setNavigationBarDividerColor", "navigation bar divider");

if (options.hasKey(KEY_DEFAULT_SHARE_MENU_ITEM) &&
options.getBoolean(KEY_DEFAULT_SHARE_MENU_ITEM)) {
builder.addDefaultShareMenuItem();
Expand Down Expand Up @@ -235,7 +226,7 @@ public void onEvent(ChromeTabsDismissedEvent event) {
unRegisterEventBus();

if (mOpenBrowserPromise == null) {
throw new AssertionError();
return;
}

if (event.isError) {
Expand Down Expand Up @@ -292,8 +283,8 @@ private void unRegisterEventBus() {
}
}

private Boolean toolbarIsLight(String themeColor) {
return ColorUtils.calculateLuminance(Color.parseColor(themeColor)) > 0.5;
private Boolean toolbarIsLight(int themeColor) {
return ColorUtils.calculateLuminance(themeColor) > 0.5;
}

private List<ResolveInfo> getPreferredPackages(Context context) {
Expand Down
14 changes: 3 additions & 11 deletions example/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
; Ignore polyfills
node_modules/react-native/Libraries/polyfills/.*

; These should not be required directly
; require from fbjs/lib instead: require('fbjs/lib/warning')
node_modules/warning/.*

; Flow doesn't support platforms
.*/Libraries/Utilities/LoadingView.js

Expand All @@ -30,6 +26,8 @@ emoji=true
esproposal.optional_chaining=enable
esproposal.nullish_coalescing=enable

exact_by_default=true

module.file_ext=.js
module.file_ext=.json
module.file_ext=.ios.js
Expand All @@ -44,10 +42,6 @@ suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

[lints]
sketchy-null-number=warn
sketchy-null-mixed=warn
Expand All @@ -56,10 +50,8 @@ untyped-type-import=warn
nonstrict-import=warn
deprecated-type=warn
unsafe-getters-setters=warn
inexact-spread=warn
unnecessary-invariant=warn
signature-verification-failure=warn
deprecated-utility=error

[strict]
deprecated-type
Expand All @@ -71,4 +63,4 @@ untyped-import
untyped-type-import

[version]
^0.113.0
^0.137.0
4 changes: 3 additions & 1 deletion example/.gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*.pbxproj -text
# Windows files should use crlf line endings
# https://help.github.com/articles/dealing-with-line-endings/
*.bat text eol=crlf
2 changes: 0 additions & 2 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,3 @@ buck-out/

# CocoaPods
/ios/Pods/

yarn.lock
1 change: 1 addition & 0 deletions example/.prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ module.exports = {
jsxBracketSameLine: true,
singleQuote: true,
trailingComma: 'all',
arrowParens: 'avoid',
};

0 comments on commit ac8b4a2

Please sign in to comment.