mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-29 13:17:43 +00:00
When receiving a file Android, show the image in the notification
Summary: The image is shown, similar to when you take a screenshot. Test Plan: Works great! Doesn't crash for non-images. Reviewers: #kde_connect, albertvaka Reviewed By: #kde_connect, albertvaka Subscribers: #kde_connect Differential Revision: https://phabricator.kde.org/D11679
This commit is contained in:
parent
bf0cab9ef2
commit
00b6677aa4
@ -26,6 +26,8 @@ import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
@ -38,6 +40,7 @@ import org.kde.kdeconnect.Helpers.NotificationHelper;
|
||||
import org.kde.kdeconnect_tp.R;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
public class ShareNotification {
|
||||
|
||||
@ -99,6 +102,18 @@ public class ShareNotification {
|
||||
* - Proxy to real files (in case of the default download folder)
|
||||
* - Proxy to the underlying content uri (in case of a custom download folder)
|
||||
*/
|
||||
|
||||
//If it's an image, try to show it in the notification
|
||||
if (mimeType.startsWith("image/")) {
|
||||
try {
|
||||
Bitmap image = BitmapFactory.decodeStream(device.getContext().getContentResolver().openInputStream(destinationUri));
|
||||
if (image != null) {
|
||||
builder.setLargeIcon(image);
|
||||
builder.setStyle(new NotificationCompat.BigPictureStyle()
|
||||
.bigPicture(image));
|
||||
}
|
||||
} catch (FileNotFoundException ignored) {}
|
||||
}
|
||||
if (!"file".equals(destinationUri.getScheme())) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user