Merge "Allow extras to be passed to app info subscreens"

This commit is contained in:
TreeHugger Robot
2018-02-17 03:48:02 +00:00
committed by Android (Google) Code Review
7 changed files with 108 additions and 6 deletions

View File

@@ -505,10 +505,12 @@ public class AppInfoDashboardFragment extends DashboardFragment
mDisableAfterUninstall = andDisable;
}
public static void startAppInfoFragment(Class<?> fragment, int title,
public static void startAppInfoFragment(Class<?> fragment, int title, Bundle args,
SettingsPreferenceFragment caller, AppEntry appEntry) {
// start new fragment to display extended information
final Bundle args = new Bundle();
if (args == null) {
args = new Bundle();
}
args.putString(ARG_PACKAGE_NAME, appEntry.info.packageName);
args.putInt(ARG_PACKAGE_UID, appEntry.info.uid);

View File

@@ -17,6 +17,7 @@
package com.android.settings.applications.appinfo;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
@@ -58,7 +59,7 @@ public abstract class AppInfoPreferenceControllerBase extends BasePreferenceCont
public boolean handlePreferenceTreeClick(Preference preference) {
if (TextUtils.equals(preference.getKey(), mPreferenceKey) && mDetailFragmenClass != null) {
AppInfoDashboardFragment.startAppInfoFragment(
mDetailFragmenClass, -1, mParent, mParent.getAppEntry());
mDetailFragmenClass, -1, getArguments(), mParent, mParent.getAppEntry());
return true;
}
return false;
@@ -77,4 +78,12 @@ public abstract class AppInfoPreferenceControllerBase extends BasePreferenceCont
return null;
}
/**
* Gets any extras that should be passed to the fragment class when the preference is clicked.
* @return a bundle of extras to include in the launch intent
*/
protected Bundle getArguments() {
return null;
}
}

View File

@@ -16,7 +16,10 @@
package com.android.settings.applications.appinfo;
import static com.android.settings.SettingsActivity.EXTRA_FRAGMENT_ARG_KEY;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.preference.Preference;
import com.android.settings.SettingsPreferenceFragment;
@@ -27,12 +30,17 @@ import com.android.settingslib.applications.ApplicationsState;
public class AppNotificationPreferenceController extends AppInfoPreferenceControllerBase {
private static final String KEY_NOTIFICATION = "notification_settings";
private String mChannelId = null;
// Used for updating notification preference.
private final NotificationBackend mBackend = new NotificationBackend();
public AppNotificationPreferenceController(Context context, AppInfoDashboardFragment parent) {
super(context, parent, KEY_NOTIFICATION);
if (parent != null && parent.getActivity() != null
&& parent.getActivity().getIntent() != null) {
mChannelId = parent.getActivity().getIntent().getStringExtra(EXTRA_FRAGMENT_ARG_KEY);
}
}
@Override
@@ -45,6 +53,16 @@ public class AppNotificationPreferenceController extends AppInfoPreferenceContro
return AppNotificationSettings.class;
}
@Override
protected Bundle getArguments() {
Bundle bundle = null;
if (mChannelId != null) {
bundle = new Bundle();
bundle.putString(EXTRA_FRAGMENT_ARG_KEY, mChannelId);
}
return bundle;
}
private CharSequence getNotificationSummary(ApplicationsState.AppEntry appEntry,
Context context, NotificationBackend backend) {
NotificationBackend.AppRow appRow =

View File

@@ -285,6 +285,7 @@ public class UnrestrictedDataAccess extends SettingsPreferenceFragment
// app is blacklisted, launch App Data Usage screen
AppInfoDashboardFragment.startAppInfoFragment(AppDataUsage.class,
R.string.app_data_usage,
null /* arguments */,
UnrestrictedDataAccess.this,
mEntry);
} else {