Update suggestion/support UI to use more negative space.

Bug: 28435214

-- Tweaked layout and padding in suggestions and support tab.
-- Added support to show different text color in SlidingTabLayout.

Change-Id: If5d90ec5360e35565176aae7475e355c27fcef7c
This commit is contained in:
Fan Zhang
2016-05-04 17:33:25 -07:00
parent 28c44ebf65
commit 50cde75ef7
14 changed files with 162 additions and 104 deletions

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="false"
android:color="#b3ffffff"/>
<item android:color="@android:color/white"/>
</selector>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<ripple
xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:attr/colorControlHighlight">
<item android:drawable="@color/card_background_grey"/>
</ripple>

View File

@@ -14,6 +14,8 @@
limitations under the License.
-->
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="6dp" />
<View
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="6dp"
android:background="@color/card_background_grey"/>

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 Android Open Source Project
<!--
Copyright (C) 2016 Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -19,10 +20,10 @@
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@android:color/white"
android:gravity="center"
android:background="?android:attr/selectableItemBackground"
android:textAllCaps="true"
android:padding="@dimen/pager_tabs_title_padding"/>
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:padding="@dimen/pager_tabs_title_padding"
android:textColor="@color/sliding_tab_title_text_color"
android:textAllCaps="true"/>

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 The Android Open Source Project
<!--
Copyright (C) 2016 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -20,27 +21,31 @@
android:layout_height="@dimen/dashboard_category_height"
android:clickable="true"
android:focusable="true"
android:background="@drawable/selectable_card"
android:elevation="@dimen/dashboard_category_elevation"
android:background="@drawable/selectable_card_grey"
android:gravity="center_vertical" >
<TextView android:id="@android:id/title"
<ImageView
android:id="@android:id/icon"
android:layout_width="@dimen/dashboard_tile_image_size"
android:layout_height="@dimen/dashboard_tile_image_size"
android:layout_marginStart="@dimen/dashboard_tile_image_margin_start"
android:layout_marginEnd="@dimen/dashboard_tile_image_margin_end"
android:src="@drawable/ic_expand_more"/>
<TextView
android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingStart="16dp"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.TileTitle"
android:textColor="?android:attr/colorAccent"
android:alpha=".87"
android:ellipsize="marquee"
android:fadingEdge="horizontal" />
<ImageView android:id="@android:id/icon"
android:layout_width="@dimen/dashboard_tile_image_size"
android:layout_height="@dimen/dashboard_tile_image_size"
android:layout_marginStart="@dimen/suggestion_arrow_margin"
android:layout_marginEnd="@dimen/suggestion_arrow_margin"
android:src="@drawable/ic_expand_more" />
android:fadingEdge="horizontal"/>
<TextView
android:id="@android:id/summary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingEnd="16dp"
android:textAppearance="@style/TextAppearance.TileTitle"
android:textColor="?android:attr/colorAccent"/>
</LinearLayout>

View File

@@ -18,70 +18,58 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/selectable_card_grey"
android:clickable="true"
android:focusable="true"
android:background="@drawable/selectable_card"
android:elevation="@dimen/dashboard_category_elevation"
android:orientation="vertical" >
android:gravity="center_vertical"
android:minHeight="@dimen/dashboard_tile_minimum_height">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider" />
<ImageView
android:id="@android:id/icon"
android:layout_width="@dimen/dashboard_tile_image_size"
android:layout_height="@dimen/dashboard_tile_image_size"
android:layout_marginStart="@dimen/dashboard_tile_image_margin_start"
android:layout_marginEnd="@dimen/dashboard_tile_image_margin_end"
android:scaleType="centerInside"/>
<LinearLayout
android:layout_width="match_parent"
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="@dimen/dashboard_tile_minimum_height">
android:layout_weight="1">
<TextView android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.TileTitle"
android:ellipsize="marquee"
android:fadingEdge="horizontal"/>
<TextView android:id="@android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@android:id/title"
android:layout_alignStart="@android:id/title"
android:textAppearance="@style/TextAppearance.Small"
android:textColor="?android:attr/textColorSecondary"/>
</RelativeLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView
android:id="@android:id/icon"
android:layout_width="@dimen/dashboard_tile_image_size"
android:layout_height="@dimen/dashboard_tile_image_size"
android:scaleType="centerInside"
android:layout_marginStart="@dimen/dashboard_tile_image_margin_start"
android:layout_marginEnd="@dimen/dashboard_tile_image_margin_end" />
<RelativeLayout
android:id="@+id/overflow"
style="?android:attr/actionOverflowButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
android:paddingStart="16dp"
android:paddingTop="16dp"
android:paddingEnd="18dp"
android:paddingBottom="16dp"
android:gravity="top"/>
<TextView android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.TileTitle"
android:ellipsize="marquee"
android:fadingEdge="horizontal" />
</FrameLayout>
<TextView android:id="@android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@android:id/title"
android:layout_alignStart="@android:id/title"
android:textAppearance="@style/TextAppearance.Small"
android:textColor="?android:attr/textColorSecondary" />
</RelativeLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView android:id="@+id/overflow"
android:layout_width="44dp"
android:layout_height="44dp"
android:paddingStart="16dp"
android:paddingBottom="16dp"
android:paddingTop="12dp"
android:paddingEnd="12dp"
android:gravity="top"
style="?android:attr/actionOverflowButtonStyle" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@@ -19,9 +19,9 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/support_escalation_background"
android:background="@color/card_background_grey"
android:gravity="center_horizontal"
android:paddingBottom="8dp">
android:paddingBottom="40dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -39,6 +39,7 @@
android:id="@+id/summary1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:textAppearance="@style/TextAppearance.Small"
android:textColor="?android:attr/textColorSecondary"/>
</LinearLayout>
@@ -59,6 +60,7 @@
android:id="@+id/summary2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:textAppearance="@style/TextAppearance.Small"
android:textColor="?android:attr/textColorSecondary"/>
</LinearLayout>

View File

@@ -19,9 +19,9 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/support_escalation_background"
android:paddingTop="32dp"
android:paddingBottom="32dp"
android:background="@color/card_background_grey"
android:paddingTop="40dp"
android:paddingBottom="42dp"
android:paddingStart="56dp"
android:paddingEnd="56dp"
android:orientation="vertical">
@@ -29,11 +29,13 @@
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textAppearance="@style/TextAppearance.SupportTitle"/>
<TextView
android:id="@android:id/text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingTop="8dp"
android:textAppearance="@style/TextAppearance.Small"
android:textColor="?android:attr/textColorSecondary"/>

View File

@@ -19,7 +19,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/support_escalation_background"
android:background="@color/card_background_grey"
android:gravity="center_horizontal"
android:orientation="vertical">
<Button
@@ -32,5 +32,7 @@
android:id="@android:id/text2"
style="@style/SupportSecondaryButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:minHeight="48dp"/>
</LinearLayout>

View File

@@ -131,6 +131,6 @@
<color name="usage_graph_dots">#B0BEC5</color>
<color name="support_escalation_background">#eeeeee</color>
<color name="card_background_grey">#eeeeee</color>
</resources>

View File

@@ -119,8 +119,6 @@
<dimen name="dashboard_tile_image_margin_start">16dp</dimen>
<dimen name="dashboard_tile_image_margin_end">32dp</dimen>
<dimen name="suggestion_arrow_margin">16dp</dimen>
<!-- SwitchBar margin start / end -->
<dimen name="switchbar_margin_start">16dp</dimen>
<dimen name="switchbar_margin_end">16dp</dimen>

View File

@@ -7200,7 +7200,10 @@
<string name="condition_work_summary">Apps, background sync, and other features related to your work profile are turned off.</string>
<!-- Title for the suggestions section on the dashboard [CHAR LIMIT=30] -->
<string name="suggestions_title">Suggestions (<xliff:g name="count" example="3">%1$d</xliff:g>)</string>
<string name="suggestions_title">Suggestions</string>
<!-- Summary for the suggestions section on the dashboard, representing number of suggestions. [CHAR LIMIT=10] -->
<string name="suggestions_summary">+<xliff:g name="count" example="3">%1$d</xliff:g></string>
<!-- Name of option to remove a suggestion from the list [CHAR LIMIT=30] -->
<string name="suggestion_remove">Remove</string>
@@ -7491,7 +7494,7 @@
<string name="deletion_helper_free_button">Free up <xliff:g id="freeable" example="1.2GB">%1$s</xliff:g></string>
<!-- Title text for connecting to customer support [CHAR LIMIT=80]-->
<string name="support_escalation_title">Around-the-clock help</string>
<string name="support_escalation_title">Around-the-clock support</string>
<!-- Summary text for connecting to customer support [CHAR LIMIT=NONE]-->
<string name="support_escalation_summary">You can request a support call or chat and we\'ll get back to you with a quickness</string>

View File

@@ -163,10 +163,7 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
countItem(null, R.layout.suggestion_header, hasSuggestions, NS_SPACER);
resetCount();
if (mSuggestions != null) {
int maxSuggestions = mSuggestionMode == SUGGESTION_MODE_DEFAULT
? Math.min(DEFAULT_SUGGESTION_COUNT, mSuggestions.size())
: mSuggestionMode == SUGGESTION_MODE_EXPANDED ? mSuggestions.size()
: 0;
int maxSuggestions = getDisplayableSuggestionCount();
for (int i = 0; i < mSuggestions.size(); i++) {
countItem(mSuggestions.get(i), R.layout.suggestion_tile, i < maxSuggestions,
NS_SUGGESTION);
@@ -208,6 +205,14 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
mId++;
}
private int getDisplayableSuggestionCount() {
final int suggestionSize = mSuggestions.size();
return mSuggestionMode == SUGGESTION_MODE_DEFAULT
? Math.min(DEFAULT_SUGGESTION_COUNT, suggestionSize)
: mSuggestionMode == SUGGESTION_MODE_EXPANDED
? suggestionSize : 0;
}
@Override
public DashboardItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new DashboardItemHolder(LayoutInflater.from(parent.getContext()).inflate(
@@ -296,6 +301,14 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
holder.icon.setImageResource(hasMoreSuggestions() ? R.drawable.ic_expand_more
: R.drawable.ic_expand_less);
holder.title.setText(mContext.getString(R.string.suggestions_title, mSuggestions.size()));
final int undisplayedSuggestionCount =
mSuggestions.size() - getDisplayableSuggestionCount();
if (undisplayedSuggestionCount == 0) {
holder.summary.setText(null);
} else {
holder.summary.setText(
mContext.getString(R.string.suggestions_summary, undisplayedSuggestionCount));
}
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View File

@@ -120,9 +120,7 @@ public final class SlidingTabLayout extends FrameLayout implements View.OnClickL
tabTitleView.setOnClickListener(this);
mTitleView.addView(tabTitleView);
if (i == mViewPager.getCurrentItem()) {
tabTitleView.setSelected(true);
}
tabTitleView.setSelected(i == mViewPager.getCurrentItem());
}
}
@@ -159,9 +157,9 @@ public final class SlidingTabLayout extends FrameLayout implements View.OnClickL
if (mScrollState == ViewPager.SCROLL_STATE_IDLE) {
onViewPagerPageChanged(position, 0f);
}
final int titleCount = getChildCount();
final int titleCount = mTitleView.getChildCount();
for (int i = 0; i < titleCount; i++) {
getChildAt(i).setSelected(position == i);
mTitleView.getChildAt(i).setSelected(position == i);
}
}
}