Snap for 5713174 from 53bd18d5e06c43c0ab39a0e5251e38a926549235 to qt-release

Change-Id: If3bff627f0023183d34da8964210a1cdd6b6fd4b
diff --git a/car-apps-common/res/values/attrs.xml b/car-apps-common/res/values/attrs.xml
index 877e5d2..f99da29 100644
--- a/car-apps-common/res/values/attrs.xml
+++ b/car-apps-common/res/values/attrs.xml
@@ -109,4 +109,11 @@
         </attr>
         <attr name="state_ux_restricted" format="boolean" />
     </declare-styleable>
+
+    <declare-styleable name="BackgroundImageView">
+        <!-- Sets a scale to be applied on top of the scaling that was used to fit the image to the frame of the view. Defaults to 1.05 -->
+        <attr name="imageAdditionalScale" format="float"/>
+    </declare-styleable>
+    <!-- Attribute for specifying a default style for all BackgroundImageViews -->
+    <attr name="backgroundImageViewStyle" format="reference"/>
 </resources>
diff --git a/car-apps-common/src/com/android/car/apps/common/BackgroundImageView.java b/car-apps-common/src/com/android/car/apps/common/BackgroundImageView.java
index 935034c..954b82a 100644
--- a/car-apps-common/src/com/android/car/apps/common/BackgroundImageView.java
+++ b/car-apps-common/src/com/android/car/apps/common/BackgroundImageView.java
@@ -16,6 +16,7 @@
 package com.android.car.apps.common;
 
 import android.content.Context;
+import android.content.res.TypedArray;
 import android.graphics.Bitmap;
 import android.util.AttributeSet;
 import android.view.View;
@@ -42,7 +43,7 @@
     }
 
     public BackgroundImageView(Context context, AttributeSet attrs) {
-        this(context, attrs, 0);
+        this(context, attrs, R.attr.backgroundImageViewStyle);
     }
 
     public BackgroundImageView(Context context, AttributeSet attrs, int defStyle) {
@@ -55,6 +56,16 @@
 
         mBitmapTargetSize = getResources().getInteger(R.integer.background_bitmap_target_size_px);
         mBitmapBlurPercent = getResources().getFloat(R.dimen.background_bitmap_blur_percent);
+
+        TypedArray a = context.getTheme().obtainStyledAttributes(attrs,
+                R.styleable.BackgroundImageView, defStyle, 0);
+
+        try {
+            setImageAdditionalScale(a.getFloat(R.styleable.BackgroundImageView_imageAdditionalScale,
+                    1.05f));
+        } finally {
+            a.recycle();
+        }
     }
 
     /**
@@ -90,6 +101,18 @@
 
     /** Dims/undims the background image by 30% */
     public void setDimmed(boolean dim) {
-        mDarkeningScrim.setVisibility(dim ?  View.VISIBLE : View.GONE);
+        mDarkeningScrim.setVisibility(dim ? View.VISIBLE : View.GONE);
+    }
+
+    /**
+     * Sets a scale to be applied on top of the scaling that was used to fit the
+     * image to the frame of the view.
+     *
+     * See {@link
+     * com.android.car.apps.common.CropAlignedImageView#setImageAdditionalScale(float)}
+     * for more details.
+     */
+    public void setImageAdditionalScale(float scale) {
+        mImageView.setImageAdditionalScale(scale);
     }
 }
diff --git a/car-apps-common/src/com/android/car/apps/common/CropAlignedImageView.java b/car-apps-common/src/com/android/car/apps/common/CropAlignedImageView.java
index 6464507..f11f33b 100644
--- a/car-apps-common/src/com/android/car/apps/common/CropAlignedImageView.java
+++ b/car-apps-common/src/com/android/car/apps/common/CropAlignedImageView.java
@@ -33,6 +33,9 @@
     private static final int ALIGN_HORIZONTAL_RIGHT = 2;
 
     private int mAlignHorizontal;
+    private float mAdditionalScale = 1f;
+    private int mFrameWidth;
+    private int mFrameHeight;
 
     public CropAlignedImageView(Context context) {
         this(context, null);
@@ -64,36 +67,58 @@
 
     @Override
     protected boolean setFrame(int frameLeft, int frameTop, int frameRight, int frameBottom) {
-        if (getDrawable() != null) {
-            setMatrix(frameRight - frameLeft, frameBottom - frameTop);
-        }
+        mFrameWidth = frameRight - frameLeft;
+        mFrameHeight = frameBottom - frameTop;
+
+        setMatrix();
 
         return super.setFrame(frameLeft, frameTop, frameRight, frameBottom);
     }
 
-    private void setMatrix(int frameWidth, int frameHeight) {
-        float originalImageWidth = (float) getDrawable().getIntrinsicWidth();
-        float originalImageHeight = (float) getDrawable().getIntrinsicHeight();
-        float fitHorizontallyScaleFactor = frameWidth / originalImageWidth;
-        float fitVerticallyScaleFactor = frameHeight / originalImageHeight;
-        float usedScaleFactor = Math.max(fitHorizontallyScaleFactor, fitVerticallyScaleFactor);
-        float newImageWidth = originalImageWidth * usedScaleFactor;
-        float newImageHeight = originalImageHeight * usedScaleFactor;
-        Matrix matrix = getImageMatrix();
-        matrix.setScale(usedScaleFactor, usedScaleFactor, 0, 0);
-        float dx = 0;
-        switch (mAlignHorizontal) {
-            case ALIGN_HORIZONTAL_CENTER:
-                dx = (frameWidth - newImageWidth) / 2;
-                break;
-            case ALIGN_HORIZONTAL_LEFT:
-                dx = 0;
-                break;
-            case ALIGN_HORIZONTAL_RIGHT:
-                dx = (frameWidth - newImageWidth);
-                break;
+    private void setMatrix() {
+        if (getDrawable() != null) {
+            float originalImageWidth = (float) getDrawable().getIntrinsicWidth();
+            float originalImageHeight = (float) getDrawable().getIntrinsicHeight();
+            float fitHorizontallyScaleFactor = mFrameWidth / originalImageWidth;
+            float fitVerticallyScaleFactor = mFrameHeight / originalImageHeight;
+            float usedScaleFactor = Math.max(fitHorizontallyScaleFactor, fitVerticallyScaleFactor);
+
+            // mAdditionalScale isn't factored into the fittedImageWidth
+            // because we want to scale from the center of the fitted image, so our translations
+            // shouldn't take it into effect
+            float fittedImageWidth = originalImageWidth * usedScaleFactor;
+
+            Matrix matrix = new Matrix();
+            matrix.setTranslate(-originalImageWidth / 2f, -originalImageHeight / 2f);
+            matrix.postScale(usedScaleFactor * mAdditionalScale,
+                    usedScaleFactor * mAdditionalScale);
+            float dx = 0;
+            switch (mAlignHorizontal) {
+                case ALIGN_HORIZONTAL_CENTER:
+                    dx = mFrameWidth / 2f;
+                    break;
+                case ALIGN_HORIZONTAL_LEFT:
+                    dx = fittedImageWidth / 2f;
+                    break;
+                case ALIGN_HORIZONTAL_RIGHT:
+                    dx = (mFrameWidth - fittedImageWidth / 2f);
+                    break;
+            }
+            matrix.postTranslate(dx, mFrameHeight / 2f);
+            setImageMatrix(matrix);
         }
-        matrix.postTranslate(dx, (frameHeight - newImageHeight) / 2);
-        setImageMatrix(matrix);
+    }
+
+    /**
+     * Sets a scale to be applied on top of the scaling that was used to fit the
+     * image to the frame of the view.
+     *
+     * This will scale the image from its center. This means it won't translate the image
+     * any further, so if it was aligned to the left, the left of the image will expand past
+     * the left edge of the view. Values <1 will cause black bars to appear.
+     */
+    public void setImageAdditionalScale(float scale) {
+        mAdditionalScale = scale;
+        setMatrix();
     }
 }
diff --git a/car-apps-common/src/com/android/car/apps/common/CrossfadeImageView.java b/car-apps-common/src/com/android/car/apps/common/CrossfadeImageView.java
index d13d928..1f4b7b6 100644
--- a/car-apps-common/src/com/android/car/apps/common/CrossfadeImageView.java
+++ b/car-apps-common/src/com/android/car/apps/common/CrossfadeImageView.java
@@ -147,4 +147,14 @@
             mInactiveImageView = mImageView2;
         }
     }
+
+    /**
+     * Sets the additional image scale. See {@link
+     * com.android.car.apps.common.CropAlignedImageView#setImageAdditionalScale(float)}
+     * for more details.
+     */
+    public void setImageAdditionalScale(float scale) {
+        mImageView2.setImageAdditionalScale(scale);
+        mImageView1.setImageAdditionalScale(scale);
+    }
 }
diff --git a/car-telephony-common/res/values-in/strings.xml b/car-telephony-common/res/values-in/strings.xml
index cd98307..53a7831 100644
--- a/car-telephony-common/res/values-in/strings.xml
+++ b/car-telephony-common/res/values-in/strings.xml
@@ -17,7 +17,7 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="unknown" msgid="3237922751873109097">"Tidak dikenal"</string>
-    <string name="voicemail" msgid="2125552157407909509">"Pesan Suara"</string>
+    <string name="voicemail" msgid="2125552157407909509">"Pesan suara"</string>
     <string name="phone_label_with_info" msgid="4652109530699808645">"<xliff:g id="LABEL">%1$s</xliff:g>  ·  <xliff:g id="DURATION">%2$s</xliff:g>"</string>
     <string name="call_state_connecting" msgid="5930724746375294866">"Menghubungkan…"</string>
     <string name="call_state_dialing" msgid="1534599871716648114">"Memanggil…"</string>