Dashboard search bar polish
Various tweaks to match redlines: - background is now grey all the time - the search icon is aligned with the other icons - the title text is primary colored instead of accent colored - the background of search bar doesn't scroll anymore Deletes a bunch of logic to add an initial view that would be colored based on the first view. It never quite worked right. Now it's consistent and never moves. Bug: 37477506 Change-Id: I82c584e8f8ecc6fc298c5cdbce08516c6a069a39 Fixes: 62267378 Fixes: 62379978 Fixes: 62361213 Test: robotests
This commit is contained in:
@@ -65,7 +65,6 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
private static final String STATE_CATEGORY_LIST = "category_list";
|
||||
private static final String STATE_SUGGESTION_MODE = "suggestion_mode";
|
||||
private static final String STATE_SUGGESTIONS_SHOWN_LOGGED = "suggestions_shown_logged";
|
||||
private static final int DONT_SET_BACKGROUND_ATTR = -1;
|
||||
private static final String STATE_SUGGESTION_CONDITION_MODE = "suggestion_condition_mode";
|
||||
|
||||
private final IconCache mCache;
|
||||
@@ -305,9 +304,6 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
public void onBindViewHolder(DashboardItemHolder holder, int position) {
|
||||
final int type = mDashboardData.getItemTypeByPosition(position);
|
||||
switch (type) {
|
||||
case R.layout.dashboard_header_spacer:
|
||||
onBindHeaderSpacer(holder, position);
|
||||
break;
|
||||
case R.layout.dashboard_tile:
|
||||
final Tile tile = (Tile) mDashboardData.getItemEntityByPosition(position);
|
||||
onBindTile(holder, tile);
|
||||
@@ -480,33 +476,6 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
notifyDashboardDataChanged(prevData);
|
||||
}
|
||||
|
||||
private void onBindHeaderSpacer(DashboardItemHolder holder, int position) {
|
||||
if (mDashboardData.size() > (position + 1)) {
|
||||
// The spacer that goes underneath the search bar needs to match the
|
||||
// background of the first real view. That view is either a condition,
|
||||
// a suggestion, or the dashboard item.
|
||||
//
|
||||
// If it's a dashboard item, set null background so it uses the parent's
|
||||
// background like the other views. Otherwise, match the colors.
|
||||
int nextType = mDashboardData.getItemTypeByPosition(position + 1);
|
||||
int colorAttr = nextType == R.layout.suggestion_header
|
||||
? android.R.attr.colorSecondary
|
||||
: nextType == R.layout.condition_card
|
||||
? android.R.attr.colorAccent
|
||||
: DONT_SET_BACKGROUND_ATTR;
|
||||
|
||||
if (colorAttr != DONT_SET_BACKGROUND_ATTR) {
|
||||
TypedArray array = holder.itemView.getContext()
|
||||
.obtainStyledAttributes(new int[]{colorAttr});
|
||||
@ColorInt int color = array.getColor(0, 0);
|
||||
array.recycle();
|
||||
holder.itemView.setBackgroundColor(color);
|
||||
} else {
|
||||
holder.itemView.setBackground(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void onBindSuggestionHeader(final DashboardItemHolder holder, DashboardData
|
||||
.SuggestionHeaderData data) {
|
||||
|
Reference in New Issue
Block a user