mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 00:59:49 +01:00
Add Device to Device Transfer UI.
This commit is contained in:
committed by
Greyson Parrelli
parent
6f8be3260c
commit
75aab4c031
@@ -42,17 +42,12 @@ public class ChooseBackupFragment extends BaseRegistrationFragment {
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
if (BackupUtil.isUserSelectionRequired(requireContext())) {
|
||||
chooseBackupButton = view.findViewById(R.id.choose_backup_fragment_button);
|
||||
chooseBackupButton.setOnClickListener(this::onChooseBackupSelected);
|
||||
chooseBackupButton = view.findViewById(R.id.choose_backup_fragment_button);
|
||||
chooseBackupButton.setOnClickListener(this::onChooseBackupSelected);
|
||||
|
||||
learnMore = view.findViewById(R.id.choose_backup_fragment_learn_more);
|
||||
learnMore.setText(HtmlCompat.fromHtml(String.format("<a href=\"%s\">%s</a>", getString(R.string.backup_support_url), getString(R.string.ChooseBackupFragment__learn_more)), 0));
|
||||
learnMore.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
} else {
|
||||
Log.i(TAG, "User Selection is not required. Skipping.");
|
||||
Navigation.findNavController(requireView()).navigate(ChooseBackupFragmentDirections.actionSkip());
|
||||
}
|
||||
learnMore = view.findViewById(R.id.choose_backup_fragment_learn_more);
|
||||
learnMore.setText(HtmlCompat.fromHtml(String.format("<a href=\"%s\">%s</a>", getString(R.string.backup_support_url), getString(R.string.ChooseBackupFragment__learn_more)), 0));
|
||||
learnMore.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -19,12 +20,16 @@ import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.navigation.ActivityNavigator;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
|
||||
import com.dd.CircularProgressButton;
|
||||
import com.google.i18n.phonenumbers.PhoneNumberUtil;
|
||||
import com.google.i18n.phonenumbers.Phonenumber;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.signal.devicetransfer.DeviceToDeviceTransferService;
|
||||
import org.signal.devicetransfer.TransferStatus;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
||||
import org.thoughtcrime.securesms.registration.viewmodel.RegistrationViewModel;
|
||||
@@ -61,7 +66,7 @@ public final class WelcomeFragment extends BaseRegistrationFragment {
|
||||
private static final int[] HEADERS_API_29 = { R.drawable.ic_contacts_white_48dp };
|
||||
|
||||
private CircularProgressButton continueButton;
|
||||
private View restoreFromBackup;
|
||||
private Button restoreFromBackup;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
@@ -104,15 +109,14 @@ public final class WelcomeFragment extends BaseRegistrationFragment {
|
||||
continueButton = view.findViewById(R.id.welcome_continue_button);
|
||||
continueButton.setOnClickListener(this::continueClicked);
|
||||
|
||||
restoreFromBackup = view.findViewById(R.id.welcome_restore_backup);
|
||||
restoreFromBackup = view.findViewById(R.id.welcome_transfer_or_restore);
|
||||
restoreFromBackup.setOnClickListener(this::restoreFromBackupClicked);
|
||||
|
||||
TextView welcomeTermsButton = view.findViewById(R.id.welcome_terms_button);
|
||||
welcomeTermsButton.setOnClickListener(v -> onTermsClicked());
|
||||
|
||||
if (canUserSelectBackup()) {
|
||||
restoreFromBackup.setVisibility(View.VISIBLE);
|
||||
welcomeTermsButton.setTextColor(ContextCompat.getColor(requireActivity(), R.color.core_grey_60));
|
||||
if (!canUserSelectBackup()) {
|
||||
restoreFromBackup.setText(R.string.registration_activity__transfer_account);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,6 +126,17 @@ public final class WelcomeFragment extends BaseRegistrationFragment {
|
||||
Permissions.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (EventBus.getDefault().getStickyEvent(TransferStatus.class) != null) {
|
||||
Log.i(TAG, "Found existing transferStatus, redirect to transfer flow");
|
||||
NavHostFragment.findNavController(this).navigate(R.id.action_welcomeFragment_to_deviceTransferSetup);
|
||||
} else {
|
||||
DeviceToDeviceTransferService.stop(requireContext());
|
||||
}
|
||||
}
|
||||
|
||||
private void continueClicked(@NonNull View view) {
|
||||
boolean isUserSelectionRequired = BackupUtil.isUserSelectionRequired(requireContext());
|
||||
|
||||
@@ -177,7 +192,7 @@ public final class WelcomeFragment extends BaseRegistrationFragment {
|
||||
initializeNumber();
|
||||
|
||||
Navigation.findNavController(view)
|
||||
.navigate(WelcomeFragmentDirections.actionChooseBackup());
|
||||
.navigate(WelcomeFragmentDirections.actionTransferOrRestore());
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
|
||||
Reference in New Issue
Block a user