Commit fb2859c2 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Prompt user to enable remote keyboard

parent 145fa4f0
......@@ -39,6 +39,7 @@
<string name="open_settings">Open settings</string>
<string name="no_permissions">You need to grant permission to access notifications</string>
<string name="no_permission_mprisreceiver">To be able to control your media players you need to grant access to the notifications</string>
<string name="no_permissions_remotekeyboard">To receive keypresses you need to activate the KDE Connect Remote Keyboard</string>
<string name="send_ping">Send ping</string>
<string name="open_mpris_controls">Multimedia control</string>
<string name="remotekeyboard_editing_only" translatable="false">remotekeyboard_editing_only</string>
......
......@@ -23,6 +23,7 @@ package org.kde.kdeconnect.Plugins.RemoteKeyboardPlugin;
import android.graphics.drawable.Drawable;
import android.os.SystemClock;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.util.Log;
import android.util.SparseIntArray;
import android.view.KeyEvent;
......@@ -34,6 +35,8 @@ import android.view.inputmethod.InputConnection;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect.UserInterface.AlertDialogFragment;
import org.kde.kdeconnect.UserInterface.StartActivityAlertDialogFragment;
import org.kde.kdeconnect_tp.R;
import java.util.ArrayList;
......@@ -393,4 +396,22 @@ public class RemoteKeyboardPlugin extends Plugin {
String getDeviceId() {
return device.getDeviceId();
}
@Override
public boolean checkRequiredPermissions() {
return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ENABLED_INPUT_METHODS).contains("org.kde.kdeconnect_tp");
}
@Override
public AlertDialogFragment getPermissionExplanationDialog(int requestCode) {
return new StartActivityAlertDialogFragment.Builder()
.setTitle(R.string.pref_plugin_remotekeyboard)
.setMessage(R.string.no_permissions_remotekeyboard)
.setPositiveButton(R.string.open_settings)
.setNegativeButton(R.string.cancel)
.setIntentAction(Settings.ACTION_INPUT_METHOD_SETTINGS)
.setStartForResult(true)
.setRequestCode(requestCode)
.create();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment