Link to external settings activity from the app header.
Bug: 26288458 Change-Id: Ib7c723f23a09f2dbcb6c9738db8e455fb7b82462
This commit is contained in:
@@ -39,27 +39,38 @@ public class AppHeader {
|
||||
|
||||
public static void createAppHeader(SettingsPreferenceFragment fragment, Drawable icon,
|
||||
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,
|
||||
String pkgName, int uid, ViewGroup pinnedHeader) {
|
||||
final View bar = activity.getLayoutInflater().inflate(R.layout.app_header,
|
||||
pinnedHeader, false);
|
||||
setupHeaderView(activity, icon, label, pkgName, uid, false, 0, bar);
|
||||
setupHeaderView(activity, icon, label, pkgName, uid, false, 0, bar, null);
|
||||
pinnedHeader.addView(bar);
|
||||
}
|
||||
|
||||
public static void createAppHeader(SettingsPreferenceFragment fragment, Drawable icon,
|
||||
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);
|
||||
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,
|
||||
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);
|
||||
appIcon.setImageDrawable(icon);
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user