From 99c30540b839d24437490347951799d47700eabe Mon Sep 17 00:00:00 2001 From: "Igor B. Poretsky" Date: Fri, 1 Mar 2013 05:25:16 +0400 Subject: [PATCH] Automatically restart settings when active plugins list is modified. --- .../osmand/plus/activities/PluginsActivity.java | 5 ++++- .../osmand/plus/activities/SettingsActivity.java | 14 +++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/PluginsActivity.java b/OsmAnd/src/net/osmand/plus/activities/PluginsActivity.java index 27518c8cfa..63fa408920 100644 --- a/OsmAnd/src/net/osmand/plus/activities/PluginsActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/PluginsActivity.java @@ -17,7 +17,9 @@ import android.widget.ListView; import android.widget.TextView; public class PluginsActivity extends OsmandListActivity { - + + public static final int ACTIVE_PLUGINS_LIST_MODIFIED = 1; + private List availablePlugins; private Set clickedPlugins = new LinkedHashSet(); private Set restartPlugins = new LinkedHashSet(); @@ -52,6 +54,7 @@ public class PluginsActivity extends OsmandListActivity { } else { restartPlugins.add(item.getId()); } + setResult(ACTIVE_PLUGINS_LIST_MODIFIED); } clickedPlugins.add(item.getId()); getListAdapter().notifyDataSetChanged(); diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java index cabeb53cf9..643229999e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java @@ -25,6 +25,7 @@ import net.osmand.plus.ProgressDialogImplementation; import net.osmand.plus.R; import net.osmand.plus.Version; import net.osmand.plus.activities.CustomTitleBar.CustomTitleBarView; +import net.osmand.plus.activities.PluginsActivity; import net.osmand.plus.render.NativeOsmandLibrary; import net.osmand.plus.routing.RouteProvider.RouteService; import net.osmand.plus.views.SeekBarPreference; @@ -67,6 +68,8 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference public static final String SCREEN_ID_NAVIGATION_SETTINGS = "routing_settings"; public static final String MORE_VALUE = "MORE_VALUE"; + private static final int PLUGINS_SELECTION_REQUEST = 1; + private Preference bidforfix; private Preference plugins; private Preference avoidRouting; @@ -441,6 +444,15 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference super.onDestroy(); } + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if ((requestCode == PLUGINS_SELECTION_REQUEST) && (resultCode == PluginsActivity.ACTIVE_PLUGINS_LIST_MODIFIED)) { + finish(); + startActivity(getIntent()); + } + } + public void updateAllSettings() { for (OsmandPreference b : booleanPreferences.values()) { CheckBoxPreference pref = (CheckBoxPreference) screenPreferences.get(b.getId()); @@ -758,7 +770,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference startActivity(new Intent(this, OsmandBidForFixActivity.class)); return true; } else if (preference == plugins) { - startActivity(new Intent(this, PluginsActivity.class)); + startActivityForResult(new Intent(this, PluginsActivity.class), PLUGINS_SELECTION_REQUEST); return true; } else if (preference == avoidRouting) { showBooleanSettings(new String[] { getString(R.string.avoid_toll_roads), getString(R.string.avoid_ferries),