From bda89e5549ba6a11bf91986957d29222505d6c6e Mon Sep 17 00:00:00 2001 From: monika Date: Mon, 20 Mar 2017 13:47:44 +0530 Subject: [PATCH 1/5] implemented customised backbutton --- .../customtabs/CustomTabsModule.java | 41 +++++++++++++++++- .../ic_chevron_left_black_24dp.png | Bin 0 -> 125 bytes .../ic_chevron_left_white_24dp.png | Bin 0 -> 132 bytes .../ic_chevron_left_black_24dp.png | Bin 0 -> 112 bytes .../ic_chevron_left_white_24dp.png | Bin 0 -> 116 bytes .../ic_chevron_left_black_24dp.png | Bin 0 -> 135 bytes .../ic_chevron_left_white_24dp.png | Bin 0 -> 136 bytes .../ic_chevron_left_black_24dp.png | Bin 0 -> 165 bytes .../ic_chevron_left_white_24dp.png | Bin 0 -> 169 bytes .../mipmap-hdpi/ic_arrow_back_white_24dp.png | Bin 0 -> 148 bytes .../mipmap-mdpi/ic_arrow_back_white_24dp.png | Bin 0 -> 115 bytes .../mipmap-xhdpi/ic_arrow_back_white_24dp.png | Bin 0 -> 131 bytes .../ic_arrow_back_white_24dp.png | Bin 0 -> 191 bytes example/index.android.js | 7 ++- 14 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 android/src/main/res/mipmap-hdpi/ic_chevron_left_black_24dp.png create mode 100644 android/src/main/res/mipmap-hdpi/ic_chevron_left_white_24dp.png create mode 100644 android/src/main/res/mipmap-mdpi/ic_chevron_left_black_24dp.png create mode 100644 android/src/main/res/mipmap-mdpi/ic_chevron_left_white_24dp.png create mode 100644 android/src/main/res/mipmap-xhdpi/ic_chevron_left_black_24dp.png create mode 100644 android/src/main/res/mipmap-xhdpi/ic_chevron_left_white_24dp.png create mode 100644 android/src/main/res/mipmap-xxhdpi/ic_chevron_left_black_24dp.png create mode 100644 android/src/main/res/mipmap-xxhdpi/ic_chevron_left_white_24dp.png create mode 100644 example/android/app/src/main/res/mipmap-hdpi/ic_arrow_back_white_24dp.png create mode 100644 example/android/app/src/main/res/mipmap-mdpi/ic_arrow_back_white_24dp.png create mode 100644 example/android/app/src/main/res/mipmap-xhdpi/ic_arrow_back_white_24dp.png create mode 100644 example/android/app/src/main/res/mipmap-xxhdpi/ic_arrow_back_white_24dp.png diff --git a/android/src/main/java/com/github/droibit/android/reactnative/customtabs/CustomTabsModule.java b/android/src/main/java/com/github/droibit/android/reactnative/customtabs/CustomTabsModule.java index ee34980..995457d 100644 --- a/android/src/main/java/com/github/droibit/android/reactnative/customtabs/CustomTabsModule.java +++ b/android/src/main/java/com/github/droibit/android/reactnative/customtabs/CustomTabsModule.java @@ -20,10 +20,16 @@ import com.facebook.react.common.MapBuilder; import com.facebook.react.common.annotations.VisibleForTesting; + import java.util.Map; import javax.annotation.Nullable; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.content.res.Resources; +import android.R.drawable; + /** * CustomTabs module. * @@ -43,6 +49,12 @@ public class CustomTabsModule extends ReactContextBaseJavaModule { /* package */ static final String KEY_ANIMATIONS = "animations"; @VisibleForTesting /* package */ static final String KEY_HEADERS = "headers"; + @VisibleForTesting + /* package */ static final String KEY_BACKBUTTON = "backButton"; + @VisibleForTesting + /* package */ static final String KEY_BACKBUTTONCOLOR = "backButtonColor"; + @VisibleForTesting + /* package */ static final String KEY_BACKBUTTONCOLORICON = "backButtonColorIcon"; @VisibleForTesting /* package */ static final int ANIMATIONS_SLIDE = 0; @@ -60,6 +72,9 @@ public class CustomTabsModule extends ReactContextBaseJavaModule { CONSTANTS.put(KEY_DEFAULT_SHARE_MENU_ITEM, KEY_DEFAULT_SHARE_MENU_ITEM); CONSTANTS.put(KEY_ANIMATIONS, KEY_ANIMATIONS); CONSTANTS.put(KEY_HEADERS, KEY_HEADERS); + CONSTANTS.put(KEY_BACKBUTTON, KEY_BACKBUTTON); + CONSTANTS.put(KEY_BACKBUTTONCOLOR, KEY_BACKBUTTONCOLOR); + CONSTANTS.put(KEY_BACKBUTTONCOLORICON, KEY_BACKBUTTONCOLORICON); } private static final String MODULE_NAME = "CustomTabsManager"; @@ -134,6 +149,30 @@ public void openURL(String url, ReadableMap option, Promise promise) { "Invalid toolbar color '" + colorString + "': " + e.getMessage()); } } + //KEY_BACKBUTTON + if (option.hasKey(KEY_BACKBUTTON) && option.getBoolean(KEY_BACKBUTTON)) { + Resources res = context.getResources(); + String packageName = context.getPackageName(); + String icon = "ic_chevron_left_black_24dp"; + if (option.hasKey(KEY_BACKBUTTONCOLOR)) { + String color = option.getString(KEY_BACKBUTTONCOLOR); + icon = color.equalsIgnoreCase("light") ? "ic_chevron_left_white_24dp" : "ic_chevron_left_black_24dp"; + } + int iconId = res.getIdentifier(icon, "mipmap", packageName); + Bitmap iconBitMap = BitmapFactory.decodeResource(res, iconId); + builder.setCloseButtonIcon(iconBitMap); + } + + //KEY_BACKBUTTONCOLORICON + if (option.hasKey(KEY_BACKBUTTONCOLORICON)) { + Resources res = context.getResources(); + String packageName = context.getPackageName(); + String icon = !option.getString(KEY_BACKBUTTONCOLORICON).equals("") ? option.getString(KEY_BACKBUTTONCOLORICON) : "ic_chevron_left_black_24dp"; + int iconId = res.getIdentifier(icon, "mipmap", packageName); + Bitmap iconBitMap = BitmapFactory.decodeResource(res, iconId); + builder.setCloseButtonIcon(iconBitMap); + } + if (option.hasKey(KEY_ENABLE_URL_BAR_HIDING) && option.getBoolean(KEY_ENABLE_URL_BAR_HIDING)) { builder.enableUrlBarHiding(); @@ -205,4 +244,4 @@ public void openURL(String url, ReadableMap option, Promise promise) { builder.setStartAnimations(context, android.R.anim.fade_in, android.R.anim.fade_out) .setExitAnimations(context, android.R.anim.fade_out, android.R.anim.fade_in); } -} +} \ No newline at end of file diff --git a/android/src/main/res/mipmap-hdpi/ic_chevron_left_black_24dp.png b/android/src/main/res/mipmap-hdpi/ic_chevron_left_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..f4ef28e1e0f968a6ffff73f80fe153eb92d794ce GIT binary patch literal 125 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K;i>HfYNCo5DGq*V#0(e{wGK(i& zZn{0G|6h{u@5Gel4T?!>ivE{PKAD_7S!5#qb>Xvr$)5urbec)TE{&R(b=*P5NAM$4 YQ|k0wldT1B5}8r;B5V$MLsUPI59R2sj5iURcJu zTy^?CB{^H^0>%9e z^F%GtC`;s{(ybm3&6TxU(&b&!NU_xn$W<3~(AlH`;&erWC# jozyvZ!6S!Bw<;J`m6a#IYQM$_G?~HE)z4*}Q$iB}{8KTY literal 0 HcmV?d00001 diff --git a/android/src/main/res/mipmap-xhdpi/ic_chevron_left_white_24dp.png b/android/src/main/res/mipmap-xhdpi/ic_chevron_left_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..62f3590eef334980b01a178f9479afb3a389d383 GIT binary patch literal 136 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}a}te@_?3kch)?&mQD$FyLW1_?jz7 zLP);Fn@?2YlA~SwlZ@pJv78L2PM!GhtR09h&wjsiqPqXSV-MaR-FzY`KIvk_86Ccp jJ9j+!teeN^AgRCaAJ3g9ySr}zjb`w4^>bP0l+XkKZbLLy literal 0 HcmV?d00001 diff --git a/android/src/main/res/mipmap-xxhdpi/ic_chevron_left_black_24dp.png b/android/src/main/res/mipmap-xxhdpi/ic_chevron_left_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..f443b3c06e520d2dabf05680e8da7a11ff18d68c GIT binary patch literal 165 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXhaway(reLn;{G-tZMX#30gqP-6vC z!Kw3~IWsbMUS%k`H1ls#!ud`W&q*Z}lV3hsbKh4qUHxl8SrBjfS#59e=S|IEP|UER zwdISQHs{M(@hvT1EVVf^UnDBy7L#0z{%-A1D4otW%NG6qw%>f@f^@z22WQ% Jmvv4FO#m2UK~w+$ literal 0 HcmV?d00001 diff --git a/android/src/main/res/mipmap-xxhdpi/ic_chevron_left_white_24dp.png b/android/src/main/res/mipmap-xxhdpi/ic_chevron_left_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..7141cc6186b2f90e2a33d59b824c5fcb2fe5fefa GIT binary patch literal 169 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXhaw3OrpLLo)8Yy|I&*$&rEOVDAH^ z2A@hZe}!oW4_YKDIcyFpWl8-mF-gVq()`nB-aJxSskqldcZuxs#xKV_^KS04V3z@d zIiijp@{`_qte({8;SsNBJ0VOpH+D(z_5T*-vWrf?&@{fT=s8K{?+SJ0>t5gQcGrXf P?PlbP0l+XkK&k;Vz literal 0 HcmV?d00001 diff --git a/example/android/app/src/main/res/mipmap-hdpi/ic_arrow_back_white_24dp.png b/example/android/app/src/main/res/mipmap-hdpi/ic_arrow_back_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..cd1972677699802e4ef9723ea50fcb284f9a2d9e GIT binary patch literal 148 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K8w5N+>NCjiE#JmKNKlwlIJIE$G zENCoBR!I0=pY}@Pupe*oHeRjdZG1q?qm{hxZ$A4bPKTOf6Ie1b1fIqz%iQ?l<@&`u s>vn;8mbGbb(!%VA{yVIsrX`2~&0ZQe`%OT@F`zXJp00i_>zopr05HKY)c^nh literal 0 HcmV?d00001 diff --git a/example/android/app/src/main/res/mipmap-mdpi/ic_arrow_back_white_24dp.png b/example/android/app/src/main/res/mipmap-mdpi/ic_arrow_back_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..4ef72eec99423c5d4f83227e34b24835a79f324f GIT binary patch literal 115 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_*1D^C~4kP60RiG2_15C3<&H0A&Q z|Ihd9Wu7|h-d41yp@_F-ZcDVc#LB3;|NKk4rwLrznlW+N(!?KWaSTDLrm Date: Mon, 20 Mar 2017 14:00:50 +0530 Subject: [PATCH 2/5] implemented customised backbutton --- .../customtabs/CustomTabsModule.java | 41 +++++++++++++++++- .../ic_chevron_left_black_24dp.png | Bin 0 -> 125 bytes .../ic_chevron_left_white_24dp.png | Bin 0 -> 132 bytes .../ic_chevron_left_black_24dp.png | Bin 0 -> 112 bytes .../ic_chevron_left_white_24dp.png | Bin 0 -> 116 bytes .../ic_chevron_left_black_24dp.png | Bin 0 -> 135 bytes .../ic_chevron_left_white_24dp.png | Bin 0 -> 136 bytes .../ic_chevron_left_black_24dp.png | Bin 0 -> 165 bytes .../ic_chevron_left_white_24dp.png | Bin 0 -> 169 bytes .../mipmap-hdpi/ic_arrow_back_white_24dp.png | Bin 0 -> 148 bytes .../mipmap-mdpi/ic_arrow_back_white_24dp.png | Bin 0 -> 115 bytes .../mipmap-xhdpi/ic_arrow_back_white_24dp.png | Bin 0 -> 131 bytes .../ic_arrow_back_white_24dp.png | Bin 0 -> 191 bytes example/index.android.js | 7 ++- 14 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 android/src/main/res/mipmap-hdpi/ic_chevron_left_black_24dp.png create mode 100644 android/src/main/res/mipmap-hdpi/ic_chevron_left_white_24dp.png create mode 100644 android/src/main/res/mipmap-mdpi/ic_chevron_left_black_24dp.png create mode 100644 android/src/main/res/mipmap-mdpi/ic_chevron_left_white_24dp.png create mode 100644 android/src/main/res/mipmap-xhdpi/ic_chevron_left_black_24dp.png create mode 100644 android/src/main/res/mipmap-xhdpi/ic_chevron_left_white_24dp.png create mode 100644 android/src/main/res/mipmap-xxhdpi/ic_chevron_left_black_24dp.png create mode 100644 android/src/main/res/mipmap-xxhdpi/ic_chevron_left_white_24dp.png create mode 100644 example/android/app/src/main/res/mipmap-hdpi/ic_arrow_back_white_24dp.png create mode 100644 example/android/app/src/main/res/mipmap-mdpi/ic_arrow_back_white_24dp.png create mode 100644 example/android/app/src/main/res/mipmap-xhdpi/ic_arrow_back_white_24dp.png create mode 100644 example/android/app/src/main/res/mipmap-xxhdpi/ic_arrow_back_white_24dp.png diff --git a/android/src/main/java/com/github/droibit/android/reactnative/customtabs/CustomTabsModule.java b/android/src/main/java/com/github/droibit/android/reactnative/customtabs/CustomTabsModule.java index ee34980..995457d 100644 --- a/android/src/main/java/com/github/droibit/android/reactnative/customtabs/CustomTabsModule.java +++ b/android/src/main/java/com/github/droibit/android/reactnative/customtabs/CustomTabsModule.java @@ -20,10 +20,16 @@ import com.facebook.react.common.MapBuilder; import com.facebook.react.common.annotations.VisibleForTesting; + import java.util.Map; import javax.annotation.Nullable; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.content.res.Resources; +import android.R.drawable; + /** * CustomTabs module. * @@ -43,6 +49,12 @@ public class CustomTabsModule extends ReactContextBaseJavaModule { /* package */ static final String KEY_ANIMATIONS = "animations"; @VisibleForTesting /* package */ static final String KEY_HEADERS = "headers"; + @VisibleForTesting + /* package */ static final String KEY_BACKBUTTON = "backButton"; + @VisibleForTesting + /* package */ static final String KEY_BACKBUTTONCOLOR = "backButtonColor"; + @VisibleForTesting + /* package */ static final String KEY_BACKBUTTONCOLORICON = "backButtonColorIcon"; @VisibleForTesting /* package */ static final int ANIMATIONS_SLIDE = 0; @@ -60,6 +72,9 @@ public class CustomTabsModule extends ReactContextBaseJavaModule { CONSTANTS.put(KEY_DEFAULT_SHARE_MENU_ITEM, KEY_DEFAULT_SHARE_MENU_ITEM); CONSTANTS.put(KEY_ANIMATIONS, KEY_ANIMATIONS); CONSTANTS.put(KEY_HEADERS, KEY_HEADERS); + CONSTANTS.put(KEY_BACKBUTTON, KEY_BACKBUTTON); + CONSTANTS.put(KEY_BACKBUTTONCOLOR, KEY_BACKBUTTONCOLOR); + CONSTANTS.put(KEY_BACKBUTTONCOLORICON, KEY_BACKBUTTONCOLORICON); } private static final String MODULE_NAME = "CustomTabsManager"; @@ -134,6 +149,30 @@ public void openURL(String url, ReadableMap option, Promise promise) { "Invalid toolbar color '" + colorString + "': " + e.getMessage()); } } + //KEY_BACKBUTTON + if (option.hasKey(KEY_BACKBUTTON) && option.getBoolean(KEY_BACKBUTTON)) { + Resources res = context.getResources(); + String packageName = context.getPackageName(); + String icon = "ic_chevron_left_black_24dp"; + if (option.hasKey(KEY_BACKBUTTONCOLOR)) { + String color = option.getString(KEY_BACKBUTTONCOLOR); + icon = color.equalsIgnoreCase("light") ? "ic_chevron_left_white_24dp" : "ic_chevron_left_black_24dp"; + } + int iconId = res.getIdentifier(icon, "mipmap", packageName); + Bitmap iconBitMap = BitmapFactory.decodeResource(res, iconId); + builder.setCloseButtonIcon(iconBitMap); + } + + //KEY_BACKBUTTONCOLORICON + if (option.hasKey(KEY_BACKBUTTONCOLORICON)) { + Resources res = context.getResources(); + String packageName = context.getPackageName(); + String icon = !option.getString(KEY_BACKBUTTONCOLORICON).equals("") ? option.getString(KEY_BACKBUTTONCOLORICON) : "ic_chevron_left_black_24dp"; + int iconId = res.getIdentifier(icon, "mipmap", packageName); + Bitmap iconBitMap = BitmapFactory.decodeResource(res, iconId); + builder.setCloseButtonIcon(iconBitMap); + } + if (option.hasKey(KEY_ENABLE_URL_BAR_HIDING) && option.getBoolean(KEY_ENABLE_URL_BAR_HIDING)) { builder.enableUrlBarHiding(); @@ -205,4 +244,4 @@ public void openURL(String url, ReadableMap option, Promise promise) { builder.setStartAnimations(context, android.R.anim.fade_in, android.R.anim.fade_out) .setExitAnimations(context, android.R.anim.fade_out, android.R.anim.fade_in); } -} +} \ No newline at end of file diff --git a/android/src/main/res/mipmap-hdpi/ic_chevron_left_black_24dp.png b/android/src/main/res/mipmap-hdpi/ic_chevron_left_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..f4ef28e1e0f968a6ffff73f80fe153eb92d794ce GIT binary patch literal 125 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K;i>HfYNCo5DGq*V#0(e{wGK(i& zZn{0G|6h{u@5Gel4T?!>ivE{PKAD_7S!5#qb>Xvr$)5urbec)TE{&R(b=*P5NAM$4 YQ|k0wldT1B5}8r;B5V$MLsUPI59R2sj5iURcJu zTy^?CB{^H^0>%9e z^F%GtC`;s{(ybm3&6TxU(&b&!NU_xn$W<3~(AlH`;&erWC# jozyvZ!6S!Bw<;J`m6a#IYQM$_G?~HE)z4*}Q$iB}{8KTY literal 0 HcmV?d00001 diff --git a/android/src/main/res/mipmap-xhdpi/ic_chevron_left_white_24dp.png b/android/src/main/res/mipmap-xhdpi/ic_chevron_left_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..62f3590eef334980b01a178f9479afb3a389d383 GIT binary patch literal 136 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}a}te@_?3kch)?&mQD$FyLW1_?jz7 zLP);Fn@?2YlA~SwlZ@pJv78L2PM!GhtR09h&wjsiqPqXSV-MaR-FzY`KIvk_86Ccp jJ9j+!teeN^AgRCaAJ3g9ySr}zjb`w4^>bP0l+XkKZbLLy literal 0 HcmV?d00001 diff --git a/android/src/main/res/mipmap-xxhdpi/ic_chevron_left_black_24dp.png b/android/src/main/res/mipmap-xxhdpi/ic_chevron_left_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..f443b3c06e520d2dabf05680e8da7a11ff18d68c GIT binary patch literal 165 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXhaway(reLn;{G-tZMX#30gqP-6vC z!Kw3~IWsbMUS%k`H1ls#!ud`W&q*Z}lV3hsbKh4qUHxl8SrBjfS#59e=S|IEP|UER zwdISQHs{M(@hvT1EVVf^UnDBy7L#0z{%-A1D4otW%NG6qw%>f@f^@z22WQ% Jmvv4FO#m2UK~w+$ literal 0 HcmV?d00001 diff --git a/android/src/main/res/mipmap-xxhdpi/ic_chevron_left_white_24dp.png b/android/src/main/res/mipmap-xxhdpi/ic_chevron_left_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..7141cc6186b2f90e2a33d59b824c5fcb2fe5fefa GIT binary patch literal 169 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXhaw3OrpLLo)8Yy|I&*$&rEOVDAH^ z2A@hZe}!oW4_YKDIcyFpWl8-mF-gVq()`nB-aJxSskqldcZuxs#xKV_^KS04V3z@d zIiijp@{`_qte({8;SsNBJ0VOpH+D(z_5T*-vWrf?&@{fT=s8K{?+SJ0>t5gQcGrXf P?PlbP0l+XkK&k;Vz literal 0 HcmV?d00001 diff --git a/example/android/app/src/main/res/mipmap-hdpi/ic_arrow_back_white_24dp.png b/example/android/app/src/main/res/mipmap-hdpi/ic_arrow_back_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..cd1972677699802e4ef9723ea50fcb284f9a2d9e GIT binary patch literal 148 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K8w5N+>NCjiE#JmKNKlwlIJIE$G zENCoBR!I0=pY}@Pupe*oHeRjdZG1q?qm{hxZ$A4bPKTOf6Ie1b1fIqz%iQ?l<@&`u s>vn;8mbGbb(!%VA{yVIsrX`2~&0ZQe`%OT@F`zXJp00i_>zopr05HKY)c^nh literal 0 HcmV?d00001 diff --git a/example/android/app/src/main/res/mipmap-mdpi/ic_arrow_back_white_24dp.png b/example/android/app/src/main/res/mipmap-mdpi/ic_arrow_back_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..4ef72eec99423c5d4f83227e34b24835a79f324f GIT binary patch literal 115 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_*1D^C~4kP60RiG2_15C3<&H0A&Q z|Ihd9Wu7|h-d41yp@_F-ZcDVc#LB3;|NKk4rwLrznlW+N(!?KWaSTDLrm Date: Mon, 20 Mar 2017 14:25:01 +0530 Subject: [PATCH 3/5] updation in prop name and README.md --- README.md | 8 +++++++- .../reactnative/customtabs/CustomTabsModule.java | 10 +++++----- example/index.android.js | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0f95875..56ad5b3 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,10 @@ CustomTabs.openURL(url, { animations: ANIMATIONS_SLIDE, // or ANIMATIONS_FADE headers: { 'my-custom-header': 'my custom header value' - } + }, + backButton:true, // or false + backButtonColor:'light', // or dark + backButtonIcon:'ic_arrow_back_white_24dp' // to provide own back-button }); ``` @@ -84,6 +87,9 @@ The option to support: |enableDefaultShare|boolean|undefined|Whether to add a default shared items of the menu.| |animations|number|undefined|Sets the exit and start animations. ANIMATIONS_FADE or ANIMATIONS_SLIDE.| |headers|Object|undefined|Sets any custom headers that should be used.| +|backButton|Boolean|false|(android only), set '<' back button insted of cross icon.| +|backButtonColor|enum|dark|(android only), 'light' or 'dark', provide white or black color '<' icon| +|backButtonIcon|string|undefined| (android only), can provide own icon, just download the custom icons for from https://material.io/icons/ and add them REACTNATIVEPROJECT/android/app/src/main/res/mipmap-*| `undefined` property is the default behavior of the Custom Tabs. diff --git a/android/src/main/java/com/github/droibit/android/reactnative/customtabs/CustomTabsModule.java b/android/src/main/java/com/github/droibit/android/reactnative/customtabs/CustomTabsModule.java index 995457d..77e1e3a 100644 --- a/android/src/main/java/com/github/droibit/android/reactnative/customtabs/CustomTabsModule.java +++ b/android/src/main/java/com/github/droibit/android/reactnative/customtabs/CustomTabsModule.java @@ -54,7 +54,7 @@ public class CustomTabsModule extends ReactContextBaseJavaModule { @VisibleForTesting /* package */ static final String KEY_BACKBUTTONCOLOR = "backButtonColor"; @VisibleForTesting - /* package */ static final String KEY_BACKBUTTONCOLORICON = "backButtonColorIcon"; + /* package */ static final String KEY_BACKBUTTONICON = "backButtonIcon"; @VisibleForTesting /* package */ static final int ANIMATIONS_SLIDE = 0; @@ -74,7 +74,7 @@ public class CustomTabsModule extends ReactContextBaseJavaModule { CONSTANTS.put(KEY_HEADERS, KEY_HEADERS); CONSTANTS.put(KEY_BACKBUTTON, KEY_BACKBUTTON); CONSTANTS.put(KEY_BACKBUTTONCOLOR, KEY_BACKBUTTONCOLOR); - CONSTANTS.put(KEY_BACKBUTTONCOLORICON, KEY_BACKBUTTONCOLORICON); + CONSTANTS.put(KEY_BACKBUTTONICON, KEY_BACKBUTTONICON); } private static final String MODULE_NAME = "CustomTabsManager"; @@ -163,11 +163,11 @@ public void openURL(String url, ReadableMap option, Promise promise) { builder.setCloseButtonIcon(iconBitMap); } - //KEY_BACKBUTTONCOLORICON - if (option.hasKey(KEY_BACKBUTTONCOLORICON)) { + //KEY_BACKBUTTONICON + if (option.hasKey(KEY_BACKBUTTONICON)) { Resources res = context.getResources(); String packageName = context.getPackageName(); - String icon = !option.getString(KEY_BACKBUTTONCOLORICON).equals("") ? option.getString(KEY_BACKBUTTONCOLORICON) : "ic_chevron_left_black_24dp"; + String icon = !option.getString(KEY_BACKBUTTONICON).equals("") ? option.getString(KEY_BACKBUTTONICON) : "ic_chevron_left_black_24dp"; int iconId = res.getIdentifier(icon, "mipmap", packageName); Bitmap iconBitMap = BitmapFactory.decodeResource(res, iconId); builder.setCloseButtonIcon(iconBitMap); diff --git a/example/index.android.js b/example/index.android.js index 9da87f5..901cb14 100644 --- a/example/index.android.js +++ b/example/index.android.js @@ -76,8 +76,8 @@ class Example extends Component { enableDefaultShare: true, animations: ANIMATIONS_SLIDE, backButton:true, - backButtonColor:'dark', - backButtonColorIcon:'ic_arrow_back_white_24dp' + backButtonColor:'light', + backButtonIcon:'ic_arrow_back_white_24dp' }); } From 926c7c13cc357150e2cf6dffda69cd20d737d820 Mon Sep 17 00:00:00 2001 From: prince8verma Date: Mon, 20 Mar 2017 15:22:57 +0530 Subject: [PATCH 4/5] added readme.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 56ad5b3..9deaf2f 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ The option to support: |headers|Object|undefined|Sets any custom headers that should be used.| |backButton|Boolean|false|(android only), set '<' back button insted of cross icon.| |backButtonColor|enum|dark|(android only), 'light' or 'dark', provide white or black color '<' icon| -|backButtonIcon|string|undefined| (android only), can provide own icon, just download the custom icons for from https://material.io/icons/ and add them REACTNATIVEPROJECT/android/app/src/main/res/mipmap-*| +|backButtonIcon|string|undefined| (android only), can provide own icon, just download the custom icons from https://material.io/icons/ and add them REACTNATIVEPROJECT/android/app/src/main/res/mipmap-*| `undefined` property is the default behavior of the Custom Tabs. From 3bf7643bda9d132325d810a6600e5c1e3aa7ac0e Mon Sep 17 00:00:00 2001 From: prince8verma Date: Mon, 20 Mar 2017 15:24:01 +0530 Subject: [PATCH 5/5] updated readme.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9deaf2f..4330702 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ The option to support: |headers|Object|undefined|Sets any custom headers that should be used.| |backButton|Boolean|false|(android only), set '<' back button insted of cross icon.| |backButtonColor|enum|dark|(android only), 'light' or 'dark', provide white or black color '<' icon| -|backButtonIcon|string|undefined| (android only), can provide own icon, just download the custom icons from https://material.io/icons/ and add them REACTNATIVEPROJECT/android/app/src/main/res/mipmap-*| +|backButtonIcon|string|undefined| (android only), can provide own icon, just download the custom icons from https://material.io/icons/ and add them in REACTNATIVEPROJECT/android/app/src/main/res/mipmap-*| `undefined` property is the default behavior of the Custom Tabs.