Skip to content

Commit ac8b4a2

Browse files
authored
Merge pull request #282 from proyecto26/develop
Release 3.6.2
2 parents 05364d3 + 214b111 commit ac8b4a2

36 files changed

+696
-1258
lines changed

CHANGELOG.md

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

2323
## [Unreleased]
2424

25+
## [3.6.2] - 2021-07-03
26+
27+
### Fixed
28+
- 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)).
29+
2530
## [3.6.1] - 2021-06-27
2631

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

194199

195-
[Unreleased]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.6.1...HEAD
200+
[Unreleased]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.6.2...HEAD
201+
[3.6.2]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.6.1...v3.6.2
196202
[3.6.1]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.6.0...v3.6.1
197203
[3.6.0]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.5.1...v3.6.0
198204
[3.5.1]: https://github.com/proyecto26/react-native-inappbrowser/compare/v3.5.0...v3.5.1

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ Linking the package manually is not required anymore with [Autolinking](https://
8686
compileSdkVersion = 28
8787
targetSdkVersion = 28
8888
// Remove 'supportLibVersion' property and put specific versions for AndroidX libraries
89-
androidXAnnotation = "1.1.0"
90-
androidXBrowser = "1.0.0"
89+
androidXAnnotation = "1.2.0"
90+
androidXBrowser = "1.3.0"
9191
// Put here other AndroidX dependencies
9292
}
9393
```

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

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.greenrobot.eventbus.EventBus;
2828
import org.greenrobot.eventbus.Subscribe;
2929

30+
import java.lang.reflect.Method;
3031
import java.util.Arrays;
3132
import java.util.regex.Pattern;
3233
import java.util.List;
@@ -62,6 +63,25 @@ public class RNInAppBrowser {
6263
private Activity currentActivity;
6364
private static final Pattern animationIdentifierPattern = Pattern.compile("^.+:.+/");
6465

66+
public Integer setColor(CustomTabsIntent.Builder builder, final ReadableMap options, String key, String method, String colorName) {
67+
String colorString = options.getString(key);
68+
Integer color = null;
69+
try {
70+
if (colorString != null) {
71+
color = Color.parseColor(colorString);
72+
Method findMethod = builder.getClass().getDeclaredMethod(method, int.class);
73+
findMethod.invoke(builder, color);
74+
}
75+
} catch (Exception e) {
76+
if (e instanceof IllegalArgumentException) {
77+
throw new JSApplicationIllegalArgumentException(
78+
"Invalid " + colorName + " color '" + colorString + "': " + e.getMessage());
79+
}
80+
} finally {
81+
return color;
82+
}
83+
}
84+
6585
public void open(Context context, final ReadableMap options, final Promise promise, Activity activity) {
6686
final String url = options.getString("url");
6787
currentActivity = activity;
@@ -82,43 +102,14 @@ public void open(Context context, final ReadableMap options, final Promise promi
82102

83103
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
84104
isLightTheme = false;
85-
if (options.hasKey(KEY_TOOLBAR_COLOR)) {
86-
final String colorString = options.getString(KEY_TOOLBAR_COLOR);
87-
try {
88-
builder.setToolbarColor(Color.parseColor(colorString));
89-
isLightTheme = toolbarIsLight(colorString);
90-
} catch (IllegalArgumentException e) {
91-
throw new JSApplicationIllegalArgumentException(
92-
"Invalid toolbar color '" + colorString + "': " + e.getMessage());
93-
}
94-
}
95-
if (options.hasKey(KEY_SECONDARY_TOOLBAR_COLOR)) {
96-
final String colorString = options.getString(KEY_SECONDARY_TOOLBAR_COLOR);
97-
try {
98-
builder.setSecondaryToolbarColor(Color.parseColor(colorString));
99-
} catch (IllegalArgumentException e) {
100-
throw new JSApplicationIllegalArgumentException(
101-
"Invalid secondary toolbar color '" + colorString + "': " + e.getMessage());
102-
}
103-
}
104-
if (options.hasKey(KEY_NAVIGATION_BAR_COLOR)) {
105-
final String colorString = options.getString(KEY_NAVIGATION_BAR_COLOR);
106-
try {
107-
builder.setNavigationBarColor(Color.parseColor(colorString));
108-
} catch (IllegalArgumentException e) {
109-
throw new JSApplicationIllegalArgumentException(
110-
"Invalid navigation bar color '" + colorString + "': " + e.getMessage());
111-
}
112-
}
113-
if (options.hasKey(KEY_NAVIGATION_BAR_DIVIDER_COLOR)) {
114-
final String colorString = options.getString(KEY_NAVIGATION_BAR_DIVIDER_COLOR);
115-
try {
116-
builder.setNavigationBarDividerColor(Color.parseColor(colorString));
117-
} catch (IllegalArgumentException e) {
118-
throw new JSApplicationIllegalArgumentException(
119-
"Invalid navigation bar divider color '" + colorString + "': " + e.getMessage());
120-
}
105+
final Integer toolbarColor = setColor(builder, options, KEY_TOOLBAR_COLOR, "setToolbarColor", "toolbar");
106+
if (toolbarColor != null) {
107+
isLightTheme = toolbarIsLight(toolbarColor);
121108
}
109+
setColor(builder, options, KEY_SECONDARY_TOOLBAR_COLOR, "setSecondaryToolbarColor", "secondary toolbar");
110+
setColor(builder, options, KEY_NAVIGATION_BAR_COLOR, "setNavigationBarColor", "navigation bar");
111+
setColor(builder, options, KEY_NAVIGATION_BAR_DIVIDER_COLOR, "setNavigationBarDividerColor", "navigation bar divider");
112+
122113
if (options.hasKey(KEY_DEFAULT_SHARE_MENU_ITEM) &&
123114
options.getBoolean(KEY_DEFAULT_SHARE_MENU_ITEM)) {
124115
builder.addDefaultShareMenuItem();
@@ -235,7 +226,7 @@ public void onEvent(ChromeTabsDismissedEvent event) {
235226
unRegisterEventBus();
236227

237228
if (mOpenBrowserPromise == null) {
238-
throw new AssertionError();
229+
return;
239230
}
240231

241232
if (event.isError) {
@@ -292,8 +283,8 @@ private void unRegisterEventBus() {
292283
}
293284
}
294285

295-
private Boolean toolbarIsLight(String themeColor) {
296-
return ColorUtils.calculateLuminance(Color.parseColor(themeColor)) > 0.5;
286+
private Boolean toolbarIsLight(int themeColor) {
287+
return ColorUtils.calculateLuminance(themeColor) > 0.5;
297288
}
298289

299290
private List<ResolveInfo> getPreferredPackages(Context context) {

example/.flowconfig

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
; Ignore polyfills
99
node_modules/react-native/Libraries/polyfills/.*
1010

11-
; These should not be required directly
12-
; require from fbjs/lib instead: require('fbjs/lib/warning')
13-
node_modules/warning/.*
14-
1511
; Flow doesn't support platforms
1612
.*/Libraries/Utilities/LoadingView.js
1713

@@ -30,6 +26,8 @@ emoji=true
3026
esproposal.optional_chaining=enable
3127
esproposal.nullish_coalescing=enable
3228

29+
exact_by_default=true
30+
3331
module.file_ext=.js
3432
module.file_ext=.json
3533
module.file_ext=.ios.js
@@ -44,10 +42,6 @@ suppress_type=$FlowFixMe
4442
suppress_type=$FlowFixMeProps
4543
suppress_type=$FlowFixMeState
4644

47-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
48-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
49-
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
50-
5145
[lints]
5246
sketchy-null-number=warn
5347
sketchy-null-mixed=warn
@@ -56,10 +50,8 @@ untyped-type-import=warn
5650
nonstrict-import=warn
5751
deprecated-type=warn
5852
unsafe-getters-setters=warn
59-
inexact-spread=warn
6053
unnecessary-invariant=warn
6154
signature-verification-failure=warn
62-
deprecated-utility=error
6355

6456
[strict]
6557
deprecated-type
@@ -71,4 +63,4 @@ untyped-import
7163
untyped-type-import
7264

7365
[version]
74-
^0.113.0
66+
^0.137.0

example/.gitattributes

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
*.pbxproj -text
1+
# Windows files should use crlf line endings
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
*.bat text eol=crlf

example/.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,3 @@ buck-out/
5757

5858
# CocoaPods
5959
/ios/Pods/
60-
61-
yarn.lock

example/.prettierrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ module.exports = {
33
jsxBracketSameLine: true,
44
singleQuote: true,
55
trailingComma: 'all',
6+
arrowParens: 'avoid',
67
};

0 commit comments

Comments
 (0)