Link to external settings activity from the app header.
Bug: 26288458 Change-Id: Ib7c723f23a09f2dbcb6c9738db8e455fb7b82462
This commit is contained in:
@@ -18,12 +18,6 @@
|
|||||||
android:title="@string/app_notifications_title"
|
android:title="@string/app_notifications_title"
|
||||||
android:key="app_notification_settings">
|
android:key="app_notification_settings">
|
||||||
|
|
||||||
<!-- App notification preferences -->
|
|
||||||
<Preference
|
|
||||||
android:key="app_settings"
|
|
||||||
android:title="@string/app_notification_preferences"
|
|
||||||
android:order="1" />
|
|
||||||
|
|
||||||
<!-- Apps without topics -->
|
<!-- Apps without topics -->
|
||||||
<!-- Importance -->
|
<!-- Importance -->
|
||||||
<Preference
|
<Preference
|
||||||
|
@@ -39,27 +39,38 @@ public class AppHeader {
|
|||||||
|
|
||||||
public static void createAppHeader(SettingsPreferenceFragment fragment, Drawable icon,
|
public static void createAppHeader(SettingsPreferenceFragment fragment, Drawable icon,
|
||||||
CharSequence label, String pkgName, int uid) {
|
CharSequence label, String pkgName, int uid) {
|
||||||
createAppHeader(fragment, icon, label, pkgName, uid, 0);
|
createAppHeader(fragment, icon, label, pkgName, uid, 0, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void createAppHeader(SettingsPreferenceFragment fragment, Drawable icon,
|
||||||
|
CharSequence label, String pkgName, int uid, Intent externalSettings) {
|
||||||
|
createAppHeader(fragment, icon, label, pkgName, uid, 0, externalSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createAppHeader(Activity activity, Drawable icon, CharSequence label,
|
public static void createAppHeader(Activity activity, Drawable icon, CharSequence label,
|
||||||
String pkgName, int uid, ViewGroup pinnedHeader) {
|
String pkgName, int uid, ViewGroup pinnedHeader) {
|
||||||
final View bar = activity.getLayoutInflater().inflate(R.layout.app_header,
|
final View bar = activity.getLayoutInflater().inflate(R.layout.app_header,
|
||||||
pinnedHeader, false);
|
pinnedHeader, false);
|
||||||
setupHeaderView(activity, icon, label, pkgName, uid, false, 0, bar);
|
setupHeaderView(activity, icon, label, pkgName, uid, false, 0, bar, null);
|
||||||
pinnedHeader.addView(bar);
|
pinnedHeader.addView(bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createAppHeader(SettingsPreferenceFragment fragment, Drawable icon,
|
public static void createAppHeader(SettingsPreferenceFragment fragment, Drawable icon,
|
||||||
CharSequence label, String pkgName, int uid, int tintColorRes) {
|
CharSequence label, String pkgName, int uid, int tintColorRes) {
|
||||||
|
createAppHeader(fragment, icon, label, pkgName, uid, tintColorRes, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void createAppHeader(SettingsPreferenceFragment fragment, Drawable icon,
|
||||||
|
CharSequence label, String pkgName, int uid, int tintColorRes,
|
||||||
|
Intent externalSettings) {
|
||||||
View bar = fragment.setPinnedHeaderView(R.layout.app_header);
|
View bar = fragment.setPinnedHeaderView(R.layout.app_header);
|
||||||
setupHeaderView(fragment.getActivity(), icon, label, pkgName, uid, includeAppInfo(fragment),
|
setupHeaderView(fragment.getActivity(), icon, label, pkgName, uid, includeAppInfo(fragment),
|
||||||
tintColorRes, bar);
|
tintColorRes, bar, externalSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static View setupHeaderView(final Activity activity, Drawable icon, CharSequence label,
|
public static View setupHeaderView(final Activity activity, Drawable icon, CharSequence label,
|
||||||
final String pkgName, final int uid, final boolean includeAppInfo, int tintColorRes,
|
final String pkgName, final int uid, final boolean includeAppInfo, int tintColorRes,
|
||||||
View bar) {
|
View bar, final Intent externalSettings) {
|
||||||
final ImageView appIcon = (ImageView) bar.findViewById(R.id.app_icon);
|
final ImageView appIcon = (ImageView) bar.findViewById(R.id.app_icon);
|
||||||
appIcon.setImageDrawable(icon);
|
appIcon.setImageDrawable(icon);
|
||||||
if (tintColorRes != 0) {
|
if (tintColorRes != 0) {
|
||||||
@@ -83,6 +94,16 @@ public class AppHeader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (externalSettings != null) {
|
||||||
|
final View appSettings = bar.findViewById(R.id.app_settings);
|
||||||
|
appSettings.setVisibility(View.VISIBLE);
|
||||||
|
appSettings.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
activity.startActivity(externalSettings);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return bar;
|
return bar;
|
||||||
}
|
}
|
||||||
|
@@ -282,7 +282,7 @@ public class AppDataUsage extends DataUsageBase implements Preference.OnPreferen
|
|||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
}
|
}
|
||||||
AppHeader.setupHeaderView(getActivity(), mIcon, mLabel,
|
AppHeader.setupHeaderView(getActivity(), mIcon, mLabel,
|
||||||
pkg, uid, AppHeader.includeAppInfo(this), 0, header);
|
pkg, uid, AppHeader.includeAppInfo(this), 0, header, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -51,7 +51,6 @@ public class AppNotificationSettings extends NotificationSettingsBase {
|
|||||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||||
|
|
||||||
private static final String KEY_BLOCK = "block";
|
private static final String KEY_BLOCK = "block";
|
||||||
private static final String KEY_APP_SETTINGS = "app_settings";
|
|
||||||
private static final String KEY_CATEGORIES = "categories";
|
private static final String KEY_CATEGORIES = "categories";
|
||||||
|
|
||||||
private static final Intent APP_NOTIFICATION_PREFS_CATEGORY_INTENT
|
private static final Intent APP_NOTIFICATION_PREFS_CATEGORY_INTENT
|
||||||
@@ -66,7 +65,8 @@ public class AppNotificationSettings extends NotificationSettingsBase {
|
|||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
if (mAppRow == null) return;
|
if (mAppRow == null) return;
|
||||||
AppHeader.createAppHeader(this, mAppRow.icon, mAppRow.label, mAppRow.pkg, mAppRow.uid);
|
AppHeader.createAppHeader(this, mAppRow.icon, mAppRow.label, mAppRow.pkg, mAppRow.uid,
|
||||||
|
mAppRow.settingsIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -127,19 +127,6 @@ public class AppNotificationSettings extends NotificationSettingsBase {
|
|||||||
mCategories.addPreference(topicPreference);
|
mCategories.addPreference(topicPreference);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mAppRow.settingsIntent != null) {
|
|
||||||
findPreference(KEY_APP_SETTINGS).setOnPreferenceClickListener(
|
|
||||||
new OnPreferenceClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
mContext.startActivity(mAppRow.settingsIntent);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
removePreference(KEY_APP_SETTINGS);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user