mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-29 05:07:40 +00:00
Fixed bug were list of enabled plugins didn't refresh itself.
Removed PreferenceListAdapter
This commit is contained in:
parent
c9d11f650c
commit
8542aaf4fa
@ -1,28 +0,0 @@
|
||||
package org.kde.kdeconnect.UserInterface;
|
||||
|
||||
import android.content.Context;
|
||||
import android.preference.Preference;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PreferenceListAdapter extends ArrayAdapter<Preference> {
|
||||
|
||||
|
||||
private final ArrayList<Preference> localList;
|
||||
|
||||
public PreferenceListAdapter(Context context, ArrayList<Preference> items) {
|
||||
super(context,0, items);
|
||||
localList = items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
Preference preference = localList.get(position);
|
||||
//We can not reuse the convertView as some views have checkboxes and other don't
|
||||
return preference.getView(null, parent);
|
||||
}
|
||||
|
||||
}
|
@ -50,37 +50,30 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
pluginPreference.setKey(pluginName + getString(R.string.plugin_settings_key));
|
||||
pluginPreference.setTitle(info.getDisplayName());
|
||||
pluginPreference.setSummary(R.string.plugin_settings);
|
||||
pluginPreference.setSelectable(false);
|
||||
preferences.add(pluginPreference);
|
||||
preferenceScreen.addPreference(pluginPreference);
|
||||
pluginPreference.setDependency(pref.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
setListAdapter(new PreferenceListAdapter(SettingsActivity.this, preferences));
|
||||
getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
Preference current_preference = preferences.get(i);
|
||||
|
||||
if (current_preference.isSelectable()) {
|
||||
CheckBoxPreference pref = (CheckBoxPreference) current_preference;
|
||||
Preference pref = preferences.get(i);
|
||||
if (pref.getDependency() == null) { //Is a plugin check
|
||||
CheckBoxPreference check = (CheckBoxPreference)pref;
|
||||
boolean enabled = device.isPluginEnabled(pref.getKey());
|
||||
device.setPluginEnabled(pref.getKey(), !enabled);
|
||||
pref.setChecked(!enabled);
|
||||
} else {
|
||||
Intent intent = new Intent(SettingsActivity.this, PluginSettingsActivity.class);
|
||||
intent.putExtra(Intent.EXTRA_INTENT, current_preference.getKey());
|
||||
startActivity(intent);
|
||||
check.setChecked(!enabled);
|
||||
} else { //Is a plugin suboption
|
||||
if (pref.isEnabled()) {
|
||||
Intent intent = new Intent(SettingsActivity.this, PluginSettingsActivity.class);
|
||||
intent.putExtra(Intent.EXTRA_INTENT, pref.getKey());
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
getListAdapter().getView(i, view, null); //This will refresh the view (yes, this is the way to do it)
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
getListView().setPadding(16,16,16,16);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user