2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 13:47:41 +00:00

Send correct keyboard state when changing onlyWhenEditing option

Otherwise the desktop side won't show the input as available

I didn't even know that feature existed :)
This commit is contained in:
Nicolas Fella
2020-07-12 00:55:43 +02:00
parent 0cea53540e
commit dff9a2218e

View File

@@ -20,6 +20,7 @@
package org.kde.kdeconnect.Plugins.RemoteKeyboardPlugin;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.os.SystemClock;
import android.preference.PreferenceManager;
@@ -47,7 +48,7 @@ import androidx.core.util.Pair;
import androidx.fragment.app.DialogFragment;
@PluginFactory.LoadablePlugin
public class RemoteKeyboardPlugin extends Plugin {
public class RemoteKeyboardPlugin extends Plugin implements SharedPreferences.OnSharedPreferenceChangeListener {
private final static String PACKET_TYPE_MOUSEPAD_REQUEST = "kdeconnect.mousepad.request";
private final static String PACKET_TYPE_MOUSEPAD_ECHO = "kdeconnect.mousepad.echo";
@@ -126,6 +127,12 @@ public class RemoteKeyboardPlugin extends Plugin {
}
if (RemoteKeyboardService.instance != null)
RemoteKeyboardService.instance.handler.post(() -> RemoteKeyboardService.instance.updateInputView());
PreferenceManager.getDefaultSharedPreferences(context).registerOnSharedPreferenceChangeListener(this);
final boolean editingOnly = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(context.getString(R.string.remotekeyboard_editing_only), true);
notifyKeyboardState(editingOnly ? RemoteKeyboardService.instance.visible : true);
return true;
}
@@ -415,4 +422,12 @@ public class RemoteKeyboardPlugin extends Plugin {
.setRequestCode(MainActivity.RESULT_NEEDS_RELOAD)
.create();
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals(context.getString(R.string.remotekeyboard_editing_only))) {
final boolean editingOnly = sharedPreferences.getBoolean(context.getString(R.string.remotekeyboard_editing_only), true);
notifyKeyboardState(editingOnly ? RemoteKeyboardService.instance.visible : true);
}
}
}