From 7fb2faba45b41bc7f1e2b8799d55506266e4592b Mon Sep 17 00:00:00 2001 From: akwizgran Date: Thu, 19 Aug 2021 13:00:54 +0100 Subject: [PATCH] Automatically scroll HotspotIntroFragment. --- .../briar/android/hotspot/HotspotIntroFragment.java | 6 ++++++ .../src/main/res/layout/fragment_hotspot_intro.xml | 1 + 2 files changed, 7 insertions(+) diff --git a/briar-android/src/main/java/org/briarproject/briar/android/hotspot/HotspotIntroFragment.java b/briar-android/src/main/java/org/briarproject/briar/android/hotspot/HotspotIntroFragment.java index fd6112bd0..85e386944 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/hotspot/HotspotIntroFragment.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/hotspot/HotspotIntroFragment.java @@ -9,6 +9,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ProgressBar; +import android.widget.ScrollView; import android.widget.TextView; import com.google.android.material.snackbar.Snackbar; @@ -26,6 +27,7 @@ import androidx.lifecycle.ViewModelProvider; import static android.content.pm.ApplicationInfo.FLAG_TEST_ONLY; import static android.os.Build.VERSION.SDK_INT; +import static android.view.View.FOCUS_DOWN; import static android.view.View.INVISIBLE; import static android.view.View.VISIBLE; import static androidx.transition.TransitionManager.beginDelayedTransition; @@ -46,6 +48,7 @@ public class HotspotIntroFragment extends Fragment { private Button startButton; private ProgressBar progressBar; private TextView progressTextView; + private ScrollView scrollView; private final AbstractConditionManager conditionManager = SDK_INT < 29 ? new ConditionManager(this, this::onPermissionUpdate) : @@ -70,6 +73,7 @@ public class HotspotIntroFragment extends Fragment { startButton = v.findViewById(R.id.startButton); progressBar = v.findViewById(R.id.progressBar); progressTextView = v.findViewById(R.id.progressTextView); + scrollView = v.findViewById(R.id.scrollView); startButton.setOnClickListener(this::onButtonClick); @@ -82,6 +86,8 @@ public class HotspotIntroFragment extends Fragment { public void onStart() { super.onStart(); conditionManager.onStart(); + // Scroll down in case the screen is small, so the button is visible + scrollView.post(() -> scrollView.fullScroll(FOCUS_DOWN)); } private void onButtonClick(View view) { diff --git a/briar-android/src/main/res/layout/fragment_hotspot_intro.xml b/briar-android/src/main/res/layout/fragment_hotspot_intro.xml index b90052f46..e0603f14a 100644 --- a/briar-android/src/main/res/layout/fragment_hotspot_intro.xml +++ b/briar-android/src/main/res/layout/fragment_hotspot_intro.xml @@ -2,6 +2,7 @@