Change settings registration (move voice preferences to global)

This commit is contained in:
vshcherb 2014-04-28 00:49:06 +02:00
parent d60df78076
commit 2ef5d3442b
7 changed files with 216 additions and 183 deletions

View file

@ -9,6 +9,9 @@
3. 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="voice_pref_title">Voice</string>
<string name="misc_pref_title">Miscallenious</string>
<string name="localization_pref_title">Localization</string>
<string name="index_item_nation_addresses">addresses nationwide</string>
<string name="index_item_world_altitude_correction">World altitude correction</string>
<string name="index_item_world_seamarks">World seamarks</string>

View file

@ -1,12 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<ListPreference android:summary="@string/settings_preset_descr" android:title="@string/settings_preset" android:key="application_mode"></ListPreference>
<ListPreference android:key="rotate_map" android:title="@string/rotate_map_to_bearing" android:summary="@string/rotate_map_to_bearing_descr"></ListPreference>
<ListPreference android:key="map_screen_orientation" android:title="@string/map_screen_orientation" android:summary="@string/map_screen_orientation_descr"></ListPreference>
<ListPreference android:key="preferred_locale" android:title="@string/preferred_locale" android:summary="@string/preferred_locale_descr"></ListPreference>
<CheckBoxPreference android:summary="@string/use_english_names_descr" android:title="@string/use_english_names"
<ListPreference android:summary="@string/settings_preset_descr" android:title="@string/settings_preset" android:key="application_mode"></ListPreference>
<ListPreference android:key="rotate_map" android:title="@string/rotate_map_to_bearing" android:summary="@string/rotate_map_to_bearing_descr"></ListPreference>
<ListPreference android:key="map_screen_orientation" android:title="@string/map_screen_orientation" android:summary="@string/map_screen_orientation_descr"></ListPreference>
<PreferenceCategory android:title="@string/localization_pref_title" android:key="localization">
<ListPreference android:key="preferred_locale" android:title="@string/preferred_locale" android:summary="@string/preferred_locale_descr"></ListPreference>
<CheckBoxPreference android:summary="@string/use_english_names_descr" android:title="@string/use_english_names"
android:key="use_english_names"></CheckBoxPreference>
<ListPreference android:key="default_driving_region" android:title="@string/driving_region" android:summary="@string/driving_region_descr"></ListPreference>
<ListPreference android:key="default_driving_region" android:title="@string/driving_region" android:summary="@string/driving_region_descr"></ListPreference>
<!--
<ListPreference android:key="default_metric_system" android:title="@string/unit_of_length" android:summary="@string/unit_of_length_descr"></ListPreference>
<ListPreference android:key="osmand_theme" android:title="@string/choose_osmand_theme" android:summary="@string/choose_osmand_theme_descr"></ListPreference>
-->
</PreferenceCategory>
<PreferenceCategory android:title="@string/voice_pref_title" android:key="voice">
<ListPreference android:title="@string/voice_provider" android:key="voice_provider" android:summary="@string/voice_provider_descr"></ListPreference>
</PreferenceCategory>
<PreferenceCategory android:title="@string/misc_pref_title" android:key="misc">
<ListPreference android:key="osmand_theme" android:title="@string/choose_osmand_theme" android:summary="@string/choose_osmand_theme_descr"></ListPreference>
</PreferenceCategory>
</PreferenceScreen>

View file

@ -7,8 +7,7 @@
<Preference android:title="@string/avoid_in_routing_title" android:summary="@string/avoid_in_routing_descr" android:key="avoid_in_routing"/>
<Preference android:title="@string/prefer_in_routing_title" android:summary="@string/prefer_in_routing_descr" android:key="prefer_in_routing"/>
</PreferenceCategory>
<PreferenceCategory android:key="guidance_preferences" android:title="@string/guidance_preferences_descr">
<ListPreference android:title="@string/voice_provider" android:key="voice_provider" android:summary="@string/voice_provider_descr"></ListPreference>
<PreferenceCategory android:key="guidance_preferences" android:title="@string/guidance_preferences_descr">
<ListPreference android:key="auto_follow_route" android:title="@string/choose_auto_follow_route"
android:summary="@string/choose_auto_follow_route_descr"></ListPreference>
<ListPreference android:key="auto_zoom_map_new" android:title="@string/auto_zoom_map"

View file

@ -29,6 +29,7 @@ import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.render.RenderingRulesStorage;
import android.content.Context;
import android.content.res.Configuration;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.net.ConnectivityManager;
@ -638,7 +639,7 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name
// cache of metrics constants as they are used very often
public final OsmandPreference<MetricsConstants> METRIC_SYSTEM = new EnumIntPreference<MetricsConstants>(
"default_metric_system", MetricsConstants.KILOMETERS_AND_METERS, MetricsConstants.values()){
"default_metric_system_new", MetricsConstants.KILOMETERS_AND_METERS, MetricsConstants.values()){
protected MetricsConstants getDefaultValue() {
return DRIVING_REGION.get().defMetrics;
};
@ -1532,7 +1533,16 @@ public class OsmandSettings {
public static final String VOICE_PROVIDER_NOT_USE = "VOICE_PROVIDER_NOT_USE";
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<String> VOICE_PROVIDER = new StringPreference("voice_provider", null).makeProfile();
// this value could localized
public final OsmandPreference<String> VOICE_PROVIDER = new StringPreference("voice_provider", null){
protected String getDefaultValue() {
Configuration config = ctx.getResources().getConfiguration();
if("de".equals(config.locale.getLanguage())) {
return "de-tts";
}
return "en-tts";
};
}.makeGlobal();
// this value string is synchronized with settings_pref.xml preference name
//public final OsmandPreference<Boolean> USE_COMPASS_IN_NAVIGATION = new BooleanPreference("use_compass_navigation", true).makeProfile().cache();

View file

@ -30,6 +30,7 @@ import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.view.View;
import android.widget.ArrayAdapter;
@ -64,7 +65,7 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im
profileSettings = profile;
}
public CheckBoxPreference registerBooleanPreference(OsmandPreference<Boolean> b, PreferenceScreen screen) {
public CheckBoxPreference registerBooleanPreference(OsmandPreference<Boolean> b, PreferenceGroup screen) {
CheckBoxPreference p = (CheckBoxPreference) screen.findPreference(b.getId());
p.setOnPreferenceChangeListener(this);
screenPreferences.put(b.getId(), p);
@ -164,7 +165,7 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im
return p;
}
public <T> void registerListPreference(OsmandPreference<T> b, PreferenceScreen screen, String[] names, T[] values) {
public <T> void registerListPreference(OsmandPreference<T> b, PreferenceGroup screen, String[] names, T[] values) {
ListPreference p = (ListPreference) screen.findPreference(b.getId());
prepareListPreference(b, names, values, p);
}

View file

@ -5,7 +5,9 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import net.osmand.CallbackWithObject;
import net.osmand.IProgress;
@ -15,7 +17,6 @@ import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.DrivingRegion;
import net.osmand.plus.OsmandSettings.MetricsConstants;
import net.osmand.plus.ProgressDialogImplementation;
import net.osmand.plus.R;
import net.osmand.plus.Version;
@ -41,6 +42,7 @@ import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.widget.EditText;
import android.widget.LinearLayout;
@ -50,6 +52,7 @@ import com.actionbarsherlock.view.Window;
public class SettingsGeneralActivity extends SettingsBaseActivity {
public static final String MORE_VALUE = "MORE_VALUE";
private Preference applicationDir;
private ListPreference applicationModePreference;
private ListPreference drivingRegionPreference;
@ -67,67 +70,14 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
PreferenceScreen screen = getPreferenceScreen();
settings = getMyApplication().getSettings();
if (!Version.isBlackberry(getMyApplication())) {
CheckBoxPreference nativeCheckbox = createCheckBoxPreference(settings.SAFE_MODE, R.string.safe_mode,
R.string.safe_mode_description);
// disable the checkbox if the library cannot be used
if ((NativeOsmandLibrary.isLoaded() && !NativeOsmandLibrary.isSupported()) || settings.NATIVE_RENDERING_FAILED.get()) {
nativeCheckbox.setEnabled(false);
nativeCheckbox.setChecked(true);
}
screen.addPreference(nativeCheckbox);
applicationDir = new Preference(this);
applicationDir.setTitle(R.string.application_dir);
applicationDir.setKey("external_storage_dir");
applicationDir.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public void showOtherDialog(){
AlertDialog.Builder editalert = new AlertDialog.Builder(SettingsGeneralActivity.this);
editalert.setTitle(R.string.application_dir);
final EditText input = new EditText(SettingsGeneralActivity.this);
input.setText(settings.getExternalStorageDirectory().getAbsolutePath());
input.setPadding(3, 3, 3, 3);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
input.setLayoutParams(lp);
settings.getExternalStorageDirectory().getAbsolutePath();
editalert.setView(input);
editalert.setNegativeButton(R.string.default_buttons_cancel, null);
editalert.setPositiveButton(R.string.default_buttons_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
warnAboutChangingStorage(input.getText().toString());
}
});
editalert.show();
}
@Override
public boolean onPreferenceClick(Preference preference) {
SuggestExternalDirectoryDialog.showDialog(SettingsGeneralActivity.this, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
showOtherDialog();
}
}, new CallbackWithObject<String>() {
@Override
public boolean processResult(String result) {
warnAboutChangingStorage(result);
return true;
}
});
return false;
}
});
screen.addPreference(applicationDir);
ApplicationMode[] appModes = ApplicationMode.values(settings).toArray(new ApplicationMode[0]);
entries = new String[appModes.length];
for(int i=0; i<entries.length; i++){
entries[i] = appModes[i].toHumanString(getMyApplication());
}
screen.addPreference(createCheckBoxPreference(settings.USE_KALMAN_FILTER_FOR_COMPASS, R.string.use_kalman_filter_compass, R.string.use_kalman_filter_compass_descr));
registerBooleanPreference(settings.USE_ENGLISH_NAMES, screen);
registerListPreference(settings.APPLICATION_MODE, screen, entries, appModes);
// List preferences
registerListPreference(settings.ROTATE_MAP, screen,
@ -138,23 +88,65 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
new String[] {getString(R.string.map_orientation_portrait), getString(R.string.map_orientation_landscape), getString(R.string.map_orientation_default)},
new Integer[] {ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED});
registerListPreference(
settings.OSMAND_THEME, screen,
new String[] { "Dark", "Light", "Dark ActionBar" }, new Integer[] { OsmandSettings.OSMAND_DARK_THEME,
OsmandSettings.OSMAND_LIGHT_THEME, OsmandSettings.OSMAND_LIGHT_DARK_ACTIONBAR_THEME });
addLocalPrefs((PreferenceGroup) screen.findPreference("localization"));
addVoicePrefs((PreferenceGroup) screen.findPreference("voice"));
addMiscPreferences((PreferenceGroup) screen.findPreference("misc"));
applicationModePreference = (ListPreference) screen.findPreference(settings.APPLICATION_MODE.getId());
applicationModePreference.setOnPreferenceChangeListener(this);
drivingRegionPreference = (ListPreference) screen.findPreference(settings.DRIVING_REGION.getId());
}
private void addVoicePrefs(PreferenceGroup cat) {
if (!Version.isBlackberry((OsmandApplication) getApplication())) {
ListPreference lp = createListPreference(
settings.AUDIO_STREAM_GUIDANCE,
new String[] { getString(R.string.voice_stream_music), getString(R.string.voice_stream_notification),
getString(R.string.voice_stream_voice_call) }, new Integer[] { AudioManager.STREAM_MUSIC,
AudioManager.STREAM_NOTIFICATION, AudioManager.STREAM_VOICE_CALL }, R.string.choose_audio_stream,
R.string.choose_audio_stream_descr);
final OnPreferenceChangeListener prev = lp.getOnPreferenceChangeListener();
lp.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
prev.onPreferenceChange(preference, newValue);
CommandPlayer player = getMyApplication().getPlayer();
if (player != null) {
player.updateAudioStream(settings.AUDIO_STREAM_GUIDANCE.get());
}
return true;
}
});
cat.addPreference(lp);
cat.addPreference(createCheckBoxPreference(settings.INTERRUPT_MUSIC, R.string.interrupt_music,
R.string.interrupt_music_descr));
}
}
private void addLocalPrefs(PreferenceGroup screen) {
String[] entries;
String[] entrieValues;
registerBooleanPreference(settings.USE_ENGLISH_NAMES, screen);
DrivingRegion[] drs = DrivingRegion.values();
entries = new String[drs.length];
for (int i = 0; i < entries.length; i++) {
entries[i] = getString(drs[i].name);
entries[i] = getString(drs[i].name) + " (" + drs[i].defMetrics.toHumanString(this) +")" ;
}
registerListPreference(settings.DRIVING_REGION, screen, entries, drs);
MetricsConstants[] mvls = MetricsConstants.values();
entries = new String[mvls.length];
for(int i=0; i<entries.length; i++){
entries[i] = mvls[i].toHumanString(getMyApplication());
}
registerListPreference(settings.METRIC_SYSTEM, screen, entries, mvls);
// MetricsConstants[] mvls = MetricsConstants.values();
// entries = new String[mvls.length];
// for(int i=0; i<entries.length; i++){
// entries[i] = mvls[i].toHumanString(getMyApplication());
// }
// registerListPreference(settings.METRIC_SYSTEM, screen, entries, mvls);
String incompleteSuffix = " (" + getString(R.string.incomplete_locale) + ")";
//getResources().getAssets().getLocales();
@ -207,54 +199,83 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
getString(R.string.lang_vi),
getString(R.string.lang_cy) + incompleteSuffix,};
registerListPreference(settings.PREFERRED_LOCALE, screen, entries, entrieValues);
}
ApplicationMode[] appModes = ApplicationMode.values(settings).toArray(new ApplicationMode[0]);
entries = new String[appModes.length];
for(int i=0; i<entries.length; i++){
entries[i] = appModes[i].toHumanString(getMyApplication());
}
registerListPreference(settings.APPLICATION_MODE, screen, entries, appModes);
if (!Version.isBlackberry((OsmandApplication) getApplication())) {
PreferenceScreen cat = getPreferenceScreen();
private void addMiscPreferences(PreferenceGroup misc) {
if (!Version.isBlackberry(getMyApplication())) {
applicationDir = new Preference(this);
applicationDir.setTitle(R.string.application_dir);
applicationDir.setKey("external_storage_dir");
applicationDir.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public void showOtherDialog(){
AlertDialog.Builder editalert = new AlertDialog.Builder(SettingsGeneralActivity.this);
editalert.setTitle(R.string.application_dir);
final EditText input = new EditText(SettingsGeneralActivity.this);
input.setText(settings.getExternalStorageDirectory().getAbsolutePath());
input.setPadding(3, 3, 3, 3);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
input.setLayoutParams(lp);
settings.getExternalStorageDirectory().getAbsolutePath();
editalert.setView(input);
editalert.setNegativeButton(R.string.default_buttons_cancel, null);
editalert.setPositiveButton(R.string.default_buttons_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
warnAboutChangingStorage(input.getText().toString());
}
});
editalert.show();
}
@Override
public boolean onPreferenceClick(Preference preference) {
SuggestExternalDirectoryDialog.showDialog(SettingsGeneralActivity.this, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
showOtherDialog();
}
}, new CallbackWithObject<String>() {
@Override
public boolean processResult(String result) {
warnAboutChangingStorage(result);
return true;
}
});
return false;
}
});
misc.addPreference(applicationDir);
CheckBoxPreference nativeCheckbox = createCheckBoxPreference(settings.SAFE_MODE, R.string.safe_mode,
R.string.safe_mode_description);
// disable the checkbox if the library cannot be used
if ((NativeOsmandLibrary.isLoaded() && !NativeOsmandLibrary.isSupported()) || settings.NATIVE_RENDERING_FAILED.get()) {
nativeCheckbox.setEnabled(false);
nativeCheckbox.setChecked(true);
}
misc.addPreference(nativeCheckbox);
int nav = getResources().getConfiguration().navigation;
if (nav == Configuration.NAVIGATION_DPAD || nav == Configuration.NAVIGATION_TRACKBALL ||
nav == Configuration.NAVIGATION_WHEEL ||
nav == Configuration.NAVIGATION_UNDEFINED) {
cat.addPreference(createCheckBoxPreference(settings.USE_TRACKBALL_FOR_MOVEMENTS, R.string.use_trackball,
misc.addPreference(createCheckBoxPreference(settings.USE_TRACKBALL_FOR_MOVEMENTS, R.string.use_trackball,
R.string.use_trackball_descr));
}
ListPreference lp = createListPreference(
settings.AUDIO_STREAM_GUIDANCE,
new String[] { getString(R.string.voice_stream_music), getString(R.string.voice_stream_notification),
getString(R.string.voice_stream_voice_call) }, new Integer[] { AudioManager.STREAM_MUSIC,
AudioManager.STREAM_NOTIFICATION, AudioManager.STREAM_VOICE_CALL }, R.string.choose_audio_stream,
R.string.choose_audio_stream_descr);
final OnPreferenceChangeListener prev = lp.getOnPreferenceChangeListener();
lp.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
prev.onPreferenceChange(preference, newValue);
CommandPlayer player = getMyApplication().getPlayer();
if (player != null) {
player.updateAudioStream(settings.AUDIO_STREAM_GUIDANCE.get());
}
return true;
}
});
cat.addPreference(lp);
cat.addPreference(createCheckBoxPreference(settings.INTERRUPT_MUSIC, R.string.interrupt_music,
R.string.interrupt_music_descr));
}
applicationModePreference = (ListPreference) screen.findPreference(settings.APPLICATION_MODE.getId());
applicationModePreference.setOnPreferenceChangeListener(this);
drivingRegionPreference = (ListPreference) screen.findPreference(settings.DRIVING_REGION.getId());
}
registerListPreference(
settings.OSMAND_THEME, misc,
new String[] { "Dark", "Light", "Dark ActionBar" }, new Integer[] { OsmandSettings.OSMAND_DARK_THEME,
OsmandSettings.OSMAND_LIGHT_THEME, OsmandSettings.OSMAND_LIGHT_DARK_ACTIONBAR_THEME });
misc.addPreference(createCheckBoxPreference(settings.USE_KALMAN_FILTER_FOR_COMPASS, R.string.use_kalman_filter_compass, R.string.use_kalman_filter_compass_descr));
}
@ -266,21 +287,30 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
}
public void updateAllSettings() {
reloadVoiceListPreference(getPreferenceScreen());
super.updateAllSettings();
updateApplicationDirTextAndSummary();
applicationModePreference.setTitle(getString(R.string.settings_preset) + " ["
+ settings.APPLICATION_MODE.get().toHumanString(getMyApplication()) + "]");
drivingRegionPreference.setTitle(getString(R.string.driving_region) + " ["
+ getString(settings.DRIVING_REGION.get().name) + "]");
// Too long
// metricsAndConstantsPreference.setTitle(getString(R.string.unit_of_length) + " ["
// + settings.METRIC_SYSTEM.get().toHumanString(getMyApplication()) + "]");
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String id = preference.getKey();
if (id.equals(settings.VOICE_PROVIDER.getId())) {
if (MORE_VALUE.equals(newValue)) {
// listPref.set(oldValue); // revert the change..
final Intent intent = new Intent(this, DownloadIndexActivity.class);
intent.putExtra(DownloadIndexActivity.FILTER_KEY, getString(R.string.voice));
startActivity(intent);
} else {
super.onPreferenceChange(preference, newValue);
getMyApplication().showDialogInitializingCommandPlayer(this, false);
}
return true;
}
super.onPreferenceChange(preference, newValue);
if (id.equals(settings.SAFE_MODE.getId())) {
if ((Boolean) newValue) {
@ -520,5 +550,38 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
}
private void reloadVoiceListPreference(PreferenceScreen screen) {
String[] entries;
String[] entrieValues;
Set<String> voiceFiles = getVoiceFiles();
entries = new String[voiceFiles.size() + 2];
entrieValues = new String[voiceFiles.size() + 2];
int k = 0;
// entries[k++] = getString(R.string.voice_not_specified);
entrieValues[k] = OsmandSettings.VOICE_PROVIDER_NOT_USE;
entries[k++] = getString(R.string.voice_not_use);
for (String s : voiceFiles) {
entries[k] = s;
entrieValues[k] = s;
k++;
}
entrieValues[k] = MORE_VALUE;
entries[k] = getString(R.string.install_more);
registerListPreference(settings.VOICE_PROVIDER, screen, entries, entrieValues);
}
private Set<String> getVoiceFiles() {
// read available voice data
File extStorage = getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR);
Set<String> setFiles = new LinkedHashSet<String>();
if (extStorage.exists()) {
for (File f : extStorage.listFiles()) {
if (f.isDirectory()) {
setFiles.add(f.getName());
}
}
}
return setFiles;
}
}

View file

@ -1,16 +1,11 @@
package net.osmand.plus.activities;
import java.io.File;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.osmand.IndexConstants;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.AutoZoomMap;
import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.R;
@ -22,7 +17,6 @@ import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.DialogInterface.OnMultiChoiceClickListener;
import android.content.Intent;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
@ -38,7 +32,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
private Preference speakAlarms;
private ListPreference routerServicePreference;
private ListPreference autoZoomMapPreference;
public static final String MORE_VALUE = "MORE_VALUE";
private List<RoutingParameter> avoidParameters = new ArrayList<RoutingParameter>();
private List<RoutingParameter> preferParameters = new ArrayList<RoutingParameter>();
@ -46,21 +40,6 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
public SettingsNavigationActivity() {
super(true);
}
private Set<String> getVoiceFiles() {
// read available voice data
File extStorage = getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR);
Set<String> setFiles = new LinkedHashSet<String>();
if (extStorage.exists()) {
for (File f : extStorage.listFiles()) {
if (f.isDirectory()) {
setFiles.add(f.getName());
}
}
}
return setFiles;
}
@Override
public void onCreate(Bundle savedInstanceState) {
@ -197,29 +176,10 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
}
private void reloadVoiceListPreference(PreferenceScreen screen) {
String[] entries;
String[] entrieValues;
Set<String> voiceFiles = getVoiceFiles();
entries = new String[voiceFiles.size() + 2];
entrieValues = new String[voiceFiles.size() + 2];
int k = 0;
// entries[k++] = getString(R.string.voice_not_specified);
entrieValues[k] = OsmandSettings.VOICE_PROVIDER_NOT_USE;
entries[k++] = getString(R.string.voice_not_use);
for (String s : voiceFiles) {
entries[k] = s;
entrieValues[k] = s;
k++;
}
entrieValues[k] = MORE_VALUE;
entries[k] = getString(R.string.install_more);
registerListPreference(settings.VOICE_PROVIDER, screen, entries, entrieValues);
}
public void updateAllSettings() {
reloadVoiceListPreference(getPreferenceScreen());
public void updateAllSettings() {
prepareRoutingPrefs(getPreferenceScreen());
super.updateAllSettings();
routerServicePreference.setSummary(getString(R.string.router_service_descr) + " [" + settings.ROUTER_SERVICE.get() + "]");
@ -228,18 +188,6 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String id = preference.getKey();
if (id.equals(settings.VOICE_PROVIDER.getId())) {
if (MORE_VALUE.equals(newValue)) {
// listPref.set(oldValue); // revert the change..
final Intent intent = new Intent(this, DownloadIndexActivity.class);
intent.putExtra(DownloadIndexActivity.FILTER_KEY, getString(R.string.voice));
startActivity(intent);
} else {
super.onPreferenceChange(preference, newValue);
getMyApplication().showDialogInitializingCommandPlayer(this, false);
}
return true;
}
super.onPreferenceChange(preference, newValue);
if (id.equals(settings.ROUTER_SERVICE.getId())) {
routerServicePreference.setSummary(getString(R.string.router_service_descr) + " ["