Make Session ID upgrades mandatory

This commit is contained in:
Niels Andriesse
2021-01-11 13:19:10 +11:00
parent 8cf3b53d74
commit ff57bed910
3 changed files with 8 additions and 30 deletions

View File

@@ -7,7 +7,7 @@
android:orientation="vertical"
android:gravity="center_horizontal"
android:padding="@dimen/large_spacing"
app:behavior_hideable="true"
app:behavior_hideable="false"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
<ImageView
@@ -29,7 +29,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/large_spacing"
android:text="Weve upgraded Session IDs to make them even more private and secure. We recommend upgrading to a new Session ID now."
android:text="Weve upgraded Session IDs to make them even more private and secure. To ensure your continued privacy you're now required to upgrade."
android:textSize="@dimen/medium_font_size"
android:textAlignment="center" />
@@ -37,7 +37,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_spacing"
android:text="You will lose existing contacts and conversations, but youll gain even more privacy and security. You will need to upgrade your Session ID eventually, but you can choose to delay the upgrade if you need to save contacts or conversations."
android:text="Your existing contacts and conversations will be lost, but youll be able to use Session knowing you have the best privacy and security possible."
android:textSize="@dimen/medium_font_size"
android:textAlignment="center" />
@@ -49,12 +49,4 @@
android:layout_marginTop="@dimen/very_large_spacing"
android:text="Upgrade Now" />
<Button
style="@style/Widget.Session.Button.Common.UnimportantOutline"
android:id="@+id/upgradeLaterButton"
android:layout_width="240dp"
android:layout_height="@dimen/medium_button_height"
android:layout_marginTop="@dimen/medium_spacing"
android:text="Upgrade Later" />
</LinearLayout>

View File

@@ -187,13 +187,8 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
private fun showKeyPairMigrationSheetIfNeeded() {
if (KeyPairUtilities.hasV2KeyPair(this)) { return }
val lastNudge = TextSecurePreferences.getLastKeyPairMigrationNudge(this)
val nudgeInterval: Long = 3 * 24 * 60 * 60 * 1000 // 3 days
val nudge = (Date().time - lastNudge > nudgeInterval)
if (!nudge) { return }
val keyPairMigrationSheet = KeyPairMigrationBottomSheet()
keyPairMigrationSheet.show(supportFragmentManager, keyPairMigrationSheet.tag)
TextSecurePreferences.setLastKeyPairMigrationNudge(this, Date().time)
}
private fun showKeyPairMigrationSuccessSheetIfNeeded() {

View File

@@ -23,31 +23,22 @@ class KeyPairMigrationBottomSheet : BottomSheetDialogFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
upgradeNowButton.setOnClickListener { upgradeNow() }
upgradeLaterButton.setOnClickListener { dismiss() }
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = super.onCreateDialog(savedInstanceState)
// Expand the bottom sheet by default
dialog.setOnShowListener {
val d = dialog as BottomSheetDialog
val bottomSheet = d.findViewById<FrameLayout>(com.google.android.material.R.id.design_bottom_sheet)
BottomSheetBehavior.from(bottomSheet!!).setState(BottomSheetBehavior.STATE_EXPANDED);
val bottomSheet = d.findViewById<FrameLayout>(com.google.android.material.R.id.design_bottom_sheet)!!
BottomSheetBehavior.from(bottomSheet).state = BottomSheetBehavior.STATE_EXPANDED
BottomSheetBehavior.from(bottomSheet).isHideable = false
}
isCancelable = false
return dialog
}
private fun upgradeNow() {
val applicationContext = requireContext().applicationContext as ApplicationContext
dismiss()
val dialog = AlertDialog.Builder(requireContext())
dialog.setMessage("Youre upgrading to a new Session ID. This will give you improved privacy and security, but it will clear ALL app data. Contacts and conversations will be lost. Proceed?")
dialog.setPositiveButton(R.string.yes) { _, _ ->
applicationContext.clearAllData(true)
}
dialog.setNegativeButton(R.string.cancel) { _, _ ->
// Do nothing
}
dialog.create().show()
applicationContext.clearAllData(true)
}
}