mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-01 14:45:08 +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:
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
package org.kde.kdeconnect.Plugins.RemoteKeyboardPlugin;
|
package org.kde.kdeconnect.Plugins.RemoteKeyboardPlugin;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
@@ -47,7 +48,7 @@ import androidx.core.util.Pair;
|
|||||||
import androidx.fragment.app.DialogFragment;
|
import androidx.fragment.app.DialogFragment;
|
||||||
|
|
||||||
@PluginFactory.LoadablePlugin
|
@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_REQUEST = "kdeconnect.mousepad.request";
|
||||||
private final static String PACKET_TYPE_MOUSEPAD_ECHO = "kdeconnect.mousepad.echo";
|
private final static String PACKET_TYPE_MOUSEPAD_ECHO = "kdeconnect.mousepad.echo";
|
||||||
@@ -126,6 +127,12 @@ public class RemoteKeyboardPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
if (RemoteKeyboardService.instance != null)
|
if (RemoteKeyboardService.instance != null)
|
||||||
RemoteKeyboardService.instance.handler.post(() -> RemoteKeyboardService.instance.updateInputView());
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,4 +422,12 @@ public class RemoteKeyboardPlugin extends Plugin {
|
|||||||
.setRequestCode(MainActivity.RESULT_NEEDS_RELOAD)
|
.setRequestCode(MainActivity.RESULT_NEEDS_RELOAD)
|
||||||
.create();
|
.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user