2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-22 18:07:55 +00:00

Hopefully fix some NPE crashes

This commit is contained in:
Albert Vaca Cintora 2022-01-24 01:09:43 +01:00
parent 5ef7154d5e
commit 2d55f282a8
2 changed files with 5 additions and 2 deletions

View File

@ -414,7 +414,8 @@ public class RemoteKeyboardPlugin extends Plugin implements SharedPreferences.On
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals(context.getString(R.string.remotekeyboard_editing_only))) { if (key.equals(context.getString(R.string.remotekeyboard_editing_only))) {
final boolean editingOnly = sharedPreferences.getBoolean(context.getString(R.string.remotekeyboard_editing_only), true); final boolean editingOnly = sharedPreferences.getBoolean(context.getString(R.string.remotekeyboard_editing_only), true);
notifyKeyboardState(editingOnly ? RemoteKeyboardService.instance.visible : true); final boolean visible = RemoteKeyboardService.instance != null && RemoteKeyboardService.instance.visible;
notifyKeyboardState(!editingOnly || visible);
} }
} }
} }

View File

@ -140,7 +140,9 @@ class RunCommandControlsProviderService : ControlsProviderService() {
private fun getAllCommandsList(): List<CommandEntryWithDevice> { private fun getAllCommandsList(): List<CommandEntryWithDevice> {
val commandList = mutableListOf<CommandEntryWithDevice>() val commandList = mutableListOf<CommandEntryWithDevice>()
for (device in BackgroundService.getInstance().devices.values) { val service = BackgroundService.getInstance() ?: return commandList
for (device in service.devices.values) {
if (!device.isReachable) { if (!device.isReachable) {
commandList.addAll(getSavedCommandsList(device)) commandList.addAll(getSavedCommandsList(device))
continue continue