use of org.signal.devicetransfer.TransferStatus in project Signal-Android by WhisperSystems.
the class DeviceTransferSetupFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), onBackPressed);
TransferStatus event = EventBus.getDefault().getStickyEvent(TransferStatus.class);
if (event == null) {
viewModel.checkPermissions();
} else {
Log.i(TAG, "Sticky event already exists for transfer, assuming service is running and we are reattaching");
}
EventBus.getDefault().register(this);
}
use of org.signal.devicetransfer.TransferStatus in project Signal-Android by WhisperSystems.
the class MainActivity method onEventMainThread.
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onEventMainThread(@NonNull TransferStatus event) {
TextView text = new TextView(this);
text.setText(event.getTransferMode().toString());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
text.setLayoutParams(params);
list.addView(text);
if (event.getTransferMode() == TransferStatus.TransferMode.VERIFICATION_REQUIRED) {
new AlertDialog.Builder(this).setTitle("Verification Required").setMessage("Code: " + event.getAuthenticationCode()).setPositiveButton("Yes, Same", (d, w) -> DeviceToDeviceTransferService.setAuthenticationCodeVerified(this, true)).setNegativeButton("No, different", (d, w) -> DeviceToDeviceTransferService.setAuthenticationCodeVerified(this, false)).setCancelable(false).show();
}
}
Aggregations