use of androidx.browser.customtabs.CustomTabColorSchemeParams in project Tusky by Vavassor.
the class LinkHelper method openLinkInCustomTab.
/**
* tries to open a link in a custom tab
* falls back to browser if not possible
*
* @param uri the uri to open
* @param context context
*/
public static void openLinkInCustomTab(Uri uri, Context context) {
int toolbarColor = ThemeUtils.getColor(context, R.attr.colorSurface);
int navigationbarColor = ThemeUtils.getColor(context, android.R.attr.navigationBarColor);
int navigationbarDividerColor = ThemeUtils.getColor(context, R.attr.dividerColor);
CustomTabColorSchemeParams colorSchemeParams = new CustomTabColorSchemeParams.Builder().setToolbarColor(toolbarColor).setNavigationBarColor(navigationbarColor).setNavigationBarDividerColor(navigationbarDividerColor).build();
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().setDefaultColorSchemeParams(colorSchemeParams).setShowTitle(true).build();
try {
customTabsIntent.launchUrl(context, uri);
} catch (ActivityNotFoundException e) {
Log.w("LinkHelper", "Activity was not found for intent " + customTabsIntent);
openLinkInBrowser(uri, context);
}
}
Aggregations