mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-24 19:07:19 +00:00
Notify Android 10 users that clipboard won't work
This commit is contained in:
parent
b1e3113343
commit
9f3b75b748
@ -39,6 +39,7 @@
|
|||||||
<string name="pref_plugin_sharereceiver_desc">Share files and URLs between devices</string>
|
<string name="pref_plugin_sharereceiver_desc">Share files and URLs between devices</string>
|
||||||
<string name="device_list_empty">No devices</string>
|
<string name="device_list_empty">No devices</string>
|
||||||
<string name="ok">OK</string>
|
<string name="ok">OK</string>
|
||||||
|
<string name="sad_ok">OK :(</string>
|
||||||
<string name="cancel">Cancel</string>
|
<string name="cancel">Cancel</string>
|
||||||
<string name="open_settings">Open settings</string>
|
<string name="open_settings">Open settings</string>
|
||||||
<string name="no_permissions">You need to grant permission to access notifications</string>
|
<string name="no_permissions">You need to grant permission to access notifications</string>
|
||||||
@ -352,4 +353,5 @@
|
|||||||
|
|
||||||
<string name="location_permission_needed_title">Permission required</string>
|
<string name="location_permission_needed_title">Permission required</string>
|
||||||
<string name="location_permission_needed_desc">Android requires the Location permission to identify your WiFi network</string>
|
<string name="location_permission_needed_desc">Android requires the Location permission to identify your WiFi network</string>
|
||||||
|
<string name="clipboard_android_x_incompat">Android 10 has removed clipboard access to all apps. This plugin will be disabled.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -20,9 +20,15 @@
|
|||||||
|
|
||||||
package org.kde.kdeconnect.Plugins.ClibpoardPlugin;
|
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.NetworkPacket;
|
||||||
import org.kde.kdeconnect.Plugins.Plugin;
|
import org.kde.kdeconnect.Plugins.Plugin;
|
||||||
import org.kde.kdeconnect.Plugins.PluginFactory;
|
import org.kde.kdeconnect.Plugins.PluginFactory;
|
||||||
|
import org.kde.kdeconnect.UserInterface.NoticeAlertDialogFragment;
|
||||||
import org.kde.kdeconnect_tp.R;
|
import org.kde.kdeconnect_tp.R;
|
||||||
|
|
||||||
@PluginFactory.LoadablePlugin
|
@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 PACKET_TYPE_CLIPBOARD_CONNECT = "kdeconnect.clipboard.connect";
|
||||||
|
|
||||||
|
private final static String ANDROID_10_INCOMPAT_DIALOG_SHOWN_PREFERENCE = "android10IncompatDialogShown";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDisplayName() {
|
public String getDisplayName() {
|
||||||
return context.getResources().getString(R.string.pref_plugin_clipboard);
|
return context.getResources().getString(R.string.pref_plugin_clipboard);
|
||||||
@ -100,6 +108,21 @@ public class ClipboardPlugin extends Plugin {
|
|||||||
device.sendPacket(np);
|
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
|
@Override
|
||||||
public boolean onCreate() {
|
public boolean onCreate() {
|
||||||
ClipboardListener.instance(context).registerObserver(observer);
|
ClipboardListener.instance(context).registerObserver(observer);
|
||||||
|
@ -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
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
if (DeviceHelper.KEY_DEVICE_NAME_PREFERENCE.equals(key)) {
|
if (DeviceHelper.KEY_DEVICE_NAME_PREFERENCE.equals(key)) {
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 Erik Duisters <e.duisters1@gmail.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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<Builder, NoticeAlertDialogFragment> {
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user