mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 18:00:02 +01:00
Improve restore complete dialog for old device.
This commit is contained in:
committed by
Greyson Parrelli
parent
862bab55af
commit
6d90330e86
@@ -3,12 +3,15 @@ package org.thoughtcrime.securesms.devicetransfer.olddevice;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.signal.devicetransfer.DeviceToDeviceTransferService;
|
||||
import org.signal.devicetransfer.TransferStatus;
|
||||
@@ -28,14 +31,18 @@ public final class OldDeviceTransferInstructionsFragment extends LoggingFragment
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
Toolbar toolbar = view.findViewById(R.id.old_device_transfer_instructions_fragment_toolbar);
|
||||
toolbar.setNavigationOnClickListener(v -> {
|
||||
if (!Navigation.findNavController(v).popBackStack()) {
|
||||
requireActivity().finish();
|
||||
}
|
||||
});
|
||||
toolbar.setNavigationOnClickListener(v -> showConfirmExitDialog());
|
||||
|
||||
view.findViewById(R.id.old_device_transfer_instructions_fragment_continue)
|
||||
.setOnClickListener(v -> SafeNavigation.safeNavigate(Navigation.findNavController(v), R.id.action_oldDeviceTransferInstructions_to_oldDeviceTransferSetup));
|
||||
|
||||
requireActivity().getOnBackPressedDispatcher()
|
||||
.addCallback(getViewLifecycleOwner(), new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
showConfirmExitDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,4 +55,19 @@ public final class OldDeviceTransferInstructionsFragment extends LoggingFragment
|
||||
DeviceToDeviceTransferService.stop(requireContext());
|
||||
}
|
||||
}
|
||||
|
||||
private void showConfirmExitDialog() {
|
||||
new MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(R.string.OldDeviceTransferInstructions__confirm_exit_title)
|
||||
.setMessage(R.string.OldDeviceTransferInstructions__confirm_exit_message)
|
||||
.setPositiveButton(R.string.OldDeviceTransferInstructions__stop_transfer, (d, w) -> exit())
|
||||
.setNegativeButton(R.string.OldDeviceTransferInstructions__continue_transfer, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void exit() {
|
||||
if (!Navigation.findNavController(requireView()).popBackStack()) {
|
||||
requireActivity().finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user