diff options
author | Jason Monk <jmonk@google.com> | 2015-05-13 11:36:45 -0400 |
---|---|---|
committer | Jason Monk <jmonk@google.com> | 2015-05-13 11:36:45 -0400 |
commit | 255452fdf4b368f150477e818b326a60210f22c1 (patch) | |
tree | db8c39d949bd768352956986999380cd72b66b0c /src | |
parent | f82cd8f4b3a533be352bdcee8cd29b6feb4df868 (diff) | |
download | packages_apps_Settings-255452fdf4b368f150477e818b326a60210f22c1.zip packages_apps_Settings-255452fdf4b368f150477e818b326a60210f22c1.tar.gz packages_apps_Settings-255452fdf4b368f150477e818b326a60210f22c1.tar.bz2 |
Start app notifications as fragment not intent
This lets it show the back arrow when coming from within the settings
app.
Bug: 20561808
Change-Id: I103c8fb74197c5a0530c363a234da5e2148726a7
Diffstat (limited to 'src')
4 files changed, 26 insertions, 37 deletions
diff --git a/src/com/android/settings/applications/AppInfoBase.java b/src/com/android/settings/applications/AppInfoBase.java index e42f246..442b1d8 100644 --- a/src/com/android/settings/applications/AppInfoBase.java +++ b/src/com/android/settings/applications/AppInfoBase.java @@ -47,6 +47,7 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment implements ApplicationsState.Callbacks { public static final String ARG_PACKAGE_NAME = "package"; + public static final String ARG_PACKAGE_UID = "uid"; protected static final String TAG = AppInfoBase.class.getSimpleName(); protected static final boolean localLOGV = false; @@ -197,10 +198,11 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment refreshUi(); } - public static void startAppInfoFragment(Class<? extends AppInfoBase> fragment, int titleRes, + public static void startAppInfoFragment(Class<?> fragment, int titleRes, String pkg, int uid, Fragment source, int request) { Bundle args = new Bundle(); args.putString(AppInfoBase.ARG_PACKAGE_NAME, pkg); + args.putInt(AppInfoBase.ARG_PACKAGE_UID, uid); Intent intent = Utils.onBuildStartFragmentIntent(source.getActivity(), fragment.getName(), args, null, titleRes, null, false); diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java index 99d0172..14ef433 100755 --- a/src/com/android/settings/applications/InstalledAppDetails.java +++ b/src/com/android/settings/applications/InstalledAppDetails.java @@ -70,6 +70,7 @@ import com.android.settings.fuelgauge.BatteryEntry; import com.android.settings.fuelgauge.PowerUsageDetail; import com.android.settings.net.ChartData; import com.android.settings.net.ChartDataLoader; +import com.android.settings.notification.AppNotificationSettings; import com.android.settings.notification.NotificationBackend; import com.android.settings.notification.NotificationBackend.AppRow; @@ -626,25 +627,17 @@ public class InstalledAppDetails extends AppInfoBase } } - private void startAppInfoFragment(Class<? extends AppInfoBase> fragment, CharSequence title) { + private void startAppInfoFragment(Class<?> fragment, CharSequence title) { // start new fragment to display extended information Bundle args = new Bundle(); - args.putString(InstalledAppDetails.ARG_PACKAGE_NAME, mAppEntry.info.packageName); + args.putString(ARG_PACKAGE_NAME, mAppEntry.info.packageName); + args.putInt(ARG_PACKAGE_UID, mAppEntry.info.uid); args.putBoolean(AppInfoWithHeader.EXTRA_HIDE_INFO_BUTTON, true); SettingsActivity sa = (SettingsActivity) getActivity(); sa.startPreferencePanel(fragment.getName(), args, -1, title, this, SUB_INFO_FRAGMENT); } - private void startNotifications() { - // start new fragment to display extended information - getActivity().startActivity(new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS) - .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) - .putExtra(AppInfoWithHeader.EXTRA_HIDE_INFO_BUTTON, true) - .putExtra(Settings.EXTRA_APP_PACKAGE, mAppEntry.info.packageName) - .putExtra(Settings.EXTRA_APP_UID, mAppEntry.info.uid)); - } - /* * Method implementing functionality of buttons clicked * @see android.view.View.OnClickListener#onClick(android.view.View) @@ -680,7 +673,8 @@ public class InstalledAppDetails extends AppInfoBase if (preference == mStoragePreference) { startAppInfoFragment(AppStorageSettings.class, mStoragePreference.getTitle()); } else if (preference == mNotificationPreference) { - startNotifications(); + startAppInfoFragment(AppNotificationSettings.class, + getString(R.string.app_notifications_title)); } else if (preference == mPermissionsPreference) { startManagePermissionsActivity(); } else if (preference == mLaunchPreference) { diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java index c74e23d..f8ba568 100644 --- a/src/com/android/settings/applications/ManageApplications.java +++ b/src/com/android/settings/applications/ManageApplications.java @@ -68,6 +68,7 @@ import com.android.settings.applications.ApplicationsState.AppFilter; import com.android.settings.applications.ApplicationsState.CompoundFilter; import com.android.settings.applications.ApplicationsState.VolumeFilter; import com.android.settings.fuelgauge.HighPowerDetail; +import com.android.settings.notification.AppNotificationSettings; import com.android.settings.notification.NotificationBackend; import com.android.settings.notification.NotificationBackend.AppRow; @@ -422,14 +423,10 @@ public class ManageApplications extends InstrumentedFragment // utility method used to start sub activity private void startApplicationDetailsActivity() { - Activity activity = getActivity(); switch (mListType) { case LIST_TYPE_NOTIFICATION: - activity.startActivityAsUser(new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS) - .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) - .putExtra(Settings.EXTRA_APP_PACKAGE, mCurrentPkgName) - .putExtra(Settings.EXTRA_APP_UID, mCurrentUid), - new UserHandle(UserHandle.getUserId(mCurrentUid))); + startAppInfoFragment(AppNotificationSettings.class, + R.string.app_notifications_title); break; case LIST_TYPE_DOMAINS_URLS: startAppInfoFragment(AppLaunchSettings.class, R.string.auto_launch_label); @@ -452,7 +449,7 @@ public class ManageApplications extends InstrumentedFragment } } - private void startAppInfoFragment(Class<? extends AppInfoBase> fragment, int titleRes) { + private void startAppInfoFragment(Class<?> fragment, int titleRes) { AppInfoBase.startAppInfoFragment(fragment, titleRes, mCurrentPkgName, mCurrentUid, this, INSTALLED_APP_DETAILS); } diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java index 52c011c..8e995fe 100644 --- a/src/com/android/settings/notification/AppNotificationSettings.java +++ b/src/com/android/settings/notification/AppNotificationSettings.java @@ -43,6 +43,7 @@ import com.android.settings.AppHeader; import com.android.settings.R; import com.android.settings.SettingsPreferenceFragment; import com.android.settings.Utils; +import com.android.settings.applications.AppInfoBase; import com.android.settings.applications.AppInfoWithHeader; import com.android.settings.notification.NotificationBackend.AppRow; @@ -59,9 +60,6 @@ public class AppNotificationSettings extends SettingsPreferenceFragment { private static final String KEY_SENSITIVE = "sensitive"; private static final String KEY_APP_SETTINGS = "app_settings"; - static final String EXTRA_HAS_SETTINGS_INTENT = "has_settings_intent"; - static final String EXTRA_SETTINGS_INTENT = "settings_intent"; - private static final Intent APP_NOTIFICATION_PREFS_CATEGORY_INTENT = new Intent(Intent.ACTION_MAIN) .addCategory(Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES); @@ -101,15 +99,20 @@ public class AppNotificationSettings extends SettingsPreferenceFragment { super.onCreate(savedInstanceState); mContext = getActivity(); Intent intent = getActivity().getIntent(); + Bundle args = getArguments(); if (DEBUG) Log.d(TAG, "onCreate getIntent()=" + intent); - if (intent == null) { + if (intent == null && args == null) { Log.w(TAG, "No intent"); toastAndFinish(); return; } - final int uid = intent.getIntExtra(Settings.EXTRA_APP_UID, -1); - final String pkg = intent.getStringExtra(Settings.EXTRA_APP_PACKAGE); + final String pkg = args != null && args.containsKey(AppInfoBase.ARG_PACKAGE_NAME) + ? args.getString(AppInfoBase.ARG_PACKAGE_NAME) + : intent.getStringExtra(Settings.EXTRA_APP_PACKAGE); + final int uid = args != null && args.containsKey(AppInfoBase.ARG_PACKAGE_UID) + ? args.getInt(AppInfoBase.ARG_PACKAGE_UID) + : intent.getIntExtra(Settings.EXTRA_APP_UID, -1); if (uid == -1 || TextUtils.isEmpty(pkg)) { Log.w(TAG, "Missing extras: " + Settings.EXTRA_APP_PACKAGE + " was " + pkg + ", " + Settings.EXTRA_APP_UID + " was " + uid); @@ -136,17 +139,10 @@ public class AppNotificationSettings extends SettingsPreferenceFragment { mAppRow = mBackend.loadAppRow(pm, info.applicationInfo); - if (intent.hasExtra(EXTRA_HAS_SETTINGS_INTENT)) { - // use settings intent from extra - if (intent.getBooleanExtra(EXTRA_HAS_SETTINGS_INTENT, false)) { - mAppRow.settingsIntent = intent.getParcelableExtra(EXTRA_SETTINGS_INTENT); - } - } else { - // load settings intent - ArrayMap<String, AppRow> rows = new ArrayMap<String, AppRow>(); - rows.put(mAppRow.pkg, mAppRow); - collectConfigActivities(getPackageManager(), rows); - } + // load settings intent + ArrayMap<String, AppRow> rows = new ArrayMap<String, AppRow>(); + rows.put(mAppRow.pkg, mAppRow); + collectConfigActivities(getPackageManager(), rows); mBlock.setChecked(mAppRow.banned); updateDependents(mAppRow.banned); |