use of android.support.customtabs.CustomTabsIntent in project Reader by TheKeeperOfPie.
the class ActivityMain method launchUrl.
private void launchUrl(String url, boolean replace) {
CustomTabsIntent intentCustomTabs = new CustomTabsIntent.Builder(customTabsSession).setStartAnimations(this, R.anim.slide_from_bottom, R.anim.nothing).setExitAnimations(this, R.anim.nothing, R.anim.slide_to_bottom).setToolbarColor(themer.getColorPrimary()).setSecondaryToolbarColor(themer.getColorAccent()).setShowTitle(true).enableUrlBarHiding().addDefaultShareMenuItem().build();
Intent intentChrome = getIntentForChrome();
if (intentChrome == null) {
if (replace) {
getSupportFragmentManager().beginTransaction().replace(R.id.frame_fragment, FragmentWeb.newInstance(url), FragmentWeb.TAG).addToBackStack(null).commit();
} else {
getSupportFragmentManager().beginTransaction().hide(getSupportFragmentManager().findFragmentById(R.id.frame_fragment)).add(R.id.frame_fragment, FragmentWeb.newInstance(url), FragmentWeb.TAG).addToBackStack(null).commit();
}
} else {
intentCustomTabs.intent.setComponent(intentChrome.getComponent());
intentCustomTabs.launchUrl(this, Uri.parse(url));
}
}
use of android.support.customtabs.CustomTabsIntent in project SeriesGuide by UweTrottmann.
the class BaseNavDrawerActivity method onNavItemClick.
private void onNavItemClick(int itemId) {
Intent launchIntent = null;
switch(itemId) {
case NAV_ITEM_ACCOUNT_CLOUD_ID:
{
launchIntent = new Intent(this, CloudSetupActivity.class);
break;
}
case NAV_ITEM_ACCOUNT_TRAKT_ID:
{
launchIntent = new Intent(this, ConnectTraktActivity.class);
break;
}
case R.id.navigation_item_shows:
if (this instanceof ShowsActivity) {
break;
}
launchIntent = new Intent(this, ShowsActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
break;
case R.id.navigation_item_lists:
if (this instanceof ListsActivity) {
break;
}
launchIntent = new Intent(this, ListsActivity.class).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
break;
case R.id.navigation_item_movies:
if (this instanceof MoviesActivity) {
break;
}
launchIntent = new Intent(this, MoviesActivity.class).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
break;
case R.id.navigation_item_stats:
if (this instanceof StatsActivity) {
break;
}
launchIntent = new Intent(this, StatsActivity.class).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
break;
case R.id.navigation_sub_item_settings:
launchIntent = new Intent(this, SeriesGuidePreferences.class);
break;
case R.id.navigation_sub_item_help:
// if we cant find a package name, it means there is no browser that supports
// Chrome Custom Tabs installed. So, we fallback to the webview activity.
String packageName = CustomTabsHelper.getPackageNameToUse(this);
if (packageName == null) {
launchIntent = new Intent(this, HelpActivity.class);
} else {
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setShowTitle(true);
//noinspection deprecation
builder.setToolbarColor(getResources().getColor(Utils.resolveAttributeToResourceId(getTheme(), R.attr.colorPrimary)));
builder.setActionButton(BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_checkin), getString(R.string.feedback), PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(getApplicationContext(), FeedbackBroadcastReceiver.class), 0));
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.intent.setPackage(packageName);
customTabsIntent.intent.setData(Uri.parse(getString(R.string.help_url)));
launchIntent = customTabsIntent.intent;
}
break;
case R.id.navigation_sub_item_unlock:
if (Utils.isAmazonVersion()) {
launchIntent = new Intent(this, AmazonBillingActivity.class);
} else {
launchIntent = new Intent(this, BillingActivity.class);
}
Utils.trackAction(this, TAG_NAV_DRAWER, "Unlock");
break;
}
// already displaying correct screen
if (launchIntent != null) {
final Intent finalLaunchIntent = launchIntent;
handler.postDelayed(new Runnable() {
@Override
public void run() {
goToNavDrawerItem(finalLaunchIntent);
}
}, NAVDRAWER_CLOSE_DELAY);
}
drawerLayout.closeDrawer(GravityCompat.START);
}
use of android.support.customtabs.CustomTabsIntent in project actor-platform by actorapp.
the class AndroidMarkdown method buildChromeIntent.
public static CustomTabsIntent buildChromeIntent() {
CustomTabsIntent.Builder customTabsIntent = new CustomTabsIntent.Builder();
// Intent sendIntent = new Intent(Intent.ACTION_SEND);
// sendIntent.setType("*/*");
// PendingIntent pi = PendingIntent.getActivity(AndroidContext.getContext() , 0, sendIntent, 0);
Intent actionIntent = new Intent(AndroidContext.getContext(), ChromeCustomTabReceiver.class);
PendingIntent pi = PendingIntent.getBroadcast(AndroidContext.getContext(), 0, actionIntent, 0);
customTabsIntent.setToolbarColor(ActorSDK.sharedActor().style.getMainColor()).setActionButton(BitmapFactory.decodeResource(AndroidContext.getContext().getResources(), R.drawable.ic_share_white_24dp), "Share", pi).setCloseButtonIcon(BitmapFactory.decodeResource(AndroidContext.getContext().getResources(), R.drawable.ic_arrow_back_white_24dp));
return customTabsIntent.build();
}
use of android.support.customtabs.CustomTabsIntent in project Talon-for-Twitter by klinker24.
the class SimpleCustomChromeTabsHelper method openUrlForResult.
public void openUrlForResult(String url, int requestCode) {
CustomTabsIntent customTabsIntent = buildCustomTabIntent(mCustomTabSession);
openUrlForResult(customTabsIntent, url, requestCode);
}
use of android.support.customtabs.CustomTabsIntent in project plaid by nickbutcher.
the class CustomTabActivityHelper method openCustomTab.
/**
* Opens the URL on a Custom Tab if possible; otherwise falls back to opening it via
* {@code Intent.ACTION_VIEW}
*
* @param activity The host activity
* @param customTabsIntent a CustomTabsIntent to be used if Custom Tabs is available
* @param uri the Uri to be opened
*/
public static void openCustomTab(Activity activity, CustomTabsIntent customTabsIntent, Uri uri) {
String packageName = CustomTabsHelper.getPackageNameToUse(activity);
// Custom Tabs installed. So, we fallback to a view intent
if (packageName != null) {
customTabsIntent.intent.setPackage(packageName);
customTabsIntent.launchUrl(activity, uri);
} else {
activity.startActivity(new Intent(Intent.ACTION_VIEW, uri));
}
}
Aggregations