2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 13:47:41 +00:00

Added a different notification message for failed file transfers

This commit is contained in:
Albert Vaca
2015-04-04 13:54:47 -07:00
parent b7faa97292
commit 11012e21e5
2 changed files with 12 additions and 7 deletions

View File

@@ -70,6 +70,7 @@
<string name="outgoing_file_title">Sending file to %1s</string>
<string name="outgoing_file_text">%1s</string>
<string name="received_file_title">Received file from %1s</string>
<string name="received_file_fail_title">Failed receiving file from %1s</string>
<string name="received_file_text">Tap to open \'%1s\'</string>
<string name="sent_file_title">Sent file to %1s</string>
<string name="sent_file_text">%1s</string>

View File

@@ -142,6 +142,7 @@ public class SharePlugin extends Plugin {
@Override
public void run() {
OutputStream output = null;
boolean successul = true;
try {
output = new FileOutputStream(destinationFullPath.getPath());
byte data[] = new byte[1024];
@@ -165,6 +166,7 @@ public class SharePlugin extends Plugin {
output.flush();
} catch (Exception e) {
successul = false;
Log.e("SharePlugin", "Receiver thread exception");
e.printStackTrace();
} finally {
@@ -193,23 +195,25 @@ public class SharePlugin extends Plugin {
Resources res = context.getResources();
String message = successul? res.getString(R.string.received_file_title, device.getName()) : res.getString(R.string.received_file_fail_title, device.getName());
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setContentTitle(res.getString(R.string.received_file_title, device.getName()))
.setContentText(res.getString(R.string.received_file_text, filename))
.setContentIntent(resultPendingIntent)
.setTicker(res.getString(R.string.received_file_title, device.getName()))
.setContentTitle(message)
.setTicker(message)
.setSmallIcon(android.R.drawable.stat_sys_download_done)
.setAutoCancel(true);
if (successul) {
builder.setContentText(res.getString(R.string.received_file_text, filename))
.setContentIntent(resultPendingIntent);
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (prefs.getBoolean("share_notification_preference", true)) {
builder.setDefaults(Notification.DEFAULT_ALL);
}
Notification noti = builder.build();
notificationManager.notify(notificationId, noti);
Notification notification = builder.build();
notificationManager.notify(notificationId, notification);
} catch (Exception e) {
Log.e("SharePlugin", "Receiver thread exception");