Show device unlink message on startup.

This commit is contained in:
Mikunj 2019-11-22 10:43:22 +11:00
parent 733ab06e70
commit 27c8b45ae3
5 changed files with 29 additions and 2 deletions

View File

@ -1647,5 +1647,8 @@
<!-- Device list bottom sheet fragment --> <!-- Device list bottom sheet fragment -->
<string name="fragment_device_list_edit_device_name_title">Edit device name</string> <string name="fragment_device_list_edit_device_name_title">Edit device name</string>
<string name="fragment_device_list_unlink_device_title">Unlink device</string> <string name="fragment_device_list_unlink_device_title">Unlink device</string>
<!-- Device unlink dialog -->
<string name="dialog_device_unlink_title">Device unlinked</string>
<string name="dialog_device_unlink_message">This device has been successfully unlinked.</string>
</resources> </resources>

View File

@ -607,12 +607,12 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
if (TextSecurePreferences.resetDatabase(this)) { if (TextSecurePreferences.resetDatabase(this)) {
boolean wasUnlinked = TextSecurePreferences.databaseResetFromUnpair(this); boolean wasUnlinked = TextSecurePreferences.databaseResetFromUnpair(this);
TextSecurePreferences.clearAll(this); TextSecurePreferences.clearAll(this);
TextSecurePreferences.setDatabaseResetFromUnpair(this, wasUnlinked); // Loki - Re-set the preference so we can use it in the starting screen to determine whether device was unlinked or not
MasterSecretUtil.clear(this); MasterSecretUtil.clear(this);
if (this.deleteDatabase("signal.db")) { if (this.deleteDatabase("signal.db")) {
Log.d("Loki", "Deleted database"); Log.d("Loki", "Deleted database");
} }
// Loki - Re-set the preference so we can use it in the starting screen to determine whether device was unlinked or not
TextSecurePreferences.setDatabaseResetFromUnpair(this, wasUnlinked);
} }
} }

View File

@ -335,6 +335,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
// Make sure we got the request from our primary device // Make sure we got the request from our primary device
String ourPrimaryDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(context); String ourPrimaryDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
if (ourPrimaryDevice != null && ourPrimaryDevice.equals(content.getSender())) { if (ourPrimaryDevice != null && ourPrimaryDevice.equals(content.getSender())) {
TextSecurePreferences.setDatabaseResetFromUnpair(context, true);
MultiDeviceUtilities.checkForRevocation(context); MultiDeviceUtilities.checkForRevocation(context);
} }
} else { } else {

View File

@ -24,6 +24,7 @@ import org.whispersystems.signalservice.api.push.SignalServiceAddress
import org.whispersystems.signalservice.loki.api.LokiStorageAPI import org.whispersystems.signalservice.loki.api.LokiStorageAPI
import org.whispersystems.signalservice.loki.api.PairingAuthorisation import org.whispersystems.signalservice.loki.api.PairingAuthorisation
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus
import org.whispersystems.signalservice.loki.utilities.Analytics
import org.whispersystems.signalservice.loki.utilities.recover import org.whispersystems.signalservice.loki.utilities.recover
import org.whispersystems.signalservice.loki.utilities.retryIfNeeded import org.whispersystems.signalservice.loki.utilities.retryIfNeeded
import java.util.* import java.util.*
@ -40,6 +41,7 @@ fun checkForRevocation(context: Context) {
DatabaseFactory.getLokiAPIDatabase(context).removePairingAuthorisations(ourDevice) DatabaseFactory.getLokiAPIDatabase(context).removePairingAuthorisations(ourDevice)
LokiStorageAPI.shared.updateUserDeviceMappings() LokiStorageAPI.shared.updateUserDeviceMappings()
}.successUi { }.successUi {
Analytics.shared.track("Secondary Device Unlinked")
TextSecurePreferences.setNeedsRevocationCheck(context, false) TextSecurePreferences.setNeedsRevocationCheck(context, false)
ApplicationContext.getInstance(context).clearData() ApplicationContext.getInstance(context).clearData()
}.fail { error -> }.fail { error ->

View File

@ -1,6 +1,8 @@
package org.thoughtcrime.securesms.registration; package org.thoughtcrime.securesms.registration;
import android.Manifest; import android.Manifest;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
@ -8,6 +10,7 @@ import android.support.annotation.NonNull;
import org.thoughtcrime.securesms.BaseActionBarActivity; import org.thoughtcrime.securesms.BaseActionBarActivity;
import org.thoughtcrime.securesms.permissions.Permissions; import org.thoughtcrime.securesms.permissions.Permissions;
import org.thoughtcrime.securesms.util.CommunicationActions; import org.thoughtcrime.securesms.util.CommunicationActions;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.whispersystems.signalservice.loki.utilities.Analytics; import org.whispersystems.signalservice.loki.utilities.Analytics;
import network.loki.messenger.R; import network.loki.messenger.R;
@ -23,6 +26,24 @@ public class WelcomeActivity extends BaseActionBarActivity {
Analytics.Companion.getShared().track("Landing Screen Viewed"); Analytics.Companion.getShared().track("Landing Screen Viewed");
} }
@Override
protected void onResume() {
super.onResume();
if (TextSecurePreferences.databaseResetFromUnpair(this)) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.dialog_device_unlink_title);
builder.setMessage(R.string.dialog_device_unlink_message);
builder.setPositiveButton(R.string.ok, null);
builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
TextSecurePreferences.setDatabaseResetFromUnpair(getBaseContext(), false);
}
});
builder.show();
}
}
@Override @Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
Permissions.onRequestPermissionsResult(this, requestCode, permissions, grantResults); Permissions.onRequestPermissionsResult(this, requestCode, permissions, grantResults);