From 115eccbde8c1a6605ef29db6b22870fb5176d2e8 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 29 Jan 2022 09:23:43 +0100 Subject: [PATCH] Scroll to bottom of manual setup --- .../main/java/eu/faircode/email/FragmentSetup.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentSetup.java b/app/src/main/java/eu/faircode/email/FragmentSetup.java index 7ec0032dc8..c8dc7899b1 100644 --- a/app/src/main/java/eu/faircode/email/FragmentSetup.java +++ b/app/src/main/java/eu/faircode/email/FragmentSetup.java @@ -29,6 +29,7 @@ import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.res.Resources; import android.graphics.Paint; +import android.graphics.Rect; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.net.ConnectivityManager; @@ -46,6 +47,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ImageButton; +import android.widget.ScrollView; import android.widget.TextView; import androidx.annotation.NonNull; @@ -370,7 +372,17 @@ public class FragmentSetup extends FragmentBase { @Override public void run() { try { - scrollTo(R.id.ibManual, 0); + Rect rect = new Rect(); + cardManual.getDrawingRect(rect); + view.offsetDescendantRectToMyCoords(cardManual, rect); + + int vh = view.getHeight(); + int ch = rect.height(); + if (vh > 0 && ch > 0) { + int y = rect.top - (vh - ch); + if (y > 0 && view instanceof ScrollView) + ((ScrollView) view).scrollTo(0, y); + } } catch (Throwable ex) { Log.e(ex); }