From 4a47b5b637360137919796c70f0dfaa9d54d1466 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Wed, 30 Jan 2019 09:35:06 -0600 Subject: [PATCH] Created AutoScrollingTextView which automatically scrolls its contents horizontally in case the contents do not fit the available width and used it in the Map suggestions' address to display the complete address. Also, improved the Map Toolbar color. --- .../views/AutoScrollingTextView.kt | 35 +++++++++++++++++++ .../main/res/layout/fragment_merchants.xml | 2 +- .../res/layout/item_merchant_suggestion.xml | 12 ++++--- .../main/res/layout/popup_menu_merchants.xml | 3 +- app/src/main/res/values/colors.xml | 1 + 5 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 app/src/main/java/cy/agorise/bitsybitshareswallet/views/AutoScrollingTextView.kt diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/views/AutoScrollingTextView.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/views/AutoScrollingTextView.kt new file mode 100644 index 0000000..018ca76 --- /dev/null +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/views/AutoScrollingTextView.kt @@ -0,0 +1,35 @@ +package cy.agorise.bitsybitshareswallet.views + +import android.content.Context +import android.graphics.Rect +import android.util.AttributeSet +import androidx.appcompat.widget.AppCompatTextView + +/** + * TextView that in case the content does not fit the available width, scrolls horizontally automatically. The + * TextView needs this xml attributes to work correctly: + * android:singleLine="true" + * android:ellipsize="marquee" + * android:marqueeRepeatLimit="marquee_forever" + * android:scrollHorizontally="true" + */ +class AutoScrollingTextView(context: Context?, attrs: AttributeSet?) : AppCompatTextView(context, attrs) { + override fun onFocusChanged( + focused: Boolean, direction: Int, + previouslyFocusedRect: Rect? + ) { + if (focused) { + super.onFocusChanged(focused, direction, previouslyFocusedRect) + } + } + + override fun onWindowFocusChanged(focused: Boolean) { + if (focused) { + super.onWindowFocusChanged(focused) + } + } + + override fun isFocused(): Boolean { + return true + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_merchants.xml b/app/src/main/res/layout/fragment_merchants.xml index e35ec02..644769b 100644 --- a/app/src/main/res/layout/fragment_merchants.xml +++ b/app/src/main/res/layout/fragment_merchants.xml @@ -14,7 +14,7 @@ android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:layout_marginTop="24dp" - android:background="@color/semiTransparent" + android:background="@color/colorMapToolbar" android:elevation="4dp" app:title="@string/title_merchants_and_tellers" android:theme="@style/ThemeOverlay.MaterialComponents" /> diff --git a/app/src/main/res/layout/item_merchant_suggestion.xml b/app/src/main/res/layout/item_merchant_suggestion.xml index 3dca4b4..2936f1c 100644 --- a/app/src/main/res/layout/item_merchant_suggestion.xml +++ b/app/src/main/res/layout/item_merchant_suggestion.xml @@ -32,17 +32,21 @@ app:layout_constraintStart_toEndOf="@id/ivMarkerPin" app:layout_constraintEnd_toEndOf="parent"/> - + app:layout_constraintStart_toEndOf="@id/ivMarkerPin" + app:layout_constraintEnd_toEndOf="parent"/> \ No newline at end of file diff --git a/app/src/main/res/layout/popup_menu_merchants.xml b/app/src/main/res/layout/popup_menu_merchants.xml index 9149b4a..d2ee9c3 100644 --- a/app/src/main/res/layout/popup_menu_merchants.xml +++ b/app/src/main/res/layout/popup_menu_merchants.xml @@ -1,8 +1,9 @@ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 91ec463..5bfd923 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -20,4 +20,5 @@ #D32F2F #B71C1C #2888 + #338888aa