2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-29 13:17:43 +00:00

Allow configuring plugins without permissions

This fixes the bug introduced in f97216 which prevented configuring storage
locations because the plugin wasn't returned by `getPlugin` when there are
no storage locations present.
This commit is contained in:
Albert Vaca Cintora 2023-03-17 18:40:03 +01:00
parent 01f44f524a
commit 2de744aad8
4 changed files with 16 additions and 8 deletions

View File

@ -722,6 +722,15 @@ public class Device implements BaseLink.PacketReceiver {
return plugins.get(pluginKey);
}
@Nullable
public Plugin getPluginIncludingWithoutPermissions(String pluginKey) {
Plugin p = plugins.get(pluginKey);
if (p == null) {
p = pluginsWithoutPermissions.get(pluginKey);
}
return p;
}
private synchronized boolean addPlugin(final String pluginKey) {
Plugin existing = plugins.get(pluginKey);
if (existing != null) {

View File

@ -30,15 +30,14 @@ public class PluginPreference extends SwitchPreference {
PluginFactory.PluginInfo info = PluginFactory.getPluginInfo(pluginKey);
setTitle(info.getDisplayName());
setSummary(info.getDescription());
setIcon(android.R.color.transparent);
setIcon(android.R.color.transparent);
setChecked(device.isPluginEnabled(pluginKey));
Plugin plugin = device.getPlugin(pluginKey);
if (info.hasSettings() && plugin != null) {
if (info.hasSettings()) {
this.listener = v -> {
Plugin plugin1 = device.getPlugin(pluginKey);
if (plugin1 != null) {
callback.onStartPluginSettingsFragment(plugin1);
Plugin plugin = device.getPluginIncludingWithoutPermissions(pluginKey);
if (plugin != null) {
callback.onStartPluginSettingsFragment(plugin);
} else { //Could happen if the device is not connected anymore
callback.onFinish();
}

View File

@ -58,7 +58,7 @@ public class PluginSettingsActivity
if (pluginKey != null) {
Device device = BackgroundService.getInstance().getDevice(deviceId);
if (device != null) {
Plugin plugin = device.getPlugin(pluginKey);
Plugin plugin = device.getPluginIncludingWithoutPermissions(pluginKey);
if (plugin != null) {
fragment = plugin.getSettingsFragment(this);
}

View File

@ -57,7 +57,7 @@ public class PluginSettingsFragment extends PreferenceFragmentCompat {
this.pluginKey = getArguments().getString(ARG_PLUGIN_KEY);
this.layout = getArguments().getInt(ARG_LAYOUT);
this.device = getDeviceOrThrow(getDeviceId());
this.plugin = device.getPlugin(pluginKey);
this.plugin = device.getPluginIncludingWithoutPermissions(pluginKey);
super.onCreate(savedInstanceState);
}