org.chromium.chrome.browser.snackbar.SnackbarManager Java Examples
The following examples show how to use
org.chromium.chrome.browser.snackbar.SnackbarManager.
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: AutoSigninSnackbarController.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Displays Auto sign-in snackbar, which communicates to the users that they * were signed in to the web site. */ @CalledByNative private static void showSnackbar(Tab tab, String text) { SnackbarManager snackbarManager = tab.getSnackbarManager(); if (snackbarManager == null) return; AutoSigninSnackbarController snackbarController = new AutoSigninSnackbarController(snackbarManager, tab); Snackbar snackbar = Snackbar.make(text, snackbarController, Snackbar.TYPE_NOTIFICATION, Snackbar.UMA_AUTO_LOGIN); Resources resources = tab.getWindowAndroid().getActivity().get().getResources(); int backgroundColor = ApiCompatibilityUtils.getColor(resources, R.color.light_active_color); Bitmap icon = BitmapFactory.decodeResource( resources, R.drawable.account_management_no_picture); snackbar.setSingleLine(false).setBackgroundColor(backgroundColor).setProfileImage(icon); snackbarManager.showSnackbar(snackbar); }
Example #2
Source File: AutoSigninSnackbarController.java From delion with Apache License 2.0 | 6 votes |
/** * Displays Auto sign-in snackbar, which communicates to the users that they * were signed in to the web site. */ @CalledByNative private static void showSnackbar(Tab tab, String text) { SnackbarManager snackbarManager = tab.getSnackbarManager(); if (snackbarManager == null) return; AutoSigninSnackbarController snackbarController = new AutoSigninSnackbarController(snackbarManager, tab); Snackbar snackbar = Snackbar.make(text, snackbarController, Snackbar.TYPE_NOTIFICATION, Snackbar.UMA_AUTO_LOGIN); Resources resources = tab.getWindowAndroid().getActivity().get().getResources(); int backgroundColor = ApiCompatibilityUtils.getColor(resources, R.color.light_active_color); Bitmap icon = BitmapFactory.decodeResource( resources, R.drawable.account_management_no_picture); snackbar.setSingleLine(false).setBackgroundColor(backgroundColor).setProfileImage(icon); snackbarManager.showSnackbar(snackbar); }
Example #3
Source File: OfflinePageTabObserver.java From 365browser with Apache License 2.0 | 6 votes |
/** * Builds a new OfflinePageTabObserver. * @param tabModelSelector Tab model selector for the activity. * @param snackbarManager The snackbar manager to show and dismiss snackbars. * @param snackbarController Controller to use to build the snackbar. */ OfflinePageTabObserver(TabModelSelector tabModelSelector, SnackbarManager snackbarManager, SnackbarController snackbarController) { mSnackbarManager = snackbarManager; mSnackbarController = snackbarController; mTabModelSelector = tabModelSelector; mTabModelObserver = new TabModelSelectorTabModelObserver(tabModelSelector) { @Override public void tabRemoved(Tab tab) { Log.d(TAG, "tabRemoved"); stopObservingTab(tab); mSnackbarManager.dismissSnackbars(mSnackbarController); } }; // The first time observer is created snackbar has net yet been shown. mIsObservingNetworkChanges = false; }
Example #4
Source File: AutoSigninSnackbarController.java From 365browser with Apache License 2.0 | 6 votes |
/** * Displays Auto sign-in snackbar, which communicates to the users that they * were signed in to the web site. */ @CalledByNative private static void showSnackbar(Tab tab, String text) { SnackbarManager snackbarManager = tab.getSnackbarManager(); if (snackbarManager == null) return; AutoSigninSnackbarController snackbarController = new AutoSigninSnackbarController(snackbarManager, tab); Snackbar snackbar = Snackbar.make(text, snackbarController, Snackbar.TYPE_NOTIFICATION, Snackbar.UMA_AUTO_LOGIN); Resources resources = tab.getWindowAndroid().getActivity().get().getResources(); int backgroundColor = ApiCompatibilityUtils.getColor(resources, R.color.light_active_color); Bitmap icon = BitmapFactory.decodeResource( resources, R.drawable.account_management_no_picture); snackbar.setSingleLine(false).setBackgroundColor(backgroundColor).setProfileImage(icon); snackbarManager.showSnackbar(snackbar); }
Example #5
Source File: SearchActivity.java From 365browser with Apache License 2.0 | 5 votes |
@Override protected void setContentView() { mSnackbarManager = new SnackbarManager(this, null); mSearchBoxDataProvider = new SearchBoxDataProvider(); mContentView = createContentView(); setContentView(mContentView); // Build the search box. mSearchBox = (SearchActivityLocationBarLayout) mContentView.findViewById( R.id.search_location_bar); mSearchBox.setDelegate(this); mSearchBox.setToolbarDataProvider(mSearchBoxDataProvider); mSearchBox.initializeControls(new WindowDelegate(getWindow()), getWindowAndroid()); // Kick off everything needed for the user to type into the box. beginQuery(); mSearchBox.showCachedZeroSuggestResultsIfAvailable(); // Kick off loading of the native library. if (!getActivityDelegate().shouldDelayNativeInitialization()) { mHandler.post(new Runnable() { @Override public void run() { startDelayedNativeInitialization(); } }); } }
Example #6
Source File: OfflinePageTabObserver.java From AndroidChromium with Apache License 2.0 | 5 votes |
void reinitialize(Context context, SnackbarManager manager, SnackbarController controller) { // TODO(fgorski): Work out if we need to also update network changes observer with the // context change. mContext = context; mSnackbarManager = manager; mSnackbarController = controller; }
Example #7
Source File: OfflinePageUtils.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Shows the "reload" snackbar for the given tab. * @param activity The activity owning the tab. * @param snackbarController Class to show the snackbar. */ public static void showReloadSnackbar(Context context, SnackbarManager snackbarManager, final SnackbarController snackbarController, int tabId) { if (tabId == Tab.INVALID_TAB_ID) return; Log.d(TAG, "showReloadSnackbar called with controller " + snackbarController); Snackbar snackbar = Snackbar.make(context.getString(R.string.offline_pages_viewing_offline_page), snackbarController, Snackbar.TYPE_ACTION, Snackbar.UMA_OFFLINE_PAGE_RELOAD) .setSingleLine(false).setAction(context.getString(R.string.reload), tabId); snackbar.setDuration(sSnackbarDurationMs); snackbarManager.showSnackbar(snackbar); }
Example #8
Source File: LocaleManager.java From AndroidChromium with Apache License 2.0 | 5 votes |
private void showSnackbar(CharSequence title) { SnackbarManager manager = mSnackbarManager.get(); if (manager == null) return; Context context = ContextUtils.getApplicationContext(); Snackbar snackbar = Snackbar.make(title, mSnackbarController, Snackbar.TYPE_NOTIFICATION, Snackbar.UMA_SPECIAL_LOCALE); snackbar.setDuration(SNACKBAR_DURATION_MS); snackbar.setAction(context.getString(R.string.preferences), null); manager.showSnackbar(snackbar); }
Example #9
Source File: GeolocationSnackbarController.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Shows the geolocation snackbar if it hasn't already been shown and the geolocation snackbar * is currently relevant: i.e. the default search engine is Google, location is enabled * for Chrome, the tab is not incognito, etc. * * @param snackbarManager The SnackbarManager used to show the snackbar. * @param view Any view that's attached to the view hierarchy. * @param isIncognito Whether the currently visible tab is incognito. * @param delayMs The delay in ms before the snackbar should be shown. This is intended to * give the keyboard time to animate in. */ public static void maybeShowSnackbar(final SnackbarManager snackbarManager, View view, boolean isIncognito, int delayMs) { final Context context = view.getContext(); if (ChromeFeatureList.isEnabled(ChromeFeatureList.CONSISTENT_OMNIBOX_GEOLOCATION)) return; if (getGeolocationSnackbarShown(context)) return; // If in incognito mode, don't show the snackbar now, but maybe show it later. if (isIncognito) return; if (neverShowSnackbar(context)) { setGeolocationSnackbarShown(context); return; } Uri searchUri = Uri.parse(TemplateUrlService.getInstance().getUrlForSearchQuery("foo")); TypefaceSpan robotoMediumSpan = new TypefaceSpan("sans-serif-medium"); String messageWithoutSpans = context.getResources().getString( R.string.omnibox_geolocation_disclosure, "<b>" + searchUri.getHost() + "</b>"); SpannableString message = SpanApplier.applySpans(messageWithoutSpans, new SpanInfo("<b>", "</b>", robotoMediumSpan)); String settings = context.getResources().getString(R.string.preferences); int durationMs = DeviceClassManager.isAccessibilityModeEnabled(view.getContext()) ? ACCESSIBILITY_SNACKBAR_DURATION_MS : SNACKBAR_DURATION_MS; final GeolocationSnackbarController controller = new GeolocationSnackbarController(); final Snackbar snackbar = Snackbar .make(message, controller, Snackbar.TYPE_ACTION, Snackbar.UMA_OMNIBOX_GEOLOCATION) .setAction(settings, view) .setSingleLine(false) .setDuration(durationMs); view.postDelayed(new Runnable() { @Override public void run() { snackbarManager.dismissSnackbars(controller); snackbarManager.showSnackbar(snackbar); setGeolocationSnackbarShown(context); } }, delayMs); }
Example #10
Source File: GeolocationSnackbarController.java From 365browser with Apache License 2.0 | 5 votes |
/** * Shows the geolocation snackbar if it hasn't already been shown and the geolocation snackbar * is currently relevant: i.e. the default search engine is Google, location is enabled * for Chrome, the tab is not incognito, etc. * * @param snackbarManager The SnackbarManager used to show the snackbar. * @param view Any view that's attached to the view hierarchy. * @param isIncognito Whether the currently visible tab is incognito. * @param delayMs The delay in ms before the snackbar should be shown. This is intended to * give the keyboard time to animate in. */ public static void maybeShowSnackbar(final SnackbarManager snackbarManager, View view, boolean isIncognito, int delayMs) { final Context context = view.getContext(); if (ChromeFeatureList.isEnabled(ChromeFeatureList.CONSISTENT_OMNIBOX_GEOLOCATION)) return; if (getGeolocationSnackbarShown(context)) return; // If in incognito mode, don't show the snackbar now, but maybe show it later. if (isIncognito) return; if (neverShowSnackbar(context)) { setGeolocationSnackbarShown(context); return; } Uri searchUri = Uri.parse(TemplateUrlService.getInstance().getUrlForSearchQuery("foo")); TypefaceSpan robotoMediumSpan = new TypefaceSpan("sans-serif-medium"); String messageWithoutSpans = context.getResources().getString( R.string.omnibox_geolocation_disclosure, "<b>" + searchUri.getHost() + "</b>"); SpannableString message = SpanApplier.applySpans(messageWithoutSpans, new SpanInfo("<b>", "</b>", robotoMediumSpan)); String settings = context.getResources().getString(R.string.preferences); int durationMs = AccessibilityUtil.isAccessibilityEnabled() ? ACCESSIBILITY_SNACKBAR_DURATION_MS : SNACKBAR_DURATION_MS; final GeolocationSnackbarController controller = new GeolocationSnackbarController(); final Snackbar snackbar = Snackbar .make(message, controller, Snackbar.TYPE_ACTION, Snackbar.UMA_OMNIBOX_GEOLOCATION) .setAction(settings, view) .setSingleLine(false) .setDuration(durationMs); view.postDelayed(new Runnable() { @Override public void run() { snackbarManager.dismissSnackbars(controller); snackbarManager.showSnackbar(snackbar); setGeolocationSnackbarShown(context); } }, delayMs); }
Example #11
Source File: BlimpMessageBuilder.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Get {@link SnackbarManager} of current focused activity. * @return The SnackbarManager or null if the activity doesn't hold a SnackbarManager. */ @VisibleForTesting protected SnackbarManager getSnackbarManager(Activity activity) { if (activity != null && activity instanceof SnackbarManager.SnackbarManageable) { return ((SnackbarManager.SnackbarManageable) activity).getSnackbarManager(); } return null; }
Example #12
Source File: LocaleManager.java From 365browser with Apache License 2.0 | 5 votes |
private void showSnackbar(CharSequence title) { SnackbarManager manager = mSnackbarManager.get(); if (manager == null) return; Context context = ContextUtils.getApplicationContext(); Snackbar snackbar = Snackbar.make(title, mSnackbarController, Snackbar.TYPE_NOTIFICATION, Snackbar.UMA_SPECIAL_LOCALE); snackbar.setDuration(SNACKBAR_DURATION_MS); snackbar.setAction(context.getString(R.string.preferences), null); manager.showSnackbar(snackbar); }
Example #13
Source File: DownloadSnackbarController.java From AndroidChromium with Apache License 2.0 | 5 votes |
public SnackbarManager getSnackbarManager() { Activity activity = ApplicationStatus.getLastTrackedFocusedActivity(); if (activity != null && ApplicationStatus.hasVisibleActivities() && activity instanceof SnackbarManager.SnackbarManageable) { return ((SnackbarManager.SnackbarManageable) activity).getSnackbarManager(); } return null; }
Example #14
Source File: BookmarkSheetContent.java From 365browser with Apache License 2.0 | 5 votes |
/** * @param activity The activity displaying the bookmark manager UI. * @param snackbarManager The {@link SnackbarManager} used to display snackbars. */ public BookmarkSheetContent(final ChromeActivity activity, SnackbarManager snackbarManager) { mBookmarkManager = new BookmarkManager(activity, false, snackbarManager); mBookmarkManager.updateForUrl(BookmarkUtils.getLastUsedUrl(activity)); mContentView = mBookmarkManager.getView(); mToolbarView = mBookmarkManager.detachToolbarView(); mToolbarView.addObserver(new SelectableListToolbar.SelectableListToolbarObserver() { @Override public void onThemeColorChanged(boolean isLightTheme) { activity.getBottomSheet().updateHandleTint(); } }); ((BottomToolbarPhone) activity.getToolbarManager().getToolbar()) .setOtherToolbarStyle(mToolbarView); }
Example #15
Source File: BookmarkUndoController.java From 365browser with Apache License 2.0 | 5 votes |
/** * Creates an instance of {@link BookmarkUndoController}. * @param context The {@link Context} in which snackbar is shown. * @param model The bookmark model. * @param snackbarManager SnackManager passed from activity. */ public BookmarkUndoController(Context context, BookmarkModel model, SnackbarManager snackbarManager) { mBookmarkModel = model; mBookmarkModel.addDeleteObserver(this); mSnackbarManager = snackbarManager; mContext = context; }
Example #16
Source File: DownloadSnackbarController.java From 365browser with Apache License 2.0 | 5 votes |
public SnackbarManager getSnackbarManager() { Activity activity = getActivity(); if (activity != null && activity instanceof SnackbarManager.SnackbarManageable) { return ((SnackbarManager.SnackbarManageable) activity).getSnackbarManager(); } return null; }
Example #17
Source File: OfflinePageUtils.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void showReloadSnackbar(Context context, SnackbarManager snackbarManager, final SnackbarController snackbarController, int tabId) { if (tabId == Tab.INVALID_TAB_ID) return; Log.d(TAG, "showReloadSnackbar called with controller " + snackbarController); Snackbar snackbar = Snackbar.make(context.getString(R.string.offline_pages_viewing_offline_page), snackbarController, Snackbar.TYPE_ACTION, Snackbar.UMA_OFFLINE_PAGE_RELOAD) .setSingleLine(false) .setAction(context.getString(R.string.reload), tabId); snackbar.setDuration(sSnackbarDurationMs); snackbarManager.showSnackbar(snackbar); }
Example #18
Source File: TileGroupDelegateImpl.java From 365browser with Apache License 2.0 | 5 votes |
public TileGroupDelegateImpl(ChromeActivity activity, Profile profile, TabModelSelector tabModelSelector, SuggestionsNavigationDelegate navigationDelegate, SnackbarManager snackbarManager) { mContext = activity; mSnackbarManager = snackbarManager; mTabModelSelector = tabModelSelector; mNavigationDelegate = navigationDelegate; mMostVisitedSites = buildMostVisitedSites(profile); }
Example #19
Source File: BookmarkUndoController.java From delion with Apache License 2.0 | 5 votes |
/** * Creates an instance of {@link BookmarkUndoController}. * @param context The {@link Context} in which snackbar is shown. * @param model The bookmark model. * @param snackbarManager SnackManager passed from activity. */ public BookmarkUndoController(Context context, BookmarkModel model, SnackbarManager snackbarManager) { mBookmarkModel = model; mBookmarkModel.addDeleteObserver(this); mSnackbarManager = snackbarManager; mContext = context; }
Example #20
Source File: HistorySheetContent.java From 365browser with Apache License 2.0 | 5 votes |
/** * @param activity The activity displaying the history manager UI. * @param snackbarManager The {@link SnackbarManager} used to display snackbars. */ public HistorySheetContent(final ChromeActivity activity, SnackbarManager snackbarManager) { mHistoryManager = new HistoryManager(activity, false, snackbarManager); mContentView = mHistoryManager.getView(); mToolbarView = mHistoryManager.detachToolbarView(); mToolbarView.addObserver(new SelectableListToolbar.SelectableListToolbarObserver() { @Override public void onThemeColorChanged(boolean isLightTheme) { activity.getBottomSheet().updateHandleTint(); } }); ((BottomToolbarPhone) activity.getToolbarManager().getToolbar()) .setOtherToolbarStyle(mToolbarView); }
Example #21
Source File: OfflinePageTabObserver.java From delion with Apache License 2.0 | 5 votes |
/** * Builds a new OfflinePageTabObserver. * @param context Android context. * @param snackbarManager The snackbar manager to show and dismiss snackbars. * @param snackbarController Controller to use to build the snackbar. */ OfflinePageTabObserver(Context context, SnackbarManager snackbarManager, SnackbarController snackbarController) { mContext = context; mSnackbarManager = snackbarManager; mSnackbarController = snackbarController; // The first time observer is created snackbar has net yet been shown. mWasSnackbarShown = false; mIsObservingNetworkChanges = false; }
Example #22
Source File: OfflinePageUtils.java From delion with Apache License 2.0 | 5 votes |
/** * Shows the "reload" snackbar for the given tab. * @param activity The activity owning the tab. * @param snackbarController Class to show the snackbar. */ public static void showReloadSnackbar(Context context, SnackbarManager snackbarManager, final SnackbarController snackbarController, int tabId) { if (tabId == Tab.INVALID_TAB_ID) return; Log.d(TAG, "showReloadSnackbar called with controller " + snackbarController); Snackbar snackbar = Snackbar.make(context.getString(R.string.offline_pages_viewing_offline_page), snackbarController, Snackbar.TYPE_ACTION, Snackbar.UMA_OFFLINE_PAGE_RELOAD) .setSingleLine(false).setAction(context.getString(R.string.reload), tabId); snackbar.setDuration(SNACKBAR_DURATION); snackbarManager.showSnackbar(snackbar); }
Example #23
Source File: DownloadSnackbarController.java From delion with Apache License 2.0 | 5 votes |
public SnackbarManager getSnackbarManager() { Activity activity = ApplicationStatus.getLastTrackedFocusedActivity(); if (activity != null && ApplicationStatus.hasVisibleActivities() && activity instanceof SnackbarManager.SnackbarManageable) { return ((SnackbarManager.SnackbarManageable) activity).getSnackbarManager(); } return null; }
Example #24
Source File: GeolocationSnackbarController.java From delion with Apache License 2.0 | 5 votes |
/** * Shows the geolocation snackbar if it hasn't already been shown and the geolocation snackbar * is currently relevant: i.e. the default search engine is Google, location is enabled * for Chrome, the tab is not incognito, etc. * * @param snackbarManager The SnackbarManager used to show the snackbar. * @param view Any view that's attached to the view hierarchy. * @param isIncognito Whether the currently visible tab is incognito. * @param delayMs The delay in ms before the snackbar should be shown. This is intended to * give the keyboard time to animate in. */ public static void maybeShowSnackbar(final SnackbarManager snackbarManager, View view, boolean isIncognito, int delayMs) { final Context context = view.getContext(); if (getGeolocationSnackbarShown(context)) return; // If in incognito mode, don't show the snackbar now, but maybe show it later. if (isIncognito) return; if (neverShowSnackbar(context)) { setGeolocationSnackbarShown(context); return; } Uri searchUri = Uri.parse(TemplateUrlService.getInstance().getUrlForSearchQuery("foo")); TypefaceSpan robotoMediumSpan = new TypefaceSpan("sans-serif-medium"); String messageWithoutSpans = context.getResources().getString( R.string.omnibox_geolocation_disclosure, "<b>" + searchUri.getHost() + "</b>"); SpannableString message = SpanApplier.applySpans(messageWithoutSpans, new SpanInfo("<b>", "</b>", robotoMediumSpan)); String settings = context.getResources().getString(R.string.preferences); int durationMs = DeviceClassManager.isAccessibilityModeEnabled(view.getContext()) ? ACCESSIBILITY_SNACKBAR_DURATION_MS : SNACKBAR_DURATION_MS; final GeolocationSnackbarController controller = new GeolocationSnackbarController(); final Snackbar snackbar = Snackbar .make(message, controller, Snackbar.TYPE_ACTION, Snackbar.UMA_OMNIBOX_GEOLOCATION) .setAction(settings, view) .setSingleLine(false) .setDuration(durationMs); view.postDelayed(new Runnable() { @Override public void run() { snackbarManager.dismissSnackbars(controller); snackbarManager.showSnackbar(snackbar); setGeolocationSnackbarShown(context); } }, delayMs); }
Example #25
Source File: OfflinePageTabObserver.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Builds a new OfflinePageTabObserver. * @param context Android context. * @param snackbarManager The snackbar manager to show and dismiss snackbars. * @param snackbarController Controller to use to build the snackbar. */ OfflinePageTabObserver(Context context, SnackbarManager snackbarManager, SnackbarController snackbarController) { reinitialize(context, snackbarManager, snackbarController); // The first time observer is created snackbar has net yet been shown. mIsObservingNetworkChanges = false; }
Example #26
Source File: InfoBarContainer.java From 365browser with Apache License 2.0 | 5 votes |
public SnackbarManager getSnackbarManager() { if (mTab != null && mTab.getActivity() != null) { return mTab.getActivity().getSnackbarManager(); } return null; }
Example #27
Source File: BookmarkUndoController.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Creates an instance of {@link BookmarkUndoController}. * @param context The {@link Context} in which snackbar is shown. * @param model The bookmark model. * @param snackbarManager SnackManager passed from activity. */ public BookmarkUndoController(Context context, BookmarkModel model, SnackbarManager snackbarManager) { mBookmarkModel = model; mBookmarkModel.addDeleteObserver(this); mSnackbarManager = snackbarManager; mContext = context; }
Example #28
Source File: OfflinePageTabObserver.java From AndroidChromium with Apache License 2.0 | 5 votes |
static void init(Context context, SnackbarManager manager, SnackbarController controller) { if (sInstance == null) { sInstance = new OfflinePageTabObserver(context, manager, controller); return; } sInstance.reinitialize(context, manager, controller); }
Example #29
Source File: SnackbarActivity.java From 365browser with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); mSnackbarManager = new SnackbarManager(this, null); }
Example #30
Source File: SnackbarActivity.java From 365browser with Apache License 2.0 | 4 votes |
@Override public SnackbarManager getSnackbarManager() { return mSnackbarManager; }