Remove Users & profiles header for phones

In Settings/Users, remove "Users & profiles" header is no longer displayed
for phones. List of UserPreference is now explicitly sorted. Before, it
was relying on an overridden compareTo method in UserPreference, which
behavior was difficult to predict when instances of UserPreference were
mixed with other instances in the same group.

Bug:17630523
Change-Id: Iba1ef863c2cd4e8ca307ae0aa0877c5cd9e0973d
This commit is contained in:
Fyodor Kupolov
2014-12-08 14:15:36 -08:00
parent a754c6ba05
commit 5514509963
2 changed files with 93 additions and 45 deletions

View File

@@ -26,10 +26,26 @@ import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
import java.util.Comparator;
public class UserPreference extends Preference {
public static final int USERID_UNKNOWN = -10;
public static final int USERID_GUEST_DEFAULTS = -11;
public static final Comparator<UserPreference> SERIAL_NUMBER_COMPARATOR =
new Comparator<UserPreference>() {
@Override
public int compare(UserPreference p1, UserPreference p2) {
int sn1 = p1.getSerialNumber();
int sn2 = p2.getSerialNumber();
if (sn1 < sn2) {
return -1;
} else if (sn1 > sn2) {
return 1;
}
return 0;
}
};
private OnClickListener mDeleteClickListener;
private OnClickListener mSettingsClickListener;
@@ -105,12 +121,4 @@ public class UserPreference extends Preference {
public int getUserId() {
return mUserId;
}
public int compareTo(Preference another) {
if (another instanceof UserPreference) {
return getSerialNumber() > ((UserPreference) another).getSerialNumber() ? 1 : -1;
} else {
return 1;
}
}
}