mirror of
https://github.com/oxen-io/session-android.git
synced 2025-04-16 10:31:28 +00:00
Add Session ID change notice.
Changes from aec7f6356
This commit is contained in:
parent
48adb63fb7
commit
c1ef2728dc
@ -10,12 +10,13 @@ import android.view.LayoutInflater
|
|||||||
import kotlinx.android.synthetic.main.dialog_clear_all_data.view.*
|
import kotlinx.android.synthetic.main.dialog_clear_all_data.view.*
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.thoughtcrime.securesms.ApplicationContext
|
import org.thoughtcrime.securesms.ApplicationContext
|
||||||
|
import org.thoughtcrime.securesms.loki.utilities.KeyPairUtilities
|
||||||
|
|
||||||
class ClearAllDataDialog : DialogFragment() {
|
class ClearAllDataDialog : DialogFragment() {
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val builder = AlertDialog.Builder(context!!)
|
val builder = AlertDialog.Builder(requireContext())
|
||||||
val contentView = LayoutInflater.from(context!!).inflate(R.layout.dialog_clear_all_data, null)
|
val contentView = LayoutInflater.from(requireContext()).inflate(R.layout.dialog_clear_all_data, null)
|
||||||
contentView.cancelButton.setOnClickListener { dismiss() }
|
contentView.cancelButton.setOnClickListener { dismiss() }
|
||||||
contentView.clearAllDataButton.setOnClickListener { clearAllData() }
|
contentView.clearAllDataButton.setOnClickListener { clearAllData() }
|
||||||
builder.setView(contentView)
|
builder.setView(contentView)
|
||||||
@ -25,6 +26,19 @@ class ClearAllDataDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun clearAllData() {
|
private fun clearAllData() {
|
||||||
|
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()
|
ApplicationContext.getInstance(context).clearData()
|
||||||
}
|
}
|
||||||
|
dialog.setNegativeButton("Cancel") { _, _ ->
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
dialog.create().show()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -40,6 +40,11 @@ object KeyPairUtilities {
|
|||||||
IdentityKeyUtil.save(context, IdentityKeyUtil.ED25519_SECRET_KEY, Base64.encodeBytes(ed25519KeyPair.secretKey.asBytes))
|
IdentityKeyUtil.save(context, IdentityKeyUtil.ED25519_SECRET_KEY, Base64.encodeBytes(ed25519KeyPair.secretKey.asBytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun hasV2KeyPair(context: Context): Boolean {
|
||||||
|
return (IdentityKeyUtil.retrieve(context, IdentityKeyUtil.ED25519_SECRET_KEY) != null)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
data class KeyPairGenerationResult(
|
data class KeyPairGenerationResult(
|
||||||
val seed: ByteArray,
|
val seed: ByteArray,
|
||||||
val ed25519KeyPair: KeyPair,
|
val ed25519KeyPair: KeyPair,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user