mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
Add Session ID change notice
This commit is contained in:
parent
c8aad73beb
commit
aec7f63560
@ -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() {
|
||||||
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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -45,4 +45,8 @@ object KeyPairUtilities {
|
|||||||
IdentityKeyUtil.save(context, IdentityKeyUtil.ED25519_PUBLIC_KEY, Base64.encodeBytes(ed25519KeyPair.publicKey.asBytes))
|
IdentityKeyUtil.save(context, IdentityKeyUtil.ED25519_PUBLIC_KEY, Base64.encodeBytes(ed25519KeyPair.publicKey.asBytes))
|
||||||
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)
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user