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
This commit is contained in:
@@ -47,6 +47,7 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment
|
|||||||
implements ApplicationsState.Callbacks {
|
implements ApplicationsState.Callbacks {
|
||||||
|
|
||||||
public static final String ARG_PACKAGE_NAME = "package";
|
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 String TAG = AppInfoBase.class.getSimpleName();
|
||||||
protected static final boolean localLOGV = false;
|
protected static final boolean localLOGV = false;
|
||||||
@@ -197,10 +198,11 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment
|
|||||||
refreshUi();
|
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) {
|
String pkg, int uid, Fragment source, int request) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString(AppInfoBase.ARG_PACKAGE_NAME, pkg);
|
args.putString(AppInfoBase.ARG_PACKAGE_NAME, pkg);
|
||||||
|
args.putInt(AppInfoBase.ARG_PACKAGE_UID, uid);
|
||||||
|
|
||||||
Intent intent = Utils.onBuildStartFragmentIntent(source.getActivity(), fragment.getName(),
|
Intent intent = Utils.onBuildStartFragmentIntent(source.getActivity(), fragment.getName(),
|
||||||
args, null, titleRes, null, false);
|
args, null, titleRes, null, false);
|
||||||
|
@@ -70,6 +70,7 @@ import com.android.settings.fuelgauge.BatteryEntry;
|
|||||||
import com.android.settings.fuelgauge.PowerUsageDetail;
|
import com.android.settings.fuelgauge.PowerUsageDetail;
|
||||||
import com.android.settings.net.ChartData;
|
import com.android.settings.net.ChartData;
|
||||||
import com.android.settings.net.ChartDataLoader;
|
import com.android.settings.net.ChartDataLoader;
|
||||||
|
import com.android.settings.notification.AppNotificationSettings;
|
||||||
import com.android.settings.notification.NotificationBackend;
|
import com.android.settings.notification.NotificationBackend;
|
||||||
import com.android.settings.notification.NotificationBackend.AppRow;
|
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
|
// start new fragment to display extended information
|
||||||
Bundle args = new Bundle();
|
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);
|
args.putBoolean(AppInfoWithHeader.EXTRA_HIDE_INFO_BUTTON, true);
|
||||||
|
|
||||||
SettingsActivity sa = (SettingsActivity) getActivity();
|
SettingsActivity sa = (SettingsActivity) getActivity();
|
||||||
sa.startPreferencePanel(fragment.getName(), args, -1, title, this, SUB_INFO_FRAGMENT);
|
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
|
* Method implementing functionality of buttons clicked
|
||||||
* @see android.view.View.OnClickListener#onClick(android.view.View)
|
* @see android.view.View.OnClickListener#onClick(android.view.View)
|
||||||
@@ -680,7 +673,8 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
if (preference == mStoragePreference) {
|
if (preference == mStoragePreference) {
|
||||||
startAppInfoFragment(AppStorageSettings.class, mStoragePreference.getTitle());
|
startAppInfoFragment(AppStorageSettings.class, mStoragePreference.getTitle());
|
||||||
} else if (preference == mNotificationPreference) {
|
} else if (preference == mNotificationPreference) {
|
||||||
startNotifications();
|
startAppInfoFragment(AppNotificationSettings.class,
|
||||||
|
getString(R.string.app_notifications_title));
|
||||||
} else if (preference == mPermissionsPreference) {
|
} else if (preference == mPermissionsPreference) {
|
||||||
startManagePermissionsActivity();
|
startManagePermissionsActivity();
|
||||||
} else if (preference == mLaunchPreference) {
|
} else if (preference == mLaunchPreference) {
|
||||||
|
@@ -68,6 +68,7 @@ import com.android.settings.applications.ApplicationsState.AppFilter;
|
|||||||
import com.android.settings.applications.ApplicationsState.CompoundFilter;
|
import com.android.settings.applications.ApplicationsState.CompoundFilter;
|
||||||
import com.android.settings.applications.ApplicationsState.VolumeFilter;
|
import com.android.settings.applications.ApplicationsState.VolumeFilter;
|
||||||
import com.android.settings.fuelgauge.HighPowerDetail;
|
import com.android.settings.fuelgauge.HighPowerDetail;
|
||||||
|
import com.android.settings.notification.AppNotificationSettings;
|
||||||
import com.android.settings.notification.NotificationBackend;
|
import com.android.settings.notification.NotificationBackend;
|
||||||
import com.android.settings.notification.NotificationBackend.AppRow;
|
import com.android.settings.notification.NotificationBackend.AppRow;
|
||||||
|
|
||||||
@@ -422,14 +423,10 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
|
|
||||||
// utility method used to start sub activity
|
// utility method used to start sub activity
|
||||||
private void startApplicationDetailsActivity() {
|
private void startApplicationDetailsActivity() {
|
||||||
Activity activity = getActivity();
|
|
||||||
switch (mListType) {
|
switch (mListType) {
|
||||||
case LIST_TYPE_NOTIFICATION:
|
case LIST_TYPE_NOTIFICATION:
|
||||||
activity.startActivityAsUser(new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
|
startAppInfoFragment(AppNotificationSettings.class,
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
R.string.app_notifications_title);
|
||||||
.putExtra(Settings.EXTRA_APP_PACKAGE, mCurrentPkgName)
|
|
||||||
.putExtra(Settings.EXTRA_APP_UID, mCurrentUid),
|
|
||||||
new UserHandle(UserHandle.getUserId(mCurrentUid)));
|
|
||||||
break;
|
break;
|
||||||
case LIST_TYPE_DOMAINS_URLS:
|
case LIST_TYPE_DOMAINS_URLS:
|
||||||
startAppInfoFragment(AppLaunchSettings.class, R.string.auto_launch_label);
|
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,
|
AppInfoBase.startAppInfoFragment(fragment, titleRes, mCurrentPkgName, mCurrentUid, this,
|
||||||
INSTALLED_APP_DETAILS);
|
INSTALLED_APP_DETAILS);
|
||||||
}
|
}
|
||||||
|
@@ -43,6 +43,7 @@ import com.android.settings.AppHeader;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
|
import com.android.settings.applications.AppInfoBase;
|
||||||
import com.android.settings.applications.AppInfoWithHeader;
|
import com.android.settings.applications.AppInfoWithHeader;
|
||||||
import com.android.settings.notification.NotificationBackend.AppRow;
|
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_SENSITIVE = "sensitive";
|
||||||
private static final String KEY_APP_SETTINGS = "app_settings";
|
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
|
private static final Intent APP_NOTIFICATION_PREFS_CATEGORY_INTENT
|
||||||
= new Intent(Intent.ACTION_MAIN)
|
= new Intent(Intent.ACTION_MAIN)
|
||||||
.addCategory(Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES);
|
.addCategory(Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES);
|
||||||
@@ -101,15 +99,20 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
mContext = getActivity();
|
mContext = getActivity();
|
||||||
Intent intent = getActivity().getIntent();
|
Intent intent = getActivity().getIntent();
|
||||||
|
Bundle args = getArguments();
|
||||||
if (DEBUG) Log.d(TAG, "onCreate getIntent()=" + intent);
|
if (DEBUG) Log.d(TAG, "onCreate getIntent()=" + intent);
|
||||||
if (intent == null) {
|
if (intent == null && args == null) {
|
||||||
Log.w(TAG, "No intent");
|
Log.w(TAG, "No intent");
|
||||||
toastAndFinish();
|
toastAndFinish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int uid = intent.getIntExtra(Settings.EXTRA_APP_UID, -1);
|
final String pkg = args != null && args.containsKey(AppInfoBase.ARG_PACKAGE_NAME)
|
||||||
final String pkg = intent.getStringExtra(Settings.EXTRA_APP_PACKAGE);
|
? 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)) {
|
if (uid == -1 || TextUtils.isEmpty(pkg)) {
|
||||||
Log.w(TAG, "Missing extras: " + Settings.EXTRA_APP_PACKAGE + " was " + pkg + ", "
|
Log.w(TAG, "Missing extras: " + Settings.EXTRA_APP_PACKAGE + " was " + pkg + ", "
|
||||||
+ Settings.EXTRA_APP_UID + " was " + uid);
|
+ Settings.EXTRA_APP_UID + " was " + uid);
|
||||||
@@ -136,17 +139,10 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
|
|||||||
|
|
||||||
mAppRow = mBackend.loadAppRow(pm, info.applicationInfo);
|
mAppRow = mBackend.loadAppRow(pm, info.applicationInfo);
|
||||||
|
|
||||||
if (intent.hasExtra(EXTRA_HAS_SETTINGS_INTENT)) {
|
// load settings intent
|
||||||
// use settings intent from extra
|
ArrayMap<String, AppRow> rows = new ArrayMap<String, AppRow>();
|
||||||
if (intent.getBooleanExtra(EXTRA_HAS_SETTINGS_INTENT, false)) {
|
rows.put(mAppRow.pkg, mAppRow);
|
||||||
mAppRow.settingsIntent = intent.getParcelableExtra(EXTRA_SETTINGS_INTENT);
|
collectConfigActivities(getPackageManager(), rows);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// load settings intent
|
|
||||||
ArrayMap<String, AppRow> rows = new ArrayMap<String, AppRow>();
|
|
||||||
rows.put(mAppRow.pkg, mAppRow);
|
|
||||||
collectConfigActivities(getPackageManager(), rows);
|
|
||||||
}
|
|
||||||
|
|
||||||
mBlock.setChecked(mAppRow.banned);
|
mBlock.setChecked(mAppRow.banned);
|
||||||
updateDependents(mAppRow.banned);
|
updateDependents(mAppRow.banned);
|
||||||
|
Reference in New Issue
Block a user