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);
}
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);
}
Aggregations