Let info screens scroll in case of insufficient space

This commit is contained in:
Torsten Grote
2021-05-07 17:35:09 -03:00
committed by Sebastian Kürten
parent b255ab07ae
commit ebd5879761
5 changed files with 199 additions and 171 deletions

View File

@@ -65,7 +65,7 @@ public abstract class AbstractTabsFragment extends Fragment {
viewPager.setAdapter(tabAdapter); viewPager.setAdapter(tabAdapter);
TabLayout tabLayout = view.findViewById(R.id.tabLayout); TabLayout tabLayout = view.findViewById(R.id.tabLayout);
new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> { new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> {
// tabs are set in XML, but just dummies that don't get not added // tabs are set in XML, but are just dummies that don't get added
if (position == 0) { if (position == 0) {
tab.setText(R.string.hotspot_tab_manual); tab.setText(R.string.hotspot_tab_manual);
tab.setIcon(R.drawable.forum_item_create_white); tab.setIcon(R.drawable.forum_item_create_white);

View File

@@ -10,7 +10,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import static android.view.View.INVISIBLE; import static android.view.View.GONE;
@MethodsNotNullByDefault @MethodsNotNullByDefault
@ParametersNotNullByDefault @ParametersNotNullByDefault
@@ -22,7 +22,7 @@ public class WebsiteFragment extends AbstractTabsFragment {
public void onViewCreated(@NonNull View view, public void onViewCreated(@NonNull View view,
@Nullable Bundle savedInstanceState) { @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
connectedButton.setVisibility(INVISIBLE); connectedButton.setVisibility(GONE);
} }
@Override @Override

View File

@@ -1,9 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:fillViewport="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView <TextView
android:id="@+id/manualIntroView" android:id="@+id/manualIntroView"
@@ -86,3 +91,5 @@
app:layout_constraintTop_toBottomOf="@+id/passwordView" /> app:layout_constraintTop_toBottomOf="@+id/passwordView" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>

View File

@@ -1,9 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:fillViewport="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView <TextView
android:id="@+id/qrIntroView" android:id="@+id/qrIntroView"
@@ -25,6 +30,7 @@
android:layout_marginLeft="64dp" android:layout_marginLeft="64dp"
android:layout_marginTop="32dp" android:layout_marginTop="32dp"
android:layout_marginEnd="64dp" android:layout_marginEnd="64dp"
android:layout_marginRight="64dp"
android:layout_marginBottom="32dp" android:layout_marginBottom="32dp"
app:cardCornerRadius="16dp" app:cardCornerRadius="16dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@@ -44,3 +50,5 @@
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>

View File

@@ -5,13 +5,23 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<com.google.android.material.tabs.TabLayout <androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/tabLayout" android:layout_width="match_parent"
android:layout_width="0dp" android:layout_height="0dp"
android:layout_height="wrap_content" app:layout_constraintBottom_toTopOf="@+id/connectedButton"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways"
app:tabBackground="@color/briar_primary" app:tabBackground="@color/briar_primary"
app:tabGravity="fill" app:tabGravity="fill"
app:tabIconTint="@color/action_bar_text" app:tabIconTint="@color/action_bar_text"
@@ -35,31 +45,19 @@
android:text="@string/qr_code" /> android:text="@string/qr_code" />
</com.google.android.material.tabs.TabLayout> </com.google.android.material.tabs.TabLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager2.widget.ViewPager2 <androidx.viewpager2.widget.ViewPager2
android:id="@+id/pager" android:id="@+id/pager"
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="match_parent"
app:layout_constraintBottom_toTopOf="@+id/stopButton" app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_constraintBottom_toTopOf="@+id/connectedButton"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tabLayout" /> app:layout_constraintTop_toBottomOf="@+id/tabLayout" />
<Button </androidx.coordinatorlayout.widget.CoordinatorLayout>
android:id="@+id/stopButton"
style="@style/BriarButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:drawableStart="@drawable/ic_portable_wifi_off"
android:drawableLeft="@drawable/ic_portable_wifi_off"
android:drawablePadding="6dp"
android:text="@string/hotspot_button_stop_sharing"
app:backgroundTint="@color/briar_red_500"
app:drawableTint="@color/button_text"
app:layout_constraintBottom_toTopOf="@+id/connectedButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:visibility="visible" />
<Button <Button
android:id="@+id/connectedButton" android:id="@+id/connectedButton"
@@ -67,10 +65,25 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="16dp" android:layout_margin="16dp"
android:drawableStart="@drawable/ic_check_white"
android:drawableLeft="@drawable/ic_check_white"
android:drawablePadding="6dp"
android:text="@string/hotspot_button_connected" android:text="@string/hotspot_button_connected"
app:drawableLeftCompat="@drawable/ic_check_white"
app:drawableStartCompat="@drawable/ic_check_white"
app:drawableTint="@color/button_text"
app:layout_constraintBottom_toTopOf="@+id/stopButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:visibility="visible" />
<Button
android:id="@+id/stopButton"
style="@style/BriarButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="@string/hotspot_button_stop_sharing"
app:backgroundTint="@color/briar_red_500"
app:drawableLeftCompat="@drawable/ic_portable_wifi_off"
app:drawableStartCompat="@drawable/ic_portable_wifi_off"
app:drawableTint="@color/button_text" app:drawableTint="@color/button_text"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"