Merge "sysui: refactor for extensibility."
This commit is contained in:
committed by
Android (Google) Code Review
commit
08b61ea500
@@ -28,7 +28,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
sysui:itemHeight="@dimen/qs_detail_item_height" />
|
||||
sysui:itemHeight="@dimen/qs_detail_item_height"
|
||||
style="@style/AutoSizingList" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@android:id/empty"
|
||||
|
||||
@@ -75,6 +75,12 @@
|
||||
<attr name="horizontalSpacing" format="dimension" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="AutoSizingList">
|
||||
<!-- Whether AutoSizingList will show only as many items as fit on screen and
|
||||
remove extra items instead of scrolling. -->
|
||||
<attr name="enableAutoSizing" format="boolean" />
|
||||
</declare-styleable>
|
||||
|
||||
<!-- Theme for icons in the status bar (light/dark). background/fillColor is used for dual tone
|
||||
icons like wifi and signal, and singleToneColor is used for icons with only one tone.
|
||||
Contract: Pixel with fillColor blended over backgroundColor blended over translucent should
|
||||
|
||||
@@ -256,6 +256,9 @@
|
||||
<item name="numColumns">3</item>
|
||||
</style>
|
||||
|
||||
<style name="AutoSizingList">
|
||||
<item name="enableAutoSizing">true</item>
|
||||
</style>
|
||||
<style name="Theme.AlertDialogHost" parent="android:Theme.DeviceDefault">
|
||||
<item name="android:windowIsTranslucent">true</item>
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
|
||||
@@ -37,6 +37,7 @@ public class AutoSizingList extends LinearLayout {
|
||||
|
||||
private ListAdapter mAdapter;
|
||||
private int mCount;
|
||||
private boolean mEnableAutoSizing;
|
||||
|
||||
public AutoSizingList(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@@ -44,6 +45,8 @@ public class AutoSizingList extends LinearLayout {
|
||||
mHandler = new Handler();
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AutoSizingList);
|
||||
mItemSize = a.getDimensionPixelSize(R.styleable.AutoSizingList_itemHeight, 0);
|
||||
mEnableAutoSizing = a.getBoolean(R.styleable.AutoSizingList_enableAutoSizing, true);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
public void setAdapter(ListAdapter adapter) {
|
||||
@@ -60,7 +63,7 @@ public class AutoSizingList extends LinearLayout {
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int requestedHeight = MeasureSpec.getSize(heightMeasureSpec);
|
||||
if (requestedHeight != 0) {
|
||||
int count = Math.min(requestedHeight / mItemSize, getDesiredCount());
|
||||
int count = getItemCount(requestedHeight);
|
||||
if (mCount != count) {
|
||||
postRebindChildren();
|
||||
mCount = count;
|
||||
@@ -69,6 +72,12 @@ public class AutoSizingList extends LinearLayout {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
private int getItemCount(int requestedHeight) {
|
||||
int desiredCount = getDesiredCount();
|
||||
return mEnableAutoSizing ? Math.min(requestedHeight / mItemSize, desiredCount)
|
||||
: desiredCount;
|
||||
}
|
||||
|
||||
private int getDesiredCount() {
|
||||
return mAdapter != null ? mAdapter.getCount() : 0;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class QSDetail extends LinearLayout {
|
||||
|
||||
protected View mQsDetailHeader;
|
||||
protected TextView mQsDetailHeaderTitle;
|
||||
private Switch mQsDetailHeaderSwitch;
|
||||
protected Switch mQsDetailHeaderSwitch;
|
||||
private ImageView mQsDetailHeaderProgress;
|
||||
|
||||
protected QSTileHost mHost;
|
||||
|
||||
@@ -40,6 +40,8 @@ import com.android.systemui.statusbar.phone.UserAvatarView;
|
||||
*/
|
||||
public class UserDetailItemView extends LinearLayout {
|
||||
|
||||
protected static int layoutResId = R.layout.qs_user_detail_item;
|
||||
|
||||
private UserAvatarView mAvatar;
|
||||
private TextView mName;
|
||||
private Typeface mRegularTypeface;
|
||||
@@ -83,7 +85,7 @@ public class UserDetailItemView extends LinearLayout {
|
||||
ViewGroup root) {
|
||||
if (!(convertView instanceof UserDetailItemView)) {
|
||||
convertView = LayoutInflater.from(context).inflate(
|
||||
R.layout.qs_user_detail_item, root, false);
|
||||
layoutResId, root, false);
|
||||
}
|
||||
return (UserDetailItemView) convertView;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ import com.android.systemui.statusbar.policy.UserSwitcherController;
|
||||
*/
|
||||
public class UserDetailView extends PseudoGridView {
|
||||
|
||||
private Adapter mAdapter;
|
||||
protected Adapter mAdapter;
|
||||
|
||||
public UserDetailView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@@ -58,7 +58,7 @@ public class UserDetailView extends PseudoGridView {
|
||||
implements OnClickListener {
|
||||
|
||||
private final Context mContext;
|
||||
private final UserSwitcherController mController;
|
||||
protected UserSwitcherController mController;
|
||||
|
||||
public Adapter(Context context, UserSwitcherController controller) {
|
||||
super(controller);
|
||||
@@ -69,6 +69,11 @@ public class UserDetailView extends PseudoGridView {
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
UserSwitcherController.UserRecord item = getItem(position);
|
||||
return createUserDetailItemView(convertView, parent, item);
|
||||
}
|
||||
|
||||
public UserDetailItemView createUserDetailItemView(View convertView, ViewGroup parent,
|
||||
UserSwitcherController.UserRecord item) {
|
||||
UserDetailItemView v = UserDetailItemView.convertOrInflate(
|
||||
mContext, convertView, parent);
|
||||
if (v != convertView) {
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.widget.FrameLayout;
|
||||
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.qs.QSPanel;
|
||||
import com.android.systemui.qs.QSTile;
|
||||
import com.android.systemui.statusbar.policy.KeyguardUserSwitcher;
|
||||
import com.android.systemui.statusbar.policy.UserSwitcherController;
|
||||
|
||||
@@ -40,7 +41,7 @@ import com.android.systemui.statusbar.policy.UserSwitcherController;
|
||||
*/
|
||||
public class MultiUserSwitch extends FrameLayout implements View.OnClickListener {
|
||||
|
||||
private QSPanel mQsPanel;
|
||||
protected QSPanel mQsPanel;
|
||||
private KeyguardUserSwitcher mKeyguardUserSwitcher;
|
||||
private boolean mKeyguardMode;
|
||||
private UserSwitcherController.BaseUserAdapter mUserListener;
|
||||
@@ -49,7 +50,7 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener
|
||||
|
||||
private final int[] mTmpInt2 = new int[2];
|
||||
|
||||
private UserSwitcherController mUserSwitcherController;
|
||||
protected UserSwitcherController mUserSwitcherController;
|
||||
|
||||
public MultiUserSwitch(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@@ -126,7 +127,7 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener
|
||||
mTmpInt2[1] += center.getHeight() / 2;
|
||||
|
||||
mQsPanel.showDetailAdapter(true,
|
||||
mUserSwitcherController.userDetailAdapter,
|
||||
getUserDetailAdapter(),
|
||||
mTmpInt2);
|
||||
}
|
||||
} else {
|
||||
@@ -182,4 +183,7 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener
|
||||
return false;
|
||||
}
|
||||
|
||||
protected QSTile.DetailAdapter getUserDetailAdapter() {
|
||||
return mUserSwitcherController.userDetailAdapter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ public class UserSwitcherController {
|
||||
mExitGuestDialog.show();
|
||||
}
|
||||
|
||||
private void showAddUserDialog() {
|
||||
public void showAddUserDialog() {
|
||||
if (mAddUserDialog != null && mAddUserDialog.isShowing()) {
|
||||
mAddUserDialog.cancel();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user