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:
@@ -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>
|
||||
|
@@ -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");
|
||||
|
Reference in New Issue
Block a user