Search in sources :

Example 1 with TransferNotificationData

use of org.signal.devicetransfer.DeviceToDeviceTransferService.TransferNotificationData in project Signal-Android by WhisperSystems.

the class MainActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    if (Build.VERSION.SDK_INT > 26) {
        NotificationChannel deviceTransfer = new NotificationChannel(TRANSFER_NOTIFICATION_CHANNEL, "Device Transfer", NotificationManager.IMPORTANCE_DEFAULT);
        NotificationManagerCompat.from(this).createNotificationChannel(deviceTransfer);
    }
    list = findViewById(R.id.list);
    final TransferNotificationData data = new TransferNotificationData(1337, TRANSFER_NOTIFICATION_CHANNEL, R.drawable.ic_refresh_20);
    findViewById(R.id.start_server).setOnClickListener(v -> {
        DeviceToDeviceTransferService.startServer(this, new ServerReceiveRandomBytes(), data, PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0));
        list.removeAllViews();
    });
    findViewById(R.id.start_client).setOnClickListener(v -> {
        DeviceToDeviceTransferService.startClient(this, new ClientSendRandomBytes(), data, PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0));
        list.removeAllViews();
    });
    findViewById(R.id.stop).setOnClickListener(v -> DeviceToDeviceTransferService.stop(this));
    findViewById(R.id.enable_permission).setOnClickListener(v -> {
        if (Build.VERSION.SDK_INT >= 23 && checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            requestPermissions(new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, 420);
        }
    });
    EventBus.getDefault().register(this);
}
Also used : NotificationChannel(android.app.NotificationChannel) TransferNotificationData(org.signal.devicetransfer.DeviceToDeviceTransferService.TransferNotificationData) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Example 2 with TransferNotificationData

use of org.signal.devicetransfer.DeviceToDeviceTransferService.TransferNotificationData in project Signal-Android by WhisperSystems.

the class NewDeviceTransferSetupFragment method startTransfer.

@Override
protected void startTransfer() {
    PendingIntent pendingIntent = PendingIntent.getActivity(requireContext(), 0, MainActivity.clearTop(requireContext()), 0);
    TransferNotificationData notificationData = new TransferNotificationData(NotificationIds.DEVICE_TRANSFER, NotificationChannels.BACKUPS, R.drawable.ic_signal_backup);
    DeviceToDeviceTransferService.startServer(requireContext(), new NewDeviceServerTask(), notificationData, pendingIntent);
}
Also used : TransferNotificationData(org.signal.devicetransfer.DeviceToDeviceTransferService.TransferNotificationData) PendingIntent(android.app.PendingIntent)

Aggregations

PendingIntent (android.app.PendingIntent)2 TransferNotificationData (org.signal.devicetransfer.DeviceToDeviceTransferService.TransferNotificationData)2 NotificationChannel (android.app.NotificationChannel)1 Intent (android.content.Intent)1