kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix export flow on small screens.
rodzic
68237df321
commit
02d9cbe01b
|
@ -7,6 +7,7 @@ import androidx.navigation.fragment.findNavController
|
||||||
import org.signal.smsexporter.DefaultSmsHelper
|
import org.signal.smsexporter.DefaultSmsHelper
|
||||||
import org.thoughtcrime.securesms.R
|
import org.thoughtcrime.securesms.R
|
||||||
import org.thoughtcrime.securesms.databinding.ExportYourSmsMessagesFragmentBinding
|
import org.thoughtcrime.securesms.databinding.ExportYourSmsMessagesFragmentBinding
|
||||||
|
import org.thoughtcrime.securesms.util.Material3OnScrollHelper
|
||||||
import org.thoughtcrime.securesms.util.navigation.safeNavigate
|
import org.thoughtcrime.securesms.util.navigation.safeNavigate
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,5 +29,7 @@ class ExportYourSmsMessagesFragment : Fragment(R.layout.export_your_sms_messages
|
||||||
findNavController().safeNavigate(ExportYourSmsMessagesFragmentDirections.actionExportYourSmsMessagesFragmentToSetSignalAsDefaultSmsAppFragment())
|
findNavController().safeNavigate(ExportYourSmsMessagesFragmentDirections.actionExportYourSmsMessagesFragmentToSetSignalAsDefaultSmsAppFragment())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Material3OnScrollHelper(requireActivity(), binding.toolbar).attach(binding.scrollView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.view.View
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
import androidx.annotation.ColorRes
|
import androidx.annotation.ColorRes
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.widget.NestedScrollView
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.android.material.animation.ArgbEvaluatorCompat
|
import com.google.android.material.animation.ArgbEvaluatorCompat
|
||||||
import com.google.android.material.appbar.AppBarLayout
|
import com.google.android.material.appbar.AppBarLayout
|
||||||
|
@ -47,6 +48,14 @@ open class Material3OnScrollHelper(
|
||||||
private var animator: ValueAnimator? = null
|
private var animator: ValueAnimator? = null
|
||||||
private var active: Boolean? = null
|
private var active: Boolean? = null
|
||||||
|
|
||||||
|
fun attach(nestedScrollView: NestedScrollView) {
|
||||||
|
nestedScrollView.setOnScrollChangeListener(
|
||||||
|
OnScrollListener().apply {
|
||||||
|
onScrollChange(nestedScrollView, 0, 0, 0, 0)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fun attach(recyclerView: RecyclerView) {
|
fun attach(recyclerView: RecyclerView) {
|
||||||
recyclerView.addOnScrollListener(
|
recyclerView.addOnScrollListener(
|
||||||
OnScrollListener().apply {
|
OnScrollListener().apply {
|
||||||
|
@ -57,7 +66,7 @@ open class Material3OnScrollHelper(
|
||||||
|
|
||||||
fun attach(appBarLayout: AppBarLayout) {
|
fun attach(appBarLayout: AppBarLayout) {
|
||||||
appBarLayout.addOnOffsetChangedListener(
|
appBarLayout.addOnOffsetChangedListener(
|
||||||
OnOffsetChangedListener().apply {
|
OnScrollListener().apply {
|
||||||
onOffsetChanged(appBarLayout, 0)
|
onOffsetChanged(appBarLayout, 0)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -119,15 +128,17 @@ open class Material3OnScrollHelper(
|
||||||
viewStubs.filter { it.resolved() }.forEach { it.get().setBackgroundColor(color) }
|
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) {
|
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||||
updateActiveState(recyclerView.canScrollVertically(-1))
|
updateActiveState(recyclerView.canScrollVertically(-1))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private inner class OnOffsetChangedListener : AppBarLayout.OnOffsetChangedListener {
|
|
||||||
override fun onOffsetChanged(appBarLayout: AppBarLayout, verticalOffset: Int) {
|
override fun onOffsetChanged(appBarLayout: AppBarLayout, verticalOffset: Int) {
|
||||||
updateActiveState(verticalOffset != 0)
|
updateActiveState(verticalOffset != 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onScrollChange(v: NestedScrollView, scrollX: Int, scrollY: Int, oldScrollX: Int, oldScrollY: Int) {
|
||||||
|
updateActiveState(v.canScrollVertically(-1))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,8 +246,9 @@
|
||||||
style="@style/Signal.Widget.Button.Large.Tonal"
|
style="@style/Signal.Widget.Button.Large.Tonal"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="48dp"
|
||||||
android:layout_marginBottom="44dp"
|
android:layout_marginBottom="44dp"
|
||||||
android:minWidth="221dp"
|
android:minWidth="220dp"
|
||||||
android:text="@string/ChooseANewDefaultSmsAppFragment__continue"
|
android:text="@string/ChooseANewDefaultSmsAppFragment__continue"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
|
|
@ -1,63 +1,77 @@
|
||||||
<?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"
|
<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"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
<androidx.appcompat.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="64dp"
|
android:layout_height="64dp"
|
||||||
android:minHeight="64dp"
|
android:minHeight="64dp"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:navigationIcon="@drawable/ic_arrow_left_24" />
|
app:navigationIcon="@drawable/ic_arrow_left_24" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
<androidx.core.widget.NestedScrollView
|
||||||
android:id="@+id/image"
|
android:id="@+id/scroll_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="20dp"
|
android:fillViewport="true">
|
||||||
android:importantForAccessibility="no"
|
|
||||||
android:scaleType="centerInside"
|
|
||||||
app:srcCompat="@drawable/sms_message"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
|
||||||
|
|
||||||
<TextView
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/headline"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="wrap_content">
|
||||||
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" />
|
|
||||||
|
|
||||||
<TextView
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
android:id="@+id/description"
|
android:id="@+id/image"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="32dp"
|
android:layout_marginTop="20dp"
|
||||||
android:layout_marginTop="24dp"
|
android:importantForAccessibility="no"
|
||||||
android:gravity="center"
|
android:scaleType="centerInside"
|
||||||
android:text="@string/ExportYourSmsMessagesFragment__you_can_export_your_sms_messages_to_your_phones_sms_database"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
android:textColor="@color/signal_colorOnSurfaceVariant"
|
app:srcCompat="@drawable/sms_message" />
|
||||||
android:textAppearance="@style/Signal.Text.BodyLarge"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/headline" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<TextView
|
||||||
android:id="@+id/continue_button"
|
android:id="@+id/headline"
|
||||||
style="@style/Signal.Widget.Button.Large.Tonal"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_marginHorizontal="32dp"
|
||||||
android:layout_marginBottom="44dp"
|
android:layout_marginTop="40dp"
|
||||||
android:minWidth="221dp"
|
android:gravity="center"
|
||||||
android:text="@string/ExportYourSmsMessagesFragment__continue"
|
android:text="@string/ExportYourSmsMessagesFragment__export_your_sms_messages"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
android:textAppearance="@style/Signal.Text.HeadlineLarge"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintTop_toBottomOf="@id/image" />
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/description"
|
|
||||||
app:layout_constraintVertical_bias="1" />
|
|
||||||
|
|
||||||
</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>
|
||||||
|
|
Ładowanie…
Reference in New Issue