diff --git a/res/values/strings.xml b/res/values/strings.xml
index cd600692..19de8dc7 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -39,6 +39,7 @@
Share files and URLs between devices
No devices
OK
+ OK :(
Cancel
Open settings
You need to grant permission to access notifications
@@ -352,4 +353,5 @@
Permission required
Android requires the Location permission to identify your WiFi network
+ Android 10 has removed clipboard access to all apps. This plugin will be disabled.
diff --git a/src/org/kde/kdeconnect/Plugins/ClibpoardPlugin/ClipboardPlugin.java b/src/org/kde/kdeconnect/Plugins/ClibpoardPlugin/ClipboardPlugin.java
index a9683319..6514202c 100644
--- a/src/org/kde/kdeconnect/Plugins/ClibpoardPlugin/ClipboardPlugin.java
+++ b/src/org/kde/kdeconnect/Plugins/ClibpoardPlugin/ClipboardPlugin.java
@@ -20,9 +20,15 @@
package org.kde.kdeconnect.Plugins.ClibpoardPlugin;
+import android.os.Build;
+
+import androidx.fragment.app.DialogFragment;
+import androidx.preference.PreferenceManager;
+
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
+import org.kde.kdeconnect.UserInterface.NoticeAlertDialogFragment;
import org.kde.kdeconnect_tp.R;
@PluginFactory.LoadablePlugin
@@ -53,6 +59,8 @@ public class ClipboardPlugin extends Plugin {
*/
private final static String PACKET_TYPE_CLIPBOARD_CONNECT = "kdeconnect.clipboard.connect";
+ private final static String ANDROID_10_INCOMPAT_DIALOG_SHOWN_PREFERENCE = "android10IncompatDialogShown";
+
@Override
public String getDisplayName() {
return context.getResources().getString(R.string.pref_plugin_clipboard);
@@ -100,6 +108,21 @@ public class ClipboardPlugin extends Plugin {
device.sendPacket(np);
}
+ @Override
+ public boolean checkRequiredPermissions() {
+ return Build.VERSION.SDK_INT <= Build.VERSION_CODES.P || PreferenceManager.getDefaultSharedPreferences(context).getBoolean(ANDROID_10_INCOMPAT_DIALOG_SHOWN_PREFERENCE, false);
+ }
+
+ @Override
+ public DialogFragment getPermissionExplanationDialog() {
+ PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(ANDROID_10_INCOMPAT_DIALOG_SHOWN_PREFERENCE, true).apply();
+ return new NoticeAlertDialogFragment.Builder()
+ .setTitle(R.string.pref_plugin_clipboard)
+ .setMessage(R.string.clipboard_android_x_incompat)
+ .setPositiveButton(R.string.sad_ok)
+ .create();
+ }
+
@Override
public boolean onCreate() {
ClipboardListener.instance(context).registerObserver(observer);
diff --git a/src/org/kde/kdeconnect/UserInterface/MainActivity.java b/src/org/kde/kdeconnect/UserInterface/MainActivity.java
index 43098713..ee862e08 100644
--- a/src/org/kde/kdeconnect/UserInterface/MainActivity.java
+++ b/src/org/kde/kdeconnect/UserInterface/MainActivity.java
@@ -378,6 +378,13 @@ public class MainActivity extends AppCompatActivity implements SharedPreferences
}
}
+ public void reloadCurrentDevicePlugins() {
+ BackgroundService.RunCommand(this, service -> {
+ Device device = service.getDevice(mCurrentDevice);
+ device.reloadPluginsFromSettings();
+ });
+ }
+
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (DeviceHelper.KEY_DEVICE_NAME_PREFERENCE.equals(key)) {
diff --git a/src/org/kde/kdeconnect/UserInterface/NoticeAlertDialogFragment.java b/src/org/kde/kdeconnect/UserInterface/NoticeAlertDialogFragment.java
new file mode 100644
index 00000000..b0c40b6a
--- /dev/null
+++ b/src/org/kde/kdeconnect/UserInterface/NoticeAlertDialogFragment.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2019 Erik Duisters
+ *
+ * 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.UserInterface;
+
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+
+import androidx.annotation.Nullable;
+import androidx.preference.PreferenceManager;
+
+import org.kde.kdeconnect_tp.R;
+
+public class NoticeAlertDialogFragment extends AlertDialogFragment {
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setCallback(new Callback() {
+ @Override
+ public void onPositiveButtonClicked() {
+ //TODO: Find a way to pass this callback from the Builder. For now, this is only used in one place and this is the callback needed.
+ MainActivity mainActivity = (MainActivity)requireActivity();
+ mainActivity.reloadCurrentDevicePlugins();
+ }
+ });
+ }
+
+ public static class Builder extends AbstractBuilder {
+
+ public Builder() {
+ super();
+ setTitle(R.string.pref_plugin_clipboard);
+ setMessage(R.string.clipboard_android_x_incompat);
+ setPositiveButton(R.string.sad_ok);
+ }
+
+ @Override
+ public Builder getThis() {
+ return this;
+ }
+
+ @Override
+ protected NoticeAlertDialogFragment createFragment() {
+ return new NoticeAlertDialogFragment();
+ }
+ }
+}