summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorZoltan Szatmary-Ban <szatmz@google.com>2015-02-09 12:53:31 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-02-09 12:53:32 +0000
commit2c228d8d7a0180f4756e018bc90dabfad60e6caa (patch)
treec32f357845e2beaf976e1cb4e7facd0d0abf8f42 /src
parent324bd766ee1af9f6b7c7027336bdc15f81e39749 (diff)
parent3af2e4c35c898d61b6268f22123135b403b3fa3b (diff)
downloadpackages_apps_Settings-2c228d8d7a0180f4756e018bc90dabfad60e6caa.zip
packages_apps_Settings-2c228d8d7a0180f4756e018bc90dabfad60e6caa.tar.gz
packages_apps_Settings-2c228d8d7a0180f4756e018bc90dabfad60e6caa.tar.bz2
Merge "Eliminate duplicated code in Settings for category headers"
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/DataUsageSummary.java12
-rw-r--r--src/com/android/settings/DeviceAdminSettings.java11
-rw-r--r--src/com/android/settings/MasterClear.java11
-rw-r--r--src/com/android/settings/TrustedCredentialsSettings.java11
-rw-r--r--src/com/android/settings/Utils.java12
5 files changed, 17 insertions, 40 deletions
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java
index ce68e3d..8eb70e6 100644
--- a/src/com/android/settings/DataUsageSummary.java
+++ b/src/com/android/settings/DataUsageSummary.java
@@ -1835,8 +1835,8 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
final AppItem item = mItems.get(position);
if (getItemViewType(position) == 1) {
if (convertView == null) {
- convertView = inflateCategoryHeader(LayoutInflater.from(parent.getContext()),
- parent);
+ convertView = Utils.inflateCategoryHeader(LayoutInflater.from(
+ parent.getContext()), parent);
}
final TextView title = (TextView) convertView.findViewById(android.R.id.title);
@@ -2527,14 +2527,6 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
return view;
}
- private static View inflateCategoryHeader(LayoutInflater inflater, ViewGroup root) {
- final TypedArray a = inflater.getContext().obtainStyledAttributes(null,
- com.android.internal.R.styleable.Preference,
- com.android.internal.R.attr.preferenceCategoryStyle, 0);
- final int resId = a.getResourceId(com.android.internal.R.styleable.Preference_layout, 0);
- return inflater.inflate(resId, root, false);
- }
-
/**
* Test if any networks are currently limited.
*/
diff --git a/src/com/android/settings/DeviceAdminSettings.java b/src/com/android/settings/DeviceAdminSettings.java
index 334d18f..0e3dc42 100644
--- a/src/com/android/settings/DeviceAdminSettings.java
+++ b/src/com/android/settings/DeviceAdminSettings.java
@@ -303,7 +303,7 @@ public class DeviceAdminSettings extends ListFragment {
bindView(convertView, (DeviceAdminInfo) o);
} else {
if (convertView == null) {
- convertView = newTitleView(parent);
+ convertView = Utils.inflateCategoryHeader(mInflater, parent);
}
final TextView title = (TextView) convertView.findViewById(android.R.id.title);
title.setText((String)o);
@@ -322,15 +322,6 @@ public class DeviceAdminSettings extends ListFragment {
return v;
}
- private View newTitleView(ViewGroup parent) {
- final TypedArray a = mInflater.getContext().obtainStyledAttributes(null,
- com.android.internal.R.styleable.Preference,
- com.android.internal.R.attr.preferenceCategoryStyle, 0);
- final int resId = a.getResourceId(com.android.internal.R.styleable.Preference_layout,
- 0);
- return mInflater.inflate(resId, parent, false);
- }
-
private void bindView(View view, DeviceAdminInfo item) {
final Activity activity = getActivity();
ViewHolder vh = (ViewHolder) view.getTag();
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java
index 2b086a6..18b51d9 100644
--- a/src/com/android/settings/MasterClear.java
+++ b/src/com/android/settings/MasterClear.java
@@ -209,7 +209,7 @@ public class MasterClear extends Fragment {
.getAuthenticatorTypesAsUser(profileId);
final int M = descs.length;
- View titleView = newTitleView(contents, inflater);
+ View titleView = Utils.inflateCategoryHeader(inflater, contents);
final TextView titleText = (TextView) titleView.findViewById(android.R.id.title);
titleText.setText(userInfo.isManagedProfile() ? R.string.category_work
: R.string.category_personal);
@@ -275,13 +275,4 @@ public class MasterClear extends Fragment {
establishInitialState();
return mContentView;
}
-
- private View newTitleView(ViewGroup parent, LayoutInflater inflater) {
- final TypedArray a = inflater.getContext().obtainStyledAttributes(null,
- com.android.internal.R.styleable.Preference,
- com.android.internal.R.attr.preferenceCategoryStyle, 0);
- final int resId = a.getResourceId(com.android.internal.R.styleable.Preference_layout,
- 0);
- return inflater.inflate(resId, parent, false);
- }
}
diff --git a/src/com/android/settings/TrustedCredentialsSettings.java b/src/com/android/settings/TrustedCredentialsSettings.java
index e2b49d6..95a6bf4 100644
--- a/src/com/android/settings/TrustedCredentialsSettings.java
+++ b/src/com/android/settings/TrustedCredentialsSettings.java
@@ -321,7 +321,7 @@ public class TrustedCredentialsSettings extends Fragment {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) getActivity()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- convertView = inflateCategoryHeader(inflater, parent);
+ convertView = Utils.inflateCategoryHeader(inflater, parent);
}
final TextView title = (TextView) convertView.findViewById(android.R.id.title);
@@ -354,15 +354,6 @@ public class TrustedCredentialsSettings extends Fragment {
public int getListViewId(Tab tab) {
return tab.mExpandableList;
}
- private View inflateCategoryHeader(LayoutInflater inflater, ViewGroup parent) {
- final TypedArray a = inflater.getContext().obtainStyledAttributes(null,
- com.android.internal.R.styleable.Preference,
- com.android.internal.R.attr.preferenceCategoryStyle, 0);
- final int resId = a.getResourceId(com.android.internal.R.styleable.Preference_layout,
- 0);
- return inflater.inflate(resId, parent, false);
- }
-
}
private class TrustedCertificateAdapter extends BaseAdapter implements
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index a3dfddb..b85f5ce 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -37,6 +37,7 @@ import android.content.pm.ResolveInfo;
import android.content.pm.Signature;
import android.content.pm.UserInfo;
import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.content.res.Resources.NotFoundException;
import android.database.Cursor;
import android.graphics.Bitmap;
@@ -65,6 +66,7 @@ import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
+import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
@@ -1058,4 +1060,14 @@ public final class Utils {
return null;
}
+ public static View inflateCategoryHeader(LayoutInflater inflater, ViewGroup parent) {
+ final TypedArray a = inflater.getContext().obtainStyledAttributes(null,
+ com.android.internal.R.styleable.Preference,
+ com.android.internal.R.attr.preferenceCategoryStyle, 0);
+ final int resId = a.getResourceId(com.android.internal.R.styleable.Preference_layout,
+ 0);
+ a.recycle();
+ return inflater.inflate(resId, parent, false);
+ }
+
}