users) {
- if (users == null) {
- throw new IllegalArgumentException("A list of user details must be provided");
- }
- this.data = users;
- mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- }
-
- public UserHandle getUserHandle(int position) {
- if (position < 0 || position >= data.size()) {
- return null;
- }
- return data.get(position).mUserHandle;
- }
-
- @Override
- public View getDropDownView(int position, View convertView, ViewGroup parent) {
- final View row = convertView != null ? convertView : createUser(parent);
-
- UserDetails user = data.get(position);
- ((ImageView) row.findViewById(android.R.id.icon)).setImageDrawable(user.mIcon);
- ((TextView) row.findViewById(android.R.id.title)).setText(getTitle(user));
- return row;
- }
-
- private int getTitle(UserDetails user) {
- int userHandle = user.mUserHandle.getIdentifier();
- if (userHandle == UserHandle.USER_CURRENT
- || userHandle == ActivityManager.getCurrentUser()) {
- return R.string.category_personal;
- } else {
- return R.string.category_work;
- }
- }
-
- private View createUser(ViewGroup parent) {
- return mInflater.inflate(R.layout.user_preference, parent, false);
- }
-
- @Override
- public void registerDataSetObserver(DataSetObserver observer) {
- // We don't support observers
- }
-
- @Override
- public void unregisterDataSetObserver(DataSetObserver observer) {
- // We don't support observers
- }
-
- @Override
- public int getCount() {
- return data.size();
- }
-
- @Override
- public UserDetails getItem(int position) {
- return data.get(position);
- }
-
- @Override
- public long getItemId(int position) {
- return data.get(position).mUserHandle.getIdentifier();
- }
-
- @Override
- public boolean hasStableIds() {
- return false;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- return getDropDownView(position, convertView, parent);
- }
-
- @Override
- public int getItemViewType(int position) {
- return 0;
- }
-
- @Override
- public int getViewTypeCount() {
- return 1;
- }
-
- @Override
- public boolean isEmpty() {
- return data.isEmpty();
- }
-
- @Override
- public boolean areAllItemsEnabled() {
- return true;
- }
-
- @Override
- public boolean isEnabled(int position) {
- return true;
- }
-}
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index a9d2c8a3963..5a54ba40117 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -83,7 +83,8 @@ import android.view.animation.AnimationUtils;
import android.widget.ListView;
import android.widget.TabWidget;
import com.android.internal.util.UserIcons;
-import com.android.settings.UserAdapter.UserDetails;
+import com.android.settingslib.drawer.UserAdapter;
+import com.android.settingslib.drawer.UserAdapter.UserDetails;
import java.io.IOException;
import java.io.InputStream;
@@ -631,39 +632,6 @@ public final class Utils {
return currentUser.isManagedProfile();
}
- /**
- * Creates a {@link UserAdapter} if there is more than one profile on the device.
- *
- * The adapter can be used to populate a spinner that switches between the Settings
- * app on the different profiles.
- *
- * @return a {@link UserAdapter} or null if there is only one profile.
- */
- public static UserAdapter createUserSpinnerAdapter(UserManager userManager,
- Context context) {
- List userProfiles = userManager.getUserProfiles();
- if (userProfiles.size() < 2) {
- return null;
- }
-
- UserHandle myUserHandle = new UserHandle(UserHandle.myUserId());
- // The first option should be the current profile
- userProfiles.remove(myUserHandle);
- userProfiles.add(0, myUserHandle);
-
- return createUserAdapter(userManager, context, userProfiles);
- }
-
- public static UserAdapter createUserAdapter(UserManager userManager,
- Context context, List userProfiles) {
- ArrayList userDetails = new ArrayList(userProfiles.size());
- final int count = userProfiles.size();
- for (int i = 0; i < count; i++) {
- userDetails.add(new UserDetails(userProfiles.get(i), userManager, context));
- }
- return new UserAdapter(context, userDetails);
- }
-
/**
* Returns the target user for a Settings activity.
*
diff --git a/src/com/android/settings/dashboard/DashboardTileView.java b/src/com/android/settings/dashboard/DashboardTileView.java
index 94219d2e83f..5239c06fb35 100644
--- a/src/com/android/settings/dashboard/DashboardTileView.java
+++ b/src/com/android/settings/dashboard/DashboardTileView.java
@@ -16,7 +16,6 @@
package com.android.settings.dashboard;
-import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
@@ -24,10 +23,8 @@ import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
-
-import com.android.settings.ProfileSelectDialog;
import com.android.settings.R;
-import com.android.settings.Utils;
+import com.android.settings.SettingsActivity;
import com.android.settingslib.drawer.DashboardTile;
public class DashboardTileView extends FrameLayout implements View.OnClickListener {
@@ -92,22 +89,6 @@ public class DashboardTileView extends FrameLayout implements View.OnClickListen
@Override
public void onClick(View v) {
- clickTile(getContext(), mTile);
- }
-
- public static void clickTile(Context context, DashboardTile tile) {
- if (tile.fragment != null) {
- Utils.startWithFragment(context, tile.fragment, tile.fragmentArguments, null, 0,
- 0, tile.title);
- } else if (tile.intent != null) {
- int numUserHandles = tile.userHandle.size();
- if (numUserHandles > 1) {
- ProfileSelectDialog.show(((Activity) context).getFragmentManager(), tile);
- } else if (numUserHandles == 1) {
- context.startActivityAsUser(tile.intent, tile.userHandle.get(0));
- } else {
- context.startActivity(tile.intent);
- }
- }
+ ((SettingsActivity) getContext()).openTile(mTile);
}
}
diff --git a/src/com/android/settings/print/PrintSettingsFragment.java b/src/com/android/settings/print/PrintSettingsFragment.java
index 13b85186bbc..60e412327a9 100644
--- a/src/com/android/settings/print/PrintSettingsFragment.java
+++ b/src/com/android/settings/print/PrintSettingsFragment.java
@@ -56,17 +56,15 @@ import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;
-
import com.android.internal.content.PackageMonitor;
import com.android.internal.logging.MetricsLogger;
import com.android.settings.DialogCreatable;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.UserAdapter;
-import com.android.settings.Utils;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;
+import com.android.settingslib.drawer.UserAdapter;
import java.text.DateFormat;
import java.util.ArrayList;
@@ -191,7 +189,7 @@ public class PrintSettingsFragment extends SettingsPreferenceFragment
setEmptyView(emptyView);
final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
- mProfileSpinnerAdapter = Utils.createUserSpinnerAdapter(um, getActivity());
+ mProfileSpinnerAdapter = UserAdapter.createUserSpinnerAdapter(um, getActivity());
if (mProfileSpinnerAdapter != null) {
mSpinner = (Spinner) setPinnedHeaderView(R.layout.spinner_view);
mSpinner.setAdapter(mProfileSpinnerAdapter);