Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/Preferences.java

Issue 942103003: Handle notification preferences intent from gear icon. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass tag. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.preferences; 5 package org.chromium.chrome.browser.preferences;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.app.Fragment; 8 import android.app.Fragment;
9 import android.app.Notification;
10 import android.content.Intent; 9 import android.content.Intent;
11 import android.content.pm.ActivityInfo; 10 import android.content.pm.ActivityInfo;
12 import android.content.pm.PackageManager.NameNotFoundException; 11 import android.content.pm.PackageManager.NameNotFoundException;
13 import android.content.res.Resources; 12 import android.content.res.Resources;
14 import android.graphics.BitmapFactory; 13 import android.graphics.BitmapFactory;
15 import android.nfc.NfcAdapter; 14 import android.nfc.NfcAdapter;
16 import android.os.Build; 15 import android.os.Build;
17 import android.os.Bundle; 16 import android.os.Bundle;
18 import android.preference.Preference; 17 import android.preference.Preference;
19 import android.preference.PreferenceFragment; 18 import android.preference.PreferenceFragment;
20 import android.preference.PreferenceFragment.OnPreferenceStartFragmentCallback; 19 import android.preference.PreferenceFragment.OnPreferenceStartFragmentCallback;
21 import android.support.v4.view.ViewCompat; 20 import android.support.v4.view.ViewCompat;
22 import android.support.v7.app.ActionBarActivity; 21 import android.support.v7.app.ActionBarActivity;
23 import android.util.Log; 22 import android.util.Log;
24 import android.view.MenuItem; 23 import android.view.MenuItem;
25 24
26 import org.chromium.base.ApiCompatibilityUtils; 25 import org.chromium.base.ApiCompatibilityUtils;
27 import org.chromium.base.VisibleForTesting; 26 import org.chromium.base.VisibleForTesting;
28 import org.chromium.base.annotations.SuppressFBWarnings; 27 import org.chromium.base.annotations.SuppressFBWarnings;
29 import org.chromium.base.library_loader.ProcessInitException; 28 import org.chromium.base.library_loader.ProcessInitException;
30 import org.chromium.chrome.R; 29 import org.chromium.chrome.R;
31 import org.chromium.chrome.browser.preferences.website.WebsitePreferences;
32 import org.chromium.chrome.browser.preferences.website.WebsiteSettingsCategoryFi lter;
33 30
34 /** 31 /**
35 * The Chrome settings activity. 32 * The Chrome settings activity.
36 * 33 *
37 * This activity displays a single Fragment, typically a PreferenceFragment. As the user navigates 34 * This activity displays a single Fragment, typically a PreferenceFragment. As the user navigates
38 * through settings, a separate Preferences activity is created for each screen. Thus each fragment 35 * through settings, a separate Preferences activity is created for each screen. Thus each fragment
39 * may freely modify its activity's action bar or title. This mimics the behavio r of 36 * may freely modify its activity's action bar or title. This mimics the behavio r of
40 * android.preference.PreferenceActivity. 37 * android.preference.PreferenceActivity.
41 */ 38 */
42 public abstract class Preferences extends ActionBarActivity implements 39 public abstract class Preferences extends ActionBarActivity implements
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 129 }
133 130
134 super.onCreate(savedInstanceState); 131 super.onCreate(savedInstanceState);
135 132
136 mIsNewlyCreated = savedInstanceState == null; 133 mIsNewlyCreated = savedInstanceState == null;
137 134
138 String initialFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT) ; 135 String initialFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT) ;
139 Bundle initialArguments = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT _ARGUMENTS); 136 Bundle initialArguments = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT _ARGUMENTS);
140 boolean displayHomeAsUp = getIntent().getBooleanExtra(EXTRA_DISPLAY_HOME _AS_UP, true); 137 boolean displayHomeAsUp = getIntent().getBooleanExtra(EXTRA_DISPLAY_HOME _AS_UP, true);
141 138
142 // The notification settings cog on the flipped side of Notifications an d in the Android
Peter Beverloo 2015/02/24 17:48:03 Please be sure to follow up by updating ChromeShel
Michael van Ouwerkerk 2015/02/25 18:12:45 Done.
143 // Settings "App Notifications" view will open us with a specific catego ry rather than
144 // the default intent extras which are commonly used to open specific vi ews.
145 if (getIntent().hasCategory(Notification.INTENT_CATEGORY_NOTIFICATION_PR EFERENCES)) {
146 Bundle arguments = new Bundle();
147 arguments.putString(WebsitePreferences.EXTRA_CATEGORY,
148 WebsiteSettingsCategoryFilter.FILTER_PUSH_NOTIFICATIONS);
149 arguments.putString(WebsitePreferences.EXTRA_TITLE,
150 getResources().getString(R.string.push_notifications_permiss ion_title));
151
152 // TODO(peter): Open the appropriate page for the origin in the Webs ite Settings.
153
154 initialFragment = WebsitePreferences.class.getName();
155 initialArguments = arguments;
156 displayHomeAsUp = false;
157 }
158
159 if (displayHomeAsUp) getSupportActionBar().setDisplayHomeAsUpEnabled(tru e); 139 if (displayHomeAsUp) getSupportActionBar().setDisplayHomeAsUpEnabled(tru e);
160 140
161 // This must be called before the fragment transaction below. 141 // This must be called before the fragment transaction below.
162 workAroundPlatformBugs(); 142 workAroundPlatformBugs();
163 143
164 // If savedInstanceState is non-null, then the activity is being 144 // If savedInstanceState is non-null, then the activity is being
165 // recreated and super.onCreate() has already recreated the fragment. 145 // recreated and super.onCreate() has already recreated the fragment.
166 if (savedInstanceState == null) { 146 if (savedInstanceState == null) {
167 if (initialFragment == null) initialFragment = getTopLevelFragmentNa me(); 147 if (initialFragment == null) initialFragment = getTopLevelFragmentNa me();
168 Fragment fragment = Fragment.instantiate(this, initialFragment, init ialArguments); 148 Fragment fragment = Fragment.instantiate(this, initialFragment, init ialArguments);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 // This must be called after setContentView(). 264 // This must be called after setContentView().
285 // https://code.google.com/p/android/issues/detail?id=78819 265 // https://code.google.com/p/android/issues/detail?id=78819
286 ViewCompat.postOnAnimation(getWindow().getDecorView(), new Runnable() { 266 ViewCompat.postOnAnimation(getWindow().getDecorView(), new Runnable() {
287 @Override 267 @Override
288 public void run() { 268 public void run() {
289 setTheme(R.style.PreferencesTheme); 269 setTheme(R.style.PreferencesTheme);
290 } 270 }
291 }); 271 });
292 } 272 }
293 } 273 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698