Fix export flow on small screens.

fork-5.53.8
Cody Henthorne 2022-10-10 14:37:18 -04:00
rodzic 68237df321
commit 02d9cbe01b
4 zmienionych plików z 80 dodań i 51 usunięć

Wyświetl plik

@ -7,6 +7,7 @@ import androidx.navigation.fragment.findNavController
import org.signal.smsexporter.DefaultSmsHelper
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.databinding.ExportYourSmsMessagesFragmentBinding
import org.thoughtcrime.securesms.util.Material3OnScrollHelper
import org.thoughtcrime.securesms.util.navigation.safeNavigate
/**
@ -28,5 +29,7 @@ class ExportYourSmsMessagesFragment : Fragment(R.layout.export_your_sms_messages
findNavController().safeNavigate(ExportYourSmsMessagesFragmentDirections.actionExportYourSmsMessagesFragmentToSetSignalAsDefaultSmsAppFragment())
}
}
Material3OnScrollHelper(requireActivity(), binding.toolbar).attach(binding.scrollView)
}
}

Wyświetl plik

@ -7,6 +7,7 @@ import android.view.View
import androidx.annotation.ColorInt
import androidx.annotation.ColorRes
import androidx.core.content.ContextCompat
import androidx.core.widget.NestedScrollView
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.animation.ArgbEvaluatorCompat
import com.google.android.material.appbar.AppBarLayout
@ -47,6 +48,14 @@ open class Material3OnScrollHelper(
private var animator: ValueAnimator? = null
private var active: Boolean? = null
fun attach(nestedScrollView: NestedScrollView) {
nestedScrollView.setOnScrollChangeListener(
OnScrollListener().apply {
onScrollChange(nestedScrollView, 0, 0, 0, 0)
}
)
}
fun attach(recyclerView: RecyclerView) {
recyclerView.addOnScrollListener(
OnScrollListener().apply {
@ -57,7 +66,7 @@ open class Material3OnScrollHelper(
fun attach(appBarLayout: AppBarLayout) {
appBarLayout.addOnOffsetChangedListener(
OnOffsetChangedListener().apply {
OnScrollListener().apply {
onOffsetChanged(appBarLayout, 0)
}
)
@ -119,15 +128,17 @@ open class Material3OnScrollHelper(
viewStubs.filter { it.resolved() }.forEach { it.get().setBackgroundColor(color) }
}
private inner class OnScrollListener : RecyclerView.OnScrollListener() {
private inner class OnScrollListener : RecyclerView.OnScrollListener(), AppBarLayout.OnOffsetChangedListener, NestedScrollView.OnScrollChangeListener {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
updateActiveState(recyclerView.canScrollVertically(-1))
}
}
private inner class OnOffsetChangedListener : AppBarLayout.OnOffsetChangedListener {
override fun onOffsetChanged(appBarLayout: AppBarLayout, verticalOffset: Int) {
updateActiveState(verticalOffset != 0)
}
override fun onScrollChange(v: NestedScrollView, scrollX: Int, scrollY: Int, oldScrollX: Int, oldScrollY: Int) {
updateActiveState(v.canScrollVertically(-1))
}
}
}

Wyświetl plik

@ -246,8 +246,9 @@
style="@style/Signal.Widget.Button.Large.Tonal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
android:layout_marginBottom="44dp"
android:minWidth="221dp"
android:minWidth="220dp"
android:text="@string/ChooseANewDefaultSmsAppFragment__continue"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"

Wyświetl plik

@ -1,63 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="64dp"
android:minHeight="64dp"
app:layout_constraintTop_toTopOf="parent"
app:navigationIcon="@drawable/ic_arrow_left_24" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/image"
<androidx.core.widget.NestedScrollView
android:id="@+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:importantForAccessibility="no"
android:scaleType="centerInside"
app:srcCompat="@drawable/sms_message"
app:layout_constraintTop_toBottomOf="@id/toolbar" />
android:layout_height="match_parent"
android:fillViewport="true">
<TextView
android:id="@+id/headline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="32dp"
android:layout_marginTop="40dp"
android:gravity="center"
android:text="@string/ExportYourSmsMessagesFragment__export_your_sms_messages"
android:textAppearance="@style/Signal.Text.HeadlineLarge"
app:layout_constraintTop_toBottomOf="@id/image" />
<androidx.constraintlayout.widget.ConstraintLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="32dp"
android:layout_marginTop="24dp"
android:gravity="center"
android:text="@string/ExportYourSmsMessagesFragment__you_can_export_your_sms_messages_to_your_phones_sms_database"
android:textColor="@color/signal_colorOnSurfaceVariant"
android:textAppearance="@style/Signal.Text.BodyLarge"
app:layout_constraintTop_toBottomOf="@id/headline" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:importantForAccessibility="no"
android:scaleType="centerInside"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/sms_message" />
<com.google.android.material.button.MaterialButton
android:id="@+id/continue_button"
style="@style/Signal.Widget.Button.Large.Tonal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="44dp"
android:minWidth="221dp"
android:text="@string/ExportYourSmsMessagesFragment__continue"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/description"
app:layout_constraintVertical_bias="1" />
<TextView
android:id="@+id/headline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="32dp"
android:layout_marginTop="40dp"
android:gravity="center"
android:text="@string/ExportYourSmsMessagesFragment__export_your_sms_messages"
android:textAppearance="@style/Signal.Text.HeadlineLarge"
app:layout_constraintTop_toBottomOf="@id/image" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="32dp"
android:layout_marginTop="24dp"
android:gravity="center"
android:text="@string/ExportYourSmsMessagesFragment__you_can_export_your_sms_messages_to_your_phones_sms_database"
android:textAppearance="@style/Signal.Text.BodyLarge"
android:textColor="@color/signal_colorOnSurfaceVariant"
app:layout_constraintTop_toBottomOf="@id/headline" />
<com.google.android.material.button.MaterialButton
android:id="@+id/continue_button"
style="@style/Signal.Widget.Button.Large.Tonal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
android:layout_marginBottom="44dp"
android:minWidth="220dp"
android:text="@string/ExportYourSmsMessagesFragment__continue"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/description"
app:layout_constraintVertical_bias="1" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>