From d402707531e4696ced9724a4cbc1c5d84d0303f5 Mon Sep 17 00:00:00 2001 From: Sawyer Blatz Date: Wed, 10 Apr 2019 06:52:49 -0700 Subject: [PATCH] Closes #1420: Moves tab preview to top of page (#1462) --- .../mozilla/fenix/home/ImageViewTopCrop.kt | 21 +++++++++++++++++++ app/src/main/res/layout/tab_list_row.xml | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/org/mozilla/fenix/home/ImageViewTopCrop.kt diff --git a/app/src/main/java/org/mozilla/fenix/home/ImageViewTopCrop.kt b/app/src/main/java/org/mozilla/fenix/home/ImageViewTopCrop.kt new file mode 100644 index 000000000..1ff0ec824 --- /dev/null +++ b/app/src/main/java/org/mozilla/fenix/home/ImageViewTopCrop.kt @@ -0,0 +1,21 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.fenix.home + +import android.content.Context +import android.util.AttributeSet +import androidx.appcompat.widget.AppCompatImageView + +class ImageViewTopCrop(context: Context, attrs: AttributeSet) : AppCompatImageView(context, attrs) { + override fun setFrame(l: Int, t: Int, r: Int, b: Int): Boolean { + val scaleFactor = width / drawable.intrinsicWidth.toFloat() + val matrix = imageMatrix + + matrix.setScale(scaleFactor, scaleFactor, 0f, 0f) + imageMatrix = matrix + + return super.setFrame(l, t, r, b) + } +} diff --git a/app/src/main/res/layout/tab_list_row.xml b/app/src/main/res/layout/tab_list_row.xml index c60b85de0..4b40acdd7 100644 --- a/app/src/main/res/layout/tab_list_row.xml +++ b/app/src/main/res/layout/tab_list_row.xml @@ -60,7 +60,7 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="@id/text_url" /> -