Search in sources :

Example 1 with TransferStatus

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);
}
Also used : TransferStatus(org.signal.devicetransfer.TransferStatus)

Example 2 with TransferStatus

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();
    }
}
Also used : TransferStatus(org.signal.devicetransfer.TransferStatus) Context(android.content.Context) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) ServerTask(org.signal.devicetransfer.ServerTask) ClientTask(org.signal.devicetransfer.ClientTask) PackageManager(android.content.pm.PackageManager) NonNull(androidx.annotation.NonNull) Intent(android.content.Intent) Random(java.util.Random) PendingIntent(android.app.PendingIntent) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) Manifest(android.Manifest) EventBus(org.greenrobot.eventbus.EventBus) NotificationChannel(android.app.NotificationChannel) NotificationManagerCompat(androidx.core.app.NotificationManagerCompat) Build(android.os.Build) Log(android.util.Log) OutputStream(java.io.OutputStream) NotificationManager(android.app.NotificationManager) DeviceToDeviceTransferService(org.signal.devicetransfer.DeviceToDeviceTransferService) TransferNotificationData(org.signal.devicetransfer.DeviceToDeviceTransferService.TransferNotificationData) IOException(java.io.IOException) ThreadMode(org.greenrobot.eventbus.ThreadMode) ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) Subscribe(org.greenrobot.eventbus.Subscribe) InputStream(java.io.InputStream) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) Subscribe(org.greenrobot.eventbus.Subscribe)

Aggregations

TransferStatus (org.signal.devicetransfer.TransferStatus)2 Manifest (android.Manifest)1 NotificationChannel (android.app.NotificationChannel)1 NotificationManager (android.app.NotificationManager)1 PendingIntent (android.app.PendingIntent)1 Context (android.content.Context)1 Intent (android.content.Intent)1 PackageManager (android.content.pm.PackageManager)1 Build (android.os.Build)1 Bundle (android.os.Bundle)1 Log (android.util.Log)1 ViewGroup (android.view.ViewGroup)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 AlertDialog (androidx.appcompat.app.AlertDialog)1 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)1 NotificationManagerCompat (androidx.core.app.NotificationManagerCompat)1 IOException (java.io.IOException)1