Refactor track menu

This commit is contained in:
Victor Shcherb 2012-08-05 14:56:58 +03:00
parent 34a6a245f7
commit edc11c4e14
4 changed files with 46 additions and 20 deletions

View file

@ -9,9 +9,12 @@
1. All your modified/created strings are in the top of the file (to make easier find what's translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="avoid_in_routing_title">Avoid..</string>
<string name="show_lanes">Show lanes</string>
<string name="avoid_unpaved">Avoid unpaved roads</string>
<string name="avoid_ferries">Avoid ferries</string>
<string name="avoid_in_routing_title">Avoid&#8230;</string>
<string name="avoid_in_routing_descr">Avoid toll roads, unpaved, ferries</string>
<string name="show_warnings_title">Show alarms</string>
<string name="show_warnings_title">Show alarms&#8230;</string>
<string name="show_warnings_descr">Show speed limits, speed cameras and traffic bumps</string>
<string name="map_widget_fluorescent">Fluorescent colors</string>
<string name="map_widget_show_ruler">Ruler</string>
@ -49,9 +52,6 @@
<string name="bg_service_screen_unlock">Unlock screen</string>
<string name="bg_service_screen_lock_toast">The screen is locked</string>
<string name="bg_service_interval">Set wake-up interval:</string>
<string name="show_cameras_descr">Show speed cameras (may be forbidden in some countries)</string>
<string name="show_speed_limits_descr">Show speed limits and traffic bumps</string>
<string name="avoid_toll_roads_descr">Avoid toll roads for route calculation</string>
<string name="show_cameras">Show speed cameras</string>
<string name="show_speed_limits">Show speed limits</string>
<string name="avoid_toll_roads">Avoid toll roads</string>

View file

@ -22,15 +22,6 @@
<ListPreference android:key="auto_follow_route" android:title="@string/choose_auto_follow_route"
android:summary="@string/choose_auto_follow_route_descr"></ListPreference>
<CheckBoxPreference android:title="@string/auto_zoom_map" android:summary="@string/auto_zoom_map_descr" android:key="auto_zoom_map"></CheckBoxPreference>
<!-- <CheckBoxPreference android:summary="@string/show_speed_limits_descr" android:title="@string/show_speed_limits"
android:key="show_speed_limits"></CheckBoxPreference>
<CheckBoxPreference android:summary="@string/show_cameras_descr" android:title="@string/show_cameras"
android:key="show_cameras"></CheckBoxPreference>
<CheckBoxPreference android:title="@string/auto_zoom_map" android:summary="@string/auto_zoom_map_descr" android:key="auto_zoom_map"></CheckBoxPreference>
<CheckBoxPreference android:summary="@string/avoid_toll_roads_descr" android:title="@string/avoid_toll_roads"
android:key="avoid_toll_roads"></CheckBoxPreference> -->
<Preference android:title="@string/show_warnings_title" android:summary="@string/show_warnings_descr" android:key="show_routing_alarms"/>
<Preference android:title="@string/avoid_in_routing_title" android:summary="@string/avoid_in_routing_descr" android:key="avoid_in_routing"/>

View file

@ -578,14 +578,13 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> FAST_ROUTE_MODE = new BooleanPreference("fast_route_mode", true).makeProfile();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> SHOW_CAMERAS = new BooleanPreference("show_cameras", true).makeGlobal().cache();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> SHOW_SPEED_LIMITS = new BooleanPreference("show_speed_limits", true).makeGlobal().cache();
public final OsmandPreference<Boolean> SHOW_LANES = new BooleanPreference("show_lanes", true).makeGlobal().cache();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> AVOID_TOLL_ROADS = new BooleanPreference("avoid_toll_roads", false).makeGlobal().cache();
public final OsmandPreference<Boolean> AVOID_UNPAVED_ROADS = new BooleanPreference("avoid_unpaved_roads", false).makeGlobal().cache();
public final OsmandPreference<Boolean> AVOID_FERRIES = new BooleanPreference("avoid_ferries", false).makeGlobal().cache();
// this value string is synchronized with settings_pref.xml preference name
public final CommonPreference<Integer> SAVE_TRACK_INTERVAL = new IntPreference("save_track_interval", 5).makeProfile();

View file

@ -38,6 +38,7 @@ import android.app.AlertDialog.Builder;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnMultiChoiceClickListener;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.AsyncTask;
@ -69,6 +70,8 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
private Preference bidforfix;
private Preference plugins;
private Preference avoidRouting;
private Preference showAlarms;
private EditTextPreference applicationDir;
private ListPreference applicationModePreference;
@ -375,8 +378,10 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
bidforfix.setOnPreferenceClickListener(this);
plugins = (Preference) screen.findPreference("plugins");
plugins.setOnPreferenceClickListener(this);
avoidRouting = (Preference) screen.findPreference("avoid_in_routing");
avoidRouting.setOnPreferenceClickListener(this);
showAlarms = (Preference) screen.findPreference("show_routing_alarms");
showAlarms.setOnPreferenceClickListener(this);
Intent intent = getIntent();
@ -744,6 +749,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
@SuppressWarnings("unchecked")
@Override
public boolean onPreferenceClick(Preference preference) {
if(preference.getKey().equals(OsmandSettings.LOCAL_INDEXES)){
@ -759,9 +765,39 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
} else if(preference == plugins){
startActivity(new Intent(this, PluginsActivity.class));
return true;
} else if (preference == avoidRouting) {
showBooleanSettings(new String[] { getString(R.string.avoid_toll_roads), getString(R.string.avoid_ferries),
getString(R.string.avoid_unpaved) }, new OsmandPreference[] { osmandSettings.AVOID_TOLL_ROADS,
osmandSettings.AVOID_FERRIES, osmandSettings.AVOID_UNPAVED_ROADS });
return true;
} else if(preference == showAlarms){
showBooleanSettings(new String[] { getString(R.string.show_cameras), getString(R.string.show_speed_limits),
getString(R.string.show_lanes) },
new OsmandPreference[] { osmandSettings.SHOW_CAMERAS, osmandSettings.SHOW_SPEED_LIMITS,
osmandSettings.SHOW_LANES});
return true;
} else if(preference.getKey().equals("show_routing_alarms")){
startActivity(new Intent(this, PluginsActivity.class));
return true;
}
return false;
}
public void showBooleanSettings(String[] vals, final OsmandPreference<Boolean>[] prefs) {
Builder bld = new AlertDialog.Builder(this);
boolean[] checkedItems = new boolean[prefs.length];
for(int i=0; i<prefs.length; i++) {
checkedItems[i] = prefs[i].get();
}
bld.setMultiChoiceItems(vals, checkedItems, new OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
prefs[which].set(isChecked);
}
});
bld.show();
}
public static void installMapLayers(final Activity activity, final ResultMatcher<TileSourceTemplate> result){