Java Code Examples for org.chromium.base.ApiCompatibilityUtils#setTaskDescription()
The following examples show how to use
org.chromium.base.ApiCompatibilityUtils#setTaskDescription() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BookmarkUtils.java From delion with Apache License 2.0 | 5 votes |
/** * Updates the title of chrome shown in recent tasks. It only takes effect in document mode. */ public static void setTaskDescriptionInDocumentMode(Activity activity, String description) { if (FeatureUtilities.isDocumentMode(activity)) { // Setting icon to be null and color to be 0 will means "take no effect". ApiCompatibilityUtils.setTaskDescription(activity, description, null, 0); } }
Example 2
Source File: CustomTabActivity.java From delion with Apache License 2.0 | 5 votes |
@Override public void postInflationStartup() { super.postInflationStartup(); setTabModelSelector(new TabModelSelectorImpl(this, TabModelSelectorImpl.CUSTOM_TABS_SELECTOR_INDEX, getWindowAndroid(), false)); getToolbarManager().setCloseButtonDrawable(mIntentDataProvider.getCloseButtonDrawable()); getToolbarManager().setShowTitle(mIntentDataProvider.getTitleVisibilityState() == CustomTabsIntent.SHOW_PAGE_TITLE); if (CustomTabsConnection.getInstance(getApplication()) .shouldHideDomainForSession(mSession)) { getToolbarManager().setUrlBarHidden(true); } int toolbarColor = mIntentDataProvider.getToolbarColor(); getToolbarManager().updatePrimaryColor(toolbarColor, false); if (!mIntentDataProvider.isOpenedByChrome()) { getToolbarManager().setShouldUpdateToolbarPrimaryColor(false); } if (toolbarColor != ApiCompatibilityUtils.getColor( getResources(), R.color.default_primary_color)) { ApiCompatibilityUtils.setStatusBarColor(getWindow(), ColorUtils.getDarkenedColorForStatusBar(toolbarColor)); } // Setting task title and icon to be null will preserve the client app's title and icon. ApiCompatibilityUtils.setTaskDescription(this, null, null, toolbarColor); showCustomButtonOnToolbar(); mBottomBarDelegate = new CustomTabBottomBarDelegate(this, mIntentDataProvider); mBottomBarDelegate.showBottomBarIfNecessary(); }
Example 3
Source File: WebappActivity.java From delion with Apache License 2.0 | 5 votes |
private void updateTaskDescription() { String title = null; if (!TextUtils.isEmpty(mWebappInfo.shortName())) { title = mWebappInfo.shortName(); } else if (getActivityTab() != null) { title = getActivityTab().getTitle(); } Bitmap icon = null; if (mWebappInfo.icon() != null) { icon = mWebappInfo.icon(); } else if (getActivityTab() != null) { icon = mLargestFavicon; } if (mBrandColor == null && mWebappInfo.hasValidThemeColor()) { mBrandColor = (int) mWebappInfo.themeColor(); } int taskDescriptionColor = ApiCompatibilityUtils.getColor(getResources(), R.color.default_primary_color); int statusBarColor = Color.BLACK; if (mBrandColor != null) { taskDescriptionColor = mBrandColor; statusBarColor = ColorUtils.getDarkenedColorForStatusBar(mBrandColor); } ApiCompatibilityUtils.setTaskDescription(this, title, icon, ColorUtils.getOpaqueColor(taskDescriptionColor)); ApiCompatibilityUtils.setStatusBarColor(getWindow(), statusBarColor); }
Example 4
Source File: CustomTabActivity.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void postInflationStartup() { super.postInflationStartup(); getToolbarManager().setCloseButtonDrawable(mIntentDataProvider.getCloseButtonDrawable()); getToolbarManager().setShowTitle(mIntentDataProvider.getTitleVisibilityState() == CustomTabsIntent.SHOW_PAGE_TITLE); if (CustomTabsConnection.getInstance(getApplication()) .shouldHideDomainForSession(mSession)) { getToolbarManager().setUrlBarHidden(true); } int toolbarColor = mIntentDataProvider.getToolbarColor(); getToolbarManager().updatePrimaryColor(toolbarColor, false); if (!mIntentDataProvider.isOpenedByChrome()) { getToolbarManager().setShouldUpdateToolbarPrimaryColor(false); } if (toolbarColor != ApiCompatibilityUtils.getColor( getResources(), R.color.default_primary_color)) { ApiCompatibilityUtils.setStatusBarColor(getWindow(), ColorUtils.getDarkenedColorForStatusBar(toolbarColor)); } // Setting task title and icon to be null will preserve the client app's title and icon. ApiCompatibilityUtils.setTaskDescription(this, null, null, toolbarColor); showCustomButtonOnToolbar(); mBottomBarDelegate = new CustomTabBottomBarDelegate(this, mIntentDataProvider); mBottomBarDelegate.showBottomBarIfNecessary(); }
Example 5
Source File: WebappActivity.java From AndroidChromium with Apache License 2.0 | 5 votes |
private void updateTaskDescription() { String title = null; if (!TextUtils.isEmpty(mWebappInfo.shortName())) { title = mWebappInfo.shortName(); } else if (getActivityTab() != null) { title = getActivityTab().getTitle(); } Bitmap icon = null; if (mWebappInfo.icon() != null) { icon = mWebappInfo.icon(); } else if (getActivityTab() != null) { icon = mLargestFavicon; } if (mBrandColor == null && mWebappInfo.hasValidThemeColor()) { mBrandColor = (int) mWebappInfo.themeColor(); } int taskDescriptionColor = ApiCompatibilityUtils.getColor(getResources(), R.color.default_primary_color); int statusBarColor = Color.BLACK; if (mBrandColor != null) { taskDescriptionColor = mBrandColor; statusBarColor = ColorUtils.getDarkenedColorForStatusBar(mBrandColor); } ApiCompatibilityUtils.setTaskDescription(this, title, icon, ColorUtils.getOpaqueColor(taskDescriptionColor)); ApiCompatibilityUtils.setStatusBarColor(getWindow(), statusBarColor); }
Example 6
Source File: CustomTabActivity.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void postInflationStartup() { super.postInflationStartup(); getToolbarManager().setCloseButtonDrawable(mIntentDataProvider.getCloseButtonDrawable()); getToolbarManager().setShowTitle(mIntentDataProvider.getTitleVisibilityState() == CustomTabsIntent.SHOW_PAGE_TITLE); if (CustomTabsConnection.getInstance(getApplication()) .shouldHideDomainForSession(mSession)) { getToolbarManager().setUrlBarHidden(true); } int toolbarColor = mIntentDataProvider.getToolbarColor(); getToolbarManager().updatePrimaryColor(toolbarColor, false); if (!mIntentDataProvider.isOpenedByChrome()) { getToolbarManager().setShouldUpdateToolbarPrimaryColor(false); } if (toolbarColor != ApiCompatibilityUtils.getColor( getResources(), R.color.default_primary_color)) { ApiCompatibilityUtils.setStatusBarColor(getWindow(), ColorUtils.getDarkenedColorForStatusBar(toolbarColor)); } // Properly attach tab's infobar to the view hierarchy, as the main tab might have been // initialized prior to inflation. if (mMainTab != null) { ViewGroup bottomContainer = (ViewGroup) findViewById(R.id.bottom_container); mMainTab.getInfoBarContainer().setParentView(bottomContainer); } // Setting task title and icon to be null will preserve the client app's title and icon. ApiCompatibilityUtils.setTaskDescription(this, null, null, toolbarColor); showCustomButtonOnToolbar(); mBottomBarDelegate = new CustomTabBottomBarDelegate(this, mIntentDataProvider, getFullscreenManager()); mBottomBarDelegate.showBottomBarIfNecessary(); }
Example 7
Source File: WebappActivity.java From 365browser with Apache License 2.0 | 5 votes |
private void updateTaskDescription() { String title = null; if (!TextUtils.isEmpty(mWebappInfo.shortName())) { title = mWebappInfo.shortName(); } else if (getActivityTab() != null) { title = getActivityTab().getTitle(); } Bitmap icon = null; if (mWebappInfo.icon() != null) { icon = mWebappInfo.icon(); } else if (getActivityTab() != null) { icon = mLargestFavicon; } if (mBrandColor == null && mWebappInfo.hasValidThemeColor()) { mBrandColor = (int) mWebappInfo.themeColor(); } int taskDescriptionColor = ApiCompatibilityUtils.getColor(getResources(), R.color.default_primary_color); // Don't use the brand color for the status bars if we're in display: fullscreen. This works // around an issue where the status bars go transparent and can't be seen on top of the page // content when users swipe them in or they appear because the on-screen keyboard was // triggered. int statusBarColor = Color.BLACK; if (mBrandColor != null && mWebappInfo.displayMode() != WebDisplayMode.FULLSCREEN) { taskDescriptionColor = mBrandColor; statusBarColor = ColorUtils.getDarkenedColorForStatusBar(mBrandColor); } ApiCompatibilityUtils.setTaskDescription(this, title, icon, ColorUtils.getOpaqueColor(taskDescriptionColor)); ApiCompatibilityUtils.setStatusBarColor(getWindow(), statusBarColor); }
Example 8
Source File: Preferences.java From delion with Apache License 2.0 | 4 votes |
@SuppressFBWarnings("DM_EXIT") @SuppressLint("InlinedApi") @Override protected void onCreate(Bundle savedInstanceState) { ensureActivityNotExported(); // The browser process must be started here because this Activity may be started explicitly // from Android notifications, when Android is restoring Preferences after Chrome was // killed, or for tests. This should happen before super.onCreate() because it might // recreate a fragment, and a fragment might depend on the native library. try { ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup(); } catch (ProcessInitException e) { Log.e(TAG, "Failed to start browser process.", e); // This can only ever happen, if at all, when the activity is started from an Android // notification (or in tests). As such we don't want to show an error messsage to the // user. The application is completely broken at this point, so close it down // completely (not just the activity). System.exit(-1); return; } super.onCreate(savedInstanceState); mIsNewlyCreated = savedInstanceState == null; String initialFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT); Bundle initialArguments = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // If savedInstanceState is non-null, then the activity is being // recreated and super.onCreate() has already recreated the fragment. if (savedInstanceState == null) { if (initialFragment == null) initialFragment = MainPreferences.class.getName(); Fragment fragment = Fragment.instantiate(this, initialFragment, initialArguments); getFragmentManager().beginTransaction() .replace(android.R.id.content, fragment) .commit(); } if (checkPermission(Manifest.permission.NFC, Process.myPid(), Process.myUid()) == PackageManager.PERMISSION_GRANTED) { // Disable Android Beam on JB and later devices. // In ICS it does nothing - i.e. we will send a Play Store link if NFC is used. NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); if (nfcAdapter != null) nfcAdapter.setNdefPushMessage(null, this); } Resources res = getResources(); ApiCompatibilityUtils.setTaskDescription(this, res.getString(R.string.app_name), BitmapFactory.decodeResource(res, R.mipmap.app_icon), ApiCompatibilityUtils.getColor(res, R.color.default_primary_color)); }
Example 9
Source File: Preferences.java From AndroidChromium with Apache License 2.0 | 4 votes |
@SuppressFBWarnings("DM_EXIT") @SuppressLint("InlinedApi") @Override protected void onCreate(Bundle savedInstanceState) { ensureActivityNotExported(); // The browser process must be started here because this Activity may be started explicitly // from Android notifications, when Android is restoring Preferences after Chrome was // killed, or for tests. This should happen before super.onCreate() because it might // recreate a fragment, and a fragment might depend on the native library. try { ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup(); } catch (ProcessInitException e) { Log.e(TAG, "Failed to start browser process.", e); // This can only ever happen, if at all, when the activity is started from an Android // notification (or in tests). As such we don't want to show an error messsage to the // user. The application is completely broken at this point, so close it down // completely (not just the activity). System.exit(-1); return; } super.onCreate(savedInstanceState); mIsNewlyCreated = savedInstanceState == null; String initialFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT); Bundle initialArguments = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // If savedInstanceState is non-null, then the activity is being // recreated and super.onCreate() has already recreated the fragment. if (savedInstanceState == null) { if (initialFragment == null) initialFragment = MainPreferences.class.getName(); Fragment fragment = Fragment.instantiate(this, initialFragment, initialArguments); getFragmentManager().beginTransaction() .replace(android.R.id.content, fragment) .commit(); } if (ApiCompatibilityUtils.checkPermission( this, Manifest.permission.NFC, Process.myPid(), Process.myUid()) == PackageManager.PERMISSION_GRANTED) { // Disable Android Beam on JB and later devices. // In ICS it does nothing - i.e. we will send a Play Store link if NFC is used. NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); if (nfcAdapter != null) nfcAdapter.setNdefPushMessage(null, this); } Resources res = getResources(); ApiCompatibilityUtils.setTaskDescription(this, res.getString(R.string.app_name), BitmapFactory.decodeResource(res, R.mipmap.app_icon), ApiCompatibilityUtils.getColor(res, R.color.default_primary_color)); }
Example 10
Source File: Preferences.java From 365browser with Apache License 2.0 | 4 votes |
@SuppressFBWarnings("DM_EXIT") @SuppressLint("InlinedApi") @Override protected void onCreate(Bundle savedInstanceState) { ensureActivityNotExported(); // The browser process must be started here because this Activity may be started explicitly // from Android notifications, when Android is restoring Preferences after Chrome was // killed, or for tests. This should happen before super.onCreate() because it might // recreate a fragment, and a fragment might depend on the native library. try { ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup(); } catch (ProcessInitException e) { Log.e(TAG, "Failed to start browser process.", e); // This can only ever happen, if at all, when the activity is started from an Android // notification (or in tests). As such we don't want to show an error messsage to the // user. The application is completely broken at this point, so close it down // completely (not just the activity). System.exit(-1); return; } super.onCreate(savedInstanceState); mIsNewlyCreated = savedInstanceState == null; String initialFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT); Bundle initialArguments = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // If savedInstanceState is non-null, then the activity is being // recreated and super.onCreate() has already recreated the fragment. if (savedInstanceState == null) { if (initialFragment == null) initialFragment = MainPreferences.class.getName(); Fragment fragment = Fragment.instantiate(this, initialFragment, initialArguments); getFragmentManager().beginTransaction() .replace(android.R.id.content, fragment) .commit(); } if (ApiCompatibilityUtils.checkPermission( this, Manifest.permission.NFC, Process.myPid(), Process.myUid()) == PackageManager.PERMISSION_GRANTED) { // Disable Android Beam on JB and later devices. // In ICS it does nothing - i.e. we will send a Play Store link if NFC is used. NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); if (nfcAdapter != null) nfcAdapter.setNdefPushMessage(null, this); } Resources res = getResources(); ApiCompatibilityUtils.setTaskDescription(this, res.getString(R.string.app_name), BitmapFactory.decodeResource(res, R.mipmap.app_icon), ApiCompatibilityUtils.getColor(res, R.color.default_primary_color)); }
Example 11
Source File: ActivityTabTaskDescriptionHelper.java From delion with Apache License 2.0 | 3 votes |
/** * Update the task description with the specified icon and label. * * <p> * This is only publicly visible to allow activities to set this early during initialization * prior to the tab's being available. * * @param label The text to use in the task description. * @param icon The icon to use in the task description. */ public void updateTaskDescription(String label, Bitmap icon) { int color = mDefaultThemeColor; if (mCurrentTab != null && !mCurrentTab.isDefaultThemeColor()) { color = mCurrentTab.getThemeColor(); } ApiCompatibilityUtils.setTaskDescription(mActivity, label, icon, color); }
Example 12
Source File: ActivityTabTaskDescriptionHelper.java From AndroidChromium with Apache License 2.0 | 3 votes |
/** * Update the task description with the specified icon and label. * * <p> * This is only publicly visible to allow activities to set this early during initialization * prior to the tab's being available. * * @param label The text to use in the task description. * @param icon The icon to use in the task description. */ public void updateTaskDescription(String label, Bitmap icon) { int color = mDefaultThemeColor; if (mCurrentTab != null && !mCurrentTab.isDefaultThemeColor()) { color = mCurrentTab.getThemeColor(); } ApiCompatibilityUtils.setTaskDescription(mActivity, label, icon, color); }
Example 13
Source File: ActivityTabTaskDescriptionHelper.java From 365browser with Apache License 2.0 | 3 votes |
/** * Update the task description with the specified icon and label. * * <p> * This is only publicly visible to allow activities to set this early during initialization * prior to the tab's being available. * * @param label The text to use in the task description. * @param icon The icon to use in the task description. */ public void updateTaskDescription(String label, Bitmap icon) { int color = mDefaultThemeColor; if (mCurrentTab != null && !mCurrentTab.isDefaultThemeColor()) { color = mCurrentTab.getThemeColor(); } ApiCompatibilityUtils.setTaskDescription(mActivity, label, icon, color); }