Coordinates fragment initial commit
This commit is contained in:
parent
221d6c8aac
commit
1a4fe63e87
9 changed files with 249 additions and 35 deletions
50
OsmAnd/res/layout/preference_radio_button.xml
Normal file
50
OsmAnd/res/layout/preference_radio_button.xml
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="72dp">
|
||||
|
||||
<RadioButton
|
||||
android:id="@android:id/checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:background="@null"
|
||||
android:clickable="true"
|
||||
android:focusable="true" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="marquee"
|
||||
android:fadingEdge="horizontal"
|
||||
android:singleLine="true"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
osmand:typeface="@string/font_roboto_regular" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="4"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
osmand:typeface="@string/font_roboto_regular" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -11,6 +11,9 @@
|
|||
Thx - Hardy
|
||||
|
||||
-->
|
||||
<string name="navigate_point_format_UTM">UTM</string>
|
||||
<string name="navigate_point_format_OLC">OLC</string>
|
||||
<string name="coordinates_format_info">The selected format will be applied to all places in the application.</string>
|
||||
<string name="pref_selected_by_default_for_profiles">This setting is selected by default for profiles: %s.</string>
|
||||
<string name="change_default_settings">Change default settings</string>
|
||||
<string name="discard_changes">Discard changes</string>
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
<Preference
|
||||
android:key="plugin_settings"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:selectable="false"
|
||||
android:summary="@string/list_of_installed_plugins"
|
||||
android:title="@string/plugin_settings" />
|
||||
|
|
47
OsmAnd/res/xml/coordinates_format.xml
Normal file
47
OsmAnd/res/xml/coordinates_format.xml
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<Preference
|
||||
android:key="coordinates_format_info"
|
||||
android:layout="@layout/preference_info"
|
||||
android:persistent="false"
|
||||
android:selectable="false"
|
||||
tools:title="@string/coordinates_format_info" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="format_degrees"
|
||||
android:layout="@layout/preference_radio_button"
|
||||
android:persistent="false"
|
||||
android:title="@string/navigate_point_format_D"
|
||||
tools:summary="@string/fast_route_mode_descr" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="format_minutes"
|
||||
android:layout="@layout/preference_radio_button"
|
||||
android:persistent="false"
|
||||
android:title="@string/navigate_point_format_DM"
|
||||
tools:summary="@string/fast_route_mode_descr" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="format_seconds"
|
||||
android:layout="@layout/preference_radio_button"
|
||||
android:persistent="false"
|
||||
android:title="@string/navigate_point_format_DMS"
|
||||
tools:summary="@string/fast_route_mode_descr" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="format_utm"
|
||||
android:layout="@layout/preference_radio_button"
|
||||
android:persistent="false"
|
||||
android:title="@string/navigate_point_format_UTM"
|
||||
tools:summary="@string/fast_route_mode_descr" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="format_olc"
|
||||
android:layout="@layout/preference_radio_button"
|
||||
android:persistent="false"
|
||||
android:title="@string/navigate_point_format_OLC"
|
||||
tools:summary="@string/fast_route_mode_descr" />
|
||||
|
||||
</PreferenceScreen>
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="appearance_category"
|
||||
|
@ -36,10 +37,11 @@
|
|||
android:layout="@layout/preference_with_descr"
|
||||
android:title="@string/unit_of_length" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.ListPreferenceEx
|
||||
<Preference
|
||||
android:key="coordinates_format"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:title="@string/coords_format" />
|
||||
android:title="@string/coords_format"
|
||||
app:fragment="net.osmand.plus.settings.CoordinatesFormatFragment" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.ListPreferenceEx
|
||||
android:key="angular_measurement"
|
||||
|
|
|
@ -3,17 +3,21 @@ package net.osmand.plus.settings;
|
|||
import android.content.Intent;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.aidl.OsmandAidlApi.ConnectedApp;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.PluginActivity;
|
||||
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.plus.profiles.EditProfileFragment.MAP_CONFIG;
|
||||
import static net.osmand.plus.profiles.EditProfileFragment.OPEN_CONFIG_ON_MAP;
|
||||
import static net.osmand.plus.profiles.EditProfileFragment.SELECTED_ITEM;
|
||||
|
||||
public class ConfigureProfileFragment extends BaseSettingsFragment {
|
||||
|
||||
public static final String TAG = "ConfigureProfileFragment";
|
||||
|
@ -34,19 +38,19 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
|
|||
|
||||
@Override
|
||||
protected void setupPreferences() {
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
|
||||
Preference generalSettings = findPreference("general_settings");
|
||||
Preference navigationSettings = findPreference("navigation_settings");
|
||||
Preference configureMap = findPreference("configure_map");
|
||||
|
||||
generalSettings.setIcon(getContentIcon(R.drawable.ic_action_settings));
|
||||
navigationSettings.setIcon(getContentIcon(R.drawable.ic_action_gdirections_dark));
|
||||
configureMap.setIcon(getContentIcon(R.drawable.ic_action_layers_dark));
|
||||
|
||||
setupConfigureMapPref();
|
||||
setupConnectedAppsPref();
|
||||
setupOsmandPluginsPref();
|
||||
}
|
||||
|
||||
private void setupConnectedAppsPref() {
|
||||
List<ConnectedApp> connectedApps = getMyApplication().getAidlApi().getConnectedApps();
|
||||
List<OsmandPlugin> plugins = OsmandPlugin.getVisiblePlugins();
|
||||
|
||||
for (ConnectedApp connectedApp : connectedApps) {
|
||||
SwitchPreference preference = new SwitchPreference(getContext());
|
||||
preference.setKey(connectedApp.getPack());
|
||||
|
@ -55,8 +59,12 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
|
|||
preference.setChecked(connectedApp.isEnabled());
|
||||
preference.setLayoutResource(R.layout.preference_dialog_and_switch);
|
||||
|
||||
screen.addPreference(preference);
|
||||
getPreferenceScreen().addPreference(preference);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupOsmandPluginsPref() {
|
||||
List<OsmandPlugin> plugins = OsmandPlugin.getVisiblePlugins();
|
||||
for (OsmandPlugin plugin : plugins) {
|
||||
SwitchPreferenceEx preference = new SwitchPreferenceEx(getContext());
|
||||
preference.setKey(plugin.getId());
|
||||
|
@ -69,10 +77,30 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
|
|||
intent.putExtra(PluginActivity.EXTRA_PLUGIN_ID, plugin.getId());
|
||||
preference.setIntent(intent);
|
||||
|
||||
screen.addPreference(preference);
|
||||
getPreferenceScreen().addPreference(preference);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupConfigureMapPref() {
|
||||
Preference configureMap = findPreference("configure_map");
|
||||
configureMap.setIcon(getContentIcon(R.drawable.ic_action_layers_dark));
|
||||
|
||||
Intent intent = new Intent(getActivity(), MapActivity.class);
|
||||
intent.putExtra(OPEN_CONFIG_ON_MAP, MAP_CONFIG);
|
||||
intent.putExtra(SELECTED_ITEM, getSelectedAppMode().getStringKey());
|
||||
configureMap.setIntent(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (preference.getKey().equals("configure_map")) {
|
||||
getActivity().getSupportFragmentManager().beginTransaction().remove(this).commit();
|
||||
return false;
|
||||
}
|
||||
|
||||
return super.onPreferenceClick(preference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String key = preference.getKey();
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.preference.CheckBoxPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
|
||||
public class CoordinatesFormatFragment extends BaseSettingsFragment {
|
||||
|
||||
public static final String TAG = "CoordinatesFormatFragment";
|
||||
|
||||
@Override
|
||||
protected int getPreferencesResId() {
|
||||
return R.xml.coordinates_format;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getToolbarResId() {
|
||||
return R.layout.profile_preference_toolbar;
|
||||
}
|
||||
|
||||
protected String getToolbarTitle() {
|
||||
return getString(R.string.coordinates_format);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupPreferences() {
|
||||
Context ctx = getContext();
|
||||
if (ctx == null) {
|
||||
return;
|
||||
}
|
||||
Preference generalSettings = findPreference("coordinates_format_info");
|
||||
generalSettings.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
|
||||
|
||||
CheckBoxPreference degreesPref = (CheckBoxPreference) findPreference("format_degrees");
|
||||
CheckBoxPreference minutesPref = (CheckBoxPreference) findPreference("format_minutes");
|
||||
CheckBoxPreference secondsPref = (CheckBoxPreference) findPreference("format_seconds");
|
||||
CheckBoxPreference utmPref = (CheckBoxPreference) findPreference("format_utm");
|
||||
CheckBoxPreference olcPref = (CheckBoxPreference) findPreference("format_olc");
|
||||
|
||||
degreesPref.setSummary(R.string.exit_at);
|
||||
minutesPref.setSummary(R.string.exit_at);
|
||||
secondsPref.setSummary(R.string.exit_at);
|
||||
utmPref.setSummary(R.string.exit_at);
|
||||
olcPref.setSummary(R.string.exit_at);
|
||||
|
||||
// settings.COORDINATES_FORMAT.get()
|
||||
|
||||
// coordinatesFormat.setEntries(new String[] {
|
||||
// PointDescription.formatToHumanString(ctx, PointDescription.FORMAT_DEGREES),
|
||||
// PointDescription.formatToHumanString(ctx, PointDescription.FORMAT_MINUTES),
|
||||
// PointDescription.formatToHumanString(ctx, PointDescription.FORMAT_SECONDS),
|
||||
// PointDescription.formatToHumanString(ctx, PointDescription.UTM_FORMAT),
|
||||
// PointDescription.formatToHumanString(ctx, PointDescription.OLC_FORMAT)
|
||||
// });
|
||||
// coordinatesFormat.setEntryValues(new Integer[] {
|
||||
// PointDescription.FORMAT_DEGREES,
|
||||
// PointDescription.FORMAT_MINUTES,
|
||||
// PointDescription.FORMAT_SECONDS,
|
||||
// PointDescription.UTM_FORMAT,
|
||||
// PointDescription.OLC_FORMAT
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
String key = preference.getKey();
|
||||
|
||||
for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) {
|
||||
Preference pref = getPreferenceScreen().getPreference(i);
|
||||
if (pref instanceof CheckBoxPreference) {
|
||||
CheckBoxPreference checkBoxPreference = ((CheckBoxPreference) pref);
|
||||
if (!checkBoxPreference.getKey().equals(key)) {
|
||||
checkBoxPreference.setChecked(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.onPreferenceClick(preference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String key = preference.getKey();
|
||||
|
||||
return super.onPreferenceChange(preference, newValue);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
@ -155,28 +154,24 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
|
|||
}
|
||||
|
||||
private void setupCoordinatesFormatPref() {
|
||||
Context ctx = getContext();
|
||||
if (ctx == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ListPreferenceEx coordinatesFormat = (ListPreferenceEx) findPreference(settings.COORDINATES_FORMAT.getId());
|
||||
Preference coordinatesFormat = findPreference(settings.COORDINATES_FORMAT.getId());
|
||||
coordinatesFormat.setIcon(getContentIcon(R.drawable.ic_action_coordinates_widget));
|
||||
coordinatesFormat.setSummary(PointDescription.formatToHumanString(app, settings.COORDINATES_FORMAT.get()));
|
||||
|
||||
coordinatesFormat.setEntries(new String[] {
|
||||
PointDescription.formatToHumanString(ctx, PointDescription.FORMAT_DEGREES),
|
||||
PointDescription.formatToHumanString(ctx, PointDescription.FORMAT_MINUTES),
|
||||
PointDescription.formatToHumanString(ctx, PointDescription.FORMAT_SECONDS),
|
||||
PointDescription.formatToHumanString(ctx, PointDescription.UTM_FORMAT),
|
||||
PointDescription.formatToHumanString(ctx, PointDescription.OLC_FORMAT)
|
||||
});
|
||||
coordinatesFormat.setEntryValues(new Integer[] {
|
||||
PointDescription.FORMAT_DEGREES,
|
||||
PointDescription.FORMAT_MINUTES,
|
||||
PointDescription.FORMAT_SECONDS,
|
||||
PointDescription.UTM_FORMAT,
|
||||
PointDescription.OLC_FORMAT
|
||||
});
|
||||
// coordinatesFormat.setEntries(new String[] {
|
||||
// PointDescription.formatToHumanString(ctx, PointDescription.FORMAT_DEGREES),
|
||||
// PointDescription.formatToHumanString(ctx, PointDescription.FORMAT_MINUTES),
|
||||
// PointDescription.formatToHumanString(ctx, PointDescription.FORMAT_SECONDS),
|
||||
// PointDescription.formatToHumanString(ctx, PointDescription.UTM_FORMAT),
|
||||
// PointDescription.formatToHumanString(ctx, PointDescription.OLC_FORMAT)
|
||||
// });
|
||||
// coordinatesFormat.setEntryValues(new Integer[] {
|
||||
// PointDescription.FORMAT_DEGREES,
|
||||
// PointDescription.FORMAT_MINUTES,
|
||||
// PointDescription.FORMAT_SECONDS,
|
||||
// PointDescription.UTM_FORMAT,
|
||||
// PointDescription.OLC_FORMAT
|
||||
// });
|
||||
}
|
||||
|
||||
private void setupAngularUnitsPref() {
|
||||
|
|
|
@ -63,7 +63,6 @@ public class SettingsMainFragment extends BaseSettingsFragment {
|
|||
Intent intent = new Intent(getActivity(), MapActivity.class);
|
||||
intent.putExtra(OPEN_CONFIG_ON_MAP, MAP_CONFIG);
|
||||
intent.putExtra(SELECTED_ITEM, getSelectedAppMode().getStringKey());
|
||||
startActivity(intent);
|
||||
browseMap.setIntent(intent);
|
||||
}
|
||||
|
||||
|
@ -91,7 +90,7 @@ public class SettingsMainFragment extends BaseSettingsFragment {
|
|||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (preference.getKey().equals("browse_map")) {
|
||||
getActivity().getSupportFragmentManager().beginTransaction().remove(this).commit();
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return super.onPreferenceClick(preference);
|
||||
|
|
Loading…
Reference in a new issue