Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Network
KDE Connect Android
Commits
75697ced
Commit
75697ced
authored
Jan 09, 2015
by
Vineet Garg
Committed by
Albert Vaca Cintora
Jan 09, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a progress bar in the notification while receiving a file
RB: 121910
parent
41aa3fe5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
8 deletions
+11
-8
src/org/kde/kdeconnect/Plugins/SharePlugin/SharePlugin.java
src/org/kde/kdeconnect/Plugins/SharePlugin/SharePlugin.java
+11
-8
No files found.
src/org/kde/kdeconnect/Plugins/SharePlugin/SharePlugin.java
View file @
75697ced
...
...
@@ -123,18 +123,20 @@ public class SharePlugin extends Plugin {
Log
.
e
(
"SharePlugin"
,
"destinationFullPath:"
+
destinationFullPath
);
final
NotificationManager
notificationManager
=
(
NotificationManager
)
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
final
int
notificationId
=
(
int
)
System
.
currentTimeMillis
();
Resources
res
=
context
.
getResources
();
Notification
noti
=
new
NotificationCompat
.
Builder
(
context
)
final
Notification
Compat
.
Builder
builder
=
new
NotificationCompat
.
Builder
(
context
)
.
setContentTitle
(
res
.
getString
(
R
.
string
.
incoming_file_title
,
device
.
getName
()))
.
setContentText
(
res
.
getString
(
R
.
string
.
incoming_file_text
,
filename
))
.
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
)
.
build
();
.
setOngoing
(
true
)
.
setProgress
(
100
,
0
,
true
);
NotificationManager
notificationManager
=
(
NotificationManager
)
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
notificationManager
.
notify
(
notificationId
,
noti
);
notificationManager
.
notify
(
notificationId
,
builder
.
build
());
new
Thread
(
new
Runnable
()
{
@Override
...
...
@@ -151,6 +153,8 @@ public class SharePlugin extends Plugin {
if
(
fileLength
>
0
)
{
if
(
total
>=
fileLength
)
break
;
float
progress
=
(
total
*
100
/
fileLength
);
builder
.
setProgress
(
100
,(
int
)
progress
,
false
);
notificationManager
.
notify
(
notificationId
,
builder
.
build
());
}
//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
))
.
setContentIntent
(
resultPendingIntent
)
.
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
);
...
...
@@ -195,9 +199,8 @@ public class SharePlugin extends Plugin {
Notification
noti
=
builder
.
build
();
NotificationManager
notificationManager
=
(
NotificationManager
)
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
notificationManager
.
notify
(
notificationId
,
noti
);
}
catch
(
Exception
e
)
{
Log
.
e
(
"SharePlugin"
,
"Receiver thread exception"
);
e
.
printStackTrace
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment