Snap for 5817401 from 2d29978062a28f131223cbde430c33525c64b6f4 to qt-c2f2-release
Change-Id: I5733fa9a9d1777352ec2f5f81454c384a3068d90
diff --git a/car-apps-common/res/drawable/hero_button_background.xml b/car-apps-common/res/drawable/hero_button_background.xml
new file mode 100644
index 0000000..15e9b2a
--- /dev/null
+++ b/car-apps-common/res/drawable/hero_button_background.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 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:color/car_card_ripple_background">
+ <item>
+ <shape android:shape="rectangle">
+ <solid android:color="@color/hero_button_background_color" />
+ <corners android:radius="@dimen/hero_button_corner_radius"/>
+ </shape>
+ </item>
+</ripple>
diff --git a/car-apps-common/res/values-port/styles.xml b/car-apps-common/res/values-port/styles.xml
new file mode 100644
index 0000000..15245c1
--- /dev/null
+++ b/car-apps-common/res/values-port/styles.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2019, 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.
+-->
+<resources>
+ <style name="FullScreenErrorMessageStyle">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:textAppearance">@style/TextAppearance.Body1</item>
+ <item name="android:gravity">center</item>
+ </style>
+</resources>
diff --git a/car-apps-common/res/values/colors.xml b/car-apps-common/res/values/colors.xml
index d0d89cd..3ba5069 100644
--- a/car-apps-common/res/values/colors.xml
+++ b/car-apps-common/res/values/colors.xml
@@ -66,4 +66,7 @@
<color name="uxr_button_text_disabled_color">#80FFFFFF</color>
<color name="control_bar_button_background_color">#66ffffff</color>
+
+ <color name="hero_button_background_color">@*android:color/car_grey_868</color>
+ <color name="hero_button_text_color">@color/uxr_button_text_color_selector</color>
</resources>
diff --git a/car-apps-common/res/values/dimens.xml b/car-apps-common/res/values/dimens.xml
index 1a17bd3..b1a51f5 100644
--- a/car-apps-common/res/values/dimens.xml
+++ b/car-apps-common/res/values/dimens.xml
@@ -77,4 +77,11 @@
The computed blur radius is capped at 25 pixels. -->
<item name="background_bitmap_blur_percent" format="float" type="dimen">0.05</item>
+ <!-- Dialog and button -->
+ <dimen name="dialog_max_width">706dp</dimen>
+ <dimen name="hero_button_max_width">@dimen/dialog_max_width</dimen>
+ <dimen name="hero_button_min_width">@dimen/touch_target_size</dimen>
+ <dimen name="hero_button_height">@dimen/touch_target_size</dimen>
+ <dimen name="hero_button_corner_radius">38dp</dimen>
+
</resources>
diff --git a/car-apps-common/res/values/styles.xml b/car-apps-common/res/values/styles.xml
index 85a5b85..82d6efd 100644
--- a/car-apps-common/res/values/styles.xml
+++ b/car-apps-common/res/values/styles.xml
@@ -14,7 +14,9 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<resources xmlns:android="http://schemas.android.com/apk/res/android">
+<resources
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- ================ -->
<!-- ActionBar Themes -->
<!-- ================ -->
@@ -113,4 +115,28 @@
</style>
<style name="PagedRecyclerView.NestedRecyclerView">
</style>
+
+ <style name="FullScreenErrorMessageStyle">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:textAppearance">@style/TextAppearance.Body1</item>
+ <item name="android:gravity">center</item>
+ <item name="android:maxWidth">@dimen/dialog_max_width</item>
+ </style>
+
+ <style name="FullScreenErrorButtonStyle">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">@dimen/hero_button_height</item>
+ <item name="android:textAppearance">@style/TextAppearance.Body1</item>
+ <item name="android:textStyle">bold</item>
+ <item name="android:maxWidth">@dimen/hero_button_max_width</item>
+ <item name="android:minWidth">@dimen/hero_button_min_width</item>
+ <item name="android:textAllCaps">false</item>
+ <item name="android:singleLine">true</item>
+ <item name="android:background">@drawable/hero_button_background</item>
+ <item name="android:textColor">@color/hero_button_text_color</item>
+ <item name="android:gravity">center</item>
+ <item name="android:paddingHorizontal">@dimen/hero_button_corner_radius</item>
+ <item name="app:carUxRestrictions">UX_RESTRICTIONS_NO_SETUP</item>
+ </style>
</resources>
diff --git a/car-apps-common/src/com/android/car/apps/common/BitmapUtils.java b/car-apps-common/src/com/android/car/apps/common/BitmapUtils.java
index 51387c2..08b5dd1 100644
--- a/car-apps-common/src/com/android/car/apps/common/BitmapUtils.java
+++ b/car-apps-common/src/com/android/car/apps/common/BitmapUtils.java
@@ -18,7 +18,10 @@
import static android.graphics.Bitmap.Config.ARGB_8888;
import android.annotation.ColorInt;
+import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.content.Context;
+import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
@@ -116,6 +119,21 @@
return clone;
}
+ /** Returns a tinted drawable if flagging is enabled and the given drawable is a bitmap. */
+ @NonNull
+ public static Drawable maybeFlagDrawable(@NonNull Context context, @NonNull Drawable drawable) {
+ if (drawable instanceof BitmapDrawable) {
+ CommonFlags flags = CommonFlags.getInstance(context);
+ Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
+ if (flags.shouldFlagImproperImageRefs() && bitmap != null) {
+ Resources res = context.getResources();
+ int tint = context.getColor(R.color.improper_image_refs_tint_color);
+ drawable = new BitmapDrawable(res, BitmapUtils.createTintedBitmap(bitmap, tint));
+ }
+ }
+ return drawable;
+ }
+
/** Renders the drawable into a bitmap if needed. */
public static Bitmap fromDrawable(Drawable drawable, @Nullable Size bitmapSize) {
if (drawable instanceof BitmapDrawable) {
diff --git a/car-apps-common/src/com/android/car/apps/common/UxrButton.java b/car-apps-common/src/com/android/car/apps/common/UxrButton.java
index 73520c0..4f86273 100644
--- a/car-apps-common/src/com/android/car/apps/common/UxrButton.java
+++ b/car-apps-common/src/com/android/car/apps/common/UxrButton.java
@@ -23,7 +23,7 @@
import android.os.Handler;
import android.util.AttributeSet;
import android.view.View;
-import android.widget.Button;
+import android.widget.TextView;
import android.widget.Toast;
/**
@@ -34,8 +34,11 @@
* If not set, it'll use UX_RESTRICTIONS_FULLY_RESTRICTED as fallback.
* If no restriction is enforced, this Button will work as a normal Button; otherwise, its
* OnClickListener will be disabled if any, and a blocking message will be displayed.
+ *
+ * This class extends from TextView instead of Button because only TextView supports gradient
+ * truncate for now.
*/
-public class UxrButton extends Button {
+public class UxrButton extends TextView {
private static final int[] STATE_UX_RESTRICTED = {R.attr.state_ux_restricted};
private CarUxRestrictionsUtil mCarUxRestrictionsUtil;
diff --git a/car-apps-common/src/com/android/car/apps/common/imaging/ImageBinder.java b/car-apps-common/src/com/android/car/apps/common/imaging/ImageBinder.java
index 4d5bc13..63b276e 100644
--- a/car-apps-common/src/com/android/car/apps/common/imaging/ImageBinder.java
+++ b/car-apps-common/src/com/android/car/apps/common/imaging/ImageBinder.java
@@ -69,6 +69,7 @@
private final PlaceholderType mPlaceholderType;
private final Size mMaxImageSize;
+ @Nullable
private final Consumer<Drawable> mClient;
private T mCurrentRef;
@@ -83,6 +84,18 @@
mClient = checkNotNull(consumer, "Cannot bind a null consumer");
}
+ protected ImageBinder(@NonNull PlaceholderType type, @NonNull Size maxImageSize) {
+ mPlaceholderType = checkNotNull(type, "Need a type");
+ mMaxImageSize = checkNotNull(maxImageSize, "Need a size");
+ mClient = null;
+ }
+
+ protected void setDrawable(@Nullable Drawable drawable) {
+ if (mClient != null) {
+ mClient.accept(drawable);
+ }
+ }
+
/** Fetches a new image if needed. */
public void setImage(Context context, @Nullable T newRef) {
if (isSameImage(context, newRef)) {
@@ -94,11 +107,11 @@
mCurrentRef = newRef;
if (mCurrentRef == null) {
- mClient.accept(null);
+ setDrawable(null);
} else {
Drawable image = mCurrentRef.getImage(context);
if (image != null) {
- mClient.accept(image);
+ setDrawable(image);
return;
}
@@ -108,7 +121,7 @@
(drawable == null && mPlaceholderType != PlaceholderType.NONE)
? mCurrentRef.getPlaceholder(context, mPlaceholderType)
: drawable;
- mClient.accept(displayed);
+ setDrawable(displayed);
onRequestFinished();
}
};
diff --git a/car-apps-common/src/com/android/car/apps/common/imaging/ImageViewBinder.java b/car-apps-common/src/com/android/car/apps/common/imaging/ImageViewBinder.java
index ea6d629..db6ee1a 100644
--- a/car-apps-common/src/com/android/car/apps/common/imaging/ImageViewBinder.java
+++ b/car-apps-common/src/com/android/car/apps/common/imaging/ImageViewBinder.java
@@ -18,10 +18,15 @@
import android.annotation.Nullable;
import android.content.Context;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
import android.util.Size;
import android.view.View;
import android.widget.ImageView;
+import com.android.car.apps.common.CommonFlags;
+import com.android.car.apps.common.R;
+
/**
* Binds images to an image view.
* @param <T> see {@link ImageRef}.
@@ -30,20 +35,42 @@
@Nullable
private final ImageView mImageView;
+ private final boolean mFlagBitmaps;
+ /** See {@link ImageViewBinder} and {@link ImageBinder}. */
public ImageViewBinder(Size maxImageSize, @Nullable ImageView imageView) {
- this(PlaceholderType.FOREGROUND, maxImageSize, imageView);
+ this(PlaceholderType.FOREGROUND, maxImageSize, imageView, false);
}
+ /**
+ * See {@link ImageViewBinder} and {@link ImageBinder}.
+ * @param flagBitmaps whether this binder should flag bitmap drawables if flagging is enabled.
+ */
public ImageViewBinder(PlaceholderType type, Size maxImageSize,
- @Nullable ImageView imageView) {
- super(type, maxImageSize, drawable -> {
- if (imageView != null) {
- imageView.setImageDrawable(drawable);
- imageView.setVisibility((drawable != null) ? View.VISIBLE : View.GONE);
- }
- });
+ @Nullable ImageView imageView, boolean flagBitmaps) {
+ super(type, maxImageSize);
mImageView = imageView;
+ mFlagBitmaps = flagBitmaps;
+ }
+
+ @Override
+ protected void setDrawable(@Nullable Drawable drawable) {
+ if (mImageView != null) {
+ mImageView.setImageDrawable(drawable);
+ mImageView.setVisibility((drawable != null) ? View.VISIBLE : View.GONE);
+ if (mFlagBitmaps) {
+ CommonFlags flags = CommonFlags.getInstance(mImageView.getContext());
+ if (flags.shouldFlagImproperImageRefs()) {
+ if (drawable instanceof BitmapDrawable) {
+ int tint = mImageView.getContext().getColor(
+ R.color.improper_image_refs_tint_color);
+ mImageView.setColorFilter(tint);
+ } else {
+ mImageView.clearColorFilter();
+ }
+ }
+ }
+ }
}
@Override
diff --git a/car-chassis-lib/AndroidManifest.xml b/car-chassis-lib/AndroidManifest.xml
index 79fafdd..c398dc1 100644
--- a/car-chassis-lib/AndroidManifest.xml
+++ b/car-chassis-lib/AndroidManifest.xml
@@ -17,5 +17,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.car.chassis">
-
+ <uses-sdk
+ android:minSdkVersion="14"
+ android:targetSdkVersion="28" />
</manifest>
diff --git a/car-chassis-lib/README.md b/car-chassis-lib/README.md
index 31bd2f1..b3e3c1c 100644
--- a/car-chassis-lib/README.md
+++ b/car-chassis-lib/README.md
@@ -25,4 +25,4 @@
4. Back on Gerrit, submit your CL
5. Back on Google3, run update.sh again and submit
-TODO: Automate this process using CaaS
\ No newline at end of file
+TODO: Automate this process using CaaS (in progress)
diff --git a/car-media-common/res/values-h600dp/dimens.xml b/car-media-common/res/values-h600dp/dimens.xml
index 4c44920..6b7980a 100644
--- a/car-media-common/res/values-h600dp/dimens.xml
+++ b/car-media-common/res/values-h600dp/dimens.xml
@@ -19,8 +19,8 @@
<dimen name="appbar_view_icon_touch_target_size">96dp</dimen>
<dimen name="appbar_view_icon_padding">26dp</dimen>
<dimen name="appbar_view_icon_background_radius">48dp</dimen>
- <dimen name="appbar_view_search_bar_padding">62dp</dimen>
<!-- negative margins to overlap icons on search bar -->
<dimen name="appbar_view_search_app_icon_margin">-76dp</dimen>
- <dimen name="appbar_view_search_close_icon_margin">-70dp</dimen>
+ <dimen name="appbar_view_search_close_icon_margin">-96dp</dimen>
+ <dimen name="appbar_view_search_bar_end_margin">26dp</dimen>
</resources>
diff --git a/car-media-common/res/values/dimens.xml b/car-media-common/res/values/dimens.xml
index 159bd3d..ead8675 100644
--- a/car-media-common/res/values/dimens.xml
+++ b/car-media-common/res/values/dimens.xml
@@ -31,11 +31,13 @@
<dimen name="appbar_view_icon_size">@*android:dimen/car_primary_icon_size</dimen>
<!-- Padding of primary icon, equals (@dimen/appbar_view_icon_touch_target_size - @dimen/appbar_view_icon_size) / 2. -->
<dimen name="appbar_view_icon_padding">16dp</dimen>
- <dimen name="appbar_view_search_bar_padding">62dp</dimen>
+ <dimen name="appbar_view_search_bar_padding_start">62dp</dimen>
+ <dimen name="appbar_view_search_bar_padding_end">60dp</dimen>
<dimen name="appbar_view_search_app_icon_size">@*android:dimen/car_secondary_icon_size</dimen>
<!-- negative margin to overlap icons on search bar -->
<dimen name="appbar_view_search_app_icon_margin">-66dp</dimen>
- <dimen name="appbar_view_search_close_icon_margin">-60dp</dimen>
+ <dimen name="appbar_view_search_close_icon_margin">-76dp</dimen>
+ <dimen name="appbar_view_search_bar_end_margin">16dp</dimen>
<!-- playback_fragment.xml -->
<dimen name="playback_fragment_text_margin_top">@*android:dimen/car_padding_4</dimen>
diff --git a/car-media-common/src/com/android/car/media/common/source/MediaSource.java b/car-media-common/src/com/android/car/media/common/source/MediaSource.java
index baf61f0..db2cc11 100644
--- a/car-media-common/src/com/android/car/media/common/source/MediaSource.java
+++ b/car-media-common/src/com/android/car/media/common/source/MediaSource.java
@@ -155,8 +155,10 @@
@NonNull
private static Drawable extractIcon(@NonNull Context context, @Nullable ServiceInfo serviceInfo,
@NonNull String packageName) throws PackageManager.NameNotFoundException {
- return serviceInfo != null ? serviceInfo.loadIcon(context.getPackageManager())
+ Drawable appIcon = serviceInfo != null ? serviceInfo.loadIcon(context.getPackageManager())
: context.getPackageManager().getApplicationIcon(packageName);
+
+ return BitmapUtils.maybeFlagDrawable(context, appIcon);
}
/**