diff options
| author | android-build-team Robot <android-build-team-robot@google.com> | 2019-07-09 02:59:05 +0000 |
|---|---|---|
| committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-07-09 02:59:05 +0000 |
| commit | 1a6b9b2da551b47136d19ea6aa85a514f8ba3d99 (patch) | |
| tree | 187387b3adb9d4ab0051a2560fde5ba3716227b2 | |
| parent | a856be388489e81a1f20116626bbe7e6439d3223 (diff) | |
| parent | 53bd18d5e06c43c0ab39a0e5251e38a926549235 (diff) | |
| download | platform_packages_apps_Car_libs-android10-s2-release.tar.gz platform_packages_apps_Car_libs-android10-s2-release.tar.bz2 platform_packages_apps_Car_libs-android10-s2-release.zip | |
Snap for 5713174 from 53bd18d5e06c43c0ab39a0e5251e38a926549235 to qt-releaseandroid-vts-10.0_r5android-vts-10.0_r4android-vts-10.0_r3android-vts-10.0_r2android-vts-10.0_r1android-cts-10.0_r5android-cts-10.0_r4android-cts-10.0_r3android-cts-10.0_r2android-cts-10.0_r1android-10.0.0_r6android-10.0.0_r5android-10.0.0_r46android-10.0.0_r4android-10.0.0_r3android-10.0.0_r2android-10.0.0_r17android-10.0.0_r11android-10.0.0_r10android-10.0.0_r1android10-tests-releaseandroid10-security-releaseandroid10-s3-releaseandroid10-s2-releaseandroid10-s1-releaseandroid10-release
Change-Id: If3bff627f0023183d34da8964210a1cdd6b6fd4b
5 files changed, 94 insertions, 29 deletions
diff --git a/car-apps-common/res/values/attrs.xml b/car-apps-common/res/values/attrs.xml index 877e5d24..f99da297 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 935034c0..954b82a2 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 class BackgroundImageView extends ConstraintLayout { } 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 @@ public class BackgroundImageView extends ConstraintLayout { 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 @@ public class BackgroundImageView extends ConstraintLayout { /** 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 64645079..f11f33be 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 @@ public class CropAlignedImageView extends ImageView { 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 @@ public class CropAlignedImageView extends ImageView { @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 d13d9283..1f4b7b68 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 @@ public class CrossfadeImageView extends FrameLayout { 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 cd98307c..53a78316 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> |
