diff --git a/AndroidManifest.xml b/AndroidManifest.xml index c6c736ed..dab5fda4 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,230 +1,229 @@ diff --git a/res/values/strings.xml b/res/values/strings.xml index 571f7379..b34247bd 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,251 +1,252 @@ KDE Connect Not connected to any device Connected to: %s Telephony notifier Send notifications for SMS and calls Battery report Periodically report battery status Filesystem expose Allows to browse this device\'s filesystem remotely Clipboard sync Share the clipboard content Remote input Use your phone or tablet as a touchpad and keyboard Receive remote keypresses Receive keypress events from remote devices Multimedia controls Provides a remote control for your media player Run Command Trigger remote commands from your phone or tablet Ping Send and receive pings Notification sync Access your notifications from other devices Receive notifications Receive notifications from the other device and display them on Android Share and receive Share files and URLs between devices This feature is not available in your Android version No devices OK Cancel Open settings You need to grant permission to access notifications To be able to control your media players you need to grant access to the notifications Send ping Multimedia control remotekeyboard_editing_only Handle remote keys only when editing There is no active remote keyboard connection, establish one in kdeconnect Remote keyboard connection is active There is more than one remote keyboard connection, select the device to configure Remote input Move a finger on the screen to move the mouse cursor. Tap for a click, and use two/three fingers for right and middle buttons. Use 2 fingers to scroll. Use a long press to drag\'n drop. Set two finger tap action Set three finger tap action Set touchpad sensitivity mousepad_double_tap_key mousepad_triple_tap_key mousepad_sensitivity_key Reverse Scrolling Direction mousepad_scroll_direction Right click Middle click Nothing right middle default right middle none Slowest Above Slowest Default Above Default Fastest slowest aboveSlowest default aboveDefault fastest Connected devices Available devices Remembered devices Plugins failed to load (tap for more info): Plugin settings Unpair Paired device not reachable Pair new device Unknown device Device not reachable Pairing already requested Device already paired Could not send package Timed out Canceled by user Canceled by other peer Invalid key received Encryption Info The other device doesn\'t use a recent version of KDE Connect, using the legacy encryption method. SHA1 fingerprint of your device certificate is: SHA1 fingerprint of remote device certificate is: Pair requested Pairing request from %1s Received link from %1s Tap to open \'%1s\' Incoming file from %1s %1s Sending file to %1s Sending files to %1s Sent %1$d file Sent %1$d out of %2$d files Received file from %1s Failed receiving file from %1s Tap to open \'%1s\' Sent file to %1s %1s Failed to send file to %1s %1s Tap to answer Reconnect Send Right Click Send Middle Click Show Keyboard Device not paired Request pairing Accept Reject Device Pair device Remote control KDE Connect Settings Play Pause Previous Rewind Fast-forward Next Volume Multimedia Settings Forward/rewind buttons Adjust the time to fast forward/rewind when pressed. mpris_interval_time 10 seconds 20 seconds 30 seconds 1 minute 2 minutes 10000000 10000000 20000000 30000000 60000000 120000000 Show media control notification Allows controlling your media players without opening KDE Connect. mpris_notification_enabled Share To... This device uses an old protocol version This device uses a newer protocol version General Settings Settings %s settings Device name %s Invalid device name Received text, saved to clipboard Custom device list Pair a new device Unpair %s Add devices by IP Noisy notifications Vibrate and play a sound when receiving a file Customize destination directory Received files will appear in Downloads Files will be stored in the directory below Destination directory Share Share \"%s\" Notification filter Notifications will be synchronized for the selected apps. Internal storage All files SD card %d SD card (read only) Camera pictures Add host/IP Hostname or IP No players found Use this option only if your device is not automatically detected. Enter IP address or hostname below and touch the button to add it to the list. Touch an existing item to remove it from the list. %1$s on %2$s Send files KDE Connect Devices Other devices running KDE Connect in your same network should appear here. Device paired Rename device Rename Refresh This paired device is not reachable. Make sure it is connected to your same network. It looks like you are on a mobile data connection. KDE Connect only works on local networks. There are no file browsers installed. Send SMS Send text messages from your desktop This plugin is not supported by the device Find my phone Find my tablet Find my TV Rings this device so you can find it Found Open Close You need to grant permissions to access the storage Some Plugins need permissions to work (tap for more info): This plugin needs permissions to work You need to grant extra permissions to enable all functions Some plugins have features disabled because of lack of permission (tap for more info): To access your files from your PC the app needs permission to access your phone\'s storage To share files between your phone and your desktop you need to give access to the phone\'s storage To read and write SMS from your desktop you need to give permission to SMS To see phone calls and SMS from the desktop you need to give permission to phone calls and SMS To see a contact name instead of a phone number you need to give access to the phone\'s contacts Select a ringtone Blocked numbers Don\'t show calls and SMS from these numbers. Please specify one number per line Cover art of current media Device icon Settings icon Add a command There are no commands registered You can add new commands in the KDE Connect System Settings You can add commands on the desktop Media Player Control Control your phones media players from another device Dark theme Other notifications Persistent indicator Media control + File transfer diff --git a/src/org/kde/kdeconnect/Helpers/NotificationHelper.java b/src/org/kde/kdeconnect/Helpers/NotificationHelper.java index bf98a7ea..048568e5 100644 --- a/src/org/kde/kdeconnect/Helpers/NotificationHelper.java +++ b/src/org/kde/kdeconnect/Helpers/NotificationHelper.java @@ -1,65 +1,78 @@ package org.kde.kdeconnect.Helpers; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.content.Context; +import android.media.AudioAttributes; +import android.media.Ringtone; +import android.media.RingtoneManager; import org.kde.kdeconnect_tp.R; public class NotificationHelper { public static class Channels { public final static String PERSISTENT = "persistent"; public final static String DEFAULT = "default"; public final static String MEDIA_CONTROL = "media_control"; + public final static String FILETRANSFER = "filetransfer"; } public static void notifyCompat(NotificationManager notificationManager, int notificationId, Notification notification) { try { notificationManager.notify(notificationId, notification); } catch (Exception e) { //4.1 will throw an exception about not having the VIBRATE permission, ignore it. //https://android.googlesource.com/platform/frameworks/base/+/android-4.2.1_r1.2%5E%5E!/ } } public static void notifyCompat(NotificationManager notificationManager, String tag, int notificationId, Notification notification) { try { notificationManager.notify(tag, notificationId, notification); } catch (Exception e) { //4.1 will throw an exception about not having the VIBRATE permission, ignore it. //https://android.googlesource.com/platform/frameworks/base/+/android-4.2.1_r1.2%5E%5E!/ } } public static void initializeChannels(Context context) { if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O) { return; } NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); NotificationChannel persistentChannel = new NotificationChannel( Channels.PERSISTENT, context.getString(R.string.notification_channel_persistent), NotificationManager.IMPORTANCE_MIN); manager.createNotificationChannel(persistentChannel); manager.createNotificationChannel(new NotificationChannel( Channels.DEFAULT, context.getString(R.string.notification_channel_default), NotificationManager.IMPORTANCE_DEFAULT) ); manager.createNotificationChannel(new NotificationChannel( Channels.MEDIA_CONTROL, context.getString(R.string.notification_channel_media_control), NotificationManager.IMPORTANCE_LOW) ); + NotificationChannel fileTransfer = new NotificationChannel( + Channels.FILETRANSFER, + context.getString(R.string.notification_channel_filetransfer), + NotificationManager.IMPORTANCE_LOW); + + fileTransfer.enableVibration(false); + + manager.createNotificationChannel(fileTransfer); + } } diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareNotification.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareNotification.java index f0153039..5df29b66 100644 --- a/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareNotification.java +++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/ShareNotification.java @@ -1,152 +1,152 @@ package org.kde.kdeconnect.Plugins.SharePlugin; /* * Copyright 2017 Nicolas Fella * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import android.app.Notification; import android.app.NotificationManager; 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; import android.support.v4.app.NotificationCompat; import android.support.v4.app.TaskStackBuilder; import android.support.v4.content.FileProvider; import org.kde.kdeconnect.Device; import org.kde.kdeconnect.Helpers.NotificationHelper; import org.kde.kdeconnect_tp.R; import java.io.File; import java.io.FileNotFoundException; public class ShareNotification { private final String filename; private NotificationManager notificationManager; private int notificationId; private NotificationCompat.Builder builder; private Device device; public ShareNotification(Device device, String filename) { this.device = device; this.filename = filename; notificationId = (int) System.currentTimeMillis(); notificationManager = (NotificationManager) device.getContext().getSystemService(Context.NOTIFICATION_SERVICE); - builder = new NotificationCompat.Builder(device.getContext(), NotificationHelper.Channels.DEFAULT) + builder = new NotificationCompat.Builder(device.getContext(), NotificationHelper.Channels.FILETRANSFER) .setContentTitle(device.getContext().getResources().getString(R.string.incoming_file_title, device.getName())) .setContentText(device.getContext().getResources().getString(R.string.incoming_file_text, filename)) .setTicker(device.getContext().getResources().getString(R.string.incoming_file_title, device.getName())) .setSmallIcon(android.R.drawable.stat_sys_download) .setAutoCancel(true) .setOngoing(true) .setProgress(100, 0, true); } public void show() { NotificationHelper.notifyCompat(notificationManager, notificationId, builder.build()); } public int getId() { return notificationId; } public void setProgress(int progress) { builder.setProgress(100, progress, false) .setContentTitle(device.getContext().getResources().getString(R.string.incoming_file_title, device.getName()) + " (" + progress + "%)"); } public void setFinished(boolean success) { String message = success ? device.getContext().getResources().getString(R.string.received_file_title, device.getName()) : device.getContext().getResources().getString(R.string.received_file_fail_title, device.getName()); builder = new NotificationCompat.Builder(device.getContext(), NotificationHelper.Channels.DEFAULT); builder.setContentTitle(message) .setTicker(message) .setSmallIcon(android.R.drawable.stat_sys_download_done) .setAutoCancel(true) .setOngoing(false); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(device.getContext()); if (prefs.getBoolean("share_notification_preference", true)) { builder.setDefaults(Notification.DEFAULT_ALL); } } public void setURI(Uri destinationUri, String mimeType) { /* * We only support file URIs (because sending a content uri to another app does not work for security reasons). * In effect, that means only the default download folder currently works. * * TODO: implement our own content provider (instead of support-v4's FileProvider). It should: * - 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; } Intent intent = new Intent(Intent.ACTION_VIEW); Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType(mimeType); if (Build.VERSION.SDK_INT >= 24) { //Nougat and later require "content://" uris instead of "file://" uris File file = new File(destinationUri.getPath()); Uri contentUri = FileProvider.getUriForFile(device.getContext(), "org.kde.kdeconnect_tp.fileprovider", file); intent.setDataAndType(contentUri, mimeType); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); shareIntent.putExtra(Intent.EXTRA_STREAM, contentUri); } else { intent.setDataAndType(destinationUri, mimeType); shareIntent.putExtra(Intent.EXTRA_STREAM, destinationUri); } intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); TaskStackBuilder stackBuilder = TaskStackBuilder.create(device.getContext()); stackBuilder.addNextIntent(intent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentText(device.getContext().getResources().getString(R.string.received_file_text, filename)) .setContentIntent(resultPendingIntent); shareIntent = Intent.createChooser(shareIntent, device.getContext().getString(R.string.share_received_file, destinationUri.getLastPathSegment())); PendingIntent sharePendingIntent = PendingIntent.getActivity(device.getContext(), 0, shareIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action.Builder shareAction = new NotificationCompat.Action.Builder( R.drawable.ic_share_white, device.getContext().getString(R.string.share), sharePendingIntent); builder.addAction(shareAction.build()); } }