|
|
|
@ -10,12 +10,13 @@ import android.view.LayoutInflater
|
|
|
|
|
import kotlinx.android.synthetic.main.dialog_clear_all_data.view.*
|
|
|
|
|
import network.loki.messenger.R
|
|
|
|
|
import org.thoughtcrime.securesms.ApplicationContext
|
|
|
|
|
import org.thoughtcrime.securesms.loki.utilities.KeyPairUtilities
|
|
|
|
|
|
|
|
|
|
class ClearAllDataDialog : DialogFragment() {
|
|
|
|
|
|
|
|
|
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
|
|
|
|
val builder = AlertDialog.Builder(context!!)
|
|
|
|
|
val contentView = LayoutInflater.from(context!!).inflate(R.layout.dialog_clear_all_data, null)
|
|
|
|
|
val builder = AlertDialog.Builder(requireContext())
|
|
|
|
|
val contentView = LayoutInflater.from(requireContext()).inflate(R.layout.dialog_clear_all_data, null)
|
|
|
|
|
contentView.cancelButton.setOnClickListener { dismiss() }
|
|
|
|
|
contentView.clearAllDataButton.setOnClickListener { clearAllData() }
|
|
|
|
|
builder.setView(contentView)
|
|
|
|
@ -25,6 +26,19 @@ class ClearAllDataDialog : DialogFragment() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun clearAllData() {
|
|
|
|
|
ApplicationContext.getInstance(context).clearData()
|
|
|
|
|
if (KeyPairUtilities.hasV2KeyPair(requireContext())) {
|
|
|
|
|
ApplicationContext.getInstance(context).clearData()
|
|
|
|
|
} else {
|
|
|
|
|
val dialog = AlertDialog.Builder(requireContext())
|
|
|
|
|
val message = "We’ve upgraded the way Session IDs are generated, so you will be unable to restore your current Session ID."
|
|
|
|
|
dialog.setMessage(message)
|
|
|
|
|
dialog.setPositiveButton("Yes") { _, _ ->
|
|
|
|
|
ApplicationContext.getInstance(context).clearData()
|
|
|
|
|
}
|
|
|
|
|
dialog.setNegativeButton("Cancel") { _, _ ->
|
|
|
|
|
// Do nothing
|
|
|
|
|
}
|
|
|
|
|
dialog.create().show()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|