diff --git a/res/values/strings.xml b/res/values/strings.xml index 43949ac6..ab5d0a27 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,327 +1,328 @@ KDE Connect Not connected to any device Connected to: %s Telephony notifier Send notifications for incoming 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 Presentation remote Use your device to change slides in a presentation 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 Contacts Synchronizer Allow synchronizing the device\'s contacts book 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 Set pointer acceleration mousepad_double_tap_key mousepad_triple_tap_key mousepad_sensitivity_key mousepad_acceleration_profile_key Reverse Scrolling Direction mousepad_scroll_direction Right click Middle click Nothing right middle default medium right middle none Slowest Above Slowest Default Above Default Fastest No Acceleration Weakest Weaker Medium Stronger Strongest slowest aboveSlowest default aboveDefault fastest noacceleration weaker weak medium strong stronger 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\' Receiving file from %1s> Receiving %1$d file from %2$s Receiving %1$d files from %2$s File: %1s (File %2$d of %3$d) : %1$s Sending file to %1s Sending files to %1s Sent %1$d file Sent %1$d out of %2$d files Received file from %1$s Received %2$d files from %1$s Failed receiving file from %1$s Failed receiving %2$d of %3$d files from %1$s Tap to open \'%1s\' Cannot create file %s 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 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 Allow 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 Delete %s? 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 To share your contacts book with the desktop, you need to give contacts permission 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 Fullscreen Exit presentation You can lock your device to use the volume keys as previous/next buttons 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 Stop the current player Copy URL to clipboard Copied to clipboard Device is not reachable Device is not paired There is no such device This device does not have the Run Command Plugin enabled Find remote device Ring your remote device Ring System volume Control the system volume of the remote device Mute All Devices Device name Dark theme More settings Per-device settings can be found under \'Plugin settings\' from within a device. Show persistent notification Required by Android since Android 8.0 Since Android 9.0, this notification can only be minimized by long tapping on it Extra options Privacy options Set your privacy options New notification Block contents of notifications Block images in notifications + Notifications from other devices diff --git a/src/org/kde/kdeconnect/Helpers/NotificationHelper.java b/src/org/kde/kdeconnect/Helpers/NotificationHelper.java index decc0483..60d19e38 100644 --- a/src/org/kde/kdeconnect/Helpers/NotificationHelper.java +++ b/src/org/kde/kdeconnect/Helpers/NotificationHelper.java @@ -1,92 +1,99 @@ package org.kde.kdeconnect.Helpers; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.content.Context; import android.content.SharedPreferences; import android.os.Build; import android.preference.PreferenceManager; 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 final static String RECEIVENOTIFICATION = "receive"; } 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); + manager.createNotificationChannel(new NotificationChannel( + Channels.RECEIVENOTIFICATION, + context.getString(R.string.notification_channel_receivenotification), + NotificationManager.IMPORTANCE_DEFAULT) + ); + } public static void setPersistentNotificationEnabled(Context context, boolean enabled) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); prefs.edit().putBoolean("persistentNotification", enabled).apply(); } public static boolean isPersistentNotificationEnabled(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { return true; } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); return prefs.getBoolean("persistentNotification", false); } } diff --git a/src/org/kde/kdeconnect/Plugins/ReceiveNotificationsPlugin/ReceiveNotificationsPlugin.java b/src/org/kde/kdeconnect/Plugins/ReceiveNotificationsPlugin/ReceiveNotificationsPlugin.java index a9a06eb3..3d3b3d11 100644 --- a/src/org/kde/kdeconnect/Plugins/ReceiveNotificationsPlugin/ReceiveNotificationsPlugin.java +++ b/src/org/kde/kdeconnect/Plugins/ReceiveNotificationsPlugin/ReceiveNotificationsPlugin.java @@ -1,135 +1,135 @@ /* * Copyright 2014 Albert Vaca Cintora * * 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 . */ package org.kde.kdeconnect.Plugins.ReceiveNotificationsPlugin; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.support.v4.app.NotificationCompat; import android.util.Log; import org.kde.kdeconnect.Helpers.NotificationHelper; import org.kde.kdeconnect.NetworkPacket; import org.kde.kdeconnect.Plugins.Plugin; import org.kde.kdeconnect.UserInterface.MainActivity; import org.kde.kdeconnect_tp.R; import java.io.InputStream; public class ReceiveNotificationsPlugin extends Plugin { private final static String PACKET_TYPE_NOTIFICATION = "kdeconnect.notification"; private final static String PACKET_TYPE_NOTIFICATION_REQUEST = "kdeconnect.notification.request"; @Override public String getDisplayName() { return context.getResources().getString(R.string.pref_plugin_receive_notifications); } @Override public String getDescription() { return context.getResources().getString(R.string.pref_plugin_receive_notifications_desc); } @Override public boolean isEnabledByDefault() { return false; } @Override public boolean onCreate() { // request all existing notifications NetworkPacket np = new NetworkPacket(PACKET_TYPE_NOTIFICATION_REQUEST); np.set("request", true); device.sendPacket(np); return true; } @Override public boolean onPacketReceived(final NetworkPacket np) { if (!np.has("ticker") || !np.has("appName") || !np.has("id")) { Log.e("NotificationsPlugin", "Received notification package lacks properties"); return true; } if (np.getBoolean("silent", false)) { return true; } PendingIntent resultPendingIntent = PendingIntent.getActivity( context, 0, new Intent(context, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT ); Bitmap largeIcon = null; if (np.hasPayload()) { int width = context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_width); int height = context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height); final InputStream input = np.getPayload().getInputStream(); largeIcon = BitmapFactory.decodeStream(input); np.getPayload().close(); if (largeIcon != null) { //Log.i("NotificationsPlugin", "hasPayload: size=" + largeIcon.getWidth() + "/" + largeIcon.getHeight() + " opti=" + width + "/" + height); if (largeIcon.getWidth() > width || largeIcon.getHeight() > height) { // older API levels don't scale notification icons automatically, therefore: largeIcon = Bitmap.createScaledBitmap(largeIcon, width, height, false); } } } NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); - Notification noti = new NotificationCompat.Builder(context, NotificationHelper.Channels.DEFAULT) + Notification noti = new NotificationCompat.Builder(context, NotificationHelper.Channels.RECEIVENOTIFICATION) .setContentTitle(np.getString("appName")) .setContentText(np.getString("ticker")) .setContentIntent(resultPendingIntent) .setTicker(np.getString("ticker")) .setSmallIcon(R.drawable.ic_notification) .setLargeIcon(largeIcon) .setAutoCancel(true) .setLocalOnly(true) // to avoid bouncing the notification back to other kdeconnect nodes .setDefaults(Notification.DEFAULT_ALL) .setStyle(new NotificationCompat.BigTextStyle().bigText(np.getString("ticker"))) .build(); NotificationHelper.notifyCompat(notificationManager, "kdeconnectId:" + np.getString("id", "0"), np.getInt("id", 0), noti); return true; } @Override public String[] getSupportedPacketTypes() { return new String[]{PACKET_TYPE_NOTIFICATION}; } @Override public String[] getOutgoingPacketTypes() { return new String[]{PACKET_TYPE_NOTIFICATION_REQUEST}; } }