Merge "Toast design polish" into sc-dev

This commit is contained in:
Beverly Tai
2021-02-22 14:56:02 +00:00
committed by Android (Google) Code Review
10 changed files with 45 additions and 70 deletions

View File

@@ -17,8 +17,7 @@
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- background is material_grey_200 with .9 alpha -->
<solid android:color="#E6EEEEEE" />
<corners android:radius="22dp" />
<solid android:color="?android:attr/colorBackground" />
<corners android:radius="28dp" />
</shape>

View File

@@ -18,24 +18,27 @@
*/
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="?android:attr/toastFrameBackground">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:maxWidth="@dimen/toast_width"
android:background="?android:attr/toastFrameBackground"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:paddingStart="16dp"
android:paddingEnd="16dp">
<TextView
android:id="@android:id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginHorizontal="24dp"
android:layout_marginVertical="15dp"
android:layout_gravity="center_horizontal"
android:textAppearance="@style/TextAppearance.Toast"
android:textColor="@color/primary_text_default_material_light"
/>
android:ellipsize="end"
android:maxLines="2"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:lineHeight="20sp"
android:textAppearance="@style/TextAppearance.Toast"/>
</LinearLayout>

View File

@@ -78,4 +78,5 @@
<dimen name="chooser_preview_width">480dp</dimen>
<dimen name="toast_y_offset">24dp</dimen>
</resources>

View File

@@ -30,7 +30,13 @@
will be displayed in the app launcher and elsewhere. -->
<dimen name="app_icon_size">48dip</dimen>
<dimen name="toast_y_offset">24dp</dimen>
<!-- Offset from the bottom of the device a toast shows -->
<dimen name="toast_y_offset">48dp</dimen>
<!-- Max width of a toast -->
<dimen name="toast_width">300dp</dimen>
<!-- Text size of the message within a toast -->
<dimen name="toast_text_size">14sp</dimen>
<!-- Height of the status bar -->
<dimen name="status_bar_height">@dimen/status_bar_height_portrait</dimen>
<!-- Height of the status bar in portrait. The height should be

View File

@@ -964,8 +964,9 @@ please see styles_device_defaults.xml.
</style>
<style name="TextAppearance.Toast">
<item name="fontFamily">sans-serif</item>
<item name="fontFamily">@*android:string/config_headlineFontFamily</item>
<item name="textSize">14sp</item>
<item name="textColor">?android:attr/textColorPrimary</item>
</style>
<style name="TextAppearance.Tooltip">

View File

@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2021 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.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFFFF" />
<corners android:radius="@dimen/toast_bg_radius" />
</shape>

View File

@@ -20,32 +20,30 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="@dimen/toast_width"
android:orientation="horizontal"
android:background="@drawable/toast_background"
android:backgroundTint="?android:attr/colorBackground"
android:gravity="center_vertical"
android:maxWidth="@*android:dimen/toast_width"
android:background="@android:drawable/toast_frame"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:gravity="center_vertical">
android:paddingStart="16dp"
android:paddingEnd="16dp">
<!-- Icon should be 24x24, make slightly larger to allow for shadowing, adjust via padding -->
<ImageView
android:id="@+id/icon"
android:alpha="@dimen/toast_icon_alpha"
android:padding="11.5dp"
android:layout_width="@dimen/toast_icon_size"
android:layout_height="@dimen/toast_icon_size"/>
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginEnd="10dp"/>
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingStart="0dp"
android:paddingEnd="22dp"
android:textSize="@dimen/toast_text_size"
android:textColor="?android:attr/textColorPrimary"
android:fontFamily="@*android:string/config_headlineFontFamily"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:lineHeight="20sp"
android:textAppearance="@*android:style/TextAppearance.Toast"/>
</LinearLayout>

View File

@@ -52,6 +52,4 @@
<!-- (footer_height -48dp)/2 -->
<dimen name="controls_management_footer_top_margin">4dp</dimen>
<dimen name="controls_management_favorites_top_margin">8dp</dimen>
<dimen name="toast_y_offset">24dp</dimen>
</resources>

View File

@@ -1359,11 +1359,4 @@
<dimen name="rounded_slider_icon_size">24dp</dimen>
<!-- rounded_slider_icon_size / 2 -->
<dimen name="rounded_slider_icon_inset">12dp</dimen>
<dimen name="toast_width">296dp</dimen>
<item name="toast_icon_alpha" format="float" type="dimen">1</item>
<dimen name="toast_text_size">14sp</dimen>
<dimen name="toast_y_offset">48dp</dimen>
<dimen name="toast_icon_size">48dp</dimen>
<dimen name="toast_bg_radius">28dp</dimen>
</resources>

View File

@@ -187,10 +187,7 @@ public class SystemUIToast implements ToastPlugin.Toast {
mPluginToast.onOrientationChange(orientation);
}
mDefaultY = mContext.getResources().getDimensionPixelSize(
mToastStyleEnabled
? com.android.systemui.R.dimen.toast_y_offset
: R.dimen.toast_y_offset);
mDefaultY = mContext.getResources().getDimensionPixelSize(R.dimen.toast_y_offset);
mDefaultGravity =
mContext.getResources().getInteger(R.integer.config_toastDefaultGravity);
}