org.chromium.chrome.browser.notifications.NotificationManagerProxyImpl Java Examples

The following examples show how to use org.chromium.chrome.browser.notifications.NotificationManagerProxyImpl. 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: UrlManager.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Construct the UrlManager.
 * @param context An instance of android.content.Context
 */
@VisibleForTesting
public UrlManager(Context context) {
    mContext = context;
    mNotificationManager = new NotificationManagerProxyImpl(
            (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE));
    mPwsClient = new PwsClientImpl(context);
    mObservers = new ObserverList<Listener>();
    mNearbyUrls = new HashSet<>();
    mUrlInfoMap = new HashMap<>();
    mPwsResultMap = new HashMap<>();
    mUrlsSortedByTimestamp = new PriorityQueue<String>(1, new Comparator<String>() {
        @Override
        public int compare(String url1, String url2) {
            Long scanTimestamp1 = Long.valueOf(mUrlInfoMap.get(url1).getScanTimestamp());
            Long scanTimestamp2 = Long.valueOf(mUrlInfoMap.get(url2).getScanTimestamp());
            return scanTimestamp1.compareTo(scanTimestamp2);
        }
    });
    initSharedPreferences();
    registerNativeInitStartupCallback();
}
 
Example #2
Source File: PhysicalWebBroadcastService.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Surfaces a notification to the user that the Physical Web is broadcasting.
 * The notification specifies the URL that is being broadcast. It cannot be swiped away,
 * but broadcasting can be terminated with the stop button on the notification.
 */
private void createBroadcastNotification(String displayUrl) {
    Context context = getApplicationContext();
    PendingIntent stopPendingIntent = PendingIntent.getBroadcast(
            context, 0, new Intent(STOP_SERVICE), PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationManagerProxy notificationManager = new NotificationManagerProxyImpl(
            (NotificationManager) getSystemService(NOTIFICATION_SERVICE));
    ChromeNotificationBuilder notificationBuilder =
            NotificationBuilderFactory
                    .createChromeNotificationBuilder(
                            true /* preferCompat */, ChannelDefinitions.CHANNEL_ID_BROWSER)
                    .setSmallIcon(R.drawable.ic_image_white_24dp)
                    .setContentTitle(getString(R.string.physical_web_broadcast_notification))
                    .setContentText(displayUrl)
                    .setOngoing(true)
                    .addAction(android.R.drawable.ic_menu_close_clear_cancel,
                            getString(R.string.physical_web_stop_broadcast), stopPendingIntent);
    notificationManager.notify(
            NotificationConstants.NOTIFICATION_ID_PHYSICAL_WEB, notificationBuilder.build());
    NotificationUmaTracker.getInstance().onNotificationShown(
            NotificationUmaTracker.PHYSICAL_WEB, ChannelDefinitions.CHANNEL_ID_BROWSER);
}
 
Example #3
Source File: UrlManager.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Construct the UrlManager.
 * @param context An instance of android.content.Context
 */
public UrlManager(Context context) {
    mContext = context;
    mNotificationManager = new NotificationManagerProxyImpl(
            (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE));
    mPwsClient = new PwsClientImpl(context);
    mObservers = new ObserverList<Listener>();
    mNearbyUrls = new HashSet<>();
    mResolvedUrls = new HashSet<>();
    mUrlInfoMap = new HashMap<>();
    mUrlsSortedByTimestamp = new PriorityQueue<String>(1, mScanTimestampComparator);
    initSharedPreferences();
}
 
Example #4
Source File: PhysicalWebBroadcastService.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/** Turns off URL broadcasting. */
private void disableUrlBroadcasting() {
    NotificationManagerProxy notificationManager = new NotificationManagerProxyImpl(
            (NotificationManager) getSystemService(NOTIFICATION_SERVICE));
    notificationManager.cancel(NotificationConstants.NOTIFICATION_ID_PHYSICAL_WEB);
}