mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-22 18:07:55 +00:00
Added a progress bar in the notification while receiving a file
RB: 121910
This commit is contained in:
parent
41aa3fe53e
commit
75697cedca
@ -123,18 +123,20 @@ public class SharePlugin extends Plugin {
|
|||||||
|
|
||||||
Log.e("SharePlugin", "destinationFullPath:" + destinationFullPath);
|
Log.e("SharePlugin", "destinationFullPath:" + destinationFullPath);
|
||||||
|
|
||||||
|
final NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
final int notificationId = (int)System.currentTimeMillis();
|
final int notificationId = (int)System.currentTimeMillis();
|
||||||
Resources res = context.getResources();
|
Resources res = context.getResources();
|
||||||
Notification noti = new NotificationCompat.Builder(context)
|
final NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
|
||||||
.setContentTitle(res.getString(R.string.incoming_file_title, device.getName()))
|
.setContentTitle(res.getString(R.string.incoming_file_title, device.getName()))
|
||||||
.setContentText(res.getString(R.string.incoming_file_text, filename))
|
.setContentText(res.getString(R.string.incoming_file_text, filename))
|
||||||
.setTicker(res.getString(R.string.incoming_file_title, device.getName()))
|
.setTicker(res.getString(R.string.incoming_file_title, device.getName()))
|
||||||
.setSmallIcon(android.R.drawable.ic_dialog_alert)
|
.setSmallIcon(android.R.drawable.stat_sys_download)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.build();
|
.setOngoing(true)
|
||||||
|
.setProgress(100,0,true);
|
||||||
|
|
||||||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
notificationManager.notify(notificationId,builder.build());
|
||||||
notificationManager.notify(notificationId, noti);
|
|
||||||
|
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -151,6 +153,8 @@ public class SharePlugin extends Plugin {
|
|||||||
if (fileLength > 0) {
|
if (fileLength > 0) {
|
||||||
if (total >= fileLength) break;
|
if (total >= fileLength) break;
|
||||||
float progress = (total * 100 / fileLength);
|
float progress = (total * 100 / fileLength);
|
||||||
|
builder.setProgress(100,(int)progress,false);
|
||||||
|
notificationManager.notify(notificationId,builder.build());
|
||||||
}
|
}
|
||||||
//else Log.e("SharePlugin", "Infinite loop? :D");
|
//else Log.e("SharePlugin", "Infinite loop? :D");
|
||||||
}
|
}
|
||||||
@ -184,7 +188,7 @@ public class SharePlugin extends Plugin {
|
|||||||
.setContentText(res.getString(R.string.received_file_text, filename))
|
.setContentText(res.getString(R.string.received_file_text, filename))
|
||||||
.setContentIntent(resultPendingIntent)
|
.setContentIntent(resultPendingIntent)
|
||||||
.setTicker(res.getString(R.string.received_file_title, device.getName()))
|
.setTicker(res.getString(R.string.received_file_title, device.getName()))
|
||||||
.setSmallIcon(android.R.drawable.ic_dialog_alert)
|
.setSmallIcon(android.R.drawable.stat_sys_download_done)
|
||||||
.setAutoCancel(true);
|
.setAutoCancel(true);
|
||||||
|
|
||||||
|
|
||||||
@ -195,7 +199,6 @@ public class SharePlugin extends Plugin {
|
|||||||
|
|
||||||
Notification noti = builder.build();
|
Notification noti = builder.build();
|
||||||
|
|
||||||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
|
||||||
notificationManager.notify(notificationId, noti);
|
notificationManager.notify(notificationId, noti);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user