Skip to content

Commit 74374e8

Browse files
committed
feat(android): Add navigationBarColor and navigationBarDividerColor options
1 parent 097e459 commit 74374e8

File tree

12 files changed

+1216
-1150
lines changed

12 files changed

+1216
-1150
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ Property | Description
162162
`showTitle` (Boolean) | Sets whether the title should be shown in the custom tab. [`true`/`false`]
163163
`toolbarColor` (String) | Sets the toolbar color. [`gray`/`#808080`]
164164
`secondaryToolbarColor` (String) | Sets the color of the secondary toolbar. [`white`/`#FFFFFF`]
165+
`navigationBarColor` (String) | Sets the navigation bar color. [`gray`/`#808080`]
166+
`navigationBarDividerColor` (String) | Sets the navigation bar divider color. [`white`/`#FFFFFF`]
165167
`enableUrlBarHiding` (Boolean) | Enables the url bar to hide as the user scrolls down on the page. [`true`/`false`]
166168
`enableDefaultShare` (Boolean) | Adds a default share item to the menu. [`true`/`false`]
167169
`animations` (Object) | Sets the start and exit animations. [`{ startEnter, startExit, endEnter, endExit }`]
@@ -180,7 +182,7 @@ import { InAppBrowser } from 'react-native-inappbrowser-reborn'
180182
...
181183
async openLink() {
182184
try {
183-
const url = 'https://www.google.com'
185+
const url = 'https://www.proyecto26.com'
184186
if (await InAppBrowser.isAvailable()) {
185187
const result = await InAppBrowser.open(url, {
186188
// iOS Properties
@@ -197,6 +199,8 @@ import { InAppBrowser } from 'react-native-inappbrowser-reborn'
197199
showTitle: true,
198200
toolbarColor: '#6200EE',
199201
secondaryToolbarColor: 'black',
202+
navigationBarColor: 'black',
203+
navigationBarDividerColor: 'white',
200204
enableUrlBarHiding: true,
201205
enableDefaultShare: true,
202206
forceCloseOnRedirection: false,

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ buildscript {
1212
}
1313

1414
dependencies {
15-
classpath 'com.android.tools.build:gradle:3.5.1'
15+
classpath 'com.android.tools.build:gradle:3.5.4'
1616
}
1717
}
1818
}

android/src/main/AndroidManifest.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@
33
package="com.proyecto26.inappbrowser">
44

55
<uses-permission android:name="android.permission.INTERNET" />
6+
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
67

78
<application>
89
<activity
910
android:name=".ChromeTabsManagerActivity">
1011
</activity>
1112
</application>
13+
<queries>
14+
<intent>
15+
<action android:name="android.support.customtabs.action.CustomTabsService" />
16+
</intent>
17+
</queries>
1218
</manifest>
1319

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public class RNInAppBrowser {
3535
private final static String ERROR_CODE = "InAppBrowser";
3636
private static final String KEY_TOOLBAR_COLOR = "toolbarColor";
3737
private static final String KEY_SECONDARY_TOOLBAR_COLOR = "secondaryToolbarColor";
38+
private static final String KEY_NAVIGATION_BAR_COLOR = "navigationBarColor";
39+
private static final String KEY_NAVIGATION_BAR_DIVIDER_COLOR = "navigationBarDividerColor";
3840
private static final String KEY_ENABLE_URL_BAR_HIDING = "enableUrlBarHiding";
3941
private static final String KEY_SHOW_PAGE_TITLE = "showTitle";
4042
private static final String KEY_DEFAULT_SHARE_MENU_ITEM = "enableDefaultShare";
@@ -79,6 +81,7 @@ public void open(Context context, final ReadableMap options, final Promise promi
7981
}
8082

8183
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
84+
isLightTheme = false;
8285
if (options.hasKey(KEY_TOOLBAR_COLOR)) {
8386
final String colorString = options.getString(KEY_TOOLBAR_COLOR);
8487
try {
@@ -98,6 +101,24 @@ public void open(Context context, final ReadableMap options, final Promise promi
98101
"Invalid secondary toolbar color '" + colorString + "': " + e.getMessage());
99102
}
100103
}
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+
}
121+
}
101122
if (options.hasKey(KEY_DEFAULT_SHARE_MENU_ITEM) &&
102123
options.getBoolean(KEY_DEFAULT_SHARE_MENU_ITEM)) {
103124
builder.addDefaultShareMenuItem();

example/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

example/App.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default class App extends Component<ComponentState> {
3737
super(props);
3838

3939
this.state = {
40-
url: 'https://www.google.com',
40+
url: 'https://www.proyecto26.com',
4141
statusBarStyle: 'dark-content',
4242
};
4343
}
@@ -69,6 +69,8 @@ export default class App extends Component<ComponentState> {
6969
showTitle: true,
7070
toolbarColor: '#6200EE',
7171
secondaryToolbarColor: 'black',
72+
navigationBarColor: 'black',
73+
navigationBarDividerColor: 'white',
7274
enableUrlBarHiding: true,
7375
enableDefaultShare: true,
7476
forceCloseOnRedirection: false,

example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ buildscript {
1212
jcenter()
1313
}
1414
dependencies {
15-
classpath("com.android.tools.build:gradle:3.5.3")
15+
classpath("com.android.tools.build:gradle:3.5.4")
1616

1717
// NOTE: Do not place your application dependencies here; they belong
1818
// in the individual module build.gradle files

0 commit comments

Comments
 (0)