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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations