mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 06:09:55 +01:00
Make OfflineFragment suitable for small screens.
This commit is contained in:
@@ -16,13 +16,12 @@ import org.briarproject.nullsafety.ParametersNotNullByDefault;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.widget.NestedScrollView;
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
import static android.view.View.FOCUS_DOWN;
|
|
||||||
import static org.briarproject.briar.android.AppModule.getAndroidComponent;
|
import static org.briarproject.briar.android.AppModule.getAndroidComponent;
|
||||||
|
import static org.briarproject.briar.android.util.UiUtils.hideViewOnSmallScreen;
|
||||||
|
|
||||||
@MethodsNotNullByDefault
|
@MethodsNotNullByDefault
|
||||||
@ParametersNotNullByDefault
|
@ParametersNotNullByDefault
|
||||||
@@ -35,8 +34,6 @@ public class OfflineFragment extends Fragment {
|
|||||||
|
|
||||||
protected MailboxViewModel viewModel;
|
protected MailboxViewModel viewModel;
|
||||||
|
|
||||||
private NestedScrollView scrollView;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Context context) {
|
public void onAttach(Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
@@ -54,7 +51,6 @@ public class OfflineFragment extends Fragment {
|
|||||||
View v = inflater
|
View v = inflater
|
||||||
.inflate(R.layout.fragment_offline, container, false);
|
.inflate(R.layout.fragment_offline, container, false);
|
||||||
|
|
||||||
scrollView = (NestedScrollView) v;
|
|
||||||
Button checkButton = v.findViewById(R.id.checkButton);
|
Button checkButton = v.findViewById(R.id.checkButton);
|
||||||
checkButton.setOnClickListener(view -> {
|
checkButton.setOnClickListener(view -> {
|
||||||
Intent i = new Intent(requireContext(), TransportsActivity.class);
|
Intent i = new Intent(requireContext(), TransportsActivity.class);
|
||||||
@@ -69,8 +65,7 @@ public class OfflineFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
// Scroll down in case the screen is small, so the button is visible
|
hideViewOnSmallScreen(requireView().findViewById(R.id.iconView));
|
||||||
scrollView.post(() -> scrollView.fullScroll(FOCUS_DOWN));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onTryAgainClicked() {
|
protected void onTryAgainClicked() {
|
||||||
|
|||||||
@@ -1,83 +1,82 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout 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">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<ScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
<ImageView
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/iconView"
|
|
||||||
android:layout_width="@dimen/hero_square"
|
|
||||||
android:layout_height="@dimen/hero_square"
|
|
||||||
android:layout_marginHorizontal="@dimen/margin_xlarge"
|
|
||||||
android:layout_marginTop="@dimen/margin_xlarge"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/titleView"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintVertical_bias="0.25"
|
|
||||||
app:layout_constraintVertical_chainStyle="packed"
|
|
||||||
app:srcCompat="@drawable/transport_tor"
|
|
||||||
app:tint="@color/briar_red_500"
|
|
||||||
tools:ignore="ContentDescription" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/titleView"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="@dimen/margin_xlarge"
|
|
||||||
android:layout_marginTop="@dimen/margin_xlarge"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/offline"
|
|
||||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline5"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/textView"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/iconView" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="@dimen/margin_xlarge"
|
|
||||||
android:layout_marginTop="@dimen/margin_xlarge"
|
|
||||||
android:layout_marginBottom="@dimen/margin_large"
|
|
||||||
android:text="@string/tor_offline_description"
|
|
||||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/checkButton"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/titleView" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/checkButton"
|
|
||||||
style="@style/BriarButtonOutline.Neutral"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:layout_marginHorizontal="16dp"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:text="@string/tor_offline_button_check"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/button"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
|
||||||
|
|
||||||
<Button
|
<ImageView
|
||||||
android:id="@+id/button"
|
android:id="@+id/iconView"
|
||||||
style="@style/BriarButton"
|
android:layout_width="@dimen/hero_square"
|
||||||
android:layout_width="0dp"
|
android:layout_height="@dimen/hero_square"
|
||||||
android:layout_height="wrap_content"
|
android:layout_marginHorizontal="@dimen/margin_xlarge"
|
||||||
android:layout_marginHorizontal="@dimen/margin_large"
|
android:layout_marginTop="@dimen/margin_xlarge"
|
||||||
android:layout_marginTop="6dp"
|
app:layout_constraintBottom_toTopOf="@+id/titleView"
|
||||||
android:text="@string/try_again_button"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
app:layout_constraintVertical_bias="0.25"
|
||||||
|
app:layout_constraintVertical_chainStyle="packed"
|
||||||
|
app:srcCompat="@drawable/transport_tor"
|
||||||
|
app:tint="@color/briar_red_500"
|
||||||
|
tools:ignore="ContentDescription" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
<TextView
|
||||||
|
android:id="@+id/titleView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="@dimen/margin_xlarge"
|
||||||
|
android:layout_marginTop="@dimen/margin_xlarge"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/offline"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline5"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/textView"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/iconView" />
|
||||||
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
<TextView
|
||||||
|
android:id="@+id/textView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="@dimen/margin_large"
|
||||||
|
android:layout_marginHorizontal="@dimen/margin_xlarge"
|
||||||
|
android:text="@string/tor_offline_description"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/titleView" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/checkButton"
|
||||||
|
style="@style/BriarButtonOutline.Neutral"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:text="@string/tor_offline_button_check" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button"
|
||||||
|
style="@style/BriarButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:layout_marginTop="6dp"
|
||||||
|
android:text="@string/try_again_button" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user