mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Add tap to submit debuglog for regv3 screens.
This commit is contained in:
committed by
Greyson Parrelli
parent
021fd16540
commit
a6aa2ca3ce
@@ -1,16 +1,10 @@
|
||||
package org.thoughtcrime.securesms.registration.fragments
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.StringRes
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.logsubmit.SubmitDebugLogActivity
|
||||
import org.thoughtcrime.securesms.phonenumbers.PhoneNumberFormatter
|
||||
import org.thoughtcrime.securesms.util.SpanUtil
|
||||
|
||||
object RegistrationViewDelegate {
|
||||
|
||||
@@ -20,45 +14,21 @@ object RegistrationViewDelegate {
|
||||
private val DEBUG_TAP_TARGET = 8
|
||||
private val DEBUG_TAP_ANNOUNCE = 4
|
||||
private var debugTapCounter = 0
|
||||
private var previousToast: Toast? = null
|
||||
|
||||
override fun onClick(view: View) {
|
||||
debugTapCounter++
|
||||
|
||||
if (debugTapCounter >= DEBUG_TAP_TARGET) {
|
||||
view.context.startActivity(Intent(view.context, SubmitDebugLogActivity::class.java))
|
||||
previousToast?.cancel()
|
||||
previousToast = null
|
||||
} else if (debugTapCounter >= DEBUG_TAP_ANNOUNCE) {
|
||||
val remaining = DEBUG_TAP_TARGET - debugTapCounter
|
||||
Toast.makeText(view.context, view.context.resources.getQuantityString(R.plurals.RegistrationActivity_debug_log_hint, remaining, remaining), Toast.LENGTH_SHORT).show()
|
||||
previousToast?.cancel()
|
||||
previousToast = Toast.makeText(view.context, view.context.resources.getQuantityString(R.plurals.RegistrationActivity_debug_log_hint, remaining, remaining), Toast.LENGTH_SHORT).apply { show() }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun showConfirmNumberDialogIfTranslated(
|
||||
context: Context,
|
||||
@StringRes title: Int?,
|
||||
@StringRes firstMessageLine: Int?,
|
||||
e164number: String,
|
||||
onConfirmed: Runnable,
|
||||
onEditNumber: Runnable
|
||||
) {
|
||||
val message: CharSequence = SpannableStringBuilder().apply {
|
||||
append(SpanUtil.bold(PhoneNumberFormatter.prettyPrint(e164number)))
|
||||
if (firstMessageLine != null) {
|
||||
append("\n\n")
|
||||
append(context.getString(firstMessageLine))
|
||||
}
|
||||
}
|
||||
|
||||
MaterialAlertDialogBuilder(context).apply {
|
||||
if (title != null) {
|
||||
setTitle(title)
|
||||
}
|
||||
setMessage(message)
|
||||
setPositiveButton(android.R.string.ok) { _, _ -> onConfirmed.run() }
|
||||
setNegativeButton(R.string.RegistrationActivity_edit_number) { _, _ -> onEditNumber.run() }
|
||||
setOnCancelListener { onEditNumber.run() }
|
||||
}.show()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user