forked from organicmaps/organicmaps
[android] Call measurement units dialog from settings activity.
This commit is contained in:
parent
c23810103e
commit
db57051cb7
16 changed files with 202 additions and 7 deletions
|
@ -2,5 +2,11 @@
|
|||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<Preference
|
||||
android:title="@string/maps_storage"
|
||||
android:summary="@string/maps_storage_summary"
|
||||
android:key="StorageActivity"/>
|
||||
<Preference
|
||||
android:title="@string/measurement_units"
|
||||
android:summary="@string/measurement_units_summary"
|
||||
android:key="MeasurementUnits"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
|
|
@ -194,6 +194,8 @@
|
|||
<string name="settings">Настройки</string>
|
||||
<!-- Header of settings activity where user defines storage path -->
|
||||
<string name="maps_storage">Хранилище карт</string>
|
||||
<!-- Summary of maps storage settings -->
|
||||
<string name="maps_storage_summary">Выбрать доступное хранилище для карт на устройстве</string>
|
||||
<!-- Question dialog for transferring maps from one storage to another -->
|
||||
<string name="move_maps">Переместить карты?</string>
|
||||
<!-- Ask to wait user several minutes (some long process in modal dialog). -->
|
||||
|
@ -204,4 +206,8 @@
|
|||
<string name="bookmarks_in_pro_version">Закладки доступны в полной верии MapsWithMe. Скачать ее прямо сейчас?</string>
|
||||
<!-- Toast which is displayed when GPS has been deactivated -->
|
||||
<string name="gps_is_disabled_long_text">GPS-позиционирование выключено. Пожалуйста, включите его в настройках для удобного использования программы.</string>
|
||||
<!-- Measurement units title in settings activity -->
|
||||
<string name="measurement_units">Единицы измерения</string>
|
||||
<!-- Measurement units summary in settings activity -->
|
||||
<string name="measurement_units_summary">Выбрать единицы измерения расстояний</string>
|
||||
</resources>
|
||||
|
|
|
@ -198,6 +198,8 @@
|
|||
<string name="settings">Settings</string>
|
||||
<!-- Header of settings activity where user defines storage path -->
|
||||
<string name="maps_storage">Maps storage</string>
|
||||
<!-- Summary of maps storage settings -->
|
||||
<string name="maps_storage_summary">Select flash storage for maps on device</string>
|
||||
<!-- Question dialog for transferring maps from one storage to another -->
|
||||
<string name="move_maps">Move maps?</string>
|
||||
<!-- Ask to wait user several minutes (some long process in modal dialog). -->
|
||||
|
@ -208,4 +210,8 @@
|
|||
<string name="bookmarks_in_pro_version">Bookmarks are available in the full version of MapsWithMe. Get it right now?</string>
|
||||
<!-- Toast which is displayed when GPS has been deactivated -->
|
||||
<string name="gps_is_disabled_long_text">GPS is disabled. Please enable it in Settings.</string>
|
||||
<!-- Measurement units title in settings activity -->
|
||||
<string name="measurement_units">Measurement units</string>
|
||||
<!-- Measurement units summary in settings activity -->
|
||||
<string name="measurement_units_summary">Select preferred distance units</string>
|
||||
</resources>
|
||||
|
|
|
@ -19,8 +19,9 @@ public class SettingsActivity extends PreferenceActivity
|
|||
|
||||
addPreferencesFromResource(R.layout.preferences);
|
||||
|
||||
Preference pref = findPreference("StorageActivity");
|
||||
final Activity parent = this;
|
||||
|
||||
Preference pref = findPreference("StorageActivity");
|
||||
pref.setOnPreferenceClickListener(new OnPreferenceClickListener()
|
||||
{
|
||||
@Override
|
||||
|
@ -30,5 +31,16 @@ public class SettingsActivity extends PreferenceActivity
|
|||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
pref = findPreference("MeasurementUnits");
|
||||
pref.setOnPreferenceClickListener(new OnPreferenceClickListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference)
|
||||
{
|
||||
UnitLocale.showUnitsSelectDlg(parent);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,81 @@
|
|||
package com.mapswithme.maps;
|
||||
package com.mapswithme.maps.settings;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
|
||||
public class UnitLocale
|
||||
{
|
||||
public static int METRIC = 0;
|
||||
public static int IMPERIAL = 1;
|
||||
/// @note This constants should be equal with platform/settings.hpp
|
||||
public static final int UNITS_UNDEFINED = -1;
|
||||
public static final int UNITS_METRIC = 0;
|
||||
public static final int UNITS_YARD = 1;
|
||||
public static final int UNITS_FOOT = 2;
|
||||
|
||||
public static int getCurrent()
|
||||
public static int getDefaultUnits()
|
||||
{
|
||||
final String code = Locale.getDefault().getCountry();
|
||||
// USA, UK, Liberia, Burma
|
||||
String arr[] = { "US", "GB", "LR", "MM" };
|
||||
for (String s : arr)
|
||||
if (s.equalsIgnoreCase(code))
|
||||
return IMPERIAL;
|
||||
return UNITS_FOOT;
|
||||
|
||||
return METRIC;
|
||||
return UNITS_METRIC;
|
||||
}
|
||||
|
||||
private static native int getCurrentUnits();
|
||||
private static native void setCurrentUnits(int u);
|
||||
|
||||
public static void showUnitsSelectDlg(Activity parent)
|
||||
{
|
||||
new AlertDialog.Builder(parent)
|
||||
.setCancelable(false)
|
||||
.setMessage(parent.getString(R.string.which_measurement_system))
|
||||
.setNegativeButton(parent.getString(R.string.miles), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
dialog.dismiss();
|
||||
setCurrentUnits(UNITS_FOOT);
|
||||
}
|
||||
})
|
||||
.setPositiveButton(parent.getString(R.string.kilometres), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
dlg.dismiss();
|
||||
setCurrentUnits(UNITS_METRIC);
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
|
||||
public static void initializeCurrentUnits(Activity parent)
|
||||
{
|
||||
final int u = getCurrentUnits();
|
||||
if (u == UNITS_UNDEFINED)
|
||||
{
|
||||
// Checking system-default measurement system
|
||||
if (getDefaultUnits() == UNITS_METRIC)
|
||||
{
|
||||
setCurrentUnits(UNITS_METRIC);
|
||||
}
|
||||
else
|
||||
{
|
||||
showUnitsSelectDlg(parent);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setCurrentUnits(u);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -309,6 +309,9 @@
|
|||
/* Header of settings activity where user defines storage path */
|
||||
"maps_storage" = "Kartenspeicher";
|
||||
|
||||
/* Summary of maps storage settings */
|
||||
"maps_storage_summary" = "Select flash storage for maps on device";
|
||||
|
||||
/* Question dialog for transferring maps from one storage to another */
|
||||
"move_maps" = "Karten verschieben?";
|
||||
|
||||
|
@ -323,3 +326,9 @@
|
|||
|
||||
/* Toast which is displayed when GPS has been deactivated */
|
||||
"gps_is_disabled_long_text" = "GPS ist deaktiviert. Schalten Sie sie bitte ein, um das Programm bequem nutzen zu können.";
|
||||
|
||||
/* Measurement units title in settings activity */
|
||||
"measurement_units" = "Measurement units";
|
||||
|
||||
/* Measurement units summary in settings activity */
|
||||
"measurement_units_summary" = "Select preferred distance units";
|
||||
|
|
|
@ -309,6 +309,9 @@
|
|||
/* Header of settings activity where user defines storage path */
|
||||
"maps_storage" = "Maps storage";
|
||||
|
||||
/* Summary of maps storage settings */
|
||||
"maps_storage_summary" = "Select flash storage for maps on device";
|
||||
|
||||
/* Question dialog for transferring maps from one storage to another */
|
||||
"move_maps" = "Move maps?";
|
||||
|
||||
|
@ -323,3 +326,9 @@
|
|||
|
||||
/* Toast which is displayed when GPS has been deactivated */
|
||||
"gps_is_disabled_long_text" = "GPS is disabled. Please enable it in Settings.";
|
||||
|
||||
/* Measurement units title in settings activity */
|
||||
"measurement_units" = "Measurement units";
|
||||
|
||||
/* Measurement units summary in settings activity */
|
||||
"measurement_units_summary" = "Select preferred distance units";
|
||||
|
|
|
@ -309,6 +309,9 @@
|
|||
/* Header of settings activity where user defines storage path */
|
||||
"maps_storage" = "Almacenamiento de mapas";
|
||||
|
||||
/* Summary of maps storage settings */
|
||||
"maps_storage_summary" = "Select flash storage for maps on device";
|
||||
|
||||
/* Question dialog for transferring maps from one storage to another */
|
||||
"move_maps" = "¿Mover mapas?";
|
||||
|
||||
|
@ -323,3 +326,9 @@
|
|||
|
||||
/* Toast which is displayed when GPS has been deactivated */
|
||||
"gps_is_disabled_long_text" = "El GPS está inhabilitado. Por favor, activelo en los ajustes.";
|
||||
|
||||
/* Measurement units title in settings activity */
|
||||
"measurement_units" = "Measurement units";
|
||||
|
||||
/* Measurement units summary in settings activity */
|
||||
"measurement_units_summary" = "Select preferred distance units";
|
||||
|
|
|
@ -309,6 +309,9 @@
|
|||
/* Header of settings activity where user defines storage path */
|
||||
"maps_storage" = "Sauvegarde des cartes";
|
||||
|
||||
/* Summary of maps storage settings */
|
||||
"maps_storage_summary" = "Select flash storage for maps on device";
|
||||
|
||||
/* Question dialog for transferring maps from one storage to another */
|
||||
"move_maps" = "Bouger les cartes?";
|
||||
|
||||
|
@ -323,3 +326,9 @@
|
|||
|
||||
/* Toast which is displayed when GPS has been deactivated */
|
||||
"gps_is_disabled_long_text" = "GPS désactivé. Veuillez s'il vous plaît la mettre en prise pour la commode utilisation du programme.";
|
||||
|
||||
/* Measurement units title in settings activity */
|
||||
"measurement_units" = "Measurement units";
|
||||
|
||||
/* Measurement units summary in settings activity */
|
||||
"measurement_units_summary" = "Select preferred distance units";
|
||||
|
|
|
@ -309,6 +309,9 @@
|
|||
/* Header of settings activity where user defines storage path */
|
||||
"maps_storage" = "Maps storage";
|
||||
|
||||
/* Summary of maps storage settings */
|
||||
"maps_storage_summary" = "Select flash storage for maps on device";
|
||||
|
||||
/* Question dialog for transferring maps from one storage to another */
|
||||
"move_maps" = "Move maps?";
|
||||
|
||||
|
@ -323,3 +326,9 @@
|
|||
|
||||
/* Toast which is displayed when GPS has been deactivated */
|
||||
"gps_is_disabled_long_text" = "GPS is disabled. Please enable it in Settings.";
|
||||
|
||||
/* Measurement units title in settings activity */
|
||||
"measurement_units" = "Measurement units";
|
||||
|
||||
/* Measurement units summary in settings activity */
|
||||
"measurement_units_summary" = "Select preferred distance units";
|
||||
|
|
|
@ -309,6 +309,9 @@
|
|||
/* Header of settings activity where user defines storage path */
|
||||
"maps_storage" = "地図収納";
|
||||
|
||||
/* Summary of maps storage settings */
|
||||
"maps_storage_summary" = "Select flash storage for maps on device";
|
||||
|
||||
/* Question dialog for transferring maps from one storage to another */
|
||||
"move_maps" = "地図を移動しますか?";
|
||||
|
||||
|
@ -323,3 +326,9 @@
|
|||
|
||||
/* Toast which is displayed when GPS has been deactivated */
|
||||
"gps_is_disabled_long_text" = "GPSが無効です。設定画面から有効にして下さい。";
|
||||
|
||||
/* Measurement units title in settings activity */
|
||||
"measurement_units" = "Measurement units";
|
||||
|
||||
/* Measurement units summary in settings activity */
|
||||
"measurement_units_summary" = "Select preferred distance units";
|
||||
|
|
|
@ -309,6 +309,9 @@
|
|||
/* Header of settings activity where user defines storage path */
|
||||
"maps_storage" = "지도 저장소";
|
||||
|
||||
/* Summary of maps storage settings */
|
||||
"maps_storage_summary" = "Select flash storage for maps on device";
|
||||
|
||||
/* Question dialog for transferring maps from one storage to another */
|
||||
"move_maps" = "지도를 이동합니까?";
|
||||
|
||||
|
@ -323,3 +326,9 @@
|
|||
|
||||
/* Toast which is displayed when GPS has been deactivated */
|
||||
"gps_is_disabled_long_text" = "GPS가 사용 중지되었습니다. 설정에서 이를 작동시켜 주시기 바랍니다.";
|
||||
|
||||
/* Measurement units title in settings activity */
|
||||
"measurement_units" = "Measurement units";
|
||||
|
||||
/* Measurement units summary in settings activity */
|
||||
"measurement_units_summary" = "Select preferred distance units";
|
||||
|
|
|
@ -309,6 +309,9 @@
|
|||
/* Header of settings activity where user defines storage path */
|
||||
"maps_storage" = "Kaarten bewaren";
|
||||
|
||||
/* Summary of maps storage settings */
|
||||
"maps_storage_summary" = "Select flash storage for maps on device";
|
||||
|
||||
/* Question dialog for transferring maps from one storage to another */
|
||||
"move_maps" = "Kaarten verplaatsen?";
|
||||
|
||||
|
@ -323,3 +326,9 @@
|
|||
|
||||
/* Toast which is displayed when GPS has been deactivated */
|
||||
"gps_is_disabled_long_text" = "GPS is uitgeschakeld. Schakel ze in bij Instellingen.";
|
||||
|
||||
/* Measurement units title in settings activity */
|
||||
"measurement_units" = "Measurement units";
|
||||
|
||||
/* Measurement units summary in settings activity */
|
||||
"measurement_units_summary" = "Select preferred distance units";
|
||||
|
|
|
@ -309,6 +309,9 @@
|
|||
/* Header of settings activity where user defines storage path */
|
||||
"maps_storage" = "Хранилище карт";
|
||||
|
||||
/* Summary of maps storage settings */
|
||||
"maps_storage_summary" = "Выбрать доступное хранилище для карт на устройстве";
|
||||
|
||||
/* Question dialog for transferring maps from one storage to another */
|
||||
"move_maps" = "Переместить карты?";
|
||||
|
||||
|
@ -323,3 +326,9 @@
|
|||
|
||||
/* Toast which is displayed when GPS has been deactivated */
|
||||
"gps_is_disabled_long_text" = "GPS-позиционирование выключено. Пожалуйста, включите его в настройках для удобного использования программы.";
|
||||
|
||||
/* Measurement units title in settings activity */
|
||||
"measurement_units" = "Единицы измерения";
|
||||
|
||||
/* Measurement units summary in settings activity */
|
||||
"measurement_units_summary" = "Выбрать единицы измерения расстояний";
|
||||
|
|
|
@ -309,6 +309,9 @@
|
|||
/* Header of settings activity where user defines storage path */
|
||||
"maps_storage" = "Пам'ять для карт";
|
||||
|
||||
/* Summary of maps storage settings */
|
||||
"maps_storage_summary" = "Select flash storage for maps on device";
|
||||
|
||||
/* Question dialog for transferring maps from one storage to another */
|
||||
"move_maps" = "Перемістити карти?";
|
||||
|
||||
|
@ -323,3 +326,9 @@
|
|||
|
||||
/* Toast which is displayed when GPS has been deactivated */
|
||||
"gps_is_disabled_long_text" = "GPS вимкнено в налаштуваннях пристрою. Будь ласка, увімкніть її для зручного використання програми.";
|
||||
|
||||
/* Measurement units title in settings activity */
|
||||
"measurement_units" = "Measurement units";
|
||||
|
||||
/* Measurement units summary in settings activity */
|
||||
"measurement_units_summary" = "Select preferred distance units";
|
||||
|
|
15
strings.txt
15
strings.txt
|
@ -1256,6 +1256,11 @@
|
|||
ko = 지도 저장소
|
||||
cs = Úložiště map
|
||||
nl = Kaarten bewaren
|
||||
[maps_storage_summary]
|
||||
en = Select flash storage for maps on device
|
||||
tags = android
|
||||
comment = Summary of maps storage settings
|
||||
ru = Выбрать доступное хранилище для карт на устройстве
|
||||
[move_maps]
|
||||
en = Move maps?
|
||||
tags = android
|
||||
|
@ -1321,3 +1326,13 @@
|
|||
ko = GPS가 사용 중지되었습니다. 설정에서 이를 작동시켜 주시기 바랍니다.
|
||||
cs = Navigace GPS deaktivována. Prosím povol je v Nastavení.
|
||||
nl = GPS is uitgeschakeld. Schakel ze in bij Instellingen.
|
||||
[measurement_units]
|
||||
en = Measurement units
|
||||
tags = all
|
||||
comment = Measurement units title in settings activity
|
||||
ru = Единицы измерения
|
||||
[measurement_units_summary]
|
||||
en = Select preferred distance units
|
||||
tags = all
|
||||
comment = Measurement units summary in settings activity
|
||||
ru = Выбрать единицы измерения расстояний
|
||||
|
|
Loading…
Add table
Reference in a new issue