use of org.chromium.base.library_loader.ProcessInitException in project AndroidChromium by JackyAndroid.
the class NotificationPlatformBridge method launchNotificationPreferences.
/**
* Launches the notifications preferences screen. If the received intent indicates it came
* from the gear button on a flipped notification, this launches the site specific preferences
* screen.
*
* @param context The context that received the intent.
* @param incomingIntent The received intent.
*/
public static void launchNotificationPreferences(Context context, Intent incomingIntent) {
// UrlFormatter.formatUrlForSecurityDisplay.
try {
ChromeBrowserInitializer.getInstance(context).handleSynchronousStartup();
} catch (ProcessInitException e) {
Log.e(TAG, "Failed to start browser process.", e);
// The library failed to initialize and nothing in the application can work, so kill
// the whole application.
System.exit(-1);
return;
}
// Use the application context because it lives longer. When using the given context, it
// may be stopped before the preferences intent is handled.
Context applicationContext = context.getApplicationContext();
// If we can read an origin from the intent, use it to open the settings screen for that
// origin.
String origin = getOriginFromTag(incomingIntent.getStringExtra(NotificationConstants.EXTRA_NOTIFICATION_TAG));
boolean launchSingleWebsitePreferences = origin != null;
String fragmentName = launchSingleWebsitePreferences ? SingleWebsitePreferences.class.getName() : SingleCategoryPreferences.class.getName();
Intent preferencesIntent = PreferencesLauncher.createIntentForSettingsPage(applicationContext, fragmentName);
Bundle fragmentArguments;
if (launchSingleWebsitePreferences) {
// Record that the user has clicked on the [Site Settings] button.
RecordUserAction.record("Notifications.ShowSiteSettings");
// All preferences for a specific origin.
fragmentArguments = SingleWebsitePreferences.createFragmentArgsForSite(origin);
} else {
// Notification preferences for all origins.
fragmentArguments = new Bundle();
fragmentArguments.putString(SingleCategoryPreferences.EXTRA_CATEGORY, SiteSettingsCategory.CATEGORY_NOTIFICATIONS);
fragmentArguments.putString(SingleCategoryPreferences.EXTRA_TITLE, applicationContext.getResources().getString(R.string.push_notifications_permission_title));
}
preferencesIntent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS, fragmentArguments);
// We need to ensure that no existing preference tasks are being re-used in order for the
// new activity to appear on top.
preferencesIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
applicationContext.startActivity(preferencesIntent);
}
Aggregations