diff --git a/muninforAndroid/src/main/java/com/chteuchteu/munin/obj/GridItem.java b/muninforAndroid/src/main/java/com/chteuchteu/munin/obj/GridItem.java index 9301a62c..edf3504d 100644 --- a/muninforAndroid/src/main/java/com/chteuchteu/munin/obj/GridItem.java +++ b/muninforAndroid/src/main/java/com/chteuchteu/munin/obj/GridItem.java @@ -23,6 +23,7 @@ import com.chteuchteu.munin.MuninFoo; import com.chteuchteu.munin.R; +import com.chteuchteu.munin.adptr.Adapter_CheckablePluginsList; import com.chteuchteu.munin.adptr.Adapter_IconList; import com.chteuchteu.munin.adptr.Adapter_NodesList; import com.chteuchteu.munin.hlpr.Settings; @@ -301,29 +302,19 @@ public void onItemClick(AdapterView arg0, View arg1, int pos, long arg3) { private static void add_pluginsListDialog(final Context c, final MuninNode node, final MuninFoo f, final Grid g, final IGridActivity activity, final Fragment_Grid fragment, final int X, final int Y) { - List l = node.getPlugins(); - - final CharSequence[] items = new CharSequence[l.size()]; - for (int i=0; i selectedItems = new ArrayList<>(); - + final Adapter_CheckablePluginsList pluginsAdapter = new Adapter_CheckablePluginsList(c, node.getPlugins()); + ListView pluginsList = new ListView(c); + pluginsList.setAdapter(pluginsAdapter); + AlertDialog dialog; AlertDialog.Builder builder = new AlertDialog.Builder(c); - builder.setTitle(c.getText(R.string.text72)); - builder.setMultiChoiceItems(items, null, new DialogInterface.OnMultiChoiceClickListener() { - @Override - public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked) { - if (isChecked) - selectedItems.add(indexSelected); - else if (selectedItems.contains(indexSelected)) - selectedItems.remove(Integer.valueOf(indexSelected)); - } - }) - .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { + builder.setTitle(c.getText(R.string.text72)) + .setView(pluginsList) + .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { + List selectedItems = pluginsAdapter.getSelectedItems(); + if (selectedItems.isEmpty()) return; @@ -333,8 +324,7 @@ public void onClick(DialogInterface dialog, int id) { int maxWidth = g.getNbColumns(); List addedItems = new ArrayList<>(); - for (Integer i : selectedItems) { - MuninPlugin p = node.getPlugin(i); + for (MuninPlugin p : selectedItems) { if (!alreadyAdded(g, p)) { GridItem item = new GridItem(g, p); item.setActivityReferences(c, activity, fragment); diff --git a/muninforAndroid/src/main/java/com/chteuchteu/munin/ui/Fragment_Notifications_Poll.java b/muninforAndroid/src/main/java/com/chteuchteu/munin/ui/Fragment_Notifications_Poll.java index f4a1ba42..b7487aab 100644 --- a/muninforAndroid/src/main/java/com/chteuchteu/munin/ui/Fragment_Notifications_Poll.java +++ b/muninforAndroid/src/main/java/com/chteuchteu/munin/ui/Fragment_Notifications_Poll.java @@ -126,7 +126,7 @@ public void onClick(View view) { MuninNode node = muninFoo.getNodes().get(i); LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View v = vi.inflate(R.layout.servers_list_checkbox, null); + View v = vi.inflate(R.layout.adapter_twolines_checkbox, null); checkboxes[i] = (CheckBox) v.findViewById(R.id.line_0); int id = Resources.getSystem().getIdentifier("btn_check_holo_light", "drawable", "android"); diff --git a/muninforAndroid/src/main/java/com/chteuchteu/munin/wdget/Widget_AlertsWidget_Configure.java b/muninforAndroid/src/main/java/com/chteuchteu/munin/wdget/Widget_AlertsWidget_Configure.java index abcf883a..260f0339 100644 --- a/muninforAndroid/src/main/java/com/chteuchteu/munin/wdget/Widget_AlertsWidget_Configure.java +++ b/muninforAndroid/src/main/java/com/chteuchteu/munin/wdget/Widget_AlertsWidget_Configure.java @@ -71,7 +71,7 @@ protected void onCreate(Bundle savedInstanceState) { for (int i=0; i - \ No newline at end of file + diff --git a/muninforAndroid/src/main/res/layout/servers_list_checkbox.xml b/muninforAndroid/src/main/res/layout/servers_list_checkbox.xml deleted file mode 100644 index c66c5553..00000000 --- a/muninforAndroid/src/main/res/layout/servers_list_checkbox.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/muninforAndroid/src/main/res/layout/twolineslist.xml b/muninforAndroid/src/main/res/layout/twolineslist.xml deleted file mode 100644 index 1c51b687..00000000 --- a/muninforAndroid/src/main/res/layout/twolineslist.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - \ No newline at end of file