Search in sources :

Example 1 with Snackbar

use of org.chromium.chrome.browser.snackbar.Snackbar in project AndroidChromium by JackyAndroid.

the class NewTabPage method showMostVisitedItemRemovedSnackbar.

private void showMostVisitedItemRemovedSnackbar(String url) {
    if (mMostVisitedItemRemovedController == null) {
        mMostVisitedItemRemovedController = new SnackbarController() {

            @Override
            public void onDismissNoAction(Object actionData) {
            }

            /** Undoes the most visited item removal. */
            @Override
            public void onAction(Object actionData) {
                if (mIsDestroyed)
                    return;
                String url = (String) actionData;
                mMostVisitedSites.removeBlacklistedUrl(url);
            }
        };
    }
    Context context = mNewTabPageView.getContext();
    Snackbar snackbar = Snackbar.make(context.getString(R.string.most_visited_item_removed), mMostVisitedItemRemovedController, Snackbar.TYPE_ACTION, Snackbar.UMA_NTP_MOST_VISITED_DELETE_UNDO).setAction(context.getString(R.string.undo), url);
    mTab.getSnackbarManager().showSnackbar(snackbar);
}
Also used : Context(android.content.Context) SnackbarController(org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController) Snackbar(org.chromium.chrome.browser.snackbar.Snackbar)

Example 2 with Snackbar

use of org.chromium.chrome.browser.snackbar.Snackbar in project AndroidChromium by JackyAndroid.

the class OfflinePageUtils method showReloadSnackbar.

/**
     * 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);
}
Also used : Snackbar(org.chromium.chrome.browser.snackbar.Snackbar)

Example 3 with Snackbar

use of org.chromium.chrome.browser.snackbar.Snackbar in project AndroidChromium by JackyAndroid.

the class DownloadSnackbarController method onDownloadSucceeded.

/**
     * Called to display the download succeeded snackbar.
     *
     * @param downloadInfo Info of the download.
     * @param notificationId Notification Id of the successful download.
     * @param downloadId Id of the download from Android DownloadManager.
     * @param canBeResolved Whether the download can be resolved to any activity.
     */
public void onDownloadSucceeded(DownloadInfo downloadInfo, int notificationId, long downloadId, boolean canBeResolved) {
    if (getSnackbarManager() == null)
        return;
    Snackbar snackbar = Snackbar.make(mContext.getString(R.string.download_succeeded_message, downloadInfo.getFileName()), this, Snackbar.TYPE_NOTIFICATION, Snackbar.UMA_DOWNLOAD_SUCCEEDED);
    // TODO(qinmin): Coalesce snackbars if multiple downloads finish at the same time.
    snackbar.setDuration(SNACKBAR_DURATION_IN_MILLISECONDS).setSingleLine(false);
    ActionDataInfo info = null;
    if (canBeResolved || downloadInfo.isOfflinePage()) {
        info = new ActionDataInfo(downloadInfo, notificationId, downloadId);
    }
    // Show downloads app if the download cannot be resolved to any activity.
    snackbar.setAction(mContext.getString(R.string.open_downloaded_label), info);
    getSnackbarManager().showSnackbar(snackbar);
}
Also used : Snackbar(org.chromium.chrome.browser.snackbar.Snackbar)

Example 4 with Snackbar

use of org.chromium.chrome.browser.snackbar.Snackbar in project AndroidChromium by JackyAndroid.

the class DownloadSnackbarController method onDownloadFailed.

/**
     * Called to display the download failed snackbar.
     *
     * @param errorMessage     The message to show on the snackbar.
     * @param showAllDownloads Whether to show all downloads in case the failure is caused by
     *                         duplicated files.
     */
public void onDownloadFailed(String errorMessage, boolean showAllDownloads) {
    if (getSnackbarManager() == null)
        return;
    // TODO(qinmin): Coalesce snackbars if multiple downloads finish at the same time.
    Snackbar snackbar = Snackbar.make(errorMessage, this, Snackbar.TYPE_NOTIFICATION, Snackbar.UMA_DOWNLOAD_FAILED).setSingleLine(false).setDuration(SNACKBAR_DURATION_IN_MILLISECONDS);
    if (showAllDownloads) {
        snackbar.setAction(mContext.getString(R.string.open_downloaded_label), null);
    }
    getSnackbarManager().showSnackbar(snackbar);
}
Also used : Snackbar(org.chromium.chrome.browser.snackbar.Snackbar)

Example 5 with Snackbar

use of org.chromium.chrome.browser.snackbar.Snackbar in project AndroidChromium by JackyAndroid.

the class AutoSigninSnackbarController method showSnackbar.

/**
     * 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);
}
Also used : Bitmap(android.graphics.Bitmap) SnackbarManager(org.chromium.chrome.browser.snackbar.SnackbarManager) Resources(android.content.res.Resources) Snackbar(org.chromium.chrome.browser.snackbar.Snackbar) CalledByNative(org.chromium.base.annotations.CalledByNative)

Aggregations

Snackbar (org.chromium.chrome.browser.snackbar.Snackbar)9 Context (android.content.Context)3 SnackbarManager (org.chromium.chrome.browser.snackbar.SnackbarManager)2 SnackbarController (org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController)2 Resources (android.content.res.Resources)1 Bitmap (android.graphics.Bitmap)1 Uri (android.net.Uri)1 SpannableString (android.text.SpannableString)1 TypefaceSpan (android.text.style.TypefaceSpan)1 CalledByNative (org.chromium.base.annotations.CalledByNative)1 BookmarkId (org.chromium.components.bookmarks.BookmarkId)1 SpanInfo (org.chromium.ui.text.SpanApplier.SpanInfo)1