From 53a3a415c3e4cfebcc1e001ead63edef235ed59e Mon Sep 17 00:00:00 2001 From: Pavol Zibrita Date: Sun, 8 Jul 2012 13:43:08 +0200 Subject: [PATCH] small changes within the plugins activity --- OsmAnd/res/layout/plugins_list_item.xml | 3 +- .../plus/activities/PluginsActivity.java | 36 +++++++++++-------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/OsmAnd/res/layout/plugins_list_item.xml b/OsmAnd/res/layout/plugins_list_item.xml index e384c4a202..aa99c2cdc0 100644 --- a/OsmAnd/res/layout/plugins_list_item.xml +++ b/OsmAnd/res/layout/plugins_list_item.xml @@ -10,13 +10,14 @@ android:layout_height="wrap_content" android:drawablePadding="10dp" android:textStyle="bold" - android:textSize="18sp" android:drawableRight="@drawable/list_activities_dot_marker1_pressed" android:drawableLeft="@drawable/list_activities_plugin_menu_symbol" android:text="@string/extra_settings" android:gravity="center_vertical" android:paddingLeft="10dp" android:paddingRight="10dp" android:background="@drawable/ic_background_plugin_listitem"> + android:textSize="20sp" android:drawableRight="@drawable/list_activities_dot_marker1_pressed" android:drawableLeft="@drawable/list_activities_plugin_menu_symbol" android:text="@string/extra_settings" android:gravity="center_vertical" android:paddingLeft="10dp" android:paddingRight="10dp" android:background="@drawable/ic_background_plugin_listitem"> availablePlugins; - private Set enabledPlugins = new LinkedHashSet(); + private Set clickedPlugins = new LinkedHashSet(); private Set restartPlugins = new LinkedHashSet(); - + private static int colorGreen = 0xff23CC6C; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -31,7 +33,6 @@ public class PluginsActivity extends OsmandListActivity { List enabledPlugins = OsmandPlugin.getEnabledPlugins(); for(OsmandPlugin p : enabledPlugins) { restartPlugins.add(p.getId()); - this.enabledPlugins.add(p.getId()); } titleBar.afterSetContentView(); @@ -41,16 +42,20 @@ public class PluginsActivity extends OsmandListActivity { @Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); + OsmandPlugin item = getListAdapter().getItem(position); boolean enable = !restartPlugins.contains(item.getId()); - - boolean ok = OsmandPlugin.enablePlugin(((OsmandApplication) getApplication()), item, enable); - if (ok) { - if (!enable) { - restartPlugins.remove(item.getId()); - } else { - restartPlugins.add(item.getId()); + if (!enable || clickedPlugins.contains(item.getId())) { + boolean ok = OsmandPlugin.enablePlugin(((OsmandApplication) getApplication()), item, enable); + if (ok) { + if (!enable) { + restartPlugins.remove(item.getId()); + } else { + restartPlugins.add(item.getId()); + } } + } else { + clickedPlugins.add(item.getId()); } getListAdapter().notifyDataSetChanged(); } @@ -73,16 +78,19 @@ public class PluginsActivity extends OsmandListActivity { LayoutInflater inflater = getLayoutInflater(); v = inflater.inflate(net.osmand.plus.R.layout.plugins_list_item, parent, false); } - final View row = v; OsmandPlugin plugin = getItem(position); + boolean toBeEnabled = restartPlugins.contains(plugin.getId()); + int resourceId = toBeEnabled ? R.drawable.list_activities_dot_marker2_pressed : R.drawable.list_activities_dot_marker1_pressed; + + final View row = v; TextView nameView = (TextView) row.findViewById(R.id.plugin_name); nameView.setText(plugin.getName()); + nameView.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.list_activities_plugin_menu_symbol), null, getResources().getDrawable(resourceId), null); TextView description = (TextView) row.findViewById(R.id.plugin_descr); description.setText(plugin.getDescription()); - boolean toBeEnabled = restartPlugins.contains(plugin.getId()); - int right = toBeEnabled ? R.drawable.list_activities_dot_marker2_pressed : R.drawable.list_activities_dot_marker1_pressed; - nameView.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.list_activities_plugin_menu_symbol), null, getResources().getDrawable(right), null); + description.setVisibility(clickedPlugins.contains(plugin.getId()) ? View.VISIBLE : View.GONE); + description.setTextColor(toBeEnabled? colorGreen : Color.LTGRAY); return row; }