From 21cd1cf472fa0a1d205a1a9e86a786e569f71115 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 5 Apr 2021 15:48:30 +0200 Subject: [PATCH] Custom tabs improvements --- .../main/java/eu/faircode/email/Helper.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index 08bfbbc90b..9bafd555cb 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -650,17 +650,27 @@ public class Helper { ToastEx.makeText(context, Log.formatThrowable(ex, false), Toast.LENGTH_LONG).show(); } } else { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + boolean navbar_colorize = prefs.getBoolean("navbar_colorize", false); + int colorPrimary = resolveColor(context, R.attr.colorPrimary); + int colorPrimaryDark = resolveColor(context, R.attr.colorPrimaryDark); + + CustomTabColorSchemeParams.Builder schemes = new CustomTabColorSchemeParams.Builder() + .setToolbarColor(colorPrimary) + .setSecondaryToolbarColor(colorPrimaryDark); + if (navbar_colorize) + schemes.setNavigationBarColor(colorPrimaryDark); + // https://developer.chrome.com/multidevice/android/customtabs - CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); - builder.setDefaultColorSchemeParams(new CustomTabColorSchemeParams.Builder() - .setToolbarColor(resolveColor(context, R.attr.colorPrimary)) - .setSecondaryToolbarColor(resolveColor(context, R.attr.colorPrimaryDark)) - .build()); - builder.setColorScheme(Helper.isDarkTheme(context) - ? CustomTabsIntent.COLOR_SCHEME_DARK - : CustomTabsIntent.COLOR_SCHEME_LIGHT); - builder.setShareState(CustomTabsIntent.SHARE_STATE_ON); - builder.setUrlBarHidingEnabled(true); + CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder() + .setDefaultColorSchemeParams(schemes.build()) + .setColorScheme(Helper.isDarkTheme(context) + ? CustomTabsIntent.COLOR_SCHEME_DARK + : CustomTabsIntent.COLOR_SCHEME_LIGHT) + .setShareState(CustomTabsIntent.SHARE_STATE_ON) + .setUrlBarHidingEnabled(true) + .setStartAnimations(context, R.anim.activity_open_enter, R.anim.activity_open_exit) + .setExitAnimations(context, R.anim.activity_close_enter, R.anim.activity_close_exit); CustomTabsIntent customTabsIntent = builder.build(); try {