mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-03-02 07:23:38 +00:00
Address UI issues on safety number verification screen.
This commit is contained in:
@@ -59,11 +59,7 @@ class PnpSafetyNumberEducationDialogFragment : FixedRoundedCornerBottomSheetDial
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun showIfNeeded(fragmentManager: FragmentManager) {
|
||||
if (SignalStore.uiHints().hasSeenSafetyNumberUpdateNux()) {
|
||||
return
|
||||
}
|
||||
|
||||
fun show(fragmentManager: FragmentManager) {
|
||||
val fragment = PnpSafetyNumberEducationDialogFragment()
|
||||
if (fragmentManager.findFragmentByTag(BottomSheetUtil.STANDARD_BOTTOM_SHEET_FRAGMENT_TAG) == null) {
|
||||
fragment.show(fragmentManager, BottomSheetUtil.STANDARD_BOTTOM_SHEET_FRAGMENT_TAG)
|
||||
|
||||
@@ -41,7 +41,6 @@ import org.thoughtcrime.securesms.util.FeatureFlags
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
import org.thoughtcrime.securesms.util.ViewUtil
|
||||
import org.thoughtcrime.securesms.util.visible
|
||||
import org.thoughtcrime.securesms.verify.PnpSafetyNumberEducationDialogFragment.Companion.showIfNeeded
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.util.Locale
|
||||
|
||||
@@ -59,6 +58,8 @@ class VerifyDisplayFragment : Fragment(), OnScrollChangedListener {
|
||||
|
||||
private var callback: Callback? = null
|
||||
|
||||
private var animateCodeChanges = true
|
||||
|
||||
private var animateSuccessOnDraw = false
|
||||
private var animateFailureOnDraw = false
|
||||
private var currentVerifiedState = false
|
||||
@@ -82,6 +83,7 @@ class VerifyDisplayFragment : Fragment(), OnScrollChangedListener {
|
||||
initializeViewModel()
|
||||
|
||||
binding.safetyNumberUpdatingBannerText.text = Html.fromHtml(String.format(getString(R.string.verify_display_fragment__safety_numbers_are_updating_banner)))
|
||||
binding.safetyNumberUpdatingBannerText.movementMethod = LinkMovementMethod.getInstance()
|
||||
|
||||
updateVerifyButton(requireArguments().getBoolean(VERIFIED_STATE, false), false)
|
||||
|
||||
@@ -141,7 +143,10 @@ class VerifyDisplayFragment : Fragment(), OnScrollChangedListener {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
showIfNeeded(childFragmentManager)
|
||||
if (!viewModel.showedSafetyNumberEducationDialog) {
|
||||
PnpSafetyNumberEducationDialogFragment.show(childFragmentManager)
|
||||
viewModel.showedSafetyNumberEducationDialog = true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
@@ -201,6 +206,8 @@ class VerifyDisplayFragment : Fragment(), OnScrollChangedListener {
|
||||
}
|
||||
|
||||
fun setScannedFingerprint(scanned: String) {
|
||||
animateCodeChanges = false
|
||||
|
||||
val fingerprints = viewModel.getFingerprints().value
|
||||
var haveMatchingVersion = false
|
||||
if (fingerprints != null) {
|
||||
@@ -218,18 +225,25 @@ class VerifyDisplayFragment : Fragment(), OnScrollChangedListener {
|
||||
Log.w(TAG, e)
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, e)
|
||||
Toast.makeText(activity, R.string.VerifyIdentityActivity_the_scanned_qr_code_is_not_a_correctly_formatted_safety_number, Toast.LENGTH_LONG).show()
|
||||
showAlertDialog(R.string.VerifyIdentityActivity_the_scanned_qr_code_is_not_a_correctly_formatted_safety_number)
|
||||
animateFailureOnDraw = true
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!haveMatchingVersion) {
|
||||
Toast.makeText(activity, R.string.VerifyIdentityActivity_your_contact_is_running_a_newer_version_of_Signal, Toast.LENGTH_LONG).show()
|
||||
showAlertDialog(R.string.VerifyIdentityActivity_your_contact_is_running_a_newer_version_of_Signal)
|
||||
animateFailureOnDraw = true
|
||||
}
|
||||
}
|
||||
|
||||
private fun showAlertDialog(stringResId: Int) {
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
.setMessage(stringResId)
|
||||
.setPositiveButton(R.string.VerifyDisplayFragment__scan_result_dialog_ok, null)
|
||||
.show()
|
||||
}
|
||||
|
||||
private fun getFormattedSafetyNumbers(fingerprint: Fingerprint): String {
|
||||
val segments = getSegments(fingerprint)
|
||||
val result = StringBuilder()
|
||||
@@ -249,12 +263,12 @@ class VerifyDisplayFragment : Fragment(), OnScrollChangedListener {
|
||||
private fun handleCompareWithClipboard() {
|
||||
val clipboardData = Util.readTextFromClipboard(requireActivity())
|
||||
if (clipboardData == null) {
|
||||
Toast.makeText(requireActivity(), R.string.VerifyIdentityActivity_no_safety_number_to_compare_was_found_in_the_clipboard, Toast.LENGTH_LONG).show()
|
||||
showAlertDialog(R.string.VerifyIdentityActivity_no_safety_number_to_compare_was_found_in_the_clipboard)
|
||||
return
|
||||
}
|
||||
val numericClipboardData = clipboardData.replace("\\D".toRegex(), "")
|
||||
if (TextUtils.isEmpty(numericClipboardData) || numericClipboardData.length != 60) {
|
||||
Toast.makeText(requireActivity(), R.string.VerifyIdentityActivity_no_safety_number_to_compare_was_found_in_the_clipboard, Toast.LENGTH_LONG).show()
|
||||
showAlertDialog(R.string.VerifyIdentityActivity_no_safety_number_to_compare_was_found_in_the_clipboard)
|
||||
return
|
||||
}
|
||||
var success = false
|
||||
@@ -276,10 +290,14 @@ class VerifyDisplayFragment : Fragment(), OnScrollChangedListener {
|
||||
}
|
||||
|
||||
private fun animateSuccess(position: Int) {
|
||||
animateCodeChanges = false
|
||||
|
||||
safetyNumberAdapter.notifyItemChanged(position, true)
|
||||
}
|
||||
|
||||
private fun animateFailure(position: Int) {
|
||||
animateCodeChanges = false
|
||||
|
||||
safetyNumberAdapter.notifyItemChanged(position, false)
|
||||
}
|
||||
|
||||
@@ -372,7 +390,7 @@ class VerifyDisplayFragment : Fragment(), OnScrollChangedListener {
|
||||
|
||||
override fun onBindViewHolder(holder: SafetyNumberQrViewHolder, position: Int) {
|
||||
val (version, _, _, _, _, fingerprint1) = fingerprints!![position]
|
||||
holder.safetyNumberQrView.setFingerprintViews(fingerprint1, true)
|
||||
holder.safetyNumberQrView.setFingerprintViews(fingerprint1, animateCodeChanges)
|
||||
holder.safetyNumberQrView.setSafetyNumberType(version == 2)
|
||||
holder.safetyNumberQrView.shareButton.setOnClickListener { v: View? -> handleShare(fingerprints!![position].fingerprint) }
|
||||
holder.safetyNumberQrView.qrCodeContainer.setOnClickListener { v: View? -> callback!!.onQrCodeContainerClicked() }
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.Manifest
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.activity.addCallback
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.Fragment
|
||||
import org.signal.core.util.ThreadUtil
|
||||
@@ -120,4 +121,15 @@ class VerifyIdentityFragment : Fragment(R.layout.fragment_container), ScanListen
|
||||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
|
||||
Permissions.onRequestPermissionsResult(this, requestCode, permissions, grantResults)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val callback = requireActivity().onBackPressedDispatcher.addCallback(this) {
|
||||
if (childFragmentManager.backStackEntryCount > 0) {
|
||||
childFragmentManager.popBackStack()
|
||||
} else {
|
||||
requireActivity().finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ class VerifySafetyNumberViewModel(
|
||||
}
|
||||
|
||||
val recipient: LiveRecipient = Recipient.live(recipientId)
|
||||
var showedSafetyNumberEducationDialog = SignalStore.uiHints().hasSeenSafetyNumberUpdateNux()
|
||||
|
||||
private val fingerprintListLiveData = MutableLiveData<List<SafetyNumberFingerprint>>()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user