mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-01 14:45:08 +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_title">Sending file to %1s</string>
|
||||||
<string name="outgoing_file_text">%1s</string>
|
<string name="outgoing_file_text">%1s</string>
|
||||||
<string name="received_file_title">Received file from %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="received_file_text">Tap to open \'%1s\'</string>
|
||||||
<string name="sent_file_title">Sent file to %1s</string>
|
<string name="sent_file_title">Sent file to %1s</string>
|
||||||
<string name="sent_file_text">%1s</string>
|
<string name="sent_file_text">%1s</string>
|
||||||
|
@@ -142,6 +142,7 @@ public class SharePlugin extends Plugin {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
OutputStream output = null;
|
OutputStream output = null;
|
||||||
|
boolean successul = true;
|
||||||
try {
|
try {
|
||||||
output = new FileOutputStream(destinationFullPath.getPath());
|
output = new FileOutputStream(destinationFullPath.getPath());
|
||||||
byte data[] = new byte[1024];
|
byte data[] = new byte[1024];
|
||||||
@@ -165,6 +166,7 @@ public class SharePlugin extends Plugin {
|
|||||||
output.flush();
|
output.flush();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
successul = false;
|
||||||
Log.e("SharePlugin", "Receiver thread exception");
|
Log.e("SharePlugin", "Receiver thread exception");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -193,23 +195,25 @@ public class SharePlugin extends Plugin {
|
|||||||
|
|
||||||
Resources res = context.getResources();
|
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)
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
|
||||||
.setContentTitle(res.getString(R.string.received_file_title, device.getName()))
|
.setContentTitle(message)
|
||||||
.setContentText(res.getString(R.string.received_file_text, filename))
|
.setTicker(message)
|
||||||
.setContentIntent(resultPendingIntent)
|
|
||||||
.setTicker(res.getString(R.string.received_file_title, device.getName()))
|
|
||||||
.setSmallIcon(android.R.drawable.stat_sys_download_done)
|
.setSmallIcon(android.R.drawable.stat_sys_download_done)
|
||||||
.setAutoCancel(true);
|
.setAutoCancel(true);
|
||||||
|
|
||||||
|
if (successul) {
|
||||||
|
builder.setContentText(res.getString(R.string.received_file_text, filename))
|
||||||
|
.setContentIntent(resultPendingIntent);
|
||||||
|
}
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
if (prefs.getBoolean("share_notification_preference", true)) {
|
if (prefs.getBoolean("share_notification_preference", true)) {
|
||||||
builder.setDefaults(Notification.DEFAULT_ALL);
|
builder.setDefaults(Notification.DEFAULT_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Notification noti = builder.build();
|
Notification notification = builder.build();
|
||||||
|
notificationManager.notify(notificationId, notification);
|
||||||
notificationManager.notify(notificationId, noti);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("SharePlugin", "Receiver thread exception");
|
Log.e("SharePlugin", "Receiver thread exception");
|
||||||
|
Reference in New Issue
Block a user