diff --git a/flutter_custom_tabs/README.md b/flutter_custom_tabs/README.md index 3854e86..dcf8c15 100644 --- a/flutter_custom_tabs/README.md +++ b/flutter_custom_tabs/README.md @@ -85,7 +85,7 @@ class MyApp extends StatelessWidget { customTabsOptions: CustomTabsOptions( toolbarColor: Theme.of(context).primaryColor, enableDefaultShare: true, - enableUrlBarHiding: true, + urlBarHidingEnabled: true, showPageTitle: true, animation: CustomTabsAnimation.slideIn(), // or user defined animation. diff --git a/flutter_custom_tabs/android/src/main/java/com/github/droibit/flutter/plugins/customtabs/CustomTabsFactory.java b/flutter_custom_tabs/android/src/main/java/com/github/droibit/flutter/plugins/customtabs/CustomTabsFactory.java index 98f6ff2..61bff4d 100644 --- a/flutter_custom_tabs/android/src/main/java/com/github/droibit/flutter/plugins/customtabs/CustomTabsFactory.java +++ b/flutter_custom_tabs/android/src/main/java/com/github/droibit/flutter/plugins/customtabs/CustomTabsFactory.java @@ -1,5 +1,6 @@ package com.github.droibit.flutter.plugins.customtabs; +import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.graphics.Color; @@ -22,7 +23,7 @@ @RestrictTo(RestrictTo.Scope.LIBRARY) class CustomTabsFactory { private static final String KEY_OPTIONS_TOOLBAR_COLOR = "toolbarColor"; - private static final String KEY_OPTIONS_ENABLE_URL_BAR_HIDING = "enableUrlBarHiding"; + private static final String KEY_OPTIONS_URL_BAR_HIDING_ENABLED = "urlBarHidingEnabled"; private static final String KEY_OPTIONS_SHOW_PAGE_TITLE = "showPageTitle"; private static final String KEY_OPTIONS_DEFAULT_SHARE_MENU_ITEM = "enableDefaultShare"; private static final String KEY_OPTIONS_ENABLE_INSTANT_APPS = "enableInstantApps"; @@ -53,9 +54,8 @@ CustomTabsIntent createIntent(@NonNull Map options) { builder.setToolbarColor(Color.parseColor(colorString)); } - if (options.containsKey(KEY_OPTIONS_ENABLE_URL_BAR_HIDING) && - ((Boolean) options.get(KEY_OPTIONS_ENABLE_URL_BAR_HIDING))) { - builder.enableUrlBarHiding(); + if (options.containsKey(KEY_OPTIONS_URL_BAR_HIDING_ENABLED)) { + builder.setUrlBarHidingEnabled(((Boolean) options.get(KEY_OPTIONS_URL_BAR_HIDING_ENABLED))); } if (options.containsKey(KEY_OPTIONS_DEFAULT_SHARE_MENU_ITEM) && @@ -100,26 +100,27 @@ private void applyAnimations(@NonNull CustomTabsIntent.Builder builder, @NonNull Map animations) { final int startEnterAnimationId = animations.containsKey(KEY_ANIMATION_START_ENTER) ? resolveAnimationIdentifierIfNeeded( - animations.get(KEY_ANIMATION_START_ENTER)) : -1; + animations.get(KEY_ANIMATION_START_ENTER)) : 0; final int startExitAnimationId = animations.containsKey(KEY_ANIMATION_START_EXIT) ? resolveAnimationIdentifierIfNeeded( - animations.get(KEY_ANIMATION_START_EXIT)) : -1; + animations.get(KEY_ANIMATION_START_EXIT)) : 0; final int endEnterAnimationId = animations.containsKey(KEY_ANIMATION_END_ENTER) ? resolveAnimationIdentifierIfNeeded( - animations.get(KEY_ANIMATION_END_ENTER)) : -1; + animations.get(KEY_ANIMATION_END_ENTER)) : 0; final int endExitAnimationId = animations.containsKey(KEY_ANIMATION_END_EXIT) ? resolveAnimationIdentifierIfNeeded( - animations.get(KEY_ANIMATION_END_EXIT)) : -1; + animations.get(KEY_ANIMATION_END_EXIT)) : 0; - if (startEnterAnimationId != -1 && startExitAnimationId != -1) { + if (startEnterAnimationId != 0 && startExitAnimationId != 0) { builder.setStartAnimations(context, startEnterAnimationId, startExitAnimationId); } - if (endEnterAnimationId != -1 && endExitAnimationId != -1) { + if (endEnterAnimationId != 0 && endExitAnimationId != 0) { builder.setExitAnimations(context, endEnterAnimationId, endExitAnimationId); } } + @SuppressLint("DiscouragedApi") @AnimRes private int resolveAnimationIdentifierIfNeeded(@NonNull String identifier) { if (animationIdentifierPattern.matcher(identifier).find()) { diff --git a/flutter_custom_tabs/example/lib/main.dart b/flutter_custom_tabs/example/lib/main.dart index 6b136df..236e54c 100644 --- a/flutter_custom_tabs/example/lib/main.dart +++ b/flutter_custom_tabs/example/lib/main.dart @@ -46,7 +46,7 @@ class MyApp extends StatelessWidget { customTabsOptions: CustomTabsOptions( toolbarColor: theme.primaryColor, enableDefaultShare: true, - enableUrlBarHiding: true, + urlBarHidingEnabled: true, showPageTitle: true, animation: CustomTabsSystemAnimation.slideIn(), extraCustomTabs: const [ diff --git a/flutter_custom_tabs/lib/src/launcher.dart b/flutter_custom_tabs/lib/src/launcher.dart index 3e0ead6..cdf3592 100644 --- a/flutter_custom_tabs/lib/src/launcher.dart +++ b/flutter_custom_tabs/lib/src/launcher.dart @@ -22,7 +22,7 @@ import 'package:flutter_custom_tabs_platform_interface/flutter_custom_tabs_platf /// 'https://flutter.io', /// customTabsOptions: CustomTabsOptions( /// toolbarColor: Theme.of(context).primaryColor, -/// enableUrlBarHiding: true, +/// urlBarHidingEnabled: true, /// showPageTitle: true, /// animation: CustomTabsAnimation.slideIn(), /// extraCustomTabs: [ diff --git a/flutter_custom_tabs/test/launcher_test.dart b/flutter_custom_tabs/test/launcher_test.dart index 9fb6a9f..9405479 100644 --- a/flutter_custom_tabs/test/launcher_test.dart +++ b/flutter_custom_tabs/test/launcher_test.dart @@ -58,7 +58,7 @@ void main() { const customTabsOptions = CustomTabsOptions( toolbarColor: Color(0xFFFFEBEE), - enableUrlBarHiding: true, + urlBarHidingEnabled: true, enableDefaultShare: false, showPageTitle: true, enableInstantApps: false, diff --git a/flutter_custom_tabs_platform_interface/lib/src/custom_tabs_options.dart b/flutter_custom_tabs_platform_interface/lib/src/custom_tabs_options.dart index 50632ea..28c2986 100644 --- a/flutter_custom_tabs_platform_interface/lib/src/custom_tabs_options.dart +++ b/flutter_custom_tabs_platform_interface/lib/src/custom_tabs_options.dart @@ -12,7 +12,7 @@ import 'package:meta/meta.dart'; class CustomTabsOptions { const CustomTabsOptions({ this.toolbarColor, - this.enableUrlBarHiding, + this.urlBarHidingEnabled, this.enableDefaultShare, this.showPageTitle, this.enableInstantApps, @@ -26,7 +26,7 @@ class CustomTabsOptions { final Color? toolbarColor; /// If enabled, hides the toolbar when the user scrolls down the page. - final bool? enableUrlBarHiding; + final bool? urlBarHidingEnabled; /// If enabled, default sharing menu is added. final bool? enableDefaultShare; @@ -55,8 +55,8 @@ class CustomTabsOptions { if (toolbarColor != null) { dest['toolbarColor'] = '#${toolbarColor!.value.toRadixString(16)}'; } - if (enableUrlBarHiding != null) { - dest['enableUrlBarHiding'] = enableUrlBarHiding; + if (urlBarHidingEnabled != null) { + dest['urlBarHidingEnabled'] = urlBarHidingEnabled; } if (enableDefaultShare != null) { dest['enableDefaultShare'] = enableDefaultShare; diff --git a/flutter_custom_tabs_platform_interface/test/src/custom_tabs_options_test.dart b/flutter_custom_tabs_platform_interface/test/src/custom_tabs_options_test.dart index e4f677d..05cb818 100644 --- a/flutter_custom_tabs_platform_interface/test/src/custom_tabs_options_test.dart +++ b/flutter_custom_tabs_platform_interface/test/src/custom_tabs_options_test.dart @@ -13,7 +13,7 @@ void main() { test('toMap() with full option', () { const options = CustomTabsOptions( toolbarColor: Color(0xFFFFEBEE), - enableUrlBarHiding: true, + urlBarHidingEnabled: true, enableDefaultShare: false, showPageTitle: true, enableInstantApps: false, @@ -32,7 +32,7 @@ void main() { expect(options.toMap(), { 'toolbarColor': '#ffffebee', - 'enableUrlBarHiding': true, + 'urlBarHidingEnabled': true, 'enableDefaultShare': false, 'showPageTitle': true, 'enableInstantApps': false, diff --git a/flutter_custom_tabs_platform_interface/test/src/method_channel_custom_tabs_test.dart b/flutter_custom_tabs_platform_interface/test/src/method_channel_custom_tabs_test.dart index 2648561..96cb10b 100644 --- a/flutter_custom_tabs_platform_interface/test/src/method_channel_custom_tabs_test.dart +++ b/flutter_custom_tabs_platform_interface/test/src/method_channel_custom_tabs_test.dart @@ -38,7 +38,7 @@ void main() { await customTabs.launch( 'http://example.com/', customTabsOptions: const CustomTabsOptions( - enableUrlBarHiding: true, + urlBarHidingEnabled: true, ), safariVCOptions: const SafariViewControllerOptions( barCollapsingEnabled: false, @@ -50,7 +50,7 @@ void main() { isMethodCall('launch', arguments: { 'url': 'http://example.com/', 'customTabsOptions': const { - 'enableUrlBarHiding': true, + 'urlBarHidingEnabled': true, }, 'safariVCOptions': const { 'barCollapsingEnabled': false