mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1068365 - Part 1: Make collapsed remote clients look grayed out. r=rnewman
There are two major ways to achieve this. One is to painstakingly update UI elements every time we fetch a group. I've done that. The other is to maintain expanded and collapsed layouts. I went quite far down that path; doing it is less pleasant than I expected for the following reasons: 1) we have to update the view graphics depending on the client device type anyway; 2) Android's view recycling does not track the expanded/collapsed state, so we either manage the expanded states and have multiple group types (see modern versions of SimpleExpandableListAdapter) or we duplicate the work we're doing here; 3) our expanded and collapsed layouts are so similar that duplicating them is worse than futzing with them in this manner.
This commit is contained in:
parent
8d4997a599
commit
535406cd17
@ -101,8 +101,27 @@ public class RemoteTabsExpandableListAdapter extends BaseExpandableListAdapter {
|
||||
|
||||
final RemoteClient client = clients.get(groupPosition);
|
||||
|
||||
// UI elements whose state depends on isExpanded, roughly from left to
|
||||
// right: device type icon; client name text color; expanded state
|
||||
// indicator.
|
||||
final int deviceTypeResId;
|
||||
final int textColorResId;
|
||||
final int deviceExpandedResId;
|
||||
|
||||
if (isExpanded && !client.tabs.isEmpty()) {
|
||||
deviceTypeResId = "desktop".equals(client.deviceType) ? R.drawable.sync_desktop : R.drawable.sync_mobile;
|
||||
textColorResId = R.color.home_text_color;
|
||||
deviceExpandedResId = R.drawable.home_group_expanded;
|
||||
} else {
|
||||
deviceTypeResId = "desktop".equals(client.deviceType) ? R.drawable.sync_desktop_inactive : R.drawable.sync_mobile_inactive;
|
||||
textColorResId = R.color.home_text_color_disabled;
|
||||
deviceExpandedResId = R.drawable.home_group_collapsed;
|
||||
}
|
||||
|
||||
// Now update the UI.
|
||||
final TextView nameView = (TextView) view.findViewById(R.id.client);
|
||||
nameView.setText(client.name);
|
||||
nameView.setTextColor(context.getResources().getColor(textColorResId));
|
||||
|
||||
final TextView lastModifiedView = (TextView) view.findViewById(R.id.last_synced);
|
||||
final long now = System.currentTimeMillis();
|
||||
@ -113,22 +132,13 @@ public class RemoteTabsExpandableListAdapter extends BaseExpandableListAdapter {
|
||||
// Therefore, we must handle null.
|
||||
final ImageView deviceTypeView = (ImageView) view.findViewById(R.id.device_type);
|
||||
if (deviceTypeView != null) {
|
||||
if ("desktop".equals(client.deviceType)) {
|
||||
deviceTypeView.setBackgroundResource(R.drawable.sync_desktop);
|
||||
} else {
|
||||
deviceTypeView.setBackgroundResource(R.drawable.sync_mobile);
|
||||
}
|
||||
deviceTypeView.setImageResource(deviceTypeResId);
|
||||
}
|
||||
|
||||
final ImageView deviceExpandedView = (ImageView) view.findViewById(R.id.device_expanded);
|
||||
if (deviceExpandedView != null) {
|
||||
// If there are no tabs to display, don't show an indicator at all.
|
||||
if (client.tabs.isEmpty()) {
|
||||
deviceExpandedView.setBackgroundResource(0);
|
||||
} else {
|
||||
final int resourceId = isExpanded ? R.drawable.home_group_expanded : R.drawable.home_group_collapsed;
|
||||
deviceExpandedView.setBackgroundResource(resourceId);
|
||||
}
|
||||
deviceExpandedView.setImageResource(client.tabs.isEmpty() ? 0 : deviceExpandedResId);
|
||||
}
|
||||
|
||||
return view;
|
||||
|
@ -18,7 +18,8 @@
|
||||
android:layout_width="@dimen/favicon_bg"
|
||||
android:layout_height="@dimen/favicon_bg"
|
||||
android:layout_marginLeft="10dip"
|
||||
android:layout_marginRight="10dip" />
|
||||
android:layout_marginRight="10dip"
|
||||
android:scaleType="center" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@ -48,6 +49,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginLeft="10dip"
|
||||
android:layout_marginRight="10dip" />
|
||||
android:layout_marginRight="10dip"
|
||||
android:scaleType="center" />
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -106,6 +106,10 @@
|
||||
|
||||
<color name="home_button_bar_bg">#FFF5F7F9</color>
|
||||
|
||||
<!-- Colour used for share overlay button labels -->
|
||||
<color name="home_text_color">@color/text_color_primary</color>
|
||||
<color name="home_text_color_disabled">#AFB1B3</color>
|
||||
|
||||
<color name="panel_image_item_background">#D1D9E1</color>
|
||||
|
||||
<!-- Swipe to refresh colors for dynamic panel -->
|
||||
|
@ -597,6 +597,7 @@
|
||||
|
||||
<style name="Widget.RemoteTabsListView" parent="Widget.HomeListView">
|
||||
<item name="android:childDivider">#E7ECF0</item>
|
||||
<item name="android:drawSelectorOnTop">true</item>
|
||||
</style>
|
||||
|
||||
<!-- TabsTray Row -->
|
||||
|
Loading…
Reference in New Issue
Block a user