mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 16:49:40 +01:00
Keep old device inactive after a successful transfer.
This commit is contained in:
committed by
Greyson Parrelli
parent
31e3e37c9b
commit
45178b3eb3
@@ -15,6 +15,7 @@ import org.signal.devicetransfer.DeviceToDeviceTransferService;
|
||||
import org.signal.devicetransfer.TransferStatus;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.devicetransfer.DeviceTransferFragment;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
|
||||
/**
|
||||
* Shows transfer progress on the old device. Most logic is in {@link DeviceTransferFragment}
|
||||
@@ -54,6 +55,7 @@ public final class OldDeviceTransferFragment extends DeviceTransferFragment {
|
||||
ignoreTransferStatusEvents();
|
||||
EventBus.getDefault().removeStickyEvent(TransferStatus.class);
|
||||
DeviceToDeviceTransferService.stop(requireContext());
|
||||
SignalStore.misc().markOldDeviceTransferLocked();
|
||||
NavHostFragment.findNavController(OldDeviceTransferFragment.this).navigate(R.id.action_oldDeviceTransfer_to_oldDeviceTransferComplete);
|
||||
} else {
|
||||
status.setText(getString(R.string.DeviceTransfer__d_messages_so_far, event.getMessageCount()));
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.thoughtcrime.securesms.devicetransfer.olddevice;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.Window;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.net.DeviceTransferBlockingInterceptor;
|
||||
|
||||
/**
|
||||
* Blocking dialog shown on old devices after a successful transfer to prevent use unless
|
||||
* the user takes action to reactivate.
|
||||
*/
|
||||
public final class OldDeviceTransferLockedDialog extends DialogFragment {
|
||||
|
||||
private static final String TAG = Log.tag(OldDeviceTransferLockedDialog.class);
|
||||
private static final String FRAGMENT_TAG = "OldDeviceTransferLockedDialog";
|
||||
|
||||
public static void show(@NonNull FragmentManager fragmentManager) {
|
||||
if (fragmentManager.findFragmentByTag(FRAGMENT_TAG) != null) {
|
||||
Log.i(TAG, "Locked dialog already being shown");
|
||||
return;
|
||||
}
|
||||
|
||||
new OldDeviceTransferLockedDialog().show(fragmentManager, FRAGMENT_TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setCancelable(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
MaterialAlertDialogBuilder dialogBuilder = new MaterialAlertDialogBuilder(requireContext(), R.style.Signal_ThemeOverlay_Dialog_Rounded);
|
||||
dialogBuilder.setView(R.layout.old_device_transfer_locked_dialog_fragment)
|
||||
.setPositiveButton(R.string.OldDeviceTransferLockedDialog__done, (d, w) -> OldDeviceExitActivity.exit(requireActivity()))
|
||||
.setNegativeButton(R.string.OldDeviceTransferLockedDialog__cancel_and_activate_this_device, (d, w) -> onUnlockRequest());
|
||||
|
||||
Dialog dialog = dialogBuilder.create();
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
private void onUnlockRequest() {
|
||||
SignalStore.misc().clearOldDeviceTransferLocked();
|
||||
DeviceTransferBlockingInterceptor.getInstance().unblockNetwork();
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public final class OldDeviceTransferSetupFragment extends DeviceTransferSetupFra
|
||||
switch (step) {
|
||||
case SETTING_UP:
|
||||
case WAITING:
|
||||
return R.string.OldDeviceTransferSetup__searching_for_your_new_android_device;
|
||||
return R.string.OldDeviceTransferSetup__searching_for_new_android_device;
|
||||
case ERROR:
|
||||
return R.string.OldDeviceTransferSetup__an_unexpected_error_occurred_while_attempting_to_connect_to_your_old_device;
|
||||
case TROUBLESHOOTING:
|
||||
|
||||
Reference in New Issue
Block a user