From 47f78fb32f7380c56e9f00477c321a28e2261683 Mon Sep 17 00:00:00 2001
From: Kolya Opahle <k.opahle@sap.com>
Date: Wed, 17 Jun 2020 14:26:27 +0200
Subject: [PATCH] Disallow scrolling tan entry text view (closes #546) (#588)

* Implemented a UnscrollableEditText which resets selection to text end on change

Signed-off-by: Kolya Opahle <k.opahle@sap.com>

* Added import for AppCompatEditText
---
 .../coronawarnapp/ui/view/UnscrollableEditText.kt   | 13 +++++++++++++
 .../src/main/res/layout/view_tan_input_edittext.xml |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)
 create mode 100644 Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/view/UnscrollableEditText.kt

diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/view/UnscrollableEditText.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/view/UnscrollableEditText.kt
new file mode 100644
index 000000000..3dbd0f6ba
--- /dev/null
+++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/view/UnscrollableEditText.kt
@@ -0,0 +1,13 @@
+package de.rki.coronawarnapp.ui.view
+
+import android.content.Context
+import android.util.AttributeSet
+import androidx.appcompat.widget.AppCompatEditText
+
+class UnscrollableEditText(context: Context, attributeSet: AttributeSet) :
+    AppCompatEditText(context, attributeSet) {
+    override fun onSelectionChanged(selStart: Int, selEnd: Int) {
+        super.onSelectionChanged(selStart, selEnd)
+        text?.length?.let { setSelection(it) }
+    }
+}
diff --git a/Corona-Warn-App/src/main/res/layout/view_tan_input_edittext.xml b/Corona-Warn-App/src/main/res/layout/view_tan_input_edittext.xml
index 9aca2e5aa..22d20e9eb 100644
--- a/Corona-Warn-App/src/main/res/layout/view_tan_input_edittext.xml
+++ b/Corona-Warn-App/src/main/res/layout/view_tan_input_edittext.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <layout xmlns:android="http://schemas.android.com/apk/res/android">
 
-    <EditText
+    <de.rki.coronawarnapp.ui.view.UnscrollableEditText
         android:id="@+id/tan_input_edittext"
         style="@style/tanInputEdittext" />
 
-- 
GitLab