Merge branch 'master' into imp_exp_osm_note
# Conflicts: # OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java # OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java # OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java
This commit is contained in:
commit
240d4466a2
62 changed files with 930 additions and 3062 deletions
|
@ -484,10 +484,6 @@
|
|||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<activity android:name="net.osmand.plus.activities.SettingsActivity" android:label="@string/shared_string_settings" android:configChanges="keyboardHidden|orientation" />
|
||||
<activity android:name="net.osmand.plus.activities.SettingsGeneralActivity" android:configChanges="keyboardHidden|orientation" />
|
||||
<activity android:name="net.osmand.plus.activities.SettingsNavigationActivity" android:configChanges="keyboardHidden|orientation" />
|
||||
|
||||
<activity android:name="net.osmand.plus.activities.search.SearchActivity" android:label="@string/search_activity" />
|
||||
<activity android:name="net.osmand.plus.activities.FavoritesListActivity" android:label="@string/favourites_list_activity" />
|
||||
<activity android:name=".myplaces.FavoritesActivity" android:windowSoftInputMode="adjustPan" />
|
||||
|
|
|
@ -1,51 +1,54 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp">
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/feedbackButton"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/feedback"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
tools:drawableTop="@drawable/ic_action_message"/>
|
||||
android:textColor="?android:textColorSecondary"
|
||||
tools:drawableTop="@drawable/ic_action_message" />
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/divider_color"/>
|
||||
android:background="?attr/divider_color" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/contactUsButton"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/contact_us"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
tools:drawableTop="@drawable/ic_action_message"/>
|
||||
android:textColor="?android:textColorSecondary"
|
||||
tools:drawableTop="@drawable/ic_action_message" />
|
||||
|
||||
<View
|
||||
android:id="@+id/sendLogButtonDiv"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/divider_color"/>
|
||||
android:background="?attr/divider_color" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/sendLogButton"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/send_log"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
tools:drawableTop="@drawable/ic_crashlog"/>
|
||||
android:textColor="?android:textColorSecondary"
|
||||
tools:drawableTop="@drawable/ic_crashlog" />
|
||||
|
||||
</LinearLayout>
|
|
@ -1,32 +0,0 @@
|
|||
<?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="default_application_mode_string"></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>
|
||||
<Preference android:key="default_driving_region" android:title="@string/driving_region" android:summary="@string/driving_region_descr"></Preference>
|
||||
<!-- ListPreference android:key="map_preferred_locale" android:title="@string/map_preferred_locale" android:summary="@string/map_preferred_locale_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="coordinates_format" android:title="@string/coords_format" android:summary="@string/coords_format_descr"></ListPreference>
|
||||
<ListPreference android:key="angular_measurement" android:title="@string/angular_measeurement" android:summary="@string/angular_measeurement_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>
|
||||
<ListPreference android:key="external_input_device" android:title="@string/external_input_device" android:summary="@string/external_input_device_descr"></ListPreference>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/settings_privacy">
|
||||
<PreferenceScreen android:title="@string/proxy_pref_title" android:description="@string/proxy_pref_descr" android:key="proxy">
|
||||
<CheckBoxPreference
|
||||
android:key="enable_proxy" android:title="@string/enable_proxy_title" android:summary="@string/enable_proxy_descr" android:defaultValue="false" />
|
||||
<EditTextPreference
|
||||
android:key="proxy_host" android:title="@string/proxy_host_title" android:summary="@string/proxy_host_descr" android:dependency="enable_proxy"
|
||||
android:defaultValue="127.0.0.1" />
|
||||
<EditTextPreference
|
||||
android:key="proxy_port" android:title="@string/proxy_port_title" android:summary="@string/proxy_port_descr" android:dependency="enable_proxy"
|
||||
android:defaultValue="8118" />
|
||||
</PreferenceScreen>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
|
@ -1,106 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="routing_preferences"
|
||||
android:title="@string/routing_preferences_descr">
|
||||
<CheckBoxPreference
|
||||
android:key="fast_route_mode"
|
||||
android:summary="@string/fast_route_mode_descr"
|
||||
android:title="@string/fast_route_mode"/>
|
||||
<Preference
|
||||
android:key="avoid_in_routing"
|
||||
android:summary="@string/avoid_in_routing_descr_"
|
||||
android:title="@string/avoid_in_routing_title"/>
|
||||
<Preference
|
||||
android:key="prefer_in_routing"
|
||||
android:summary="@string/prefer_in_routing_descr"
|
||||
android:title="@string/prefer_in_routing_title"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="guidance_preferences"
|
||||
android:title="@string/guidance_preferences_descr">
|
||||
<ListPreference
|
||||
android:key="auto_follow_route"
|
||||
android:summary="@string/choose_auto_follow_route_descr"
|
||||
android:title="@string/choose_auto_follow_route"/>
|
||||
<Preference
|
||||
android:key="auto_zoom_map_on_off"
|
||||
android:summary="@string/auto_zoom_map_descr"
|
||||
android:title="@string/auto_zoom_map"/>
|
||||
<CheckBoxPreference
|
||||
android:key="snap_to_road"
|
||||
android:summary="@string/snap_to_road_descr"
|
||||
android:title="@string/snap_to_road"/>
|
||||
<CheckBoxPreference
|
||||
android:key="enable_time_conditional_routing"
|
||||
android:title="@string/temporary_conditional_routing"/>
|
||||
<Preference
|
||||
android:key="show_routing_alarms"
|
||||
android:summary="@string/show_warnings_descr"
|
||||
android:title="@string/show_warnings_title"/>
|
||||
<Preference
|
||||
android:key="speak_routing_alarms"
|
||||
android:summary="@string/speak_descr"
|
||||
android:title="@string/speak_title"/>
|
||||
<ListPreference
|
||||
android:key="keep_informing"
|
||||
android:summary="@string/keep_informing_descr"
|
||||
android:title="@string/keep_informing"/>
|
||||
<ListPreference
|
||||
android:key="arrival_distance_factor"
|
||||
android:summary="@string/arrival_distance_descr"
|
||||
android:title="@string/arrival_distance"/>
|
||||
<ListPreference
|
||||
android:key="default_speed_system"
|
||||
android:summary="@string/default_speed_system_descr"
|
||||
android:title="@string/default_speed_system"/>
|
||||
<ListPreference
|
||||
android:key="speed_limit_exceed"
|
||||
android:summary="@string/speed_limit_exceed_message"
|
||||
android:title="@string/speed_limit_exceed"/>
|
||||
<ListPreference
|
||||
android:key="speed_for_map_to_direction_of_movement"
|
||||
android:summary="@string/map_orientation_change_in_accordance_with_speed_descr"
|
||||
android:title="@string/map_orientation_change_in_accordance_with_speed"/>
|
||||
<!--
|
||||
<CheckBoxPreference android:title="@string/show_zoom_buttons_navigation" android:summary="@string/show_zoom_buttons_navigation_descr" android:key="show_zoom_buttons_navigation" />
|
||||
-->
|
||||
<!--
|
||||
<ListPreference
|
||||
android:key="delay_to_start_navigation"
|
||||
android:title="@string/delay_to_start_navigation"
|
||||
android:summary="@string/delay_to_start_navigation_descr" />
|
||||
-->
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="turn_screen_on"
|
||||
android:title="@string/wake_on_voice">
|
||||
|
||||
<Preference
|
||||
android:selectable="false"
|
||||
android:summary="@string/wake_on_voice_descr" />
|
||||
|
||||
<ListPreference
|
||||
android:key="turn_screen_on_time_int"
|
||||
android:summary="@string/turn_screen_on_time_descr"
|
||||
android:title="@string/shared_string_time"/>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="turn_screen_on_sensor"
|
||||
android:summary="@string/turn_screen_on_sensor_descr"
|
||||
android:title="@string/turn_screen_on_sensor"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="voice"
|
||||
android:title="@string/voice_pref_title">
|
||||
<ListPreference
|
||||
android:key="voice_provider"
|
||||
android:summary="@string/voice_provider_descr"
|
||||
android:title="@string/voice_provider"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
|
@ -53,6 +53,13 @@
|
|||
android:title="@string/import_profile"
|
||||
tools:icon="@drawable/ic_action_import" />
|
||||
|
||||
<Preference
|
||||
android:key="export_profiles"
|
||||
android:layout="@layout/preference_button"
|
||||
android:persistent="false"
|
||||
android:title="@string/shared_string_export"
|
||||
tools:icon="@drawable/ic_action_export" />
|
||||
|
||||
<Preference
|
||||
android:key="reorder_profiles"
|
||||
android:layout="@layout/preference_button"
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<Preference android:key="general_settings" android:title="@string/general_settings_2" android:summary="@string/general_settings_descr"/>
|
||||
<Preference android:key="routing_settings" android:title="@string/routing_settings_2" android:summary="@string/routing_settings_descr"/>
|
||||
<Preference android:key="subscription_settings" android:title="@string/osm_live_subscription" android:summary="@string/osm_live_subscription_desc"/>
|
||||
<Preference android:key="privacy_and_security" android:title="@string/settings_privacy_and_security" android:summary="@string/settings_privacy_and_security_desc"/>
|
||||
<PreferenceCategory android:key="plugin_settings" android:title="@string/plugin_settings" />
|
||||
</PreferenceScreen>
|
|
@ -67,6 +67,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -884,4 +885,65 @@ public class AndroidUtils {
|
|||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static String getRoutingStringPropertyName(Context ctx, String propertyName, String defValue) {
|
||||
String value = getStringByProperty(ctx, "routing_attr_" + propertyName + "_name");
|
||||
return value != null ? value : defValue;
|
||||
}
|
||||
|
||||
public static String getRoutingStringPropertyDescription(Context ctx, String propertyName, String defValue) {
|
||||
String value = getStringByProperty(ctx, "routing_attr_" + propertyName + "_description");
|
||||
return value != null ? value : defValue;
|
||||
}
|
||||
|
||||
public static String getRenderingStringPropertyName(Context ctx, String propertyName, String defValue) {
|
||||
String value = getStringByProperty(ctx, "rendering_attr_" + propertyName + "_name");
|
||||
return value != null ? value : defValue;
|
||||
}
|
||||
|
||||
public static String getRenderingStringPropertyDescription(Context ctx, String propertyName, String defValue) {
|
||||
String value = getStringByProperty(ctx, "rendering_attr_" + propertyName + "_description");
|
||||
return value != null ? value : defValue;
|
||||
}
|
||||
|
||||
public static String getIconStringPropertyName(Context ctx, String propertyName) {
|
||||
String value = getStringByProperty(ctx, "icon_group_" + propertyName);
|
||||
return value != null ? value : propertyName;
|
||||
}
|
||||
|
||||
public static String getRenderingStringPropertyValue(Context ctx, String propertyValue) {
|
||||
if (propertyValue == null) {
|
||||
return "";
|
||||
}
|
||||
String propertyValueReplaced = propertyValue.replaceAll("\\s+", "_");
|
||||
String value = getStringByProperty(ctx, "rendering_value_" + propertyValueReplaced + "_name");
|
||||
return value != null ? value : propertyValue;
|
||||
}
|
||||
|
||||
public static String getStringRouteInfoPropertyValue(Context ctx, String propertyValue) {
|
||||
if (propertyValue == null) {
|
||||
return "";
|
||||
}
|
||||
String propertyValueReplaced = propertyValue.replaceAll("\\s+", "_");
|
||||
String value = getStringByProperty(ctx, "routeInfo_" + propertyValueReplaced + "_name");
|
||||
return value != null ? value : propertyValue;
|
||||
}
|
||||
|
||||
private static String getStringByProperty(@NonNull Context ctx, @NonNull String property) {
|
||||
try {
|
||||
Field field = R.string.class.getField(property);
|
||||
return getStringForField(ctx, field);
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String getStringForField(@NonNull Context ctx, @Nullable Field field) throws IllegalAccessException {
|
||||
if (field != null) {
|
||||
Integer in = (Integer) field.get(null);
|
||||
return ctx.getString(in);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -2312,7 +2312,7 @@ public class OsmandAidlApi {
|
|||
File exportDir = app.getSettings().getExternalStorageDirectory();
|
||||
String fileName = appMode.toHumanString();
|
||||
SettingsHelper settingsHelper = app.getSettingsHelper();
|
||||
settingsItems.addAll(settingsHelper.getFilteredSettingsItems(settingsHelper.getAdditionalData(), settingsTypes));
|
||||
settingsItems.addAll(settingsHelper.getFilteredSettingsItems(settingsHelper.getAdditionalData(false), settingsTypes));
|
||||
settingsHelper.exportSettings(exportDir, fileName, null, settingsItems, true);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,119 +0,0 @@
|
|||
package net.osmand.plus.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build.VERSION;
|
||||
import android.os.Build.VERSION_CODES;
|
||||
import android.os.Bundle;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.view.ViewCompat;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
|
||||
public abstract class ActionBarPreferenceActivity extends AppCompatPreferenceActivity {
|
||||
private Toolbar tb;
|
||||
private View shadowView;
|
||||
|
||||
public Toolbar getToolbar() {
|
||||
return tb;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
//settings needed it's own theme because of check boxes not styled properly
|
||||
OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings();
|
||||
int t = settings.isLightContent()
|
||||
? R.style.OsmandLightTheme_NoActionbar_Preferences
|
||||
: R.style.OsmandDarkTheme_NoActionbar_Preferences;
|
||||
setTheme(t);
|
||||
super.onCreate(savedInstanceState);
|
||||
boolean lightTheme = settings.isLightContent();
|
||||
setContentView(R.layout.preference_activity);
|
||||
tb = (Toolbar) findViewById(R.id.toolbar);
|
||||
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
|
||||
shadowView = findViewById(R.id.shadowView);
|
||||
final ViewGroup parent = (ViewGroup) shadowView.getParent();
|
||||
parent.removeView(shadowView);
|
||||
shadowView = null;
|
||||
}
|
||||
tb.setClickable(true);
|
||||
int activeButtonsAndLinksTextColorResId = lightTheme ? R.color.active_buttons_and_links_text_light : R.color.active_buttons_and_links_text_dark;
|
||||
int navigationIconResId = AndroidUtils.getNavigationIconResId(getApplication());
|
||||
Drawable icBack = ((OsmandApplication) getApplication()).getUIUtilities().getIcon(navigationIconResId, activeButtonsAndLinksTextColorResId);
|
||||
tb.setNavigationIcon(icBack);
|
||||
tb.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
|
||||
tb.setBackgroundColor(getResources().getColor(getResIdFromAttribute(this, R.attr.pstsTabBackground)));
|
||||
tb.setTitleTextColor(getResources().getColor(getResIdFromAttribute(this, R.attr.pstsTextColor)));
|
||||
tb.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
getSpinner().setVisibility(View.GONE);
|
||||
getTypeButton().setVisibility(View.GONE);
|
||||
setProgressVisibility(false);
|
||||
}
|
||||
|
||||
static int getResIdFromAttribute(final Activity activity, final int attr) {
|
||||
if (attr == 0)
|
||||
return 0;
|
||||
final TypedValue typedvalueattr = new TypedValue();
|
||||
activity.getTheme().resolveAttribute(attr, typedvalueattr, true);
|
||||
return typedvalueattr.resourceId;
|
||||
}
|
||||
|
||||
protected void setEnabledActionBarShadow(final boolean enable) {
|
||||
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
|
||||
ViewCompat.setElevation(tb, enable ? 4 : 0);
|
||||
} else {
|
||||
if (shadowView == null)
|
||||
shadowView = findViewById(R.id.shadowView);
|
||||
shadowView.setVisibility(enable ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
protected Spinner getSpinner() {
|
||||
return (Spinner) findViewById(R.id.spinner_nav);
|
||||
}
|
||||
|
||||
protected LinearLayout getTypeButton() {
|
||||
return (LinearLayout) findViewById(R.id.type_selection_button);
|
||||
}
|
||||
|
||||
protected TextView getModeTitleTV() {
|
||||
return (TextView) findViewById(R.id.mode_title);
|
||||
}
|
||||
|
||||
protected TextView getModeSubTitleTV() {
|
||||
return (TextView) findViewById(R.id.mode_subtitle);
|
||||
}
|
||||
|
||||
protected ImageView getModeIconIV() {
|
||||
return (ImageView) findViewById(R.id.mode_icon);
|
||||
}
|
||||
protected ImageView getDropDownArrow() {
|
||||
return (ImageView) findViewById(R.id.type_down_arrow);
|
||||
}
|
||||
|
||||
protected void setProgressVisibility(boolean visibility) {
|
||||
if (visibility) {
|
||||
findViewById(R.id.ProgressBar).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
findViewById(R.id.ProgressBar).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package net.osmand.plus.activities;
|
||||
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
/**
|
||||
* A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
|
||||
* to be used with AppCompat.
|
||||
*
|
||||
* This technique can be used with an {@link android.app.Activity} class, not just
|
||||
* {@link android.preference.PreferenceActivity}.
|
||||
*/
|
||||
public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
|
||||
private AppCompatDelegate mDelegate;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
getDelegate().installViewFactory();
|
||||
getDelegate().onCreate(savedInstanceState);
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
getDelegate().onPostCreate(savedInstanceState);
|
||||
}
|
||||
public ActionBar getSupportActionBar() {
|
||||
return getDelegate().getSupportActionBar();
|
||||
}
|
||||
public void setSupportActionBar(@Nullable Toolbar toolbar) {
|
||||
getDelegate().setSupportActionBar(toolbar);
|
||||
}
|
||||
@Override
|
||||
public MenuInflater getMenuInflater() {
|
||||
return getDelegate().getMenuInflater();
|
||||
}
|
||||
@Override
|
||||
public void setContentView(@LayoutRes int layoutResID) {
|
||||
getDelegate().setContentView(layoutResID);
|
||||
}
|
||||
@Override
|
||||
public void setContentView(View view) {
|
||||
getDelegate().setContentView(view);
|
||||
}
|
||||
@Override
|
||||
public void setContentView(View view, ViewGroup.LayoutParams params) {
|
||||
getDelegate().setContentView(view, params);
|
||||
}
|
||||
@Override
|
||||
public void addContentView(View view, ViewGroup.LayoutParams params) {
|
||||
getDelegate().addContentView(view, params);
|
||||
}
|
||||
@Override
|
||||
protected void onPostResume() {
|
||||
super.onPostResume();
|
||||
getDelegate().onPostResume();
|
||||
}
|
||||
@Override
|
||||
protected void onTitleChanged(CharSequence title, int color) {
|
||||
super.onTitleChanged(title, color);
|
||||
getDelegate().setTitle(title);
|
||||
}
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
getDelegate().onConfigurationChanged(newConfig);
|
||||
}
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
getDelegate().onStop();
|
||||
}
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
getDelegate().onDestroy();
|
||||
}
|
||||
public void invalidateOptionsMenu() {
|
||||
getDelegate().invalidateOptionsMenu();
|
||||
}
|
||||
private AppCompatDelegate getDelegate() {
|
||||
if (mDelegate == null) {
|
||||
mDelegate = AppCompatDelegate.create(this, null);
|
||||
}
|
||||
return mDelegate;
|
||||
}
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
package net.osmand.plus.activities;
|
||||
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceCategory;
|
||||
import android.preference.PreferenceScreen;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.liveupdates.OsmLiveActivity;
|
||||
|
||||
public class SettingsActivity extends SettingsBaseActivity {
|
||||
|
||||
public static final String INTENT_KEY_SETTINGS_SCREEN = "INTENT_KEY_SETTINGS_SCREEN";
|
||||
public static final int SCREEN_GENERAL_SETTINGS = 1;
|
||||
public static final int SCREEN_NAVIGATION_SETTINGS = 2;
|
||||
|
||||
private static final int PLUGINS_SELECTION_REQUEST = 1;
|
||||
private static final String CONTRIBUTION_VERSION_FLAG = "CONTRIBUTION_VERSION_FLAG";
|
||||
|
||||
|
||||
private Preference general;
|
||||
private Preference routing;
|
||||
private Preference subscription;
|
||||
private Preference privacy;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
((OsmandApplication) getApplication()).applyTheme(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.settings_pref);
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
general = (Preference) screen.findPreference("general_settings");
|
||||
general.setOnPreferenceClickListener(this);
|
||||
routing = (Preference) screen.findPreference("routing_settings");
|
||||
routing.setOnPreferenceClickListener(this);
|
||||
subscription = (Preference) screen.findPreference("subscription_settings");
|
||||
subscription.setOnPreferenceClickListener(this);
|
||||
privacy = (Preference) screen.findPreference("privacy_and_security");
|
||||
privacy.setOnPreferenceClickListener(this);
|
||||
|
||||
getToolbar().setTitle(Version.getFullVersion(getMyApplication()));
|
||||
|
||||
Intent intent = getIntent();
|
||||
if(intent != null && intent.getIntExtra(INTENT_KEY_SETTINGS_SCREEN, 0) != 0){
|
||||
int s = intent.getIntExtra(INTENT_KEY_SETTINGS_SCREEN, 0);
|
||||
if(s == SCREEN_GENERAL_SETTINGS){
|
||||
startActivity(new Intent(this, SettingsGeneralActivity.class));
|
||||
} else if(s == SCREEN_NAVIGATION_SETTINGS){
|
||||
startActivity(new Intent(this, SettingsNavigationActivity.class));
|
||||
}
|
||||
}
|
||||
PreferenceCategory plugins = (PreferenceCategory) screen.findPreference("plugin_settings");
|
||||
for(OsmandPlugin op : OsmandPlugin.getEnabledPlugins()) {
|
||||
// final Class<? extends Activity> sa = op.getSettingsActivity();
|
||||
// if(sa != null) {
|
||||
// Preference preference = new Preference(this);
|
||||
// preference.setTitle(op.getName());
|
||||
// preference.setKey(op.getId());
|
||||
// preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
//
|
||||
// @Override
|
||||
// public boolean onPreferenceClick(Preference preference) {
|
||||
// startActivity(new Intent(SettingsActivity.this, sa));
|
||||
// return false;
|
||||
// }
|
||||
// });
|
||||
// plugins.addPreference(preference);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (preference == general) {
|
||||
startActivity(new Intent(this, SettingsGeneralActivity.class));
|
||||
return true;
|
||||
} else if (preference == routing) {
|
||||
startActivity(new Intent(this, SettingsNavigationActivity.class));
|
||||
return true;
|
||||
} else if (preference == subscription) {
|
||||
Intent intent = new Intent(this, OsmLiveActivity.class);
|
||||
intent.putExtra(OsmLiveActivity.SHOW_SETTINGS_ONLY_INTENT_PARAM, true);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
} else if (preference == privacy) {
|
||||
Intent intent = new Intent(this, PrivacyAndSecurityActivity.class);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
} else {
|
||||
super.onPreferenceClick(preference);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,623 +0,0 @@
|
|||
package net.osmand.plus.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.content.DialogInterface.OnMultiChoiceClickListener;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.EditTextPreference;
|
||||
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.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AlertDialog.Builder;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.settings.backend.CommonPreference;
|
||||
import net.osmand.plus.settings.backend.OsmandPreference;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.profiles.AppProfileArrayAdapter;
|
||||
import net.osmand.plus.profiles.ProfileDataObject;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
|
||||
public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
|
||||
implements OnPreferenceChangeListener, OnPreferenceClickListener {
|
||||
|
||||
private static final Log LOG = PlatformUtil.getLog(SettingsBaseActivity.class);
|
||||
public static final String INTENT_APP_MODE = "INTENT_APP_MODE";
|
||||
private static final String PREV_MODE_KEY = "previous_mode";
|
||||
private static final String SELECTED_MODE_KEY = "selected_mode";
|
||||
|
||||
protected OsmandSettings settings;
|
||||
protected final boolean profileSettings;
|
||||
protected List<ApplicationMode> modes = new ArrayList<ApplicationMode>();
|
||||
private ApplicationMode previousAppMode;
|
||||
protected ApplicationMode selectedAppMode;
|
||||
|
||||
private Map<String, Preference> screenPreferences = new LinkedHashMap<String, Preference>();
|
||||
private Map<String, OsmandPreference<Boolean>> booleanPreferences = new LinkedHashMap<String, OsmandPreference<Boolean>>();
|
||||
private Map<String, OsmandPreference<?>> listPreferences = new LinkedHashMap<String, OsmandPreference<?>>();
|
||||
private Map<String, OsmandPreference<String>> editTextPreferences = new LinkedHashMap<String, OsmandPreference<String>>();
|
||||
|
||||
private Map<String, Map<String, ?>> listPrefValues = new LinkedHashMap<String, Map<String, ?>>();
|
||||
|
||||
public SettingsBaseActivity() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
private boolean isModeSelected = false;
|
||||
|
||||
public SettingsBaseActivity(boolean profile) {
|
||||
profileSettings = profile;
|
||||
}
|
||||
|
||||
public CheckBoxPreference registerBooleanPreference(OsmandPreference<Boolean> b, PreferenceGroup screen) {
|
||||
CheckBoxPreference p = (CheckBoxPreference) screen.findPreference(b.getId());
|
||||
p.setOnPreferenceChangeListener(this);
|
||||
screenPreferences.put(b.getId(), p);
|
||||
booleanPreferences.put(b.getId(), b);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
public CheckBoxPreference createCheckBoxPreference(OsmandPreference<Boolean> b, int title, int summary) {
|
||||
CheckBoxPreference p = new CheckBoxPreference(this);
|
||||
p.setTitle(title);
|
||||
p.setKey(b.getId());
|
||||
p.setSummary(summary);
|
||||
p.setOnPreferenceChangeListener(this);
|
||||
screenPreferences.put(b.getId(), p);
|
||||
booleanPreferences.put(b.getId(), b);
|
||||
return p;
|
||||
}
|
||||
|
||||
public CheckBoxPreference createCheckBoxPreference(OsmandPreference<Boolean> b, String title, String summary) {
|
||||
CheckBoxPreference p = new CheckBoxPreference(this);
|
||||
p.setTitle(title);
|
||||
p.setKey(b.getId());
|
||||
p.setSummary(summary);
|
||||
p.setOnPreferenceChangeListener(this);
|
||||
screenPreferences.put(b.getId(), p);
|
||||
booleanPreferences.put(b.getId(), b);
|
||||
return p;
|
||||
}
|
||||
|
||||
public CheckBoxPreference createCheckBoxPreference(OsmandPreference<Boolean> b) {
|
||||
CheckBoxPreference p = new CheckBoxPreference(this);
|
||||
p.setKey(b.getId());
|
||||
p.setOnPreferenceChangeListener(this);
|
||||
screenPreferences.put(b.getId(), p);
|
||||
booleanPreferences.put(b.getId(), b);
|
||||
return p;
|
||||
}
|
||||
|
||||
public static String getIconStringPropertyName(Context ctx, String propertyName, String defValue) {
|
||||
try {
|
||||
Field f = R.string.class.getField("icon_group_" + propertyName);
|
||||
if (f != null) {
|
||||
Integer in = (Integer) f.get(null);
|
||||
return ctx.getString(in);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
return defValue;
|
||||
}
|
||||
|
||||
public static String getRoutingStringPropertyName(Context ctx, String propertyName, String defValue) {
|
||||
try {
|
||||
Field f = R.string.class.getField("routing_attr_" + propertyName + "_name");
|
||||
if (f != null) {
|
||||
Integer in = (Integer) f.get(null);
|
||||
return ctx.getString(in);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
return defValue;
|
||||
}
|
||||
|
||||
public static String getRoutingStringPropertyDescription(Context ctx, String propertyName, String defValue) {
|
||||
try {
|
||||
Field f = R.string.class.getField("routing_attr_" + propertyName + "_description");
|
||||
if (f != null) {
|
||||
Integer in = (Integer) f.get(null);
|
||||
return ctx.getString(in);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
return defValue;
|
||||
}
|
||||
|
||||
public static String getStringPropertyName(Context ctx, String propertyName, String defValue) {
|
||||
try {
|
||||
Field f = R.string.class.getField("rendering_attr_" + propertyName + "_name");
|
||||
if (f != null) {
|
||||
Integer in = (Integer) f.get(null);
|
||||
return ctx.getString(in);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
return defValue;
|
||||
}
|
||||
|
||||
public static String getStringPropertyDescription(Context ctx, String propertyName, String defValue) {
|
||||
try {
|
||||
Field f = R.string.class.getField("rendering_attr_" + propertyName + "_description");
|
||||
if (f != null) {
|
||||
Integer in = (Integer) f.get(null);
|
||||
return ctx.getString(in);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
return defValue;
|
||||
}
|
||||
|
||||
public static String getStringPropertyValue(Context ctx, String propertyValue) {
|
||||
try {
|
||||
if(propertyValue == null) {
|
||||
return "";
|
||||
}
|
||||
final String propertyValueReplaced = propertyValue.replaceAll("\\s+","_");
|
||||
Field f = R.string.class.getField("rendering_value_" + propertyValueReplaced + "_name");
|
||||
if (f != null) {
|
||||
Integer in = (Integer) f.get(null);
|
||||
return ctx.getString(in);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
return propertyValue;
|
||||
}
|
||||
|
||||
public static String getStringRouteInfoPropertyValue(Context ctx, String propertyValue) {
|
||||
try {
|
||||
if(propertyValue == null) {
|
||||
return "";
|
||||
}
|
||||
final String propertyValueReplaced = propertyValue.replaceAll("\\s+","_");
|
||||
Field f = R.string.class.getField("routeInfo_" + propertyValueReplaced + "_name");
|
||||
if (f != null) {
|
||||
Integer in = (Integer) f.get(null);
|
||||
return ctx.getString(in);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
return propertyValue;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public <T> ListPreference createListPreference(OsmandPreference<T> b, String[] names, T[] values, int title, int summary) {
|
||||
ListPreference p = new ListPreference(this);
|
||||
p.setTitle(title);
|
||||
p.setKey(b.getId());
|
||||
p.setDialogTitle(title);
|
||||
p.setSummary(summary);
|
||||
prepareListPreference(b, names, values, p);
|
||||
return p;
|
||||
}
|
||||
|
||||
public <T> ListPreference createListPreference(OsmandPreference<T> b, String[] names, T[] values, String title, String summary) {
|
||||
ListPreference p = new ListPreference(this);
|
||||
p.setTitle(title);
|
||||
p.setKey(b.getId());
|
||||
p.setDialogTitle(title);
|
||||
p.setSummary(summary);
|
||||
prepareListPreference(b, names, values, p);
|
||||
return p;
|
||||
}
|
||||
|
||||
public <T> ListPreference createListPreference(OsmandPreference<T> b, String[] names, T[] values) {
|
||||
ListPreference p = new ListPreference(this);
|
||||
p.setKey(b.getId());
|
||||
prepareListPreference(b, names, values, p);
|
||||
return p;
|
||||
}
|
||||
|
||||
private <T> void prepareListPreference(OsmandPreference<T> b, String[] names, T[] values, ListPreference p) {
|
||||
p.setOnPreferenceChangeListener(this);
|
||||
LinkedHashMap<String, Object> vals = new LinkedHashMap<String, Object>();
|
||||
screenPreferences.put(b.getId(), p);
|
||||
listPreferences.put(b.getId(), b);
|
||||
listPrefValues.put(b.getId(), vals);
|
||||
assert names.length == values.length;
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
vals.put(names[i], values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerDisablePreference(OsmandPreference p, String value, OsmandPreference<Boolean> disable) {
|
||||
LinkedHashMap<String, Object> vals = (LinkedHashMap<String, Object>) listPrefValues.get(p.getId());
|
||||
vals.put(value, disable);
|
||||
}
|
||||
|
||||
public void registerEditTextPreference(OsmandPreference<String> b, PreferenceScreen screen) {
|
||||
EditTextPreference p = (EditTextPreference) screen.findPreference(b.getId());
|
||||
p.setOnPreferenceChangeListener(this);
|
||||
screenPreferences.put(b.getId(), p);
|
||||
editTextPreferences.put(b.getId(), b);
|
||||
}
|
||||
|
||||
public EditTextPreference createEditTextPreference(OsmandPreference<String> b, int title, int summary) {
|
||||
EditTextPreference p = new EditTextPreference(this);
|
||||
p.setTitle(title);
|
||||
p.setKey(b.getId());
|
||||
p.setDialogTitle(title);
|
||||
p.setSummary(summary);
|
||||
p.setOnPreferenceChangeListener(this);
|
||||
screenPreferences.put(b.getId(), p);
|
||||
editTextPreferences.put(b.getId(), b);
|
||||
return p;
|
||||
}
|
||||
|
||||
public void registerTimeListPreference(OsmandPreference<Integer> b, PreferenceScreen screen, int[] seconds, int[] minutes, int coeff) {
|
||||
int minutesLength = minutes == null ? 0 : minutes.length;
|
||||
int secondsLength = seconds == null ? 0 : seconds.length;
|
||||
Integer[] ints = new Integer[secondsLength + minutesLength];
|
||||
String[] intDescriptions = new String[ints.length];
|
||||
for (int i = 0; i < secondsLength; i++) {
|
||||
ints[i] = seconds[i] * coeff;
|
||||
intDescriptions[i] = seconds[i] + " " + getString(R.string.int_seconds); //$NON-NLS-1$
|
||||
}
|
||||
for (int i = 0; i < minutesLength; i++) {
|
||||
ints[secondsLength + i] = (minutes[i] * 60) * coeff;
|
||||
intDescriptions[secondsLength + i] = minutes[i] + " " + getString(R.string.int_min); //$NON-NLS-1$
|
||||
}
|
||||
registerListPreference(b, screen, intDescriptions, ints);
|
||||
}
|
||||
|
||||
public ListPreference createTimeListPreference(OsmandPreference<Integer> b, int[] seconds, int[] minutes, int coeff, int title, int summary) {
|
||||
return createTimeListPreference(b, seconds, minutes, coeff, null, title, summary);
|
||||
}
|
||||
|
||||
public ListPreference createTimeListPreference(OsmandPreference<Integer> b, int[] seconds, int[] minutes,
|
||||
int coeff, CommonPreference<Boolean> disable, int title, int summary) {
|
||||
int minutesLength = minutes == null ? 0 : minutes.length;
|
||||
int secondsLength = seconds == null ? 0 : seconds.length;
|
||||
Integer[] ints = new Integer[secondsLength + minutesLength];
|
||||
String[] intDescriptions = new String[ints.length];
|
||||
int k = 0;
|
||||
for (int i = 0; i < secondsLength; i++) {
|
||||
ints[k] = seconds[i] * coeff;
|
||||
intDescriptions[k] = seconds[i] + " " + getString(R.string.int_seconds); //$NON-NLS-1$
|
||||
k++;
|
||||
}
|
||||
OsmandApplication app = getMyApplication();
|
||||
for (int i = 0; i < minutesLength; i++) {
|
||||
ints[k] = (minutes[i] * 60) * coeff;
|
||||
intDescriptions[k] = OsmAndFormatter.getFormattedDuration(minutes[i] * 60, app);
|
||||
k++;
|
||||
}
|
||||
ListPreference lp = createListPreference(b, intDescriptions, ints, title, summary);
|
||||
if (disable != null) {
|
||||
registerDisablePreference(b, getString(R.string.confirm_every_run), disable);
|
||||
}
|
||||
return lp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int itemId = item.getItemId();
|
||||
switch (itemId) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
OsmandApplication app = getMyApplication();
|
||||
settings = app.getSettings();
|
||||
getToolbar().setTitle(R.string.shared_string_settings);
|
||||
|
||||
if (profileSettings) {
|
||||
modes.clear();
|
||||
findViewById(R.id.selector_shadow).setVisibility(View.VISIBLE);
|
||||
if (this instanceof SettingsNavigationActivity) {
|
||||
for (ApplicationMode a : ApplicationMode.values(app)) {
|
||||
if (a != ApplicationMode.DEFAULT) {
|
||||
modes.add(a);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
modes.addAll(ApplicationMode.values(app));
|
||||
}
|
||||
|
||||
getTypeButton().setVisibility(View.VISIBLE);
|
||||
getTypeButton().setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
selectAppModeDialog().show();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
setPreferenceScreen(getPreferenceManager().createPreferenceScreen(this));
|
||||
}
|
||||
|
||||
protected AlertDialog.Builder selectAppModeDialog() {
|
||||
AlertDialog.Builder singleSelectDialogBuilder = new Builder(SettingsBaseActivity.this);
|
||||
singleSelectDialogBuilder.setTitle(R.string.profile_settings);
|
||||
|
||||
final List<ProfileDataObject> activeModes = new ArrayList<>();
|
||||
for (ApplicationMode am : ApplicationMode.values(getMyApplication())) {
|
||||
boolean isSelected = am == selectedAppMode;
|
||||
|
||||
if (am != ApplicationMode.DEFAULT || !(this instanceof SettingsNavigationActivity)) {
|
||||
activeModes.add(new ProfileDataObject(
|
||||
am.toHumanString(),
|
||||
getAppModeDescription(am),
|
||||
am.getStringKey(),
|
||||
am.getIconRes(),
|
||||
isSelected,
|
||||
am.getIconColorInfo()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
final AppProfileArrayAdapter modeNames = new AppProfileArrayAdapter(
|
||||
SettingsBaseActivity.this, R.layout.bottom_sheet_item_with_descr_and_radio_btn, activeModes, isModeSelected);
|
||||
|
||||
singleSelectDialogBuilder.setNegativeButton(R.string.shared_string_cancel,
|
||||
new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
singleSelectDialogBuilder.setOnDismissListener(new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
if (!isModeSelected) {
|
||||
List<ApplicationMode> m = ApplicationMode.values(getMyApplication());
|
||||
setSelectedAppMode(m.get(m.size() > 1 ? 1 : 0));
|
||||
}
|
||||
}
|
||||
});
|
||||
singleSelectDialogBuilder.setAdapter(modeNames, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
settings.APPLICATION_MODE.set(modes.get(which));
|
||||
updateModeButton(modes.get(which));
|
||||
updateAllSettings();
|
||||
}
|
||||
});
|
||||
return singleSelectDialogBuilder;
|
||||
}
|
||||
|
||||
void updateModeButton(ApplicationMode mode) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
boolean nightMode = !app.getSettings().isLightContent();
|
||||
String title = mode.toHumanString();
|
||||
|
||||
getModeTitleTV().setText(title);
|
||||
getModeSubTitleTV().setText(getAppModeDescription(mode));
|
||||
settings.APPLICATION_MODE.set(mode);
|
||||
selectedAppMode = mode;
|
||||
getModeIconIV().setImageDrawable(getMyApplication().getUIUtilities().getIcon(mode.getIconRes(),
|
||||
mode.getIconColorInfo().getColor(nightMode)));
|
||||
getDropDownArrow().setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down, !nightMode));
|
||||
isModeSelected = true;
|
||||
updateAllSettings();
|
||||
}
|
||||
|
||||
private String getAppModeDescription(ApplicationMode mode) {
|
||||
String descr;
|
||||
if (!mode.isCustomProfile()) {
|
||||
descr = getString(R.string.profile_type_base_string);
|
||||
} else {
|
||||
descr = String.format(getString(R.string.profile_type_descr_string),
|
||||
mode.getParent().toHumanString());
|
||||
if (mode.getRoutingProfile() != null && mode.getRoutingProfile().contains("/")) {
|
||||
descr = descr.concat(", " + mode.getRoutingProfile()
|
||||
.substring(0, mode.getRoutingProfile().indexOf("/")));
|
||||
}
|
||||
}
|
||||
return descr;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (profileSettings) {
|
||||
if (previousAppMode == null) {
|
||||
previousAppMode = settings.getApplicationMode();
|
||||
}
|
||||
if (getIntent() != null && getIntent().hasExtra(INTENT_APP_MODE)) {
|
||||
String modeStr = getIntent().getStringExtra(INTENT_APP_MODE);
|
||||
ApplicationMode mode = ApplicationMode.valueOfStringKey(modeStr, previousAppMode);
|
||||
setSelectedAppMode(mode);
|
||||
} else {
|
||||
setSelectedAppMode(selectedAppMode);
|
||||
}
|
||||
} else {
|
||||
updateAllSettings();
|
||||
}
|
||||
}
|
||||
|
||||
protected void setSelectedAppMode(ApplicationMode am) {
|
||||
for (ApplicationMode a : modes) {
|
||||
if (am != null && am == a) {
|
||||
updateModeButton(a);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
if(profileSettings) {
|
||||
settings.APPLICATION_MODE.set(previousAppMode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
if (profileSettings) {
|
||||
if (previousAppMode != null) {
|
||||
outState.putString(PREV_MODE_KEY, previousAppMode.getStringKey());
|
||||
}
|
||||
if (selectedAppMode != null) {
|
||||
outState.putString(SELECTED_MODE_KEY, selectedAppMode.getStringKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Bundle state) {
|
||||
super.onRestoreInstanceState(state);
|
||||
if (state != null) {
|
||||
if (profileSettings && state.containsKey(SELECTED_MODE_KEY) && state.containsKey(PREV_MODE_KEY)) {
|
||||
for (ApplicationMode am : ApplicationMode.values(getMyApplication())) {
|
||||
if (am.getStringKey() == state.get(SELECTED_MODE_KEY)) {
|
||||
setSelectedAppMode(am);
|
||||
}
|
||||
if (am.getStringKey() == state.get(PREV_MODE_KEY)) {
|
||||
previousAppMode = am;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAllSettings() {
|
||||
for (OsmandPreference<Boolean> b : booleanPreferences.values()) {
|
||||
CheckBoxPreference pref = (CheckBoxPreference) screenPreferences.get(b.getId());
|
||||
pref.setChecked(b.get());
|
||||
}
|
||||
|
||||
for (OsmandPreference<?> p : listPreferences.values()) {
|
||||
ListPreference listPref = (ListPreference) screenPreferences.get(p.getId());
|
||||
Map<String, ?> prefValues = listPrefValues.get(p.getId());
|
||||
String[] entryValues = new String[prefValues.size()];
|
||||
String[] entries = new String[prefValues.size()];
|
||||
int i = 0;
|
||||
for (Entry<String, ?> e : prefValues.entrySet()) {
|
||||
entries[i] = e.getKey();
|
||||
entryValues[i] = e.getValue() + ""; // case of null
|
||||
i++;
|
||||
}
|
||||
listPref.setEntries(entries);
|
||||
listPref.setEntryValues(entryValues);
|
||||
listPref.setValue(p.get() + "");
|
||||
}
|
||||
|
||||
for (OsmandPreference<String> s : editTextPreferences.values()) {
|
||||
EditTextPreference pref = (EditTextPreference) screenPreferences.get(s.getId());
|
||||
pref.setText(s.get());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
// handle boolean preferences
|
||||
OsmandPreference<Boolean> boolPref = booleanPreferences.get(preference.getKey());
|
||||
OsmandPreference<Object> listPref = (OsmandPreference<Object>) listPreferences.get(preference.getKey());
|
||||
OsmandPreference<String> editPref = editTextPreferences.get(preference.getKey());
|
||||
if (boolPref != null) {
|
||||
boolPref.set((Boolean) newValue);
|
||||
} else if (editPref != null) {
|
||||
editPref.set((String) newValue);
|
||||
} else if (listPref != null) {
|
||||
int ind = ((ListPreference) preference).findIndexOfValue((String) newValue);
|
||||
CharSequence entry = ((ListPreference) preference).getEntries()[ind];
|
||||
Map<String, ?> map = listPrefValues.get(preference.getKey());
|
||||
Object obj = map.get(entry);
|
||||
boolean changed ;
|
||||
if(obj instanceof OsmandPreference) {
|
||||
changed = true;
|
||||
((OsmandPreference<Boolean>) obj).set(false);
|
||||
} else {
|
||||
changed = listPref.set(obj);
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected Map<String, Map<String, ?>> getListPrefValues() {
|
||||
return listPrefValues;
|
||||
}
|
||||
|
||||
protected OsmandApplication getMyApplication() {
|
||||
return (OsmandApplication) getApplication();
|
||||
}
|
||||
|
||||
public static void showWarnings(final OsmandApplication app, List<String> warnings) {
|
||||
if (!warnings.isEmpty()) {
|
||||
final StringBuilder b = AndroidUtils.formatWarnings(warnings);
|
||||
app.runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(app, b.toString(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void showBooleanSettings(String[] vals, final OsmandPreference<Boolean>[] prefs) {
|
||||
AlertDialog.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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,720 +0,0 @@
|
|||
package net.osmand.plus.activities;
|
||||
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.EditTextPreference;
|
||||
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.util.Pair;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.AppCompatCheckedTextView;
|
||||
import androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.osm.io.NetworkUtils;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.helpers.enums.AngularConstants;
|
||||
import net.osmand.plus.helpers.enums.DrivingRegion;
|
||||
import net.osmand.plus.helpers.enums.MetricsConstants;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.base.MapViewTrackingUtilities;
|
||||
import net.osmand.plus.dashboard.DashChooseAppDirFragment;
|
||||
import net.osmand.plus.dashboard.DashChooseAppDirFragment.ChooseAppDirFragment;
|
||||
import net.osmand.plus.dashboard.DashChooseAppDirFragment.MoveFilesToDifferentDirectory;
|
||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.render.NativeOsmandLibrary;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class SettingsGeneralActivity extends SettingsBaseActivity implements OnRequestPermissionsResultCallback {
|
||||
|
||||
public static final String IP_ADDRESS_PATTERN =
|
||||
"^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
|
||||
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
|
||||
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
|
||||
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])$";
|
||||
|
||||
private Preference applicationDir;
|
||||
private ListPreference applicationModePreference;
|
||||
private Preference drivingRegionPreference;
|
||||
private ChooseAppDirFragment chooseAppDirFragment;
|
||||
private boolean permissionRequested;
|
||||
private boolean permissionGranted;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
((OsmandApplication) getApplication()).applyTheme(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
getToolbar().setTitle(R.string.global_app_settings);
|
||||
addPreferencesFromResource(R.xml.general_settings);
|
||||
String[] entries;
|
||||
String[] entrieValues;
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
OsmandApplication app = getMyApplication();
|
||||
settings = app.getSettings();
|
||||
|
||||
ApplicationMode[] appModes = ApplicationMode.values(app).toArray(new ApplicationMode[0]);
|
||||
entries = new String[appModes.length];
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
entries[i] = appModes[i].toHumanString();
|
||||
}
|
||||
registerListPreference(settings.DEFAULT_APPLICATION_MODE, screen, entries, appModes);
|
||||
|
||||
// List preferences
|
||||
registerListPreference(settings.ROTATE_MAP, screen,
|
||||
new String[]{getString(R.string.rotate_map_none_opt), getString(R.string.rotate_map_bearing_opt), getString(R.string.rotate_map_compass_opt)},
|
||||
new Integer[]{OsmandSettings.ROTATE_MAP_NONE, OsmandSettings.ROTATE_MAP_BEARING, OsmandSettings.ROTATE_MAP_COMPASS});
|
||||
|
||||
registerListPreference(settings.MAP_SCREEN_ORIENTATION, screen,
|
||||
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_SENSOR_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED});
|
||||
|
||||
drivingRegionPreference = screen.findPreference(settings.DRIVING_REGION.getId());
|
||||
|
||||
addLocalPrefs((PreferenceGroup) screen.findPreference("localization"));
|
||||
addProxyPrefs((PreferenceGroup) screen.findPreference("proxy"));
|
||||
addMiscPreferences((PreferenceGroup) screen.findPreference("misc"));
|
||||
|
||||
applicationModePreference = (ListPreference) screen.findPreference(settings.DEFAULT_APPLICATION_MODE.getId());
|
||||
applicationModePreference.setOnPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
private void addLocalPrefs(PreferenceGroup screen) {
|
||||
drivingRegionPreference.setTitle(R.string.driving_region);
|
||||
drivingRegionPreference.setSummary(R.string.driving_region_descr);
|
||||
drivingRegionPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
final AlertDialog.Builder b = new AlertDialog.Builder(SettingsGeneralActivity.this);
|
||||
|
||||
b.setTitle(getString(R.string.driving_region));
|
||||
|
||||
final List<DrivingRegion> drs = new ArrayList<>();
|
||||
drs.add(null);
|
||||
drs.addAll(Arrays.asList(DrivingRegion.values()));
|
||||
int sel = -1;
|
||||
DrivingRegion selectedDrivingRegion = settings.DRIVING_REGION.get();
|
||||
if (settings.DRIVING_REGION_AUTOMATIC.get()) {
|
||||
sel = 0;
|
||||
}
|
||||
for (int i = 1; i < drs.size(); i++) {
|
||||
if (sel == -1 && drs.get(i) == selectedDrivingRegion) {
|
||||
sel = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final int selected = sel;
|
||||
final ArrayAdapter<DrivingRegion> singleChoiceAdapter =
|
||||
new ArrayAdapter<DrivingRegion>(SettingsGeneralActivity.this, R.layout.single_choice_description_item, R.id.text1, drs) {
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
|
||||
View v = convertView;
|
||||
if (v == null) {
|
||||
LayoutInflater inflater = SettingsGeneralActivity.this.getLayoutInflater();
|
||||
v = inflater.inflate(R.layout.single_choice_description_item, parent, false);
|
||||
}
|
||||
DrivingRegion item = getItem(position);
|
||||
AppCompatCheckedTextView title = (AppCompatCheckedTextView) v.findViewById(R.id.text1);
|
||||
TextView desc = (TextView) v.findViewById(R.id.description);
|
||||
if (item != null) {
|
||||
title.setText(getString(item.name));
|
||||
desc.setVisibility(View.VISIBLE);
|
||||
desc.setText(item.getDescription(v.getContext()));
|
||||
} else {
|
||||
title.setText(getString(R.string.driving_region_automatic));
|
||||
desc.setVisibility(View.GONE);
|
||||
}
|
||||
title.setChecked(position == selected);
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
b.setAdapter(singleChoiceAdapter, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (drs.get(which) == null) {
|
||||
settings.DRIVING_REGION_AUTOMATIC.set(true);
|
||||
MapViewTrackingUtilities mapViewTrackingUtilities = getMyApplication().getMapViewTrackingUtilities();
|
||||
if (mapViewTrackingUtilities != null) {
|
||||
mapViewTrackingUtilities.resetDrivingRegionUpdate();
|
||||
}
|
||||
} else {
|
||||
settings.DRIVING_REGION_AUTOMATIC.set(false);
|
||||
settings.DRIVING_REGION.set(drs.get(which));
|
||||
}
|
||||
updateAllSettings();
|
||||
}
|
||||
});
|
||||
|
||||
b.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
b.show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
String[] entries;
|
||||
String[] entrieValues;
|
||||
|
||||
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);
|
||||
|
||||
Integer[] cvls = new Integer[5];
|
||||
cvls[0] = PointDescription.FORMAT_DEGREES;
|
||||
cvls[1] = PointDescription.FORMAT_MINUTES;
|
||||
cvls[2] = PointDescription.FORMAT_SECONDS;
|
||||
cvls[3] = PointDescription.UTM_FORMAT;
|
||||
cvls[4] = PointDescription.OLC_FORMAT;
|
||||
entries = new String[5];
|
||||
entries[0] = PointDescription.formatToHumanString(this, PointDescription.FORMAT_DEGREES);
|
||||
entries[1] = PointDescription.formatToHumanString(this, PointDescription.FORMAT_MINUTES);
|
||||
entries[2] = PointDescription.formatToHumanString(this, PointDescription.FORMAT_SECONDS);
|
||||
entries[3] = PointDescription.formatToHumanString(this, PointDescription.UTM_FORMAT);
|
||||
entries[4] = PointDescription.formatToHumanString(this, PointDescription.OLC_FORMAT);
|
||||
registerListPreference(settings.COORDINATES_FORMAT, screen, entries, cvls);
|
||||
|
||||
AngularConstants[] ac = AngularConstants.values();
|
||||
entries = new String[ac.length];
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
if (ac[i] == AngularConstants.DEGREES) {
|
||||
entries[i] = AngularConstants.DEGREES.toHumanString(getMyApplication()) + " 180";
|
||||
} else if (ac [i] == AngularConstants.DEGREES360) {
|
||||
entries[i] = AngularConstants.DEGREES.toHumanString(getMyApplication()) + " 360";
|
||||
} else {
|
||||
entries[i] = ac[i].toHumanString(getMyApplication());
|
||||
}
|
||||
}
|
||||
registerListPreference(settings.ANGULAR_UNITS, screen, entries, ac);
|
||||
|
||||
Pair<String[], String[]> preferredLocaleInfo = getPreferredLocaleIdsAndValues(this);
|
||||
if (preferredLocaleInfo != null) {
|
||||
registerListPreference(settings.PREFERRED_LOCALE, screen, preferredLocaleInfo.first, preferredLocaleInfo.second);
|
||||
}
|
||||
|
||||
// Add " (Display language)" to menu title in Latin letters for all non-en languages
|
||||
if (!getResources().getString(R.string.preferred_locale).equals(getResources().getString(R.string.preferred_locale_no_translate))) {
|
||||
((ListPreference) screen.findPreference(settings.PREFERRED_LOCALE.getId())).setTitle(getString(R.string.preferred_locale) + " (" + getString(R.string.preferred_locale_no_translate) + ")");
|
||||
}
|
||||
|
||||
// This setting now only in "Confgure map" menu
|
||||
//String[] values = ConfigureMapMenu.getMapNamesValues(this, ConfigureMapMenu.mapNamesIds);
|
||||
//String[] ids = ConfigureMapMenu.getSortedMapNamesIds(this, ConfigureMapMenu.mapNamesIds, values);
|
||||
//registerListPreference(settings.MAP_PREFERRED_LOCALE, screen, ConfigureMapMenu.getMapNamesValues(this, ids), ids);
|
||||
}
|
||||
|
||||
public static Pair<String[], String[]> getPreferredLocaleIdsAndValues(Context ctx) {
|
||||
// See language list and statistics at: https://hosted.weblate.org/projects/osmand/main/
|
||||
// Hardy maintenance 2016-05-29:
|
||||
// - Include languages if their translation is >= ~10% (but any language will be visible if it is the device's system locale)
|
||||
// - Mark as "incomplete" if < ~80%
|
||||
String incompleteSuffix = " (" + ctx.getString(R.string.incomplete_locale) + ")";
|
||||
|
||||
// Add " (Device language)" to system default entry in Latin letters, so it can be more easily identified if a foreign language has been selected by mistake
|
||||
String latinSystemDefaultSuffix = " (" + ctx.getString(R.string.system_locale_no_translate) + ")";
|
||||
|
||||
//getResources().getAssets().getLocales();
|
||||
String[] entryValues = new String[] {
|
||||
"",
|
||||
"en",
|
||||
"af",
|
||||
"ar",
|
||||
"ast",
|
||||
"az",
|
||||
"be",
|
||||
//"be_BY",
|
||||
"bg",
|
||||
"ca",
|
||||
"cs",
|
||||
"cy",
|
||||
"da",
|
||||
"de",
|
||||
"el",
|
||||
"en_GB",
|
||||
"eo",
|
||||
"es",
|
||||
"es_AR",
|
||||
"es_US",
|
||||
"eu",
|
||||
"fa",
|
||||
"fi",
|
||||
"fr",
|
||||
"gl",
|
||||
"iw",
|
||||
"hr",
|
||||
"hsb",
|
||||
"hu",
|
||||
"hy",
|
||||
"is",
|
||||
"it",
|
||||
"ja",
|
||||
"ka",
|
||||
"kab",
|
||||
"kn",
|
||||
"ko",
|
||||
"lt",
|
||||
"lv",
|
||||
"ml",
|
||||
"mr",
|
||||
"nb",
|
||||
"nl",
|
||||
"nn",
|
||||
"oc",
|
||||
"pl",
|
||||
"pt",
|
||||
"pt_BR",
|
||||
"ro",
|
||||
"ru",
|
||||
"sc",
|
||||
"sk",
|
||||
"sl",
|
||||
"sr",
|
||||
"sr+Latn",
|
||||
"sv",
|
||||
"tr",
|
||||
"uk",
|
||||
"vi",
|
||||
"zh_CN",
|
||||
"zh_TW"};
|
||||
|
||||
String[] entries = new String[] {
|
||||
ctx.getString(R.string.system_locale) + latinSystemDefaultSuffix,
|
||||
ctx.getString(R.string.lang_en),
|
||||
ctx.getString(R.string.lang_af) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_ar),
|
||||
ctx.getString(R.string.lang_ast) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_az),
|
||||
ctx.getString(R.string.lang_be),
|
||||
// getString(R.string.lang_be_by),
|
||||
ctx.getString(R.string.lang_bg),
|
||||
ctx.getString(R.string.lang_ca),
|
||||
ctx.getString(R.string.lang_cs),
|
||||
ctx.getString(R.string.lang_cy) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_da),
|
||||
ctx.getString(R.string.lang_de),
|
||||
ctx.getString(R.string.lang_el),
|
||||
ctx.getString(R.string.lang_en_gb),
|
||||
ctx.getString(R.string.lang_eo),
|
||||
ctx.getString(R.string.lang_es),
|
||||
ctx.getString(R.string.lang_es_ar),
|
||||
ctx.getString(R.string.lang_es_us),
|
||||
ctx.getString(R.string.lang_eu),
|
||||
ctx.getString(R.string.lang_fa),
|
||||
ctx.getString(R.string.lang_fi) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_fr),
|
||||
ctx.getString(R.string.lang_gl),
|
||||
ctx.getString(R.string.lang_he),
|
||||
ctx.getString(R.string.lang_hr) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_hsb) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_hu),
|
||||
ctx.getString(R.string.lang_hy),
|
||||
ctx.getString(R.string.lang_is),
|
||||
ctx.getString(R.string.lang_it),
|
||||
ctx.getString(R.string.lang_ja),
|
||||
ctx.getString(R.string.lang_ka) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_kab) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_kn) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_ko),
|
||||
ctx.getString(R.string.lang_lt),
|
||||
ctx.getString(R.string.lang_lv),
|
||||
ctx.getString(R.string.lang_ml),
|
||||
ctx.getString(R.string.lang_mr) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_nb),
|
||||
ctx.getString(R.string.lang_nl),
|
||||
ctx.getString(R.string.lang_nn) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_oc) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_pl),
|
||||
ctx.getString(R.string.lang_pt),
|
||||
ctx.getString(R.string.lang_pt_br),
|
||||
ctx.getString(R.string.lang_ro) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_ru),
|
||||
ctx.getString(R.string.lang_sc),
|
||||
ctx.getString(R.string.lang_sk),
|
||||
ctx.getString(R.string.lang_sl),
|
||||
ctx.getString(R.string.lang_sr),
|
||||
ctx.getString(R.string.lang_sr_latn) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_sv),
|
||||
ctx.getString(R.string.lang_tr),
|
||||
ctx.getString(R.string.lang_uk),
|
||||
ctx.getString(R.string.lang_vi) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_zh_cn) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_zh_tw)};
|
||||
|
||||
String[] valuesPl = ConfigureMapMenu.getSortedMapNamesIds(ctx, entries, entries);
|
||||
String[] idsPl = ConfigureMapMenu.getSortedMapNamesIds(ctx, entryValues, entries);
|
||||
|
||||
return Pair.create(valuesPl, idsPl);
|
||||
}
|
||||
|
||||
protected void enableProxy(boolean enable) {
|
||||
settings.ENABLE_PROXY.set(enable);
|
||||
if (enable) {
|
||||
NetworkUtils.setProxy(settings.PROXY_HOST.get(), settings.PROXY_PORT.get());
|
||||
} else {
|
||||
NetworkUtils.setProxy(null, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void addProxyPrefs(PreferenceGroup proxy) {
|
||||
CheckBoxPreference enableProxyPref = (CheckBoxPreference) proxy.findPreference(settings.ENABLE_PROXY.getId());
|
||||
enableProxyPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
enableProxy((Boolean) newValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
EditTextPreference hostPref = (EditTextPreference) proxy.findPreference(settings.PROXY_HOST.getId());
|
||||
hostPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String ipAddress = (String) newValue;
|
||||
if (ipAddress.matches(IP_ADDRESS_PATTERN)) {
|
||||
settings.PROXY_HOST.set(ipAddress);
|
||||
enableProxy(NetworkUtils.getProxy() != null);
|
||||
return true;
|
||||
} else {
|
||||
Toast.makeText(SettingsGeneralActivity.this, getString(R.string.wrong_format), Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
EditTextPreference portPref = (EditTextPreference) proxy.findPreference(settings.PROXY_PORT.getId());
|
||||
portPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
int port = -1;
|
||||
String portString = (String) newValue;
|
||||
try {
|
||||
port = Integer.valueOf(portString.replaceAll("[^0-9]", ""));
|
||||
} catch (NumberFormatException e1) {
|
||||
}
|
||||
settings.PROXY_PORT.set(port);
|
||||
enableProxy(NetworkUtils.getProxy() != null);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void showAppDirDialog() {
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
showAppDirDialogV19();
|
||||
return;
|
||||
}
|
||||
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());
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT);
|
||||
lp.leftMargin = lp.rightMargin = 5;
|
||||
lp.bottomMargin = lp.topMargin = 5;
|
||||
input.setLayoutParams(lp);
|
||||
settings.getExternalStorageDirectory().getAbsolutePath();
|
||||
editalert.setView(input);
|
||||
editalert.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
editalert.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
warnAboutChangingStorage(input.getText().toString());
|
||||
}
|
||||
});
|
||||
editalert.show();
|
||||
|
||||
}
|
||||
|
||||
private void showAppDirDialogV19() {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(this);
|
||||
chooseAppDirFragment = new DashChooseAppDirFragment.ChooseAppDirFragment(this, (Dialog) null) {
|
||||
@Override
|
||||
protected void successCallback() {
|
||||
updateApplicationDirTextAndSummary();
|
||||
}
|
||||
};
|
||||
if (permissionRequested && !permissionGranted) {
|
||||
chooseAppDirFragment.setPermissionDenied();
|
||||
}
|
||||
bld.setView(chooseAppDirFragment.initView(getLayoutInflater(), null, null));
|
||||
AlertDialog dlg = bld.show();
|
||||
chooseAppDirFragment.setDialog(dlg);
|
||||
}
|
||||
|
||||
|
||||
private void addMiscPreferences(PreferenceGroup misc) {
|
||||
if (!Version.isBlackberry(getMyApplication())) {
|
||||
applicationDir = new Preference(this);
|
||||
applicationDir.setTitle(R.string.application_dir);
|
||||
applicationDir.setKey(OsmandSettings.EXTERNAL_STORAGE_DIR);
|
||||
applicationDir.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
showAppDirDialog();
|
||||
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) {
|
||||
misc.addPreference(createCheckBoxPreference(settings.USE_TRACKBALL_FOR_MOVEMENTS, R.string.use_trackball,
|
||||
R.string.use_trackball_descr));
|
||||
}
|
||||
}
|
||||
|
||||
registerListPreference(
|
||||
settings.OSMAND_THEME, misc,
|
||||
new String[]{getString(R.string.dark_theme), getString(R.string.light_theme)}, new Integer[]{OsmandSettings.OSMAND_DARK_THEME,
|
||||
OsmandSettings.OSMAND_LIGHT_THEME});
|
||||
|
||||
registerListPreference(
|
||||
settings.EXTERNAL_INPUT_DEVICE, misc,
|
||||
new String[]{getString(R.string.sett_no_ext_input), getString(R.string.sett_generic_ext_input), getString(R.string.sett_wunderlinq_ext_input), getString(R.string.sett_parrot_ext_input)}, new Integer[]{OsmandSettings.NO_EXTERNAL_DEVICE,
|
||||
OsmandSettings.GENERIC_EXTERNAL_DEVICE, OsmandSettings.WUNDERLINQ_EXTERNAL_DEVICE, OsmandSettings.PARROT_EXTERNAL_DEVICE});
|
||||
|
||||
misc.addPreference(createCheckBoxPreference(settings.MAP_EMPTY_STATE_ALLOWED, R.string.tap_on_map_to_hide_interface, R.string.tap_on_map_to_hide_interface_descr));
|
||||
misc.addPreference(createCheckBoxPreference(settings.USE_KALMAN_FILTER_FOR_COMPASS, R.string.use_kalman_filter_compass, R.string.use_kalman_filter_compass_descr));
|
||||
misc.addPreference(createCheckBoxPreference(settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS, R.string.use_magnetic_sensor, R.string.use_magnetic_sensor_descr));
|
||||
misc.addPreference(createCheckBoxPreference(settings.ANIMATE_MY_LOCATION,R.string.animate_my_location, R.string.animate_my_location_desc));
|
||||
misc.addPreference(createCheckBoxPreference(settings.DO_NOT_USE_ANIMATIONS, R.string.do_not_use_animations, R.string.do_not_use_animations_descr));
|
||||
misc.addPreference(createCheckBoxPreference(settings.DO_NOT_SHOW_STARTUP_MESSAGES, R.string.do_not_show_startup_messages, R.string.do_not_show_startup_messages_desc));
|
||||
}
|
||||
|
||||
|
||||
private void updateApplicationDirTextAndSummary() {
|
||||
if (applicationDir != null) {
|
||||
String storageDir = settings.getExternalStorageDirectory().getAbsolutePath();
|
||||
applicationDir.setSummary(storageDir);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAllSettings() {
|
||||
super.updateAllSettings();
|
||||
updateApplicationDirTextAndSummary();
|
||||
applicationModePreference.setTitle(getString(R.string.settings_preset) + " ["
|
||||
+ settings.APPLICATION_MODE.get().toHumanString() + "]");
|
||||
drivingRegionPreference.setTitle(getString(R.string.driving_region) + " ["
|
||||
+ getString(settings.DRIVING_REGION_AUTOMATIC.get() ? R.string.driving_region_automatic : settings.DRIVING_REGION.get().name) + "]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String id = preference.getKey();
|
||||
super.onPreferenceChange(preference, newValue);
|
||||
if (id.equals(settings.SAFE_MODE.getId())) {
|
||||
if ((Boolean) newValue) {
|
||||
loadNativeLibrary();
|
||||
}
|
||||
} else if (preference == applicationDir) {
|
||||
return false;
|
||||
} else if (id.equals(settings.DEFAULT_APPLICATION_MODE.getId())) {
|
||||
settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get());
|
||||
updateAllSettings();
|
||||
} else if (id.equals(settings.PREFERRED_LOCALE.getId())) {
|
||||
// restart application to update locale
|
||||
getMyApplication().checkPreferredLocale();
|
||||
getMyApplication().restartApp(this);
|
||||
} else if (id.equals(settings.OSMAND_THEME.getId())) {
|
||||
getMyApplication().restartApp(this);
|
||||
} else if (id.equals(settings.DO_NOT_USE_ANIMATIONS.getId())) {
|
||||
getMyApplication().restartApp(this);
|
||||
} else {
|
||||
updateAllSettings();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void warnAboutChangingStorage(final String newValue) {
|
||||
String newDir = newValue != null ? newValue.trim() : newValue;
|
||||
if (!newDir.replace('/', ' ').trim().
|
||||
toLowerCase().endsWith(IndexConstants.APP_DIR.replace('/', ' ').trim())) {
|
||||
newDir += "/" + IndexConstants.APP_DIR;
|
||||
}
|
||||
final File path = new File(newDir);
|
||||
path.mkdirs();
|
||||
if (!path.canRead() || !path.exists()) {
|
||||
Toast.makeText(this, R.string.specified_dir_doesnt_exist, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setMessage(getString(R.string.application_dir_change_warning3));
|
||||
builder.setPositiveButton(R.string.shared_string_yes, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
MoveFilesToDifferentDirectory task =
|
||||
new MoveFilesToDifferentDirectory(SettingsGeneralActivity.this,
|
||||
settings.getExternalStorageDirectory(), path);
|
||||
task.setRunOnSuccess(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateSettingsToNewDir(path.getParentFile().getAbsolutePath());
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
});
|
||||
builder.setNeutralButton(R.string.shared_string_no, new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
updateSettingsToNewDir(path.getParentFile().getAbsolutePath());
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
builder.show();
|
||||
}
|
||||
|
||||
private void updateSettingsToNewDir(final String newDir) {
|
||||
// edit the preference
|
||||
settings.setExternalStorageDirectoryPre19(newDir);
|
||||
getMyApplication().getResourceManager().resetStoreDirectory();
|
||||
reloadIndexes();
|
||||
updateApplicationDirTextAndSummary();
|
||||
}
|
||||
|
||||
public void reloadIndexes() {
|
||||
setProgressVisibility(true);
|
||||
final CharSequence oldTitle = getToolbar().getTitle();
|
||||
getToolbar().setTitle(getString(R.string.loading_data));
|
||||
getToolbar().setSubtitle(getString(R.string.reading_indexes));
|
||||
new AsyncTask<Void, Void, List<String>>() {
|
||||
|
||||
@Override
|
||||
protected List<String> doInBackground(Void... params) {
|
||||
return getMyApplication().getResourceManager().reloadIndexes(IProgress.EMPTY_PROGRESS,
|
||||
new ArrayList<String>());
|
||||
}
|
||||
|
||||
protected void onPostExecute(List<String> result) {
|
||||
showWarnings(result);
|
||||
getToolbar().setTitle(oldTitle);
|
||||
getToolbar().setSubtitle("");
|
||||
setProgressVisibility(false);
|
||||
}
|
||||
|
||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
public void loadNativeLibrary() {
|
||||
if (!NativeOsmandLibrary.isLoaded()) {
|
||||
final RenderingRulesStorage storage = getMyApplication().getRendererRegistry().getCurrentSelectedRenderer();
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
setProgressVisibility(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
NativeOsmandLibrary.getLibrary(storage, getMyApplication());
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
setProgressVisibility(false);
|
||||
if (!NativeOsmandLibrary.isNativeSupported(storage, getMyApplication())) {
|
||||
Toast.makeText(SettingsGeneralActivity.this, R.string.native_library_not_supported, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void showWarnings(List<String> warnings) {
|
||||
if (!warnings.isEmpty()) {
|
||||
final StringBuilder b = AndroidUtils.formatWarnings(warnings);
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(SettingsGeneralActivity.this, b.toString(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (permissionRequested) {
|
||||
showAppDirDialogV19();
|
||||
permissionRequested = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode,
|
||||
String permissions[], int[] grantResults) {
|
||||
permissionRequested = requestCode == DownloadActivity.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE;
|
||||
if (permissionRequested
|
||||
&& grantResults.length > 0
|
||||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
permissionGranted = true;
|
||||
} else {
|
||||
permissionGranted = false;
|
||||
Toast.makeText(this,
|
||||
R.string.missing_write_external_storage_permission,
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,915 +0,0 @@
|
|||
package net.osmand.plus.activities;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.DialogInterface.OnMultiChoiceClickListener;
|
||||
import android.content.Intent;
|
||||
import android.media.AudioAttributes;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceCategory;
|
||||
import android.preference.PreferenceGroup;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.google.android.material.slider.Slider;
|
||||
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.helpers.enums.MetricsConstants;
|
||||
import net.osmand.plus.settings.backend.CommonPreference;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.helpers.enums.AutoZoomMap;
|
||||
import net.osmand.plus.settings.backend.OsmandPreference;
|
||||
import net.osmand.plus.helpers.enums.SpeedConstants;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.DownloadActivityType;
|
||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper;
|
||||
import net.osmand.plus.routing.RouteProvider.RouteService;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.voice.CommandPlayer;
|
||||
import net.osmand.router.GeneralRouter;
|
||||
import net.osmand.router.GeneralRouter.GeneralRouterProfile;
|
||||
import net.osmand.router.GeneralRouter.RoutingParameter;
|
||||
import net.osmand.router.GeneralRouter.RoutingParameterType;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||
public static final String MORE_VALUE = "MORE_VALUE";
|
||||
|
||||
private Preference avoidRouting;
|
||||
private Preference preferRouting;
|
||||
private Preference reliefFactorRouting;
|
||||
private Preference autoZoom;
|
||||
private Preference showAlarms;
|
||||
private Preference speakAlarms;
|
||||
private Preference defaultSpeed;
|
||||
private Preference defaultSpeedOnly;
|
||||
private ListPreference routerServicePreference;
|
||||
private ListPreference speedLimitExceed;
|
||||
|
||||
private List<RoutingParameter> avoidParameters = new ArrayList<RoutingParameter>();
|
||||
private List<RoutingParameter> preferParameters = new ArrayList<RoutingParameter>();
|
||||
private List<RoutingParameter> reliefFactorParameters = new ArrayList<RoutingParameter>();
|
||||
public static final String INTENT_SKIP_DIALOG = "INTENT_SKIP_DIALOG";
|
||||
|
||||
public SettingsNavigationActivity() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
((OsmandApplication) getApplication()).applyTheme(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
settings = getMyApplication().getSettings();
|
||||
if (!settings.hasAvailableApplicationMode()) {
|
||||
Toast.makeText(this, R.string.turn_on_profile_desc, Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
getToolbar().setTitle(R.string.routing_settings);
|
||||
createUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if(getIntent() != null && getIntent().hasExtra(INTENT_SKIP_DIALOG)) {
|
||||
setSelectedAppMode(settings.getApplicationMode());
|
||||
} else if (selectedAppMode == null) {
|
||||
selectAppModeDialog().show();
|
||||
}
|
||||
}
|
||||
|
||||
private void createUI() {
|
||||
addPreferencesFromResource(R.xml.navigation_settings);
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
RouteService[] vls = RouteService.getAvailableRouters(getMyApplication());
|
||||
String[] entries = new String[vls.length];
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
entries[i] = vls[i].getName();
|
||||
}
|
||||
|
||||
registerBooleanPreference(settings.SNAP_TO_ROAD, screen);
|
||||
|
||||
Integer[] intValues = new Integer[] { 0, 5, 10, 15, 20, 25, 30, 45, 60, 90};
|
||||
entries = new String[intValues.length];
|
||||
entries[0] = getString(R.string.shared_string_never);
|
||||
for (int i = 1; i < intValues.length; i++) {
|
||||
entries[i] = (int) intValues[i] + " " + getString(R.string.int_seconds);
|
||||
}
|
||||
registerListPreference(settings.AUTO_FOLLOW_ROUTE, screen, entries, intValues);
|
||||
|
||||
autoZoom = screen.findPreference("auto_zoom_map_on_off");
|
||||
autoZoom.setOnPreferenceClickListener(this);
|
||||
|
||||
//keep informing option:
|
||||
Integer[] keepInformingValues = new Integer[]{0, 1, 2, 3, 5, 7, 10, 15, 20, 25, 30};
|
||||
String[] keepInformingNames = new String[keepInformingValues.length];
|
||||
keepInformingNames[0] = getString(R.string.keep_informing_never);
|
||||
for (int i = 1; i < keepInformingValues.length; i++)
|
||||
{
|
||||
keepInformingNames[i] = keepInformingValues[i] + " " + getString(R.string.int_min);
|
||||
}
|
||||
registerListPreference(settings.KEEP_INFORMING, screen, keepInformingNames, keepInformingValues);
|
||||
|
||||
SpeedConstants[] speedValues = SpeedConstants.values();
|
||||
String[] speedNamesVls = new String[speedValues.length];
|
||||
for(int i = 0; i < speedValues.length; i++) {
|
||||
speedNamesVls[i] = speedValues[i].toHumanString(this);
|
||||
};
|
||||
registerListPreference(settings.SPEED_SYSTEM, screen, speedNamesVls, speedValues);
|
||||
|
||||
// registerBooleanPreference(settings.SHOW_ZOOM_BUTTONS_NAVIGATION, screen);
|
||||
|
||||
showAlarms = (Preference) screen.findPreference("show_routing_alarms");
|
||||
showAlarms.setOnPreferenceClickListener(this);
|
||||
|
||||
speakAlarms = (Preference) screen.findPreference("speak_routing_alarms");
|
||||
speakAlarms.setOnPreferenceClickListener(this);
|
||||
|
||||
Float[] arrivalValues = new Float[] {1.5f, 1f, 0.5f, 0.25f} ;
|
||||
String[] arrivalNames = new String[] {
|
||||
getString(R.string.arrival_distance_factor_early),
|
||||
getString(R.string.arrival_distance_factor_normally),
|
||||
getString(R.string.arrival_distance_factor_late),
|
||||
getString(R.string.arrival_distance_factor_at_last)
|
||||
};
|
||||
registerListPreference(settings.ARRIVAL_DISTANCE_FACTOR, screen, arrivalNames, arrivalValues);
|
||||
|
||||
|
||||
//array size must be equal!
|
||||
Float[] speedLimitsKmh = new Float[]{-10f, -7f, -5f, 0f, 5f, 7f, 10f, 15f, 20f};
|
||||
Float[] speedLimitsMph = new Float[]{-7f, -5f, -3f, 0f, 3f, 5f, 7f, 10f, 15f};
|
||||
//array size must be equal!
|
||||
Float[] speedLimitsKmhPos = new Float[]{0f, 5f, 7f, 10f, 15f, 20f};
|
||||
Float[] speedLimitsMphPos = new Float[]{0f, 3f, 5f, 7f, 10f, 15f};
|
||||
if (settings.METRIC_SYSTEM.get() == MetricsConstants.KILOMETERS_AND_METERS) {
|
||||
String[] speedNames = new String[speedLimitsKmh.length];
|
||||
String[] speedNamesPos = new String[speedLimitsKmhPos.length];
|
||||
for (int i = 0; i < speedLimitsKmh.length; i++) {
|
||||
speedNames[i] = speedLimitsKmh[i].intValue() + " " + getString(R.string.km_h);
|
||||
}
|
||||
for (int i = 0; i < speedLimitsKmhPos.length; i++) {
|
||||
speedNamesPos[i] = speedLimitsKmhPos[i].intValue() + " " + getString(R.string.km_h);
|
||||
}
|
||||
registerListPreference(settings.SPEED_LIMIT_EXCEED_KMH, screen, speedNames, speedLimitsKmh);
|
||||
registerListPreference(settings.SWITCH_MAP_DIRECTION_TO_COMPASS_KMH, screen, speedNamesPos, speedLimitsKmhPos);
|
||||
} else {
|
||||
String[] speedNames = new String[speedLimitsMph.length];
|
||||
String[] speedNamesPos = new String[speedLimitsMphPos.length];
|
||||
for (int i = 0; i < speedNames.length; i++) {
|
||||
speedNames[i] = speedLimitsMph[i].intValue() + " " + getString(R.string.mile_per_hour);
|
||||
}
|
||||
for (int i = 0; i < speedNamesPos.length; i++) {
|
||||
speedNamesPos[i] = speedLimitsMphPos[i].intValue() + " " + getString(R.string.mile_per_hour);
|
||||
}
|
||||
registerListPreference(settings.SPEED_LIMIT_EXCEED_KMH, screen, speedNames, speedLimitsKmh);
|
||||
registerListPreference(settings.SWITCH_MAP_DIRECTION_TO_COMPASS_KMH, screen, speedNamesPos, speedLimitsKmhPos);
|
||||
}
|
||||
|
||||
PreferenceCategory category = (PreferenceCategory) screen.findPreference("guidance_preferences");
|
||||
speedLimitExceed = (ListPreference) category.findPreference("speed_limit_exceed");
|
||||
ApplicationMode mode = getMyApplication().getSettings().getApplicationMode();
|
||||
if (!mode.isDerivedRoutingFrom(ApplicationMode.CAR)) {
|
||||
category.removePreference(speedLimitExceed);
|
||||
}
|
||||
|
||||
// deprecated 2.2
|
||||
// Integer[] delayIntervals = new Integer[] { -1, 3, 5, 7, 10, 15, 20 };
|
||||
// String[] delayIntervalNames = new String[delayIntervals.length];
|
||||
// for (int i = 0; i < delayIntervals.length; i++) {
|
||||
// if (i == 0) {
|
||||
// delayIntervalNames[i] = getString(R.string.auto_follow_route_never);
|
||||
// } else {
|
||||
// delayIntervalNames[i] = delayIntervals[i] + " " + getString(R.string.int_seconds);
|
||||
// }
|
||||
// }
|
||||
// registerListPreference(settings.DELAY_TO_START_NAVIGATION, screen, delayIntervalNames, delayIntervals);
|
||||
|
||||
|
||||
|
||||
registerBooleanPreference(settings.ENABLE_TIME_CONDITIONAL_ROUTING, screen);
|
||||
|
||||
addTurnScreenOn((PreferenceGroup) screen.findPreference("turn_screen_on"));
|
||||
|
||||
addVoicePrefs((PreferenceGroup) screen.findPreference("voice"));
|
||||
}
|
||||
|
||||
private void addTurnScreenOn(PreferenceGroup screen) {
|
||||
Integer[] screenPowerSaveValues = new Integer[] { 0, 5, 10, 15, 20, 30, 45, 60 };
|
||||
String[] screenPowerSaveNames = new String[screenPowerSaveValues.length];
|
||||
screenPowerSaveNames[0] = getString(R.string.shared_string_never);
|
||||
for (int i = 1; i < screenPowerSaveValues.length; i++) {
|
||||
screenPowerSaveNames[i] = screenPowerSaveValues[i] + " "
|
||||
+ getString(R.string.int_seconds);
|
||||
}
|
||||
registerListPreference(settings.TURN_SCREEN_ON_TIME_INT, screen, screenPowerSaveNames, screenPowerSaveValues);
|
||||
registerBooleanPreference(settings.TURN_SCREEN_ON_SENSOR, screen);
|
||||
}
|
||||
|
||||
private void reloadVoiceListPreference(PreferenceScreen screen) {
|
||||
String[] entries;
|
||||
String[] entrieValues;
|
||||
Set<String> voiceFiles = getMyApplication().getRoutingOptionsHelper().getVoiceFiles(this);
|
||||
entries = new String[voiceFiles.size() + 2];
|
||||
entrieValues = new String[voiceFiles.size() + 2];
|
||||
int k = 0;
|
||||
// entries[k++] = getString(R.string.shared_string_none);
|
||||
entrieValues[k] = OsmandSettings.VOICE_PROVIDER_NOT_USE;
|
||||
entries[k++] = getString(R.string.shared_string_do_not_use);
|
||||
for (String s : voiceFiles) {
|
||||
entries[k] = (s.contains("tts") ? getString(R.string.ttsvoice) + " " : "") +
|
||||
FileNameTranslationHelper.getVoiceName(this, s);
|
||||
entrieValues[k] = s;
|
||||
k++;
|
||||
}
|
||||
entrieValues[k] = MORE_VALUE;
|
||||
entries[k] = getString(R.string.install_more);
|
||||
registerListPreference(settings.VOICE_PROVIDER, screen, entries, entrieValues);
|
||||
}
|
||||
|
||||
private void addVoicePrefs(PreferenceGroup cat) {
|
||||
if (!Version.isBlackberry((OsmandApplication) getApplication())) {
|
||||
String[] streamTypes = new String[]{getString(R.string.voice_stream_music),
|
||||
getString(R.string.voice_stream_notification), getString(R.string.voice_stream_voice_call)};
|
||||
//getString(R.string.shared_string_default)};
|
||||
Integer[] streamIntTypes = new Integer[]{AudioManager.STREAM_MUSIC,
|
||||
AudioManager.STREAM_NOTIFICATION, AudioManager.STREAM_VOICE_CALL};
|
||||
//AudioManager.USE_DEFAULT_STREAM_TYPE};
|
||||
ListPreference lp = createListPreference(
|
||||
settings.AUDIO_MANAGER_STREAM, streamTypes, streamIntTypes , R.string.choose_audio_stream,
|
||||
R.string.choose_audio_stream_descr);
|
||||
final Preference.OnPreferenceChangeListener prev = lp.getOnPreferenceChangeListener();
|
||||
lp.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
prev.onPreferenceChange(preference, newValue);
|
||||
CommandPlayer player = getMyApplication().getPlayer();
|
||||
if (player != null) {
|
||||
player.updateAudioStream(settings.AUDIO_MANAGER_STREAM.get());
|
||||
}
|
||||
// Sync corresponding AUDIO_USAGE value
|
||||
ApplicationMode mode = getMyApplication().getSettings().getApplicationMode();
|
||||
int stream = settings.AUDIO_MANAGER_STREAM.getModeValue(mode);
|
||||
if (stream == AudioManager.STREAM_MUSIC) {
|
||||
settings.AUDIO_USAGE.setModeValue(mode, AudioAttributes.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE);
|
||||
} else if (stream == AudioManager.STREAM_NOTIFICATION) {
|
||||
settings.AUDIO_USAGE.setModeValue(mode, AudioAttributes.USAGE_NOTIFICATION);
|
||||
} else if (stream == AudioManager.STREAM_VOICE_CALL) {
|
||||
settings.AUDIO_USAGE.setModeValue(mode, AudioAttributes.USAGE_VOICE_COMMUNICATION);
|
||||
}
|
||||
|
||||
// Sync DEFAULT value with CAR value, as we have other way to set it for now
|
||||
settings.AUDIO_MANAGER_STREAM.setModeValue(ApplicationMode.DEFAULT, settings.AUDIO_MANAGER_STREAM.getModeValue(ApplicationMode.CAR));
|
||||
settings.AUDIO_USAGE.setModeValue(ApplicationMode.DEFAULT, settings.AUDIO_USAGE.getModeValue(ApplicationMode.CAR));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
cat.addPreference(lp);
|
||||
cat.addPreference(createCheckBoxPreference(settings.INTERRUPT_MUSIC, R.string.interrupt_music,
|
||||
R.string.interrupt_music_descr));
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareRoutingPrefs(PreferenceScreen screen) {
|
||||
PreferenceCategory cat = (PreferenceCategory) screen.findPreference("routing_preferences");
|
||||
cat.removeAll();
|
||||
CheckBoxPreference fastRoute = createCheckBoxPreference(settings.FAST_ROUTE_MODE, R.string.fast_route_mode, R.string.fast_route_mode_descr);
|
||||
RouteService routeService = settings.getApplicationMode().getRouteService();
|
||||
if (routeService != RouteService.OSMAND) {
|
||||
if (routeService == RouteService.STRAIGHT) {
|
||||
defaultSpeedOnly = new Preference(this);
|
||||
defaultSpeedOnly.setTitle(R.string.default_speed_setting_title);
|
||||
defaultSpeedOnly.setSummary(R.string.default_speed_setting_descr);
|
||||
defaultSpeedOnly.setOnPreferenceClickListener(this);
|
||||
cat.addPreference(defaultSpeedOnly);
|
||||
}
|
||||
cat.addPreference(fastRoute);
|
||||
} else {
|
||||
ApplicationMode am = settings.getApplicationMode();
|
||||
GeneralRouter router = settings.getContext().getRouter(am);
|
||||
clearParameters();
|
||||
if (router != null) {
|
||||
GeneralRouterProfile routerProfile = router.getProfile();
|
||||
if (routerProfile != GeneralRouterProfile.PUBLIC_TRANSPORT) {
|
||||
defaultSpeed = new Preference(this);
|
||||
defaultSpeed.setTitle(R.string.default_speed_setting_title);
|
||||
defaultSpeed.setSummary(R.string.default_speed_setting_descr);
|
||||
defaultSpeed.setOnPreferenceClickListener(this);
|
||||
cat.addPreference(defaultSpeed);
|
||||
}
|
||||
|
||||
Map<String, RoutingParameter> parameters = router.getParameters();
|
||||
if(parameters.containsKey(GeneralRouter.USE_SHORTEST_WAY)) {
|
||||
cat.addPreference(fastRoute);
|
||||
}
|
||||
List<RoutingParameter> others = new ArrayList<GeneralRouter.RoutingParameter>();
|
||||
for(Map.Entry<String, RoutingParameter> e : parameters.entrySet()) {
|
||||
String param = e.getKey();
|
||||
RoutingParameter routingParameter = e.getValue();
|
||||
if (param.startsWith("avoid_")) {
|
||||
avoidParameters.add(routingParameter);
|
||||
} else if (param.startsWith("prefer_")) {
|
||||
preferParameters.add(routingParameter);
|
||||
} else if ("relief_smoothness_factor".equals(routingParameter.getGroup())) {
|
||||
reliefFactorParameters.add(routingParameter);
|
||||
} else if (!param.equals(GeneralRouter.USE_SHORTEST_WAY) && !RoutingOptionsHelper.DRIVING_STYLE.equals(routingParameter.getGroup())) {
|
||||
others.add(routingParameter);
|
||||
}
|
||||
}
|
||||
if (avoidParameters.size() > 0) {
|
||||
avoidRouting = new Preference(this);
|
||||
avoidRouting.setTitle(R.string.avoid_in_routing_title);
|
||||
avoidRouting.setSummary(R.string.avoid_in_routing_descr_);
|
||||
avoidRouting.setOnPreferenceClickListener(this);
|
||||
cat.addPreference(avoidRouting);
|
||||
}
|
||||
if (preferParameters.size() > 0) {
|
||||
preferRouting = new Preference(this);
|
||||
preferRouting.setTitle(R.string.prefer_in_routing_title);
|
||||
preferRouting.setSummary(R.string.prefer_in_routing_descr);
|
||||
preferRouting.setOnPreferenceClickListener(this);
|
||||
cat.addPreference(preferRouting);
|
||||
}
|
||||
if (reliefFactorParameters.size() > 0) {
|
||||
reliefFactorRouting = new Preference(this);
|
||||
reliefFactorRouting.setTitle(SettingsBaseActivity.getRoutingStringPropertyName(this, reliefFactorParameters.get(0).getGroup(),
|
||||
Algorithms.capitalizeFirstLetterAndLowercase(reliefFactorParameters.get(0).getGroup().replace('_', ' '))));
|
||||
reliefFactorRouting.setSummary(R.string.relief_smoothness_factor_descr);
|
||||
reliefFactorRouting.setOnPreferenceClickListener(this);
|
||||
cat.addPreference(reliefFactorRouting);
|
||||
}
|
||||
for(RoutingParameter p : others) {
|
||||
Preference basePref;
|
||||
if(p.getType() == RoutingParameterType.BOOLEAN) {
|
||||
basePref = createCheckBoxPreference(settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean()));
|
||||
} else {
|
||||
Object[] vls = p.getPossibleValues();
|
||||
String[] svlss = new String[vls.length];
|
||||
int i = 0;
|
||||
for(Object o : vls) {
|
||||
svlss[i++] = o.toString();
|
||||
}
|
||||
basePref = createListPreference(settings.getCustomRoutingProperty(p.getId(),
|
||||
p.getType() == RoutingParameterType.NUMERIC ? "0.0" : "-"),
|
||||
p.getPossibleValueDescriptions(), svlss,
|
||||
SettingsBaseActivity.getRoutingStringPropertyName(this, p.getId(), p.getName()),
|
||||
SettingsBaseActivity.getRoutingStringPropertyDescription(this, p.getId(), p.getDescription()));
|
||||
}
|
||||
basePref.setTitle(SettingsBaseActivity.getRoutingStringPropertyName(this, p.getId(), p.getName()));
|
||||
basePref.setSummary(SettingsBaseActivity.getRoutingStringPropertyDescription(this, p.getId(), p.getDescription()));
|
||||
cat.addPreference(basePref);
|
||||
}
|
||||
}
|
||||
ApplicationMode mode = getMyApplication().getSettings().getApplicationMode();
|
||||
if (mode.isDerivedRoutingFrom(ApplicationMode.CAR)) {
|
||||
PreferenceCategory category = (PreferenceCategory) screen.findPreference("guidance_preferences");
|
||||
category.addPreference(speedLimitExceed);
|
||||
} else {
|
||||
PreferenceCategory category = (PreferenceCategory) screen.findPreference("guidance_preferences");
|
||||
category.removePreference(speedLimitExceed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getRoutinParameterTitle(Context context, RoutingParameter routingParameter) {
|
||||
return SettingsBaseActivity.getRoutingStringPropertyName(context, routingParameter.getId(),
|
||||
routingParameter.getName());
|
||||
}
|
||||
|
||||
public static boolean isRoutingParameterSelected(OsmandSettings settings, ApplicationMode am, RoutingParameter routingParameter) {
|
||||
final CommonPreference<Boolean> property =
|
||||
settings.getCustomRoutingBooleanProperty(routingParameter.getId(), routingParameter.getDefaultBoolean());
|
||||
if(am != null) {
|
||||
return property.getModeValue(am);
|
||||
} else {
|
||||
return property.get();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setRoutingParameterSelected(OsmandSettings settings, ApplicationMode am, String routingParameterId, boolean defaultBoolean, boolean isChecked) {
|
||||
final CommonPreference<Boolean> property = settings.getCustomRoutingBooleanProperty(routingParameterId, defaultBoolean);
|
||||
if (am != null) {
|
||||
property.setModeValue(am, isChecked);
|
||||
} else {
|
||||
property.set(isChecked);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void clearParameters() {
|
||||
preferParameters.clear();
|
||||
avoidParameters.clear();
|
||||
reliefFactorParameters.clear();
|
||||
}
|
||||
|
||||
public void updateAllSettings() {
|
||||
prepareRoutingPrefs(getPreferenceScreen());
|
||||
reloadVoiceListPreference(getPreferenceScreen());
|
||||
super.updateAllSettings();
|
||||
}
|
||||
|
||||
@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, DownloadActivity.class);
|
||||
intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB);
|
||||
intent.putExtra(DownloadActivity.FILTER_CAT, DownloadActivityType.VOICE_FILE.getTag());
|
||||
startActivity(intent);
|
||||
} else {
|
||||
super.onPreferenceChange(preference, newValue);
|
||||
getMyApplication().initVoiceCommandPlayer(this, settings.APPLICATION_MODE.get(),
|
||||
false, null, true, false, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
super.onPreferenceChange(preference, newValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (preference == avoidRouting || preference == preferRouting) {
|
||||
List<RoutingParameter> prms = preference == avoidRouting ? avoidParameters : preferParameters;
|
||||
String[] vals = new String[prms.size()];
|
||||
OsmandPreference[] bls = new OsmandPreference[prms.size()];
|
||||
for (int i = 0; i < prms.size(); i++) {
|
||||
RoutingParameter p = prms.get(i);
|
||||
vals[i] = SettingsBaseActivity.getRoutingStringPropertyName(this, p.getId(), p.getName());
|
||||
bls[i] = settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean());
|
||||
}
|
||||
showBooleanSettings(this, vals, bls, preference.getTitle());
|
||||
return true;
|
||||
} else if (preference == autoZoom) {
|
||||
final ApplicationMode am = settings.getApplicationMode();
|
||||
final ContextMenuAdapter adapter = new ContextMenuAdapter(getMyApplication());
|
||||
int i = 0;
|
||||
int selectedIndex = -1;
|
||||
adapter.addItem(ContextMenuItem.createBuilder(getString(R.string.auto_zoom_none))
|
||||
.setSelected(false).createItem());
|
||||
if (!settings.AUTO_ZOOM_MAP.get()) {
|
||||
selectedIndex = 0;
|
||||
}
|
||||
i++;
|
||||
for (AutoZoomMap autoZoomMap : AutoZoomMap.values()) {
|
||||
adapter.addItem(ContextMenuItem.createBuilder(getString(autoZoomMap.name))
|
||||
.setSelected(false).createItem());
|
||||
if (selectedIndex == -1 && settings.AUTO_ZOOM_MAP_SCALE.get() == autoZoomMap) {
|
||||
selectedIndex = i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (selectedIndex == -1) {
|
||||
selectedIndex = 0;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
final int layout = R.layout.list_menu_item_native_singlechoice;
|
||||
|
||||
final ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(this, layout, R.id.text1,
|
||||
adapter.getItemNames()) {
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
// User super class to create the View
|
||||
View v = convertView;
|
||||
if (v == null) {
|
||||
v = SettingsNavigationActivity.this.getLayoutInflater().inflate(layout, null);
|
||||
}
|
||||
final ContextMenuItem item = adapter.getItem(position);
|
||||
TextView tv = (TextView) v.findViewById(R.id.text1);
|
||||
tv.setText(item.getTitle());
|
||||
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f);
|
||||
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
final int[] selectedPosition = {selectedIndex};
|
||||
builder.setSingleChoiceItems(listAdapter, selectedIndex, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int position) {
|
||||
selectedPosition[0] = position;
|
||||
}
|
||||
});
|
||||
builder.setTitle(R.string.auto_zoom_map)
|
||||
.setPositiveButton(R.string.shared_string_ok, new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
int position = selectedPosition[0];
|
||||
if (position == 0) {
|
||||
settings.AUTO_ZOOM_MAP.set(false);
|
||||
} else {
|
||||
settings.AUTO_ZOOM_MAP.set(true);
|
||||
settings.AUTO_ZOOM_MAP_SCALE.set(AutoZoomMap.values()[position -1]);
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
|
||||
builder.create().show();
|
||||
return true;
|
||||
} else if (preference == reliefFactorRouting) {
|
||||
final ApplicationMode am = settings.getApplicationMode();
|
||||
final ContextMenuAdapter adapter = new ContextMenuAdapter(getMyApplication());
|
||||
int i = 0;
|
||||
int selectedIndex = -1;
|
||||
for (RoutingParameter p : reliefFactorParameters) {
|
||||
adapter.addItem(ContextMenuItem.createBuilder(getRoutinParameterTitle(this, p))
|
||||
.setSelected(false).createItem());
|
||||
if (isRoutingParameterSelected(settings, am, p)) {
|
||||
selectedIndex = i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (selectedIndex == -1) {
|
||||
selectedIndex = 0;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
final int layout = R.layout.list_menu_item_native_singlechoice;
|
||||
|
||||
final ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(this, layout, R.id.text1,
|
||||
adapter.getItemNames()) {
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
// User super class to create the View
|
||||
View v = convertView;
|
||||
if (v == null) {
|
||||
v = SettingsNavigationActivity.this.getLayoutInflater().inflate(layout, null);
|
||||
}
|
||||
final ContextMenuItem item = adapter.getItem(position);
|
||||
TextView tv = (TextView) v.findViewById(R.id.text1);
|
||||
tv.setText(item.getTitle());
|
||||
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f);
|
||||
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
final int[] selectedPosition = {selectedIndex};
|
||||
builder.setSingleChoiceItems(listAdapter, selectedIndex, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int position) {
|
||||
selectedPosition[0] = position;
|
||||
}
|
||||
});
|
||||
builder.setTitle(SettingsBaseActivity.getRoutingStringPropertyName(this, reliefFactorParameters.get(0).getGroup(),
|
||||
Algorithms.capitalizeFirstLetterAndLowercase(reliefFactorParameters.get(0).getGroup().replace('_', ' '))))
|
||||
.setPositiveButton(R.string.shared_string_ok, new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
int position = selectedPosition[0];
|
||||
if (position >= 0 && position < reliefFactorParameters.size()) {
|
||||
for (int i = 0; i < reliefFactorParameters.size(); i++) {
|
||||
RoutingParameter parameter = reliefFactorParameters.get(i);
|
||||
setRoutingParameterSelected(settings, am, parameter.getId(), parameter.getDefaultBoolean(), i == position);
|
||||
}
|
||||
//mapActivity.getRoutingHelper().recalculateRouteDueToSettingsChange();
|
||||
//updateParameters();
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
|
||||
builder.create().show();
|
||||
return true;
|
||||
} else if (preference == showAlarms) {
|
||||
showBooleanSettings(this, new String[] { getString(R.string.show_traffic_warnings), getString(R.string.show_pedestrian_warnings),
|
||||
getString(R.string.show_cameras), getString(R.string.show_lanes), getString(R.string.show_tunnels) }, new OsmandPreference[] { settings.SHOW_TRAFFIC_WARNINGS,
|
||||
settings.SHOW_PEDESTRIAN, settings.SHOW_CAMERAS, settings.SHOW_LANES, settings.SHOW_TUNNELS }, preference.getTitle());
|
||||
return true;
|
||||
} else if (preference == speakAlarms) {
|
||||
AlertDialog dlg = showBooleanSettings(this, new String[] { getString(R.string.speak_street_names),
|
||||
getString(R.string.speak_traffic_warnings), getString(R.string.speak_pedestrian),
|
||||
getString(R.string.speak_speed_limit), getString(R.string.speak_cameras), getString(R.string.show_tunnels),
|
||||
getString(R.string.shared_string_gpx_waypoints), getString(R.string.speak_favorites),
|
||||
getString(R.string.speak_poi) }, new OsmandPreference[] { settings.SPEAK_STREET_NAMES,
|
||||
settings.SPEAK_TRAFFIC_WARNINGS, settings.SPEAK_PEDESTRIAN, settings.SPEAK_SPEED_LIMIT,
|
||||
settings.SPEAK_SPEED_CAMERA, settings.SPEAK_TUNNELS,
|
||||
settings.ANNOUNCE_WPT, settings.ANNOUNCE_NEARBY_FAVORITES,
|
||||
settings.ANNOUNCE_NEARBY_POI }, preference.getTitle());
|
||||
final boolean initialSpeedCam = settings.SPEAK_SPEED_CAMERA.get();
|
||||
final boolean initialFavorites = settings.ANNOUNCE_NEARBY_FAVORITES.get();
|
||||
final boolean initialPOI = settings.ANNOUNCE_NEARBY_POI.get();
|
||||
// final boolean initialWpt = settings.ANNOUNCE_WPT.get();
|
||||
|
||||
dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
if (settings.ANNOUNCE_NEARBY_POI.get() != initialPOI) {
|
||||
settings.SHOW_NEARBY_POI.set(settings.ANNOUNCE_NEARBY_POI.get());
|
||||
}
|
||||
if (settings.ANNOUNCE_NEARBY_FAVORITES.get() != initialFavorites) {
|
||||
settings.SHOW_NEARBY_FAVORITES.set(settings.ANNOUNCE_NEARBY_FAVORITES.get());
|
||||
}
|
||||
if (settings.ANNOUNCE_WPT.get()) {
|
||||
settings.SHOW_WPT.set(settings.ANNOUNCE_WPT.get());
|
||||
}
|
||||
if (!initialSpeedCam) {
|
||||
if (settings.SPEAK_SPEED_CAMERA.get()) {
|
||||
settings.SPEAK_SPEED_CAMERA.set(false);
|
||||
confirmSpeedCamerasDlg();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
return true;
|
||||
} else if (preference == defaultSpeed) {
|
||||
showSeekbarSettingsDialog(this, false, settings.getApplicationMode());
|
||||
} else if (preference == defaultSpeedOnly) {
|
||||
showSeekbarSettingsDialog(this, true, settings.getApplicationMode());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void confirmSpeedCamerasDlg() {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(this);
|
||||
bld.setMessage(R.string.confirm_usage_speed_cameras);
|
||||
bld.setPositiveButton(R.string.shared_string_yes, new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
settings.SPEAK_SPEED_CAMERA.set(true);
|
||||
}
|
||||
});
|
||||
bld.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
bld.show();
|
||||
}
|
||||
|
||||
public static AlertDialog showBooleanSettings(Context ctx, String[] vals, final OsmandPreference<Boolean>[] prefs, final CharSequence title) {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(ctx);
|
||||
boolean[] checkedItems = new boolean[prefs.length];
|
||||
for (int i = 0; i < prefs.length; i++) {
|
||||
checkedItems[i] = prefs[i].get();
|
||||
}
|
||||
|
||||
final boolean[] tempPrefs = new boolean[prefs.length];
|
||||
for (int i = 0; i < prefs.length; i++) {
|
||||
tempPrefs[i] = prefs[i].get();
|
||||
}
|
||||
|
||||
bld.setMultiChoiceItems(vals, checkedItems, new OnMultiChoiceClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
||||
tempPrefs[which] = isChecked;
|
||||
}
|
||||
});
|
||||
|
||||
bld.setTitle(title);
|
||||
|
||||
bld.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
|
||||
bld.setPositiveButton(R.string.shared_string_ok, new OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
for (int i = 0; i < prefs.length; i++) {
|
||||
prefs[i].set(tempPrefs[i]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return bld.show();
|
||||
}
|
||||
|
||||
public static void showSeekbarSettingsDialog(Activity activity, final boolean defaultSpeedOnly, final ApplicationMode mode) {
|
||||
if (activity == null || mode == null) {
|
||||
return;
|
||||
}
|
||||
final OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
|
||||
GeneralRouter router = app.getRouter(mode);
|
||||
SpeedConstants units = settings.SPEED_SYSTEM.getModeValue(mode);
|
||||
String speedUnits = units.toShortString(activity);
|
||||
final float[] ratio = new float[1];
|
||||
switch (units) {
|
||||
case MILES_PER_HOUR:
|
||||
ratio[0] = 3600 / OsmAndFormatter.METERS_IN_ONE_MILE;
|
||||
break;
|
||||
case KILOMETERS_PER_HOUR:
|
||||
ratio[0] = 3600 / OsmAndFormatter.METERS_IN_KILOMETER;
|
||||
break;
|
||||
case MINUTES_PER_KILOMETER:
|
||||
ratio[0] = 3600 / OsmAndFormatter.METERS_IN_KILOMETER;
|
||||
speedUnits = activity.getString(R.string.km_h);
|
||||
break;
|
||||
case NAUTICALMILES_PER_HOUR:
|
||||
ratio[0] = 3600 / OsmAndFormatter.METERS_IN_ONE_NAUTICALMILE;
|
||||
break;
|
||||
case MINUTES_PER_MILE:
|
||||
ratio[0] = 3600 / OsmAndFormatter.METERS_IN_ONE_MILE;
|
||||
speedUnits = activity.getString(R.string.mile_per_hour);
|
||||
break;
|
||||
case METERS_PER_SECOND:
|
||||
ratio[0] = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
float settingsMinSpeed = mode.getMinSpeed();
|
||||
float settingsMaxSpeed = mode.getMaxSpeed();
|
||||
float settingsDefaultSpeed = mode.getDefaultSpeed();
|
||||
|
||||
final int[] defaultValue = {Math.round(settingsDefaultSpeed * ratio[0])};
|
||||
final int[] minValue = new int[1];
|
||||
final int[] maxValue = new int[1];
|
||||
final int min;
|
||||
final int max;
|
||||
if (defaultSpeedOnly || router == null) {
|
||||
minValue[0] = Math.round(Math.min(1, settingsDefaultSpeed) * ratio[0]);
|
||||
maxValue[0] = Math.round(Math.max(300, settingsDefaultSpeed) * ratio[0]);
|
||||
min = minValue[0];
|
||||
max = maxValue[0];
|
||||
} else {
|
||||
float minSpeedValue = settingsMinSpeed > 0 ? settingsMinSpeed : router.getMinSpeed();
|
||||
float maxSpeedValue = settingsMaxSpeed > 0 ? settingsMaxSpeed : router.getMaxSpeed();
|
||||
minValue[0] = Math.round(Math.min(minSpeedValue, settingsDefaultSpeed) * ratio[0]);
|
||||
maxValue[0] = Math.round(Math.max(maxSpeedValue, settingsDefaultSpeed) * ratio[0]);
|
||||
|
||||
min = Math.round(Math.min(minValue[0], router.getMinSpeed() * ratio[0] / 2f));
|
||||
max = Math.round(Math.max(maxValue[0], router.getMaxSpeed() * ratio[0] * 1.5f));
|
||||
}
|
||||
|
||||
boolean nightMode = !app.getSettings().isLightContentForMode(mode);
|
||||
Context themedContext = UiUtilities.getThemedContext(activity, nightMode);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(themedContext);
|
||||
View seekbarView = LayoutInflater.from(themedContext).inflate(R.layout.default_speed_dialog, null, false);
|
||||
builder.setView(seekbarView);
|
||||
builder.setPositiveButton(R.string.shared_string_ok, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
mode.setDefaultSpeed(defaultValue[0] / ratio[0]);
|
||||
if (!defaultSpeedOnly) {
|
||||
mode.setMinSpeed(minValue[0] / ratio[0]);
|
||||
mode.setMaxSpeed(maxValue[0] / ratio[0]);
|
||||
}
|
||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
if (mode.equals(routingHelper.getAppMode()) && (routingHelper.isRouteCalculated() || routingHelper.isRouteBeingCalculated())) {
|
||||
routingHelper.recalculateRouteDueToSettingsChange();
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
builder.setNeutralButton(R.string.shared_string_revert, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
mode.resetDefaultSpeed();
|
||||
if (!defaultSpeedOnly) {
|
||||
mode.setMinSpeed(0f);
|
||||
mode.setMaxSpeed(0f);
|
||||
}
|
||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
if (mode.equals(routingHelper.getAppMode()) && (routingHelper.isRouteCalculated() || routingHelper.isRouteBeingCalculated())) {
|
||||
routingHelper.recalculateRouteDueToSettingsChange();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
int selectedModeColor = ContextCompat.getColor(app, mode.getIconColorInfo().getColor(nightMode));
|
||||
if (!defaultSpeedOnly) {
|
||||
setupSpeedSlider(app, SpeedSliderType.DEFAULT_SPEED, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView, nightMode, selectedModeColor);
|
||||
setupSpeedSlider(app, SpeedSliderType.MIN_SPEED, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView, nightMode, selectedModeColor);
|
||||
setupSpeedSlider(app, SpeedSliderType.MAX_SPEED, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView, nightMode, selectedModeColor);
|
||||
} else {
|
||||
setupSpeedSlider(app, SpeedSliderType.DEFAULT_SPEED_ONLY, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView, nightMode, selectedModeColor);
|
||||
seekbarView.findViewById(R.id.default_speed_div).setVisibility(View.GONE);
|
||||
seekbarView.findViewById(R.id.default_speed_container).setVisibility(View.GONE);
|
||||
seekbarView.findViewById(R.id.max_speed_div).setVisibility(View.GONE);
|
||||
seekbarView.findViewById(R.id.max_speed_container).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
builder.show();
|
||||
}
|
||||
|
||||
private enum SpeedSliderType {
|
||||
DEFAULT_SPEED_ONLY,
|
||||
DEFAULT_SPEED,
|
||||
MIN_SPEED,
|
||||
MAX_SPEED,
|
||||
}
|
||||
|
||||
private static void setupSpeedSlider(final OsmandApplication app, final SpeedSliderType type, String speedUnits,
|
||||
final int[] minValue, final int[] defaultValue, final int[] maxValue,
|
||||
final int min, final int max, View seekbarView, final boolean nightMode,
|
||||
final int activeColor) {
|
||||
View sliderLayout;
|
||||
int titleId;
|
||||
final int[] speedValue;
|
||||
switch (type) {
|
||||
case DEFAULT_SPEED_ONLY:
|
||||
speedValue = defaultValue;
|
||||
sliderLayout = seekbarView.findViewById(R.id.min_speed_layout);
|
||||
titleId = R.string.default_speed_setting_title;
|
||||
break;
|
||||
case MIN_SPEED:
|
||||
speedValue = minValue;
|
||||
sliderLayout = seekbarView.findViewById(R.id.min_speed_layout);
|
||||
titleId = R.string.shared_string_min_speed;
|
||||
break;
|
||||
case MAX_SPEED:
|
||||
speedValue = maxValue;
|
||||
sliderLayout = seekbarView.findViewById(R.id.max_speed_layout);
|
||||
titleId = R.string.shared_string_max_speed;
|
||||
break;
|
||||
default:
|
||||
speedValue = defaultValue;
|
||||
sliderLayout = seekbarView.findViewById(R.id.default_speed_layout);
|
||||
titleId = R.string.default_speed_setting_title;
|
||||
break;
|
||||
}
|
||||
final Slider slider = sliderLayout.findViewById(R.id.speed_slider);
|
||||
final TextView speedTitleTv = sliderLayout.findViewById(R.id.speed_title);
|
||||
final TextView speedMinTv = sliderLayout.findViewById(R.id.speed_seekbar_min_text);
|
||||
final TextView speedMaxTv = sliderLayout.findViewById(R.id.speed_seekbar_max_text);
|
||||
final TextView speedUnitsTv = sliderLayout.findViewById(R.id.speed_units);
|
||||
final TextView speedTv = sliderLayout.findViewById(R.id.speed_text);
|
||||
|
||||
speedTitleTv.setText(titleId);
|
||||
speedMinTv.setText(String.valueOf(min));
|
||||
speedMaxTv.setText(String.valueOf(max));
|
||||
speedTv.setText(String.valueOf(speedValue[0]));
|
||||
speedUnitsTv.setText(speedUnits);
|
||||
slider.setValueTo(max - min);
|
||||
slider.setValue(Math.max(speedValue[0] - min, 0));
|
||||
slider.addOnChangeListener(new Slider.OnChangeListener() {
|
||||
@Override
|
||||
public void onValueChange(@NonNull Slider slider, float val, boolean fromUser) {
|
||||
int progress = (int) val;
|
||||
int value = progress + min;
|
||||
switch (type) {
|
||||
case DEFAULT_SPEED:
|
||||
case DEFAULT_SPEED_ONLY:
|
||||
if (value > maxValue[0]) {
|
||||
value = maxValue[0];
|
||||
slider.setValue(Math.max(value - min, 0));
|
||||
} else if (value < minValue[0]) {
|
||||
value = minValue[0];
|
||||
slider.setValue(Math.max(value - min, 0));
|
||||
}
|
||||
break;
|
||||
case MIN_SPEED:
|
||||
if (value > defaultValue[0]) {
|
||||
value = defaultValue[0];
|
||||
slider.setValue(Math.max(value - min, 0));
|
||||
}
|
||||
break;
|
||||
case MAX_SPEED:
|
||||
if (value < defaultValue[0]) {
|
||||
value = defaultValue[0];
|
||||
slider.setValue(Math.max(value - min, 0));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
speedValue[0] = value;
|
||||
speedTv.setText(String.valueOf(value));
|
||||
}
|
||||
});
|
||||
UiUtilities.setupSlider(slider, nightMode, activeColor);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package net.osmand.plus.importfiles;
|
||||
package net.osmand.plus.base;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.AsyncTask;
|
||||
|
@ -12,13 +12,13 @@ import net.osmand.plus.R;
|
|||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
abstract class BaseImportAsyncTask<Params, Progress, Result> extends AsyncTask<Params, Progress, Result> {
|
||||
public abstract class BaseLoadAsyncTask<Params, Progress, Result> extends AsyncTask<Params, Progress, Result> {
|
||||
|
||||
protected OsmandApplication app;
|
||||
protected WeakReference<FragmentActivity> activityRef;
|
||||
protected ProgressDialog progress;
|
||||
|
||||
public BaseImportAsyncTask(@NonNull FragmentActivity activity) {
|
||||
public BaseLoadAsyncTask(@NonNull FragmentActivity activity) {
|
||||
app = (OsmandApplication) activity.getApplicationContext();
|
||||
activityRef = new WeakReference<>(activity);
|
||||
}
|
|
@ -1,8 +1,10 @@
|
|||
package net.osmand.plus.development;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Debug;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import net.osmand.plus.OsmAndLocationSimulation;
|
||||
|
@ -11,6 +13,7 @@ import net.osmand.plus.Version;
|
|||
import net.osmand.plus.render.NativeOsmandLibrary;
|
||||
import net.osmand.plus.settings.fragments.BaseSettingsFragment;
|
||||
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
import net.osmand.util.SunriseSunset;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -199,4 +202,23 @@ public class DevelopmentSettingsFragment extends BaseSettingsFragment {
|
|||
}
|
||||
return super.onPreferenceClick(preference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String prefId = preference.getKey();
|
||||
if (settings.SAFE_MODE.getId().equals(prefId) && newValue instanceof Boolean) {
|
||||
loadNativeLibrary();
|
||||
return true;
|
||||
}
|
||||
return super.onPreferenceChange(preference, newValue);
|
||||
}
|
||||
|
||||
public void loadNativeLibrary() {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (!NativeOsmandLibrary.isLoaded() && activity != null) {
|
||||
RenderingRulesStorage storage = app.getRendererRegistry().getCurrentSelectedRenderer();
|
||||
NativeLibraryLoadTask nativeLibraryLoadTask = new NativeLibraryLoadTask(activity, storage);
|
||||
nativeLibraryLoadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package net.osmand.plus.development;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.BaseLoadAsyncTask;
|
||||
import net.osmand.plus.render.NativeOsmandLibrary;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
|
||||
class NativeLibraryLoadTask extends BaseLoadAsyncTask<Void, Void, Void> {
|
||||
|
||||
private RenderingRulesStorage storage;
|
||||
|
||||
public NativeLibraryLoadTask(@NonNull FragmentActivity activity, @NonNull RenderingRulesStorage storage) {
|
||||
super(activity);
|
||||
this.storage = storage;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
NativeOsmandLibrary.getLibrary(storage, app);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
hideProgress();
|
||||
if (!NativeOsmandLibrary.isNativeSupported(storage, app)) {
|
||||
app.showToastMessage(R.string.native_library_not_supported);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -41,7 +41,6 @@ import net.osmand.plus.settings.backend.ListStringPreference;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.render.RendererRegistry;
|
||||
|
@ -821,7 +820,7 @@ public class ConfigureMapMenu {
|
|||
final String[] vals = new String[ps.size()];
|
||||
for (int i = 0; i < ps.size(); i++) {
|
||||
RenderingRuleProperty p = ps.get(i);
|
||||
String propertyName = SettingsActivity.getStringPropertyName(activity, p.getAttrName(),
|
||||
String propertyName = AndroidUtils.getRenderingStringPropertyName(activity, p.getAttrName(),
|
||||
p.getName());
|
||||
vals[i] = propertyName;
|
||||
}
|
||||
|
@ -904,9 +903,9 @@ public class ConfigureMapMenu {
|
|||
final Spinner spinner = (Spinner) spinnerView.findViewById(R.id.spinner);
|
||||
TextView description = (TextView) spinnerView.findViewById(R.id.description);
|
||||
|
||||
String propertyName = SettingsActivity.getStringPropertyName(activity, p.getAttrName(),
|
||||
String propertyName = AndroidUtils.getRenderingStringPropertyName(activity, p.getAttrName(),
|
||||
p.getName());
|
||||
String propertyDescr = SettingsActivity.getStringPropertyDescription(activity,
|
||||
String propertyDescr = AndroidUtils.getRenderingStringPropertyDescription(activity,
|
||||
p.getAttrName(), p.getName());
|
||||
|
||||
title.setText(propertyName);
|
||||
|
@ -920,11 +919,11 @@ public class ConfigureMapMenu {
|
|||
}
|
||||
|
||||
String[] possibleValuesString = new String[p.getPossibleValues().length + 1];
|
||||
possibleValuesString[0] = SettingsActivity.getStringPropertyValue(activity,
|
||||
possibleValuesString[0] = AndroidUtils.getRenderingStringPropertyValue(activity,
|
||||
p.getDefaultValueDescription());
|
||||
|
||||
for (int j = 0; j < p.getPossibleValues().length; j++) {
|
||||
possibleValuesString[j + 1] = SettingsActivity.getStringPropertyValue(activity,
|
||||
possibleValuesString[j + 1] = AndroidUtils.getRenderingStringPropertyValue(activity,
|
||||
p.getPossibleValues()[j]);
|
||||
}
|
||||
|
||||
|
@ -1027,10 +1026,10 @@ public class ConfigureMapMenu {
|
|||
@DrawableRes final int icon, final RenderingRuleProperty p, final String id,
|
||||
final OsmandApplication app, final int currentProfileColor, final boolean nightMode, final int themeRes) {
|
||||
final OsmandMapTileView view = activity.getMapView();
|
||||
String propertyName = SettingsActivity.getStringPropertyName(view.getContext(), p.getAttrName(),
|
||||
String propertyName = AndroidUtils.getRenderingStringPropertyName(view.getContext(), p.getAttrName(),
|
||||
p.getName());
|
||||
|
||||
final String propertyDescr = SettingsActivity.getStringPropertyDescription(view.getContext(),
|
||||
final String propertyDescr = AndroidUtils.getRenderingStringPropertyDescription(view.getContext(),
|
||||
p.getAttrName(), p.getName());
|
||||
if (p.isBoolean()) {
|
||||
final CommonPreference<Boolean> pref = view.getApplication().getSettings()
|
||||
|
@ -1053,9 +1052,9 @@ public class ConfigureMapMenu {
|
|||
.getCustomRenderProperty(p.getAttrName());
|
||||
final String descr;
|
||||
if (!Algorithms.isEmpty(pref.get())) {
|
||||
descr = SettingsActivity.getStringPropertyValue(activity, pref.get());
|
||||
descr = AndroidUtils.getRenderingStringPropertyValue(activity, pref.get());
|
||||
} else {
|
||||
descr = SettingsActivity.getStringPropertyValue(view.getContext(),
|
||||
descr = AndroidUtils.getRenderingStringPropertyValue(view.getContext(),
|
||||
p.getDefaultValueDescription());
|
||||
}
|
||||
ContextMenuItem.ItemBuilder builder = ContextMenuItem.createBuilder(propertyName)
|
||||
|
@ -1080,11 +1079,11 @@ public class ConfigureMapMenu {
|
|||
}
|
||||
|
||||
String[] possibleValuesString = new String[p.getPossibleValues().length + 1];
|
||||
possibleValuesString[0] = SettingsActivity.getStringPropertyValue(view.getContext(),
|
||||
possibleValuesString[0] = AndroidUtils.getRenderingStringPropertyValue(view.getContext(),
|
||||
p.getDefaultValueDescription());
|
||||
|
||||
for (int j = 0; j < p.getPossibleValues().length; j++) {
|
||||
possibleValuesString[j + 1] = SettingsActivity.getStringPropertyValue(view.getContext(),
|
||||
possibleValuesString[j + 1] = AndroidUtils.getRenderingStringPropertyValue(view.getContext(),
|
||||
p.getPossibleValues()[j]);
|
||||
}
|
||||
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
|
||||
|
@ -1098,7 +1097,7 @@ public class ConfigureMapMenu {
|
|||
pref.set(p.getPossibleValues()[which - 1]);
|
||||
}
|
||||
refreshMapComplete(activity);
|
||||
String description = SettingsActivity.getStringPropertyValue(activity, pref.get());
|
||||
String description = AndroidUtils.getRenderingStringPropertyValue(activity, pref.get());
|
||||
adapter.getItem(pos).setDescription(description);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,12 +15,12 @@ import androidx.annotation.Nullable;
|
|||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemTwoChoicesButton;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemTwoChoicesButton.OnBottomBtnClickListener;
|
||||
|
@ -125,7 +125,7 @@ public class DetailsBottomSheet extends BasePreferenceBottomSheet {
|
|||
for (int i = 0; i < properties.size(); i++) {
|
||||
RenderingRuleProperty property = properties.get(i);
|
||||
final CommonPreference<Boolean> pref = preferences.get(i);
|
||||
final String propertyName = SettingsActivity.getStringPropertyName(app, property.getAttrName(), property.getName());
|
||||
final String propertyName = AndroidUtils.getRenderingStringPropertyName(app, property.getAttrName(), property.getName());
|
||||
if (STREET_LIGHTING.equals(property.getAttrName()) && streetLightNightProp != null) {
|
||||
final CommonPreference<Boolean> streetLightsNightPref = preferences.get(properties.indexOf(streetLightNightProp));
|
||||
final BottomSheetItemTwoChoicesButton[] item = new BottomSheetItemTwoChoicesButton[1];
|
||||
|
|
|
@ -12,7 +12,6 @@ import androidx.annotation.NonNull;
|
|||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.render.RenderingRule;
|
||||
import net.osmand.render.RenderingRuleProperty;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
|
@ -124,7 +123,7 @@ public class GpxAppearanceAdapter extends ArrayAdapter<GpxAppearanceAdapter.Appe
|
|||
for (int j = 0; j < trackWidthProp.getPossibleValues().length; j++) {
|
||||
AppearanceListItem item = new AppearanceListItem(ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR,
|
||||
trackWidthProp.getPossibleValues()[j],
|
||||
SettingsActivity.getStringPropertyValue(app, trackWidthProp.getPossibleValues()[j]));
|
||||
AndroidUtils.getRenderingStringPropertyValue(app, trackWidthProp.getPossibleValues()[j]));
|
||||
items.add(item);
|
||||
if (adapterType != GpxAppearanceAdapterType.TRACK_WIDTH_COLOR) {
|
||||
if (j == trackWidthProp.getPossibleValues().length - 1) {
|
||||
|
@ -143,7 +142,7 @@ public class GpxAppearanceAdapter extends ArrayAdapter<GpxAppearanceAdapter.Appe
|
|||
for (int j = 0; j < trackColorProp.getPossibleValues().length; j++) {
|
||||
AppearanceListItem item = new AppearanceListItem(ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR,
|
||||
trackColorProp.getPossibleValues()[j],
|
||||
SettingsActivity.getStringPropertyValue(app, trackColorProp.getPossibleValues()[j]),
|
||||
AndroidUtils.getRenderingStringPropertyValue(app, trackColorProp.getPossibleValues()[j]),
|
||||
parseTrackColor(renderer, trackColorProp.getPossibleValues()[j]));
|
||||
items.add(item);
|
||||
if (j == trackColorProp.getPossibleValues().length - 1) {
|
||||
|
|
|
@ -92,7 +92,6 @@ import net.osmand.plus.Version;
|
|||
import net.osmand.plus.activities.ActivityResultListener;
|
||||
import net.osmand.plus.activities.ActivityResultListener.OnActivityResultListener;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||
import net.osmand.plus.dialogs.GpxAppearanceAdapter;
|
||||
import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem;
|
||||
|
@ -810,9 +809,9 @@ public class GpxUiHelper {
|
|||
TextView widthTextView = (TextView) apprTitleView.findViewById(R.id.widthTitle);
|
||||
ImageView colorImageView = (ImageView) apprTitleView.findViewById(R.id.colorImage);
|
||||
if (Algorithms.isEmpty(prefWidthValue)) {
|
||||
widthTextView.setText(SettingsActivity.getStringPropertyValue(activity, trackWidthProp.getDefaultValueDescription()));
|
||||
widthTextView.setText(AndroidUtils.getRenderingStringPropertyValue(activity, trackWidthProp.getDefaultValueDescription()));
|
||||
} else {
|
||||
widthTextView.setText(SettingsActivity.getStringPropertyValue(activity, prefWidthValue));
|
||||
widthTextView.setText(AndroidUtils.getRenderingStringPropertyValue(activity, prefWidthValue));
|
||||
}
|
||||
int color = GpxAppearanceAdapter.parseTrackColor(renderer, prefColorValue);
|
||||
if (color == -1) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.osmand.GPXUtilities.GPXFile;
|
|||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.BaseLoadAsyncTask;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -16,7 +17,7 @@ import static net.osmand.plus.importfiles.ImportHelper.asFavourites;
|
|||
import static net.osmand.plus.myplaces.FavoritesActivity.FAV_TAB;
|
||||
import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID;
|
||||
|
||||
class FavoritesImportTask extends BaseImportAsyncTask<Void, Void, GPXFile> {
|
||||
class FavoritesImportTask extends BaseLoadAsyncTask<Void, Void, GPXFile> {
|
||||
|
||||
private GPXFile gpxFile;
|
||||
private String fileName;
|
||||
|
|
|
@ -7,13 +7,14 @@ import androidx.fragment.app.FragmentActivity;
|
|||
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.base.BaseLoadAsyncTask;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
class GpxImportTask extends BaseImportAsyncTask<Void, Void, GPXFile> {
|
||||
class GpxImportTask extends BaseLoadAsyncTask<Void, Void, GPXFile> {
|
||||
|
||||
private ImportHelper importHelper;
|
||||
private Uri gpxFile;
|
||||
|
|
|
@ -7,6 +7,7 @@ import androidx.fragment.app.FragmentActivity;
|
|||
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.base.BaseLoadAsyncTask;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
|
@ -17,7 +18,7 @@ import java.util.zip.ZipInputStream;
|
|||
|
||||
import static net.osmand.plus.importfiles.KmlImportTask.convertKmlToGpxStream;
|
||||
|
||||
class GpxOrFavouritesImportTask extends BaseImportAsyncTask<Void, Void, GPXFile> {
|
||||
class GpxOrFavouritesImportTask extends BaseLoadAsyncTask<Void, Void, GPXFile> {
|
||||
|
||||
private ImportHelper importHelper;
|
||||
private Uri fileUri;
|
||||
|
|
|
@ -7,6 +7,7 @@ import androidx.fragment.app.FragmentActivity;
|
|||
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.base.BaseLoadAsyncTask;
|
||||
import net.osmand.plus.helpers.Kml2Gpx;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
@ -16,7 +17,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
class KmlImportTask extends BaseImportAsyncTask<Void, Void, GPXFile> {
|
||||
class KmlImportTask extends BaseLoadAsyncTask<Void, Void, GPXFile> {
|
||||
|
||||
private ImportHelper importHelper;
|
||||
private Uri uri;
|
||||
|
|
|
@ -7,6 +7,7 @@ import androidx.fragment.app.FragmentActivity;
|
|||
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.base.BaseLoadAsyncTask;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
@ -16,7 +17,7 @@ import java.util.zip.ZipInputStream;
|
|||
import static net.osmand.plus.importfiles.ImportHelper.KML_SUFFIX;
|
||||
import static net.osmand.plus.importfiles.KmlImportTask.convertKmlToGpxStream;
|
||||
|
||||
class KmzImportTask extends BaseImportAsyncTask<Void, Void, GPXFile> {
|
||||
class KmzImportTask extends BaseLoadAsyncTask<Void, Void, GPXFile> {
|
||||
|
||||
private ImportHelper importHelper;
|
||||
private Uri uri;
|
||||
|
|
|
@ -8,11 +8,12 @@ import androidx.fragment.app.FragmentActivity;
|
|||
import net.osmand.IProgress;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.BaseLoadAsyncTask;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
class ObfImportTask extends BaseImportAsyncTask<Void, Void, String> {
|
||||
class ObfImportTask extends BaseLoadAsyncTask<Void, Void, String> {
|
||||
|
||||
private Uri uri;
|
||||
private String name;
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.osmand.FileUtils;
|
|||
import net.osmand.IndexConstants;
|
||||
import net.osmand.plus.CustomOsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.BaseLoadAsyncTask;
|
||||
import net.osmand.plus.settings.backend.backup.SettingsHelper.CheckDuplicatesListener;
|
||||
import net.osmand.plus.settings.backend.backup.PluginSettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.ProfileSettingsItem;
|
||||
|
@ -28,7 +29,7 @@ import java.util.List;
|
|||
|
||||
import static net.osmand.plus.AppInitializer.loadRoutingFiles;
|
||||
|
||||
class SettingsImportTask extends BaseImportAsyncTask<Void, Void, String> {
|
||||
class SettingsImportTask extends BaseLoadAsyncTask<Void, Void, String> {
|
||||
|
||||
private Uri uri;
|
||||
private String name;
|
||||
|
|
|
@ -9,11 +9,12 @@ import androidx.fragment.app.FragmentActivity;
|
|||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.BaseLoadAsyncTask;
|
||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||
|
||||
import static net.osmand.IndexConstants.TILES_INDEX_DIR;
|
||||
|
||||
class SqliteTileImportTask extends BaseImportAsyncTask<Void, Void, String> {
|
||||
class SqliteTileImportTask extends BaseLoadAsyncTask<Void, Void, String> {
|
||||
|
||||
private Uri uri;
|
||||
private String name;
|
||||
|
|
|
@ -8,6 +8,7 @@ import androidx.fragment.app.FragmentActivity;
|
|||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.FileUtils;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.BaseLoadAsyncTask;
|
||||
import net.osmand.plus.importfiles.ImportHelper.ImportType;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
@ -32,7 +33,7 @@ import static net.osmand.util.Algorithms.SQLITE_FILE_SIGNATURE;
|
|||
import static net.osmand.util.Algorithms.XML_FILE_SIGNATURE;
|
||||
import static net.osmand.util.Algorithms.ZIP_FILE_SIGNATURE;
|
||||
|
||||
class UriImportTask extends BaseImportAsyncTask<Void, Void, String> {
|
||||
class UriImportTask extends BaseLoadAsyncTask<Void, Void, String> {
|
||||
|
||||
private ImportHelper importHelper;
|
||||
private Uri uri;
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.osmand.PlatformUtil;
|
|||
import net.osmand.plus.AppInitializer.LoadRoutingFilesCallback;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.BaseLoadAsyncTask;
|
||||
import net.osmand.plus.importfiles.ImportHelper.ImportType;
|
||||
import net.osmand.router.RoutingConfiguration.Builder;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -28,7 +29,7 @@ import java.io.InputStream;
|
|||
import static net.osmand.IndexConstants.RENDERER_INDEX_EXT;
|
||||
import static net.osmand.plus.AppInitializer.loadRoutingFiles;
|
||||
|
||||
class XmlImportTask extends BaseImportAsyncTask<Void, Void, String> {
|
||||
class XmlImportTask extends BaseLoadAsyncTask<Void, Void, String> {
|
||||
|
||||
private Uri uri;
|
||||
private String destFileName;
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.net.Uri;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import net.osmand.plus.base.BaseLoadAsyncTask;
|
||||
import net.osmand.plus.importfiles.ImportHelper.ImportType;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
@ -20,7 +21,7 @@ import static net.osmand.IndexConstants.OSMAND_SETTINGS_FILE_EXT;
|
|||
import static net.osmand.IndexConstants.TEMP_DIR;
|
||||
import static net.osmand.plus.importfiles.ImportHelper.KML_SUFFIX;
|
||||
|
||||
public class ZipImportTask extends BaseImportAsyncTask<Void, Void, ImportType> {
|
||||
public class ZipImportTask extends BaseLoadAsyncTask<Void, Void, ImportType> {
|
||||
|
||||
private ImportHelper importHelper;
|
||||
private Uri uri;
|
||||
|
|
|
@ -2,7 +2,6 @@ package net.osmand.plus.mapcontextmenu.builders.cards;
|
|||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.TrafficStats;
|
||||
import android.os.AsyncTask;
|
||||
|
@ -16,24 +15,19 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.osmand.*;
|
||||
import net.osmand.AndroidNetworkUtils;
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.mapillary.MapillaryContributeCard;
|
||||
import net.osmand.plus.mapillary.MapillaryImageCard;
|
||||
import net.osmand.plus.osmedit.OsmBugsLayer;
|
||||
import net.osmand.plus.views.layers.ContextMenuLayer;
|
||||
import net.osmand.plus.wikimedia.WikiImageHelper;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
@ -45,9 +39,13 @@ import org.json.JSONObject;
|
|||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class ImageCard extends AbstractCard {
|
||||
|
||||
|
@ -427,7 +425,7 @@ public abstract class ImageCard extends AbstractCard {
|
|||
}
|
||||
|
||||
public GetImageCardsTask(@NonNull MapActivity mapActivity, LatLon latLon,
|
||||
@Nullable Map<String, String> params, GetImageCardsListener listener) {
|
||||
@Nullable Map<String, String> params, GetImageCardsListener listener) {
|
||||
this.mapActivity = mapActivity;
|
||||
this.app = mapActivity.getMyApplication();
|
||||
this.latLon = latLon;
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.graphics.drawable.Drawable;
|
|||
import android.text.SpannableString;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
|
@ -25,7 +24,6 @@ import net.osmand.plus.helpers.FontCache;
|
|||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
import net.osmand.plus.mapcontextmenu.builders.FavouritePointMenuBuilder;
|
||||
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor;
|
||||
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragment;
|
||||
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragmentNew;
|
||||
import net.osmand.plus.transport.TransportStopRoute;
|
||||
import net.osmand.plus.widgets.style.CustomTypefaceSpan;
|
||||
|
@ -102,14 +100,8 @@ public class FavouritePointMenuController extends MenuController {
|
|||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
Fragment fragment = mapActivity.getSupportFragmentManager().findFragmentByTag(FavoritePointEditor.TAG);
|
||||
if (fragment != null) {
|
||||
// TODO: uncomment & delete if else after switch to new UI Fragment
|
||||
//((FavoritePointEditorFragment) fragment).dismiss();
|
||||
if (fragment instanceof FavoritePointEditorFragmentNew) {
|
||||
((FavoritePointEditorFragmentNew) fragment).dismiss();
|
||||
} else {
|
||||
((FavoritePointEditorFragment) fragment).dismiss();
|
||||
}
|
||||
if (fragment instanceof FavoritePointEditorFragmentNew) {
|
||||
((FavoritePointEditorFragmentNew) fragment).dismiss();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.helpers.ColorDialogs;
|
||||
|
@ -595,9 +594,9 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
JSONObject categories = obj.getJSONObject("categories");
|
||||
for (int i = 0; i < categories.length(); i++) {
|
||||
JSONArray names = categories.names();
|
||||
JSONObject icons = categories.getJSONObject(names.get(i).toString());
|
||||
String name = names.get(i).toString();
|
||||
String translatedName = SettingsBaseActivity.getIconStringPropertyName(app, name, name);
|
||||
JSONObject icons = categories.getJSONObject(name);
|
||||
String translatedName = AndroidUtils.getIconStringPropertyName(app, name);
|
||||
iconCategories.put(translatedName, icons.getJSONArray("icons"));
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package net.osmand.plus.mapcontextmenu.other;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.util.TypedValue;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
@ -21,15 +20,11 @@ import androidx.appcompat.widget.PopupMenu;
|
|||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||
import net.osmand.plus.activities.SettingsNavigationActivity;
|
||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper;
|
||||
|
@ -43,6 +38,8 @@ import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherSettingsRo
|
|||
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.VoiceGuidanceRoutingParameter;
|
||||
import net.osmand.plus.routing.RouteProvider;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.router.GeneralRouter;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -148,11 +145,6 @@ public class RoutePreferencesMenu {
|
|||
.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
|
||||
builder.create().show();
|
||||
} else if (obj instanceof OtherSettingsRoutingParameter) {
|
||||
final Intent settings = new Intent(mapActivity, SettingsNavigationActivity.class);
|
||||
settings.putExtra(SettingsNavigationActivity.INTENT_SKIP_DIALOG, true);
|
||||
settings.putExtra(SettingsBaseActivity.INTENT_APP_MODE, routingHelper.getAppMode().getStringKey());
|
||||
mapActivity.startActivity(settings);
|
||||
} else if (obj instanceof MuteSoundRoutingParameter) {
|
||||
final CompoundButton btn = (CompoundButton) view.findViewById(R.id.toggle_item);
|
||||
btn.performClick();
|
||||
|
|
|
@ -16,13 +16,13 @@ import com.github.mikephil.charting.data.ChartData;
|
|||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
|
||||
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType;
|
||||
import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
|
||||
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter;
|
||||
import net.osmand.plus.measurementtool.MeasurementToolFragment.OnUpdateAdditionalInfoListener;
|
||||
import net.osmand.plus.routepreparationmenu.RouteDetailsFragment;
|
||||
|
@ -30,16 +30,16 @@ import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
|||
import net.osmand.router.RouteSegmentResult;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import static net.osmand.router.RouteStatisticsHelper.RouteStatistics;
|
||||
import static net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||
import static net.osmand.GPXUtilities.GPXFile;
|
||||
import static net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.GPXUtilities.GPXFile;
|
||||
import static net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||
import static net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionItem;
|
||||
import static net.osmand.router.RouteStatisticsHelper.RouteStatistics;
|
||||
|
||||
public class GraphsCard extends BaseCard implements OnUpdateAdditionalInfoListener {
|
||||
|
||||
private static String GRAPH_DATA_GPX_FILE_NAME = "graph_data_tmp";
|
||||
|
@ -254,7 +254,7 @@ public class GraphsCard extends BaseCard implements OnUpdateAdditionalInfoListen
|
|||
List<RouteStatistics> routeStatistics = calculateRouteStatistics(routeSegments);
|
||||
if (analysis != null && routeStatistics != null) {
|
||||
for (RouteStatistics statistics : routeStatistics) {
|
||||
String title = SettingsBaseActivity.getStringRouteInfoPropertyValue(app, statistics.name);
|
||||
String title = AndroidUtils.getStringRouteInfoPropertyValue(app, statistics.name);
|
||||
BarData data = null;
|
||||
if (!Algorithms.isEmpty(statistics.elements)) {
|
||||
data = GpxUiHelper.buildStatisticChart(
|
||||
|
|
|
@ -81,12 +81,12 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
|||
super(app);
|
||||
OsmandSettings set = app.getSettings();
|
||||
ApplicationMode.regWidgetVisibility("parking", (ApplicationMode[]) null);
|
||||
parkingLat = set.registerFloatPreference(PARKING_POINT_LAT, 0f).makeGlobal();
|
||||
parkingLon = set.registerFloatPreference(PARKING_POINT_LON, 0f).makeGlobal();
|
||||
parkingType = set.registerBooleanPreference(PARKING_TYPE, false).makeGlobal();
|
||||
parkingEvent = set.registerBooleanPreference(PARKING_EVENT_ADDED, false).makeGlobal();
|
||||
parkingTime = set.registerLongPreference(PARKING_TIME, -1).makeGlobal();
|
||||
parkingStartTime = set.registerLongPreference(PARKING_START_TIME, -1).makeGlobal();
|
||||
parkingLat = set.registerFloatPreference(PARKING_POINT_LAT, 0f).makeGlobal().makeShared();
|
||||
parkingLon = set.registerFloatPreference(PARKING_POINT_LON, 0f).makeGlobal().makeShared();
|
||||
parkingType = set.registerBooleanPreference(PARKING_TYPE, false).makeGlobal().makeShared();
|
||||
parkingEvent = set.registerBooleanPreference(PARKING_EVENT_ADDED, false).makeGlobal().makeShared();
|
||||
parkingTime = set.registerLongPreference(PARKING_TIME, -1).makeGlobal().makeShared();
|
||||
parkingStartTime = set.registerLongPreference(PARKING_START_TIME, -1).makeGlobal().makeShared();
|
||||
parkingPosition = constructParkingPosition();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import net.osmand.plus.settings.backend.CommonPreference;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
|
||||
|
@ -222,7 +221,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
|
|||
if (parameter != null) {
|
||||
defValue = parameter.getName();
|
||||
}
|
||||
String parameterName = SettingsBaseActivity.getRoutingStringPropertyName(app, parameterId, defValue);
|
||||
String parameterName = AndroidUtils.getRoutingStringPropertyName(app, parameterId, defValue);
|
||||
|
||||
final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1];
|
||||
item[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
|
||||
|
|
|
@ -62,7 +62,6 @@ import net.osmand.plus.TargetPointsHelper;
|
|||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||
import net.osmand.plus.activities.actions.AppModeDialog;
|
||||
import net.osmand.plus.activities.actions.OsmAndDialogs;
|
||||
import net.osmand.plus.base.ContextMenuFragment.MenuState;
|
||||
|
@ -1303,7 +1302,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
final OsmandSettings settings = mapActivity.getMyApplication().getSettings();
|
||||
for (int i = 0; i < avoidedParameters.size(); i++) {
|
||||
final RoutingParameter routingParameter = avoidedParameters.get(i);
|
||||
final View container = createToolbarSubOptionView(false, SettingsBaseActivity.getRoutingStringPropertyName(app, routingParameter.getId(), routingParameter.getName()), R.drawable.ic_action_remove_dark, i == avoidedParameters.size() - 1, new OnClickListener() {
|
||||
final View container = createToolbarSubOptionView(false, AndroidUtils.getRoutingStringPropertyName(app, routingParameter.getId(), routingParameter.getName()), R.drawable.ic_action_remove_dark, i == avoidedParameters.size() - 1, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
OsmandApplication app = getApp();
|
||||
|
|
|
@ -16,13 +16,11 @@ import androidx.appcompat.app.AlertDialog;
|
|||
import androidx.appcompat.widget.AppCompatCheckedTextView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.DialogListItemAdapter;
|
||||
|
@ -35,7 +33,6 @@ import net.osmand.plus.TargetPointsHelper;
|
|||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.DownloadActivityType;
|
||||
|
@ -45,7 +42,6 @@ import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
|
|||
import net.osmand.plus.routing.RouteProvider.RouteService;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.voice.JSMediaCommandPlayerImpl;
|
||||
import net.osmand.plus.voice.JSTTSCommandPlayerImpl;
|
||||
import net.osmand.plus.voice.MediaCommandPlayerImpl;
|
||||
|
@ -57,7 +53,6 @@ import net.osmand.util.MapUtils;
|
|||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
@ -666,7 +661,7 @@ public class RoutingOptionsHelper {
|
|||
}
|
||||
|
||||
public String getText(MapActivity mapActivity) {
|
||||
return SettingsBaseActivity.getRoutingStringPropertyName(mapActivity, routingParameter.getId(),
|
||||
return AndroidUtils.getRoutingStringPropertyName(mapActivity, routingParameter.getId(),
|
||||
routingParameter.getName());
|
||||
}
|
||||
|
||||
|
@ -730,7 +725,7 @@ public class RoutingOptionsHelper {
|
|||
|
||||
@Override
|
||||
public String getText(MapActivity mapActivity) {
|
||||
return SettingsBaseActivity.getRoutingStringPropertyName(mapActivity, groupName,
|
||||
return AndroidUtils.getRoutingStringPropertyName(mapActivity, groupName,
|
||||
Algorithms.capitalizeFirstLetterAndLowercase(groupName.replace('_', ' ')));
|
||||
}
|
||||
|
||||
|
|
|
@ -22,12 +22,11 @@ import com.github.mikephil.charting.data.Entry;
|
|||
import com.github.mikephil.charting.highlight.Highlight;
|
||||
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||
import net.osmand.plus.activities.SettingsNavigationActivity;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.router.RouteStatisticsHelper.RouteSegmentAttribute;
|
||||
import net.osmand.router.RouteStatisticsHelper.RouteStatistics;
|
||||
|
@ -127,7 +126,7 @@ public class RouteInfoCard extends BaseCard {
|
|||
|
||||
private void updateHeader() {
|
||||
TextView title = (TextView) view.findViewById(R.id.info_type_title);
|
||||
String name = SettingsBaseActivity.getStringRouteInfoPropertyValue(app, routeStatistics.name);
|
||||
String name = AndroidUtils.getStringRouteInfoPropertyValue(app, routeStatistics.name);
|
||||
title.setText(name);
|
||||
}
|
||||
|
||||
|
@ -148,7 +147,7 @@ public class RouteInfoCard extends BaseCard {
|
|||
legendIcon.setBackgroundResource(nightMode ? R.drawable.circle_contour_bg_dark : R.drawable.circle_contour_bg_light);
|
||||
}
|
||||
String propertyName = segment.getUserPropertyName();
|
||||
String name = SettingsNavigationActivity.getStringPropertyName(app, propertyName, propertyName.replaceAll("_", " "));
|
||||
String name = AndroidUtils.getRenderingStringPropertyName(app, propertyName, propertyName.replaceAll("_", " "));
|
||||
Spannable text = getSpanLegend(name, segment, segment.getUserPropertyName().equals(selectedPropertyName));
|
||||
TextView legend = (TextView) view.findViewById(R.id.legend_text);
|
||||
legend.setText(text);
|
||||
|
|
|
@ -22,6 +22,7 @@ public abstract class CommonPreference<T> extends PreferenceWithListener<T> {
|
|||
|
||||
private boolean cache;
|
||||
private boolean global;
|
||||
private boolean shared;
|
||||
|
||||
|
||||
public CommonPreference(OsmandSettings settings, String id, T defaultValue) {
|
||||
|
@ -71,6 +72,11 @@ public abstract class CommonPreference<T> extends PreferenceWithListener<T> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public final CommonPreference<T> makeShared() {
|
||||
shared = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected final Object getPreferences() {
|
||||
return settings.getPreferences(global);
|
||||
|
||||
|
@ -200,6 +206,10 @@ public abstract class CommonPreference<T> extends PreferenceWithListener<T> {
|
|||
return global;
|
||||
}
|
||||
|
||||
public final boolean isShared() {
|
||||
return shared;
|
||||
}
|
||||
|
||||
// TODO final
|
||||
@Override
|
||||
public boolean writeToJson(JSONObject json, ApplicationMode appMode) throws JSONException {
|
||||
|
|
|
@ -8,10 +8,9 @@ public enum ExportSettingsType {
|
|||
CUSTOM_RENDER_STYLE,
|
||||
CUSTOM_ROUTING,
|
||||
AVOID_ROADS,
|
||||
MARKERS,
|
||||
FAVORITES,
|
||||
TRACKS,
|
||||
MULTIMEDIA_NOTES,
|
||||
GLOBAL,
|
||||
OSM_NOTES,
|
||||
OSM_EDITS,
|
||||
OFFLINE_MAPS
|
||||
|
|
|
@ -27,7 +27,6 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.plus.activities.TrackActivity;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.helpers.WaypointHelper;
|
||||
|
@ -174,9 +173,6 @@ public class OsmAndAppCustomization {
|
|||
}
|
||||
|
||||
// Activities
|
||||
public Class<? extends Activity> getSettingsActivity() {
|
||||
return SettingsActivity.class;
|
||||
}
|
||||
|
||||
public Class<MapActivity> getMapActivity() {
|
||||
return MapActivity.class;
|
||||
|
|
|
@ -641,7 +641,7 @@ public class OsmandSettings {
|
|||
public static final String NUMBER_OF_FREE_DOWNLOADS_ID = "free_downloads_v3";
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
private final OsmandPreference<String> PLUGINS = new StringPreference(this, "enabled_plugins", MapillaryPlugin.ID).makeGlobal();
|
||||
private final OsmandPreference<String> PLUGINS = new StringPreference(this, "enabled_plugins", MapillaryPlugin.ID).makeGlobal().makeShared();
|
||||
|
||||
public Set<String> getEnabledPlugins() {
|
||||
String plugs = PLUGINS.get();
|
||||
|
@ -689,49 +689,49 @@ public class OsmandSettings {
|
|||
return false;
|
||||
}
|
||||
|
||||
public final CommonPreference<RulerMode> RULER_MODE = new EnumStringPreference<>(this, "ruler_mode", RulerMode.FIRST, RulerMode.values()).makeGlobal();
|
||||
public final CommonPreference<RulerMode> RULER_MODE = new EnumStringPreference<>(this, "ruler_mode", RulerMode.FIRST, RulerMode.values()).makeGlobal().makeShared();
|
||||
|
||||
public final OsmandPreference<Boolean> SHOW_COMPASS_CONTROL_RULER = new BooleanPreference(this, "show_compass_ruler", true).makeGlobal();
|
||||
public final OsmandPreference<Boolean> SHOW_COMPASS_CONTROL_RULER = new BooleanPreference(this, "show_compass_ruler", true).makeGlobal().makeShared();
|
||||
|
||||
public final CommonPreference<Boolean> SHOW_LINES_TO_FIRST_MARKERS = new BooleanPreference(this, "show_lines_to_first_markers", false).makeProfile();
|
||||
public final CommonPreference<Boolean> SHOW_ARROWS_TO_FIRST_MARKERS = new BooleanPreference(this, "show_arrows_to_first_markers", false).makeProfile();
|
||||
|
||||
public final CommonPreference<Boolean> WIKI_ARTICLE_SHOW_IMAGES_ASKED = new BooleanPreference(this, "wikivoyage_show_images_asked", false).makeGlobal();
|
||||
public final CommonPreference<WikiArticleShowImages> WIKI_ARTICLE_SHOW_IMAGES = new EnumStringPreference<>(this, "wikivoyage_show_imgs", WikiArticleShowImages.OFF, WikiArticleShowImages.values()).makeGlobal();
|
||||
public final CommonPreference<WikiArticleShowImages> WIKI_ARTICLE_SHOW_IMAGES = new EnumStringPreference<>(this, "wikivoyage_show_imgs", WikiArticleShowImages.OFF, WikiArticleShowImages.values()).makeGlobal().makeShared();
|
||||
public final CommonPreference<Boolean> GLOBAL_WIKIPEDIA_POI_ENABLED = new BooleanPreference(this, "global_wikipedia_poi_enabled", false).makeProfile();
|
||||
public final ListStringPreference WIKIPEDIA_POI_ENABLED_LANGUAGES = (ListStringPreference) new ListStringPreference(this, "wikipedia_poi_enabled_languages", null, ",").makeProfile().cache();
|
||||
|
||||
public final CommonPreference<Boolean> SELECT_MARKER_ON_SINGLE_TAP = new BooleanPreference(this, "select_marker_on_single_tap", false).makeProfile();
|
||||
public final CommonPreference<Boolean> KEEP_PASSED_MARKERS_ON_MAP = new BooleanPreference(this, "keep_passed_markers_on_map", true).makeProfile();
|
||||
|
||||
public final CommonPreference<Boolean> COORDS_INPUT_USE_RIGHT_SIDE = new BooleanPreference(this, "coords_input_use_right_side", true).makeGlobal();
|
||||
public final OsmandPreference<Format> COORDS_INPUT_FORMAT = new EnumStringPreference<>(this, "coords_input_format", Format.DD_MM_MMM, Format.values()).makeGlobal();
|
||||
public final CommonPreference<Boolean> COORDS_INPUT_USE_OSMAND_KEYBOARD = new BooleanPreference(this, "coords_input_use_osmand_keyboard", Build.VERSION.SDK_INT >= 16).makeGlobal();
|
||||
public final CommonPreference<Boolean> COORDS_INPUT_TWO_DIGITS_LONGTITUDE = new BooleanPreference(this, "coords_input_two_digits_longitude", false).makeGlobal();
|
||||
public final CommonPreference<Boolean> COORDS_INPUT_USE_RIGHT_SIDE = new BooleanPreference(this, "coords_input_use_right_side", true).makeGlobal().makeShared();
|
||||
public final OsmandPreference<Format> COORDS_INPUT_FORMAT = new EnumStringPreference<>(this, "coords_input_format", Format.DD_MM_MMM, Format.values()).makeGlobal().makeShared();
|
||||
public final CommonPreference<Boolean> COORDS_INPUT_USE_OSMAND_KEYBOARD = new BooleanPreference(this, "coords_input_use_osmand_keyboard", Build.VERSION.SDK_INT >= 16).makeGlobal().makeShared();
|
||||
public final CommonPreference<Boolean> COORDS_INPUT_TWO_DIGITS_LONGTITUDE = new BooleanPreference(this, "coords_input_two_digits_longitude", false).makeGlobal().makeShared();
|
||||
|
||||
public final CommonPreference<Boolean> USE_MAPILLARY_FILTER = new BooleanPreference(this, "use_mapillary_filters", false).makeGlobal();
|
||||
public final CommonPreference<String> MAPILLARY_FILTER_USER_KEY = new StringPreference(this, "mapillary_filter_user_key", "").makeGlobal();
|
||||
public final CommonPreference<String> MAPILLARY_FILTER_USERNAME = new StringPreference(this, "mapillary_filter_username", "").makeGlobal();
|
||||
public final CommonPreference<Long> MAPILLARY_FILTER_FROM_DATE = new LongPreference(this, "mapillary_filter_from_date", 0).makeGlobal();
|
||||
public final CommonPreference<Long> MAPILLARY_FILTER_TO_DATE = new LongPreference(this, "mapillary_filter_to_date", 0).makeGlobal();
|
||||
public final CommonPreference<Boolean> MAPILLARY_FILTER_PANO = new BooleanPreference(this, "mapillary_filter_pano", false).makeGlobal();
|
||||
public final CommonPreference<Boolean> USE_MAPILLARY_FILTER = new BooleanPreference(this, "use_mapillary_filters", false).makeGlobal().makeShared();
|
||||
public final CommonPreference<String> MAPILLARY_FILTER_USER_KEY = new StringPreference(this, "mapillary_filter_user_key", "").makeGlobal().makeShared();
|
||||
public final CommonPreference<String> MAPILLARY_FILTER_USERNAME = new StringPreference(this, "mapillary_filter_username", "").makeGlobal().makeShared();
|
||||
public final CommonPreference<Long> MAPILLARY_FILTER_FROM_DATE = new LongPreference(this, "mapillary_filter_from_date", 0).makeGlobal().makeShared();
|
||||
public final CommonPreference<Long> MAPILLARY_FILTER_TO_DATE = new LongPreference(this, "mapillary_filter_to_date", 0).makeGlobal().makeShared();
|
||||
public final CommonPreference<Boolean> MAPILLARY_FILTER_PANO = new BooleanPreference(this, "mapillary_filter_pano", false).makeGlobal().makeShared();
|
||||
|
||||
public final CommonPreference<Boolean> USE_FAST_RECALCULATION = new BooleanPreference(this, "use_fast_recalculation", true).makeProfile().cache();
|
||||
public final CommonPreference<Boolean> FORCE_PRIVATE_ACCESS_ROUTING_ASKED = new BooleanPreference(this, "force_private_access_routing", false).makeProfile().cache();
|
||||
|
||||
public final CommonPreference<Boolean> SHOW_CARD_TO_CHOOSE_DRAWER = new BooleanPreference(this, "show_card_to_choose_drawer", false).makeGlobal();
|
||||
public final CommonPreference<Boolean> SHOW_DASHBOARD_ON_START = new BooleanPreference(this, "should_show_dashboard_on_start", false).makeGlobal();
|
||||
public final CommonPreference<Boolean> SHOW_DASHBOARD_ON_MAP_SCREEN = new BooleanPreference(this, "show_dashboard_on_map_screen", false).makeGlobal();
|
||||
public final CommonPreference<Boolean> SHOW_CARD_TO_CHOOSE_DRAWER = new BooleanPreference(this, "show_card_to_choose_drawer", false).makeGlobal().makeShared();
|
||||
public final CommonPreference<Boolean> SHOW_DASHBOARD_ON_START = new BooleanPreference(this, "should_show_dashboard_on_start", false).makeGlobal().makeShared();
|
||||
public final CommonPreference<Boolean> SHOW_DASHBOARD_ON_MAP_SCREEN = new BooleanPreference(this, "show_dashboard_on_map_screen", false).makeGlobal().makeShared();
|
||||
public final CommonPreference<Boolean> SHOW_OSMAND_WELCOME_SCREEN = new BooleanPreference(this, "show_osmand_welcome_screen", true).makeGlobal();
|
||||
|
||||
public final CommonPreference<String> API_NAV_DRAWER_ITEMS_JSON = new StringPreference(this, "api_nav_drawer_items_json", "{}").makeGlobal();
|
||||
public final CommonPreference<String> API_CONNECTED_APPS_JSON = new StringPreference(this, "api_connected_apps_json", "[]").makeGlobal();
|
||||
public final CommonPreference<String> API_NAV_DRAWER_ITEMS_JSON = new StringPreference(this, "api_nav_drawer_items_json", "{}").makeGlobal().makeShared();
|
||||
public final CommonPreference<String> API_CONNECTED_APPS_JSON = new StringPreference(this, "api_connected_apps_json", "[]").makeGlobal().makeShared();
|
||||
public final CommonPreference<String> NAV_DRAWER_LOGO = new StringPreference(this, "drawer_logo", "").makeProfile();
|
||||
public final CommonPreference<String> NAV_DRAWER_URL = new StringPreference(this, "drawer_url", "").makeProfile();
|
||||
|
||||
public final CommonPreference<Integer> NUMBER_OF_STARTS_FIRST_XMAS_SHOWN = new IntPreference(this, "number_of_starts_first_xmas_shown", 0).makeGlobal();
|
||||
|
||||
public final OsmandPreference<String> AVAILABLE_APP_MODES = new StringPreference(this, "available_application_modes", "car,bicycle,pedestrian,public_transport,").makeGlobal().cache();
|
||||
public final OsmandPreference<String> AVAILABLE_APP_MODES = new StringPreference(this, "available_application_modes", "car,bicycle,pedestrian,public_transport,").makeGlobal().makeShared().cache();
|
||||
|
||||
public final OsmandPreference<String> LAST_FAV_CATEGORY_ENTERED = new StringPreference(this, "last_fav_category", "").makeGlobal();
|
||||
|
||||
|
@ -779,7 +779,7 @@ public class OsmandSettings {
|
|||
public ApplicationMode parseString(String s) {
|
||||
return appModeFromString(s);
|
||||
}
|
||||
}.makeGlobal();
|
||||
}.makeGlobal().makeShared();
|
||||
|
||||
public final OsmandPreference<ApplicationMode> LAST_ROUTE_APPLICATION_MODE = new CommonPreference<ApplicationMode>(this, "last_route_application_mode_backup_string", ApplicationMode.DEFAULT) {
|
||||
|
||||
|
@ -1043,13 +1043,13 @@ public class OsmandSettings {
|
|||
public final OsmandPreference<Boolean> USE_KALMAN_FILTER_FOR_COMPASS = new BooleanPreference(this, "use_kalman_filter_compass", true).makeProfile().cache();
|
||||
public final OsmandPreference<Boolean> USE_VOLUME_BUTTONS_AS_ZOOM = new BooleanPreference(this, "use_volume_buttons_as_zoom", false).makeProfile().cache();
|
||||
|
||||
public final OsmandPreference<Boolean> DO_NOT_SHOW_STARTUP_MESSAGES = new BooleanPreference(this, "do_not_show_startup_messages", false).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> SHOW_DOWNLOAD_MAP_DIALOG = new BooleanPreference(this, "show_download_map_dialog", true).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> DO_NOT_SHOW_STARTUP_MESSAGES = new BooleanPreference(this, "do_not_show_startup_messages", false).makeGlobal().makeShared().cache();
|
||||
public final OsmandPreference<Boolean> SHOW_DOWNLOAD_MAP_DIALOG = new BooleanPreference(this, "show_download_map_dialog", true).makeGlobal().makeShared().cache();
|
||||
public final OsmandPreference<Boolean> DO_NOT_USE_ANIMATIONS = new BooleanPreference(this, "do_not_use_animations", false).makeProfile().cache();
|
||||
|
||||
public final OsmandPreference<Boolean> SEND_ANONYMOUS_MAP_DOWNLOADS_DATA = new BooleanPreference(this, "send_anonymous_map_downloads_data", false).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> SEND_ANONYMOUS_APP_USAGE_DATA = new BooleanPreference(this, "send_anonymous_app_usage_data", false).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> SEND_ANONYMOUS_DATA_REQUEST_PROCESSED = new BooleanPreference(this, "send_anonymous_data_request_processed", false).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> SEND_ANONYMOUS_MAP_DOWNLOADS_DATA = new BooleanPreference(this, "send_anonymous_map_downloads_data", false).makeGlobal().makeShared().cache();
|
||||
public final OsmandPreference<Boolean> SEND_ANONYMOUS_APP_USAGE_DATA = new BooleanPreference(this, "send_anonymous_app_usage_data", false).makeGlobal().makeShared().cache();
|
||||
public final OsmandPreference<Boolean> SEND_ANONYMOUS_DATA_REQUEST_PROCESSED = new BooleanPreference(this, "send_anonymous_data_request_processed", false).makeGlobal().makeShared().cache();
|
||||
public final OsmandPreference<Integer> SEND_ANONYMOUS_DATA_REQUESTS_COUNT = new IntPreference(this, "send_anonymous_data_requests_count", 0).makeGlobal().cache();
|
||||
public final OsmandPreference<Integer> SEND_ANONYMOUS_DATA_LAST_REQUEST_NS = new IntPreference(this, "send_anonymous_data_last_request_ns", -1).makeGlobal().cache();
|
||||
|
||||
|
@ -1073,21 +1073,21 @@ public class OsmandSettings {
|
|||
|
||||
public final OsmandPreference<Boolean> SHOW_MAPILLARY = new BooleanPreference(this, "show_mapillary", false).makeProfile();
|
||||
public final OsmandPreference<Boolean> MAPILLARY_FIRST_DIALOG_SHOWN = new BooleanPreference(this, "mapillary_first_dialog_shown", false).makeGlobal();
|
||||
public final OsmandPreference<Boolean> ONLINE_PHOTOS_ROW_COLLAPSED = new BooleanPreference(this, "mapillary_menu_collapsed", true).makeGlobal();
|
||||
public final OsmandPreference<Boolean> ONLINE_PHOTOS_ROW_COLLAPSED = new BooleanPreference(this, "mapillary_menu_collapsed", true).makeGlobal().makeShared();
|
||||
public final OsmandPreference<Boolean> WEBGL_SUPPORTED = new BooleanPreference(this, "webgl_supported", true).makeGlobal();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<String> PREFERRED_LOCALE = new StringPreference(this, "preferred_locale", "").makeGlobal();
|
||||
public final OsmandPreference<String> PREFERRED_LOCALE = new StringPreference(this, "preferred_locale", "").makeGlobal().makeShared();
|
||||
|
||||
public final OsmandPreference<String> MAP_PREFERRED_LOCALE = new StringPreference(this, "map_preferred_locale", "").makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> MAP_TRANSLITERATE_NAMES = new BooleanPreference(this, "map_transliterate_names", false).makeGlobal().cache();
|
||||
public final OsmandPreference<String> MAP_PREFERRED_LOCALE = new StringPreference(this, "map_preferred_locale", "").makeGlobal().makeShared().cache();
|
||||
public final OsmandPreference<Boolean> MAP_TRANSLITERATE_NAMES = new BooleanPreference(this, "map_transliterate_names", false).makeGlobal().makeShared().cache();
|
||||
|
||||
public boolean usingEnglishNames() {
|
||||
return MAP_PREFERRED_LOCALE.get().equals("en");
|
||||
}
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<String> USER_NAME = new StringPreference(this, "user_name", "").makeGlobal();
|
||||
public final OsmandPreference<String> USER_NAME = new StringPreference(this, "user_name", "").makeGlobal().makeShared();
|
||||
|
||||
public static final String BILLING_USER_DONATION_WORLD_PARAMETER = "";
|
||||
public static final String BILLING_USER_DONATION_NONE_PARAMETER = "none";
|
||||
|
@ -1119,11 +1119,11 @@ public class OsmandSettings {
|
|||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<String> USER_OSM_BUG_NAME =
|
||||
new StringPreference(this, "user_osm_bug_name", "NoName/OsmAnd").makeGlobal();
|
||||
new StringPreference(this, "user_osm_bug_name", "NoName/OsmAnd").makeGlobal().makeShared();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<String> USER_PASSWORD =
|
||||
new StringPreference(this, "user_password", "").makeGlobal();
|
||||
new StringPreference(this, "user_password", "").makeGlobal().makeShared();
|
||||
|
||||
public final OsmandPreference<String> USER_ACCESS_TOKEN =
|
||||
new StringPreference(this, "user_access_token", "").makeGlobal();
|
||||
|
@ -1132,7 +1132,7 @@ public class OsmandSettings {
|
|||
new StringPreference(this, "user_access_token_secret", "").makeGlobal();
|
||||
|
||||
// this value boolean is synchronized with settings_pref.xml preference offline POI/Bugs edition
|
||||
public final OsmandPreference<Boolean> OFFLINE_EDITION = new BooleanPreference(this, "offline_osm_editing", true).makeGlobal();
|
||||
public final OsmandPreference<Boolean> OFFLINE_EDITION = new BooleanPreference(this, "offline_osm_editing", true).makeGlobal().makeShared();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final CommonPreference<DayNightMode> DAYNIGHT_MODE =
|
||||
|
@ -1170,7 +1170,7 @@ public class OsmandSettings {
|
|||
}
|
||||
return -1;
|
||||
}
|
||||
}.makeGlobal().cache();
|
||||
}.makeGlobal().makeShared().cache();
|
||||
|
||||
public final CommonPreference<Boolean> SNAP_TO_ROAD = new BooleanPreference(this, "snap_to_road", false).makeProfile().cache();
|
||||
|
||||
|
@ -1190,10 +1190,10 @@ public class OsmandSettings {
|
|||
}
|
||||
return valueSaved;
|
||||
}
|
||||
}.makeGlobal();
|
||||
}.makeGlobal().makeShared();
|
||||
|
||||
public final CommonPreference<String> PROXY_HOST = new StringPreference(this, "proxy_host", "127.0.0.1").makeGlobal();
|
||||
public final CommonPreference<Integer> PROXY_PORT = new IntPreference(this, "proxy_port", 8118).makeGlobal();
|
||||
public final CommonPreference<String> PROXY_HOST = new StringPreference(this, "proxy_host", "127.0.0.1").makeGlobal().makeShared();
|
||||
public final CommonPreference<Integer> PROXY_PORT = new IntPreference(this, "proxy_port", 8118).makeGlobal().makeShared();
|
||||
public final CommonPreference<String> USER_ANDROID_ID = new StringPreference(this, "user_android_id", "").makeGlobal();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
|
@ -1202,7 +1202,7 @@ public class OsmandSettings {
|
|||
public final CommonPreference<Boolean> SAVE_GLOBAL_TRACK_TO_GPX = new BooleanPreference(this, "save_global_track_to_gpx", false).makeGlobal().cache();
|
||||
public final CommonPreference<Integer> SAVE_GLOBAL_TRACK_INTERVAL = new IntPreference(this, "save_global_track_interval", 5000).makeProfile().cache();
|
||||
public final CommonPreference<Boolean> SAVE_GLOBAL_TRACK_REMEMBER = new BooleanPreference(this, "save_global_track_remember", false).makeProfile().cache();
|
||||
public final CommonPreference<Boolean> SHOW_SAVED_TRACK_REMEMBER = new BooleanPreference(this, "show_saved_track_remember", true).makeGlobal();
|
||||
public final CommonPreference<Boolean> SHOW_SAVED_TRACK_REMEMBER = new BooleanPreference(this, "show_saved_track_remember", true).makeGlobal().makeShared();
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final CommonPreference<Boolean> SAVE_TRACK_TO_GPX = new BooleanPreference(this, "save_track_to_gpx", false).makeProfile().cache();
|
||||
|
||||
|
@ -1258,7 +1258,7 @@ public class OsmandSettings {
|
|||
SHOW_LANES.setModeDefaultValue(ApplicationMode.BICYCLE, true);
|
||||
}
|
||||
|
||||
public final OsmandPreference<Boolean> SHOW_WPT = new BooleanPreference(this, "show_gpx_wpt", true).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> SHOW_WPT = new BooleanPreference(this, "show_gpx_wpt", true).makeGlobal().makeShared().cache();
|
||||
public final OsmandPreference<Boolean> SHOW_NEARBY_FAVORITES = new BooleanPreference(this, "show_nearby_favorites", false).makeProfile().cache();
|
||||
public final OsmandPreference<Boolean> SHOW_NEARBY_POI = new BooleanPreference(this, "show_nearby_poi", false).makeProfile().cache();
|
||||
|
||||
|
@ -1278,8 +1278,8 @@ public class OsmandSettings {
|
|||
public final OsmandPreference<Boolean> SPEAK_SPEED_CAMERA = new BooleanPreference(this, "speak_cameras", false).makeProfile().cache();
|
||||
public final OsmandPreference<Boolean> SPEAK_TUNNELS = new BooleanPreference(this, "speak_tunnels", false).makeProfile().cache();
|
||||
|
||||
public final OsmandPreference<Boolean> SPEED_CAMERAS_UNINSTALLED = new BooleanPreference(this, "speed_cameras_uninstalled", false).makeGlobal();
|
||||
public final OsmandPreference<Boolean> SPEED_CAMERAS_ALERT_SHOWED = new BooleanPreference(this, "speed_cameras_alert_showed", false).makeGlobal();
|
||||
public final OsmandPreference<Boolean> SPEED_CAMERAS_UNINSTALLED = new BooleanPreference(this, "speed_cameras_uninstalled", false).makeGlobal().makeShared();
|
||||
public final OsmandPreference<Boolean> SPEED_CAMERAS_ALERT_SHOWED = new BooleanPreference(this, "speed_cameras_alert_showed", false).makeGlobal().makeShared();
|
||||
|
||||
public Set<String> getForbiddenTypes() {
|
||||
Set<String> typeNames = new HashSet<>();
|
||||
|
@ -1325,10 +1325,10 @@ public class OsmandSettings {
|
|||
}
|
||||
}.makeProfile().cache();
|
||||
|
||||
public final OsmandPreference<Boolean> GPX_ROUTE_CALC_OSMAND_PARTS = new BooleanPreference(this, "gpx_routing_calculate_osmand_route", true).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> GPX_CALCULATE_RTEPT = new BooleanPreference(this, "gpx_routing_calculate_rtept", true).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> GPX_ROUTE_CALC = new BooleanPreference(this, "calc_gpx_route", false).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> SHOW_START_FINISH_ICONS = new BooleanPreference(this, "show_start_finish_icons", true).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> GPX_ROUTE_CALC_OSMAND_PARTS = new BooleanPreference(this, "gpx_routing_calculate_osmand_route", true).makeGlobal().makeShared().cache();
|
||||
public final OsmandPreference<Boolean> GPX_CALCULATE_RTEPT = new BooleanPreference(this, "gpx_routing_calculate_rtept", true).makeGlobal().makeShared().cache();
|
||||
public final OsmandPreference<Boolean> GPX_ROUTE_CALC = new BooleanPreference(this, "calc_gpx_route", false).makeGlobal().makeShared().cache();
|
||||
public final OsmandPreference<Boolean> SHOW_START_FINISH_ICONS = new BooleanPreference(this, "show_start_finish_icons", true).makeGlobal().makeShared().cache();
|
||||
|
||||
public final OsmandPreference<Boolean> AVOID_TOLL_ROADS = new BooleanPreference(this, "avoid_toll_roads", false).makeProfile().cache();
|
||||
public final OsmandPreference<Boolean> AVOID_MOTORWAY = new BooleanPreference(this, "avoid_motorway", false).makeProfile().cache();
|
||||
|
@ -1339,11 +1339,11 @@ public class OsmandSettings {
|
|||
|
||||
public final OsmandPreference<Long> LAST_UPDATES_CARD_REFRESH = new LongPreference(this, "last_updates_card_refresh", 0).makeGlobal();
|
||||
|
||||
public final CommonPreference<Integer> CURRENT_TRACK_COLOR = new IntPreference(this, "current_track_color", 0).makeGlobal().cache();
|
||||
public final CommonPreference<String> CURRENT_TRACK_WIDTH = new StringPreference(this, "current_track_width", "").makeGlobal().cache();
|
||||
public final CommonPreference<Boolean> CURRENT_TRACK_SHOW_ARROWS = new BooleanPreference(this, "current_track_show_arrows", false).makeGlobal().cache();
|
||||
public final CommonPreference<Boolean> CURRENT_TRACK_SHOW_START_FINISH = new BooleanPreference(this, "current_track_show_start_finish", true).makeGlobal().cache();
|
||||
public final ListStringPreference CUSTOM_TRACK_COLORS = (ListStringPreference) new ListStringPreference(this, "custom_track_colors", null, ",").makeGlobal();
|
||||
public final CommonPreference<Integer> CURRENT_TRACK_COLOR = new IntPreference(this, "current_track_color", 0).makeGlobal().makeShared().cache();
|
||||
public final CommonPreference<String> CURRENT_TRACK_WIDTH = new StringPreference(this, "current_track_width", "").makeGlobal().makeShared().cache();
|
||||
public final CommonPreference<Boolean> CURRENT_TRACK_SHOW_ARROWS = new BooleanPreference(this, "current_track_show_arrows", false).makeGlobal().makeShared().cache();
|
||||
public final CommonPreference<Boolean> CURRENT_TRACK_SHOW_START_FINISH = new BooleanPreference(this, "current_track_show_start_finish", true).makeGlobal().makeShared().cache();
|
||||
public final ListStringPreference CUSTOM_TRACK_COLORS = (ListStringPreference) new ListStringPreference(this, "custom_track_colors", null, ",").makeShared().makeGlobal();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final CommonPreference<Integer> SAVE_TRACK_INTERVAL = new IntPreference(this, "save_track_interval", 5000).makeProfile();
|
||||
|
@ -1390,7 +1390,7 @@ public class OsmandSettings {
|
|||
public final CommonPreference<String> LIVE_MONITORING_URL = new StringPreference(this, "live_monitoring_url",
|
||||
"https://example.com?lat={0}&lon={1}×tamp={2}&hdop={3}&altitude={4}&speed={5}").makeProfile();
|
||||
|
||||
public final CommonPreference<String> GPS_STATUS_APP = new StringPreference(this, "gps_status_app", "").makeGlobal();
|
||||
public final CommonPreference<String> GPS_STATUS_APP = new StringPreference(this, "gps_status_app", "").makeGlobal().makeShared();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<Boolean> SHOW_OSM_BUGS = new BooleanPreference(this, "show_osm_bugs", false).makeProfile().cache();
|
||||
|
@ -1410,7 +1410,7 @@ public class OsmandSettings {
|
|||
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<Boolean> DEBUG_RENDERING_INFO = new BooleanPreference(this, "debug_rendering", false).makeGlobal();
|
||||
public final OsmandPreference<Boolean> DEBUG_RENDERING_INFO = new BooleanPreference(this, "debug_rendering", false).makeGlobal().makeShared();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<Boolean> SHOW_FAVORITES = new BooleanPreference(this, "show_favorites", true).makeProfile().cache();
|
||||
|
@ -1422,7 +1422,7 @@ public class OsmandSettings {
|
|||
}
|
||||
|
||||
// Json
|
||||
public final OsmandPreference<String> SELECTED_GPX = new StringPreference(this, "selected_gpx", "").makeGlobal();
|
||||
public final OsmandPreference<String> SELECTED_GPX = new StringPreference(this, "selected_gpx", "").makeGlobal().makeShared();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<Integer> MAP_SCREEN_ORIENTATION =
|
||||
|
@ -1544,13 +1544,13 @@ public class OsmandSettings {
|
|||
|
||||
{
|
||||
// 1500 ms delay works for most configurations to establish a BT SCO link
|
||||
VOICE_PROMPT_DELAY[0] = new IntPreference(this, "voice_prompt_delay_0", 1500).makeGlobal().cache(); /*AudioManager.STREAM_VOICE_CALL*/
|
||||
VOICE_PROMPT_DELAY[0] = new IntPreference(this, "voice_prompt_delay_0", 1500).makeGlobal().makeShared().cache(); /*AudioManager.STREAM_VOICE_CALL*/
|
||||
// On most devices sound output works pomptly so usually no voice prompt delay needed
|
||||
VOICE_PROMPT_DELAY[3] = new IntPreference(this, "voice_prompt_delay_3", 0).makeGlobal().cache(); /*AudioManager.STREAM_MUSIC*/
|
||||
VOICE_PROMPT_DELAY[5] = new IntPreference(this, "voice_prompt_delay_5", 0).makeGlobal().cache(); /*AudioManager.STREAM_NOTIFICATION*/
|
||||
VOICE_PROMPT_DELAY[3] = new IntPreference(this, "voice_prompt_delay_3", 0).makeGlobal().makeShared().cache(); /*AudioManager.STREAM_MUSIC*/
|
||||
VOICE_PROMPT_DELAY[5] = new IntPreference(this, "voice_prompt_delay_5", 0).makeGlobal().makeShared().cache(); /*AudioManager.STREAM_NOTIFICATION*/
|
||||
}
|
||||
|
||||
public final OsmandPreference<Boolean> DISPLAY_TTS_UTTERANCE = new BooleanPreference(this, "display_tts_utterance", false).makeGlobal();
|
||||
public final OsmandPreference<Boolean> DISPLAY_TTS_UTTERANCE = new BooleanPreference(this, "display_tts_utterance", false).makeGlobal().makeShared();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final CommonPreference<Boolean> MAP_ONLINE_DATA = new BooleanPreference(this, "map_online_data", false).makeProfile();
|
||||
|
@ -1598,7 +1598,7 @@ public class OsmandSettings {
|
|||
|
||||
public CommonPreference<String> PREVIOUS_INSTALLED_VERSION = new StringPreference(this, "previous_installed_version", "").makeGlobal();
|
||||
|
||||
public final OsmandPreference<Boolean> SHOULD_SHOW_FREE_VERSION_BANNER = new BooleanPreference(this, "should_show_free_version_banner", false).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> SHOULD_SHOW_FREE_VERSION_BANNER = new BooleanPreference(this, "should_show_free_version_banner", false).makeGlobal().makeShared().cache();
|
||||
|
||||
public final OsmandPreference<Boolean> MARKERS_DISTANCE_INDICATION_ENABLED = new BooleanPreference(this, "markers_distance_indication_enabled", true).makeProfile();
|
||||
|
||||
|
@ -1626,8 +1626,8 @@ public class OsmandSettings {
|
|||
|
||||
public final OsmandPreference<Integer> EXTERNAL_INPUT_DEVICE = new IntPreference(this, "external_input_device", 0).makeProfile();
|
||||
|
||||
public final OsmandPreference<Boolean> ROUTE_MAP_MARKERS_START_MY_LOC = new BooleanPreference(this, "route_map_markers_start_my_loc", false).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> ROUTE_MAP_MARKERS_ROUND_TRIP = new BooleanPreference(this, "route_map_markers_round_trip", false).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> ROUTE_MAP_MARKERS_START_MY_LOC = new BooleanPreference(this, "route_map_markers_start_my_loc", false).makeGlobal().makeShared().cache();
|
||||
public final OsmandPreference<Boolean> ROUTE_MAP_MARKERS_ROUND_TRIP = new BooleanPreference(this, "route_map_markers_round_trip", false).makeGlobal().makeShared().cache();
|
||||
|
||||
public ITileSource getMapTileSource(boolean warnWhenSelected) {
|
||||
String tileName = MAP_TILE_SOURCES.get();
|
||||
|
@ -2329,9 +2329,9 @@ public class OsmandSettings {
|
|||
|
||||
public final CommonPreference<Boolean> QUICK_ACTION = new BooleanPreference(this, "quick_action_state", false).makeProfile();
|
||||
|
||||
public final CommonPreference<String> QUICK_ACTION_LIST = new StringPreference(this, "quick_action_list", "").makeGlobal();
|
||||
public final CommonPreference<String> QUICK_ACTION_LIST = new StringPreference(this, "quick_action_list", "").makeGlobal().makeShared();
|
||||
|
||||
public final CommonPreference<Boolean> IS_QUICK_ACTION_TUTORIAL_SHOWN = new BooleanPreference(this, "quick_action_tutorial", false).makeGlobal();
|
||||
public final CommonPreference<Boolean> IS_QUICK_ACTION_TUTORIAL_SHOWN = new BooleanPreference(this, "quick_action_tutorial", false).makeGlobal().makeShared();
|
||||
|
||||
private final CommonPreference<Integer> QUICK_ACTION_FAB_MARGIN_X_PORTRAIT = new IntPreference(this, QUICK_FAB_MARGIN_X_PORTRAIT_MARGIN, 0).makeProfile();
|
||||
private final CommonPreference<Integer> QUICK_ACTION_FAB_MARGIN_Y_PORTRAIT = new IntPreference(this, QUICK_FAB_MARGIN_Y_PORTRAIT_MARGIN, 0).makeProfile();
|
||||
|
@ -2620,13 +2620,13 @@ public class OsmandSettings {
|
|||
public final OsmandPreference<Boolean> MAP_ACTIVITY_ENABLED = new BooleanPreference(this, "map_activity_enabled", false).makeGlobal();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<Boolean> SAFE_MODE = new BooleanPreference(this, "safe_mode", false).makeGlobal();
|
||||
public final OsmandPreference<Boolean> SAFE_MODE = new BooleanPreference(this, "safe_mode", false).makeGlobal().makeShared();
|
||||
public final OsmandPreference<Boolean> PT_SAFE_MODE = new BooleanPreference(this, "pt_safe_mode", false).makeProfile();
|
||||
public final OsmandPreference<Boolean> NATIVE_RENDERING_FAILED = new BooleanPreference(this, "native_rendering_failed_init", false).makeGlobal();
|
||||
|
||||
public final OsmandPreference<Boolean> USE_OPENGL_RENDER = new BooleanPreference(this, "use_opengl_render",
|
||||
false /*Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH*/
|
||||
).makeGlobal().cache();
|
||||
).makeGlobal().makeShared().cache();
|
||||
|
||||
public final OsmandPreference<Boolean> OPENGL_RENDER_FAILED = new BooleanPreference(this, "opengl_render_failed", false).makeGlobal().cache();
|
||||
|
||||
|
@ -2639,7 +2639,7 @@ public class OsmandSettings {
|
|||
public final OsmandPreference<Boolean> FOLLOW_THE_ROUTE = new BooleanPreference(this, "follow_to_route", false).makeGlobal();
|
||||
public final OsmandPreference<String> FOLLOW_THE_GPX_ROUTE = new StringPreference(this, "follow_gpx", null).makeGlobal();
|
||||
|
||||
public final OsmandPreference<String> SELECTED_TRAVEL_BOOK = new StringPreference(this, "selected_travel_book", "").makeGlobal();
|
||||
public final OsmandPreference<String> SELECTED_TRAVEL_BOOK = new StringPreference(this, "selected_travel_book", "").makeGlobal().makeShared();
|
||||
|
||||
public final ListStringPreference DISPLAYED_TRANSPORT_SETTINGS = (ListStringPreference)
|
||||
new ListStringPreference(this, "displayed_transport_settings", null, ",").makeProfile();
|
||||
|
@ -2658,7 +2658,7 @@ public class OsmandSettings {
|
|||
|
||||
// Live Updates
|
||||
public final OsmandPreference<Boolean> IS_LIVE_UPDATES_ON =
|
||||
new BooleanPreference(this, "is_live_updates_on", false).makeGlobal();
|
||||
new BooleanPreference(this, "is_live_updates_on", false).makeGlobal().makeShared();
|
||||
public final OsmandPreference<Integer> LIVE_UPDATES_RETRIES =
|
||||
new IntPreference(this, "live_updates_retryes", 2).makeGlobal();
|
||||
|
||||
|
@ -2746,7 +2746,7 @@ public class OsmandSettings {
|
|||
}
|
||||
|
||||
public final CommonPreference<Boolean> FLUORESCENT_OVERLAYS =
|
||||
new BooleanPreference(this, "fluorescent_overlays", false).makeGlobal().cache();
|
||||
new BooleanPreference(this, "fluorescent_overlays", false).makeGlobal().makeShared().cache();
|
||||
|
||||
|
||||
// public final OsmandPreference<Integer> NUMBER_OF_FREE_DOWNLOADS_V2 = new IntPreference("free_downloads_v2", 0).makeGlobal();
|
||||
|
@ -2767,7 +2767,7 @@ public class OsmandSettings {
|
|||
new EnumStringPreference<>(this, "rate_us_state", RateUsState.INITIAL_STATE, RateUsState.values()).makeGlobal();
|
||||
|
||||
public final CommonPreference<String> CUSTOM_APP_MODES_KEYS =
|
||||
new StringPreference(this, "custom_app_modes_keys", "").makeGlobal().cache();
|
||||
new StringPreference(this, "custom_app_modes_keys", "").makeGlobal().makeShared().cache();
|
||||
|
||||
public Set<String> getCustomAppModesKeys() {
|
||||
String appModesKeys = CUSTOM_APP_MODES_KEYS.get();
|
||||
|
|
|
@ -6,6 +6,7 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.settings.backend.CommonPreference;
|
||||
import net.osmand.plus.settings.backend.OsmandPreference;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
|
||||
|
@ -47,7 +48,10 @@ public class GlobalSettingsItem extends OsmandSettingsItem {
|
|||
return new OsmandSettingsItemReader<OsmandSettingsItem>(this, getSettings()) {
|
||||
@Override
|
||||
protected void readPreferenceFromJson(@NonNull OsmandPreference<?> preference, @NonNull JSONObject json) throws JSONException {
|
||||
preference.readFromJson(json, null);
|
||||
if ((preference instanceof CommonPreference) && (((CommonPreference<?>) preference).isShared())
|
||||
|| getSettings().APPLICATION_MODE.getId().equals(preference.getId())) {
|
||||
preference.readFromJson(json, null);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -58,7 +62,10 @@ public class GlobalSettingsItem extends OsmandSettingsItem {
|
|||
return new OsmandSettingsItemWriter<OsmandSettingsItem>(this, getSettings()) {
|
||||
@Override
|
||||
protected void writePreferenceToJson(@NonNull OsmandPreference<?> preference, @NonNull JSONObject json) throws JSONException {
|
||||
preference.writeToJson(json, null);
|
||||
if ((preference instanceof CommonPreference) && (((CommonPreference<?>) preference).isShared())
|
||||
|| getSettings().APPLICATION_MODE.getId().equals(preference.getId())) {
|
||||
preference.writeToJson(json, null);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import net.osmand.plus.CustomOsmandPlugin;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBuilder;
|
||||
import net.osmand.plus.settings.backend.OsmandPreference;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.router.GeneralRouter;
|
||||
|
@ -28,8 +30,8 @@ import java.util.Set;
|
|||
public class ProfileSettingsItem extends OsmandSettingsItem {
|
||||
|
||||
private ApplicationMode appMode;
|
||||
private ApplicationMode.ApplicationModeBuilder builder;
|
||||
private ApplicationMode.ApplicationModeBean modeBean;
|
||||
private ApplicationModeBuilder builder;
|
||||
private ApplicationModeBean modeBean;
|
||||
|
||||
private JSONObject additionalPrefsJson;
|
||||
private Set<String> appModeBeanPrefsIds;
|
||||
|
@ -39,7 +41,7 @@ public class ProfileSettingsItem extends OsmandSettingsItem {
|
|||
this.appMode = appMode;
|
||||
}
|
||||
|
||||
public ProfileSettingsItem(@NonNull OsmandApplication app, @Nullable ProfileSettingsItem baseItem, @NonNull ApplicationMode.ApplicationModeBean modeBean) {
|
||||
public ProfileSettingsItem(@NonNull OsmandApplication app, @Nullable ProfileSettingsItem baseItem, @NonNull ApplicationModeBean modeBean) {
|
||||
super(app.getSettings(), baseItem);
|
||||
this.modeBean = modeBean;
|
||||
builder = ApplicationMode.fromModeBean(app, modeBean);
|
||||
|
@ -66,7 +68,7 @@ public class ProfileSettingsItem extends OsmandSettingsItem {
|
|||
return appMode;
|
||||
}
|
||||
|
||||
public ApplicationMode.ApplicationModeBean getModeBean() {
|
||||
public ApplicationModeBean getModeBean() {
|
||||
return modeBean;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import net.osmand.plus.osmedit.OsmNotesPoint;
|
|||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.quickaction.QuickAction;
|
||||
import net.osmand.plus.quickaction.QuickActionRegistry;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
|
||||
import net.osmand.plus.settings.backend.ExportSettingsType;
|
||||
|
||||
|
@ -434,7 +435,7 @@ public class SettingsHelper {
|
|||
return settingsItems;
|
||||
}
|
||||
|
||||
public Map<ExportSettingsType, List<?>> getAdditionalData() {
|
||||
public Map<ExportSettingsType, List<?>> getAdditionalData(boolean globalExport) {
|
||||
Map<ExportSettingsType, List<?>> dataList = new HashMap<>();
|
||||
|
||||
QuickActionRegistry registry = app.getQuickActionRegistry();
|
||||
|
@ -512,6 +513,13 @@ public class SettingsHelper {
|
|||
dataList.put(ExportSettingsType.TRACKS, files);
|
||||
}
|
||||
}
|
||||
if (globalExport) {
|
||||
List<ApplicationModeBean> appModeBeans = new ArrayList<>();
|
||||
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
|
||||
appModeBeans.add(mode.toModeBean());
|
||||
}
|
||||
dataList.put(ExportSettingsType.PROFILE, appModeBeans);
|
||||
}
|
||||
OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||
if (osmEditingPlugin != null) {
|
||||
List<OsmNotesPoint> notesPointList = osmEditingPlugin.getDBBug().getOsmbugsPoints();
|
||||
|
@ -553,6 +561,7 @@ public class SettingsHelper {
|
|||
List<PoiUIFilter> poiUIFilters = new ArrayList<>();
|
||||
List<ITileSource> tileSourceTemplates = new ArrayList<>();
|
||||
List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
|
||||
List<ApplicationModeBean> appModeBeans = new ArrayList<>();
|
||||
List<OsmNotesPoint> osmNotesPointList = new ArrayList<>();
|
||||
List<OpenstreetmapPoint> osmEditsPointList = new ArrayList<>();
|
||||
|
||||
|
@ -571,6 +580,8 @@ public class SettingsHelper {
|
|||
}
|
||||
} else if (object instanceof AvoidRoadInfo) {
|
||||
avoidRoads.add((AvoidRoadInfo) object);
|
||||
} else if (object instanceof ApplicationModeBean) {
|
||||
appModeBeans.add((ApplicationModeBean) object);
|
||||
} else if (object instanceof OsmNotesPoint) {
|
||||
osmNotesPointList.add((OsmNotesPoint) object);
|
||||
} else if (object instanceof OpenstreetmapPoint) {
|
||||
|
@ -589,6 +600,14 @@ public class SettingsHelper {
|
|||
if (!avoidRoads.isEmpty()) {
|
||||
settingsItems.add(new AvoidRoadsSettingsItem(app, avoidRoads));
|
||||
}
|
||||
if (!appModeBeans.isEmpty()) {
|
||||
for (ApplicationModeBean modeBean : appModeBeans) {
|
||||
ApplicationMode mode = ApplicationMode.valueOfStringKey(modeBean.stringKey, null);
|
||||
if (mode != null) {
|
||||
settingsItems.add(new ProfileSettingsItem(app, mode));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!osmNotesPointList.isEmpty()) {
|
||||
settingsItems.add(new OsmNotesSettingsItem(app, osmNotesPointList));
|
||||
}
|
||||
|
@ -610,6 +629,7 @@ public class SettingsHelper {
|
|||
List<File> tracksFilesList = new ArrayList<>();
|
||||
List<FileSettingsItem> mapFilesList = new ArrayList<>();
|
||||
List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
|
||||
List<GlobalSettingsItem> globalSettingsItems = new ArrayList<>();
|
||||
List<OsmNotesPoint> notesPointList = new ArrayList<>();
|
||||
List<OpenstreetmapPoint> editsPointList = new ArrayList<>();
|
||||
for (SettingsItem item : settingsItems) {
|
||||
|
@ -666,6 +686,9 @@ public class SettingsHelper {
|
|||
avoidRoads.addAll(avoidRoadsItem.getItems());
|
||||
}
|
||||
break;
|
||||
case GLOBAL:
|
||||
globalSettingsItems.add((GlobalSettingsItem) item);
|
||||
break;
|
||||
case OSM_NOTES:
|
||||
OsmNotesSettingsItem osmNotesSettingsItem = (OsmNotesSettingsItem) item;
|
||||
if (importComplete) {
|
||||
|
@ -714,6 +737,9 @@ public class SettingsHelper {
|
|||
if (!tracksFilesList.isEmpty()) {
|
||||
settingsToOperate.put(ExportSettingsType.TRACKS, tracksFilesList);
|
||||
}
|
||||
if (!globalSettingsItems.isEmpty()) {
|
||||
settingsToOperate.put(ExportSettingsType.GLOBAL, globalSettingsItems);
|
||||
}
|
||||
if (!notesPointList.isEmpty()) {
|
||||
settingsToOperate.put(ExportSettingsType.OSM_NOTES, notesPointList);
|
||||
}
|
||||
|
|
|
@ -436,7 +436,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
|
|||
ExportProfileBottomSheet.showInstance(
|
||||
fragmentManager,
|
||||
this,
|
||||
getSelectedAppMode());
|
||||
getSelectedAppMode(), false);
|
||||
}
|
||||
} else if (DELETE_PROFILE.equals(prefId)) {
|
||||
onDeleteProfileClick();
|
||||
|
|
|
@ -35,6 +35,7 @@ import net.osmand.plus.render.RenderingIcons;
|
|||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
|
||||
import net.osmand.plus.settings.backend.ExportSettingsType;
|
||||
import net.osmand.plus.settings.backend.backup.GlobalSettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.FileSettingsItem;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.view.ThreeStateCheckbox;
|
||||
|
@ -260,6 +261,11 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
|||
title.setText(GpxUiHelper.getGpxTitle(fileName));
|
||||
setupIcon(icon, R.drawable.ic_action_route_distance, itemSelected);
|
||||
break;
|
||||
case GLOBAL:
|
||||
String name = ((GlobalSettingsItem) currentItem).getPublicName(app);
|
||||
title.setText(name);
|
||||
setupIcon(icon, R.drawable.ic_action_settings, itemSelected);
|
||||
break;
|
||||
case OSM_NOTES:
|
||||
title.setText(((OsmNotesPoint) currentItem).getText());
|
||||
setupIcon(icon, R.drawable.ic_action_osm_note_add, itemSelected);
|
||||
|
@ -379,6 +385,8 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter {
|
|||
return R.string.shared_string_tracks;
|
||||
case MULTIMEDIA_NOTES:
|
||||
return R.string.audionotes_plugin_name;
|
||||
case GLOBAL:
|
||||
return R.string.general_settings_2;
|
||||
case OSM_NOTES:
|
||||
return R.string.osm_notes;
|
||||
case OSM_EDITS:
|
||||
|
|
|
@ -31,17 +31,20 @@ import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
|||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
|
||||
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||
import net.osmand.plus.settings.backend.ExportSettingsType;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.settings.backend.backup.SettingsHelper;
|
||||
import net.osmand.plus.settings.backend.ExportSettingsType;
|
||||
import net.osmand.plus.settings.backend.backup.GlobalSettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.ProfileSettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.SettingsHelper.SettingsExportListener;
|
||||
import net.osmand.plus.settings.backend.backup.SettingsItem;
|
||||
import net.osmand.plus.settings.bottomsheets.BasePreferenceBottomSheet;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -52,37 +55,50 @@ public class ExportProfileBottomSheet extends BasePreferenceBottomSheet {
|
|||
|
||||
private static final Log LOG = PlatformUtil.getLog(ExportProfileBottomSheet.class);
|
||||
|
||||
private static final String INCLUDE_ADDITIONAL_DATA_KEY = "INCLUDE_ADDITIONAL_DATA_KEY";
|
||||
private static final String GLOBAL_EXPORT_KEY = "global_export_key";
|
||||
private static final String EXPORT_START_TIME_KEY = "export_start_time_key";
|
||||
private static final String EXPORTING_PROFILE_KEY = "exporting_profile_key";
|
||||
private static final String INCLUDE_ADDITIONAL_DATA_KEY = "include_additional_data_key";
|
||||
private static final String INCLUDE_GLOBAL_SETTINGS_KEY = "include_global_settings_key";
|
||||
|
||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd-MM-yy");
|
||||
|
||||
private OsmandApplication app;
|
||||
private ApplicationMode profile;
|
||||
private Map<ExportSettingsType, List<?>> dataList = new HashMap<>();
|
||||
private ExportImportSettingsAdapter adapter;
|
||||
|
||||
private SettingsHelper.SettingsExportListener exportListener;
|
||||
private SettingsExportListener exportListener;
|
||||
private ProgressDialog progress;
|
||||
|
||||
private boolean includeAdditionalData = false;
|
||||
private long exportStartTime;
|
||||
|
||||
private boolean globalExport = false;
|
||||
private boolean exportingProfile = false;
|
||||
private boolean includeAdditionalData = false;
|
||||
private boolean includeGlobalSettings = false;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
app = requiredMyApplication();
|
||||
profile = getAppMode();
|
||||
dataList = app.getSettingsHelper().getAdditionalData();
|
||||
if (savedInstanceState != null) {
|
||||
includeAdditionalData = savedInstanceState.getBoolean(INCLUDE_ADDITIONAL_DATA_KEY);
|
||||
globalExport = savedInstanceState.getBoolean(GLOBAL_EXPORT_KEY);
|
||||
exportingProfile = savedInstanceState.getBoolean(EXPORTING_PROFILE_KEY);
|
||||
includeAdditionalData = savedInstanceState.getBoolean(INCLUDE_ADDITIONAL_DATA_KEY);
|
||||
includeGlobalSettings = savedInstanceState.getBoolean(INCLUDE_GLOBAL_SETTINGS_KEY);
|
||||
exportStartTime = savedInstanceState.getLong(EXPORT_START_TIME_KEY);
|
||||
}
|
||||
dataList = app.getSettingsHelper().getAdditionalData(globalExport);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(INCLUDE_ADDITIONAL_DATA_KEY, includeAdditionalData);
|
||||
outState.putBoolean(GLOBAL_EXPORT_KEY, globalExport);
|
||||
outState.putBoolean(EXPORTING_PROFILE_KEY, exportingProfile);
|
||||
outState.putBoolean(INCLUDE_ADDITIONAL_DATA_KEY, includeAdditionalData);
|
||||
outState.putBoolean(INCLUDE_GLOBAL_SETTINGS_KEY, includeGlobalSettings);
|
||||
outState.putLong(EXPORT_START_TIME_KEY, exportStartTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -91,32 +107,55 @@ public class ExportProfileBottomSheet extends BasePreferenceBottomSheet {
|
|||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
|
||||
if (globalExport) {
|
||||
items.add(new TitleItem(getString(R.string.shared_string_export)));
|
||||
|
||||
int profileColor = profile.getIconColorInfo().getColor(nightMode);
|
||||
int colorNoAlpha = ContextCompat.getColor(context, profileColor);
|
||||
final BottomSheetItemWithCompoundButton[] globalSettingsItem = new BottomSheetItemWithCompoundButton[1];
|
||||
globalSettingsItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setChecked(includeGlobalSettings)
|
||||
.setTitle(getString(R.string.general_settings_2))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_with_switch_no_icon)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean checked = !globalSettingsItem[0].isChecked();
|
||||
globalSettingsItem[0].setChecked(checked);
|
||||
includeGlobalSettings = checked;
|
||||
}
|
||||
})
|
||||
.create();
|
||||
items.add(globalSettingsItem[0]);
|
||||
} else {
|
||||
items.add(new TitleItem(getString(R.string.export_profile)));
|
||||
ApplicationMode profile = getAppMode();
|
||||
int profileColor = profile.getIconColorInfo().getColor(nightMode);
|
||||
int colorNoAlpha = ContextCompat.getColor(context, profileColor);
|
||||
|
||||
Drawable backgroundIcon = UiUtilities.getColoredSelectableDrawable(context, colorNoAlpha, 0.3f);
|
||||
Drawable[] layers = {new ColorDrawable(UiUtilities.getColorWithAlpha(colorNoAlpha, 0.10f)), backgroundIcon};
|
||||
Drawable backgroundIcon = UiUtilities.getColoredSelectableDrawable(context, colorNoAlpha, 0.3f);
|
||||
Drawable[] layers = {new ColorDrawable(UiUtilities.getColorWithAlpha(colorNoAlpha, 0.10f)), backgroundIcon};
|
||||
|
||||
items.add(new TitleItem(getString(R.string.export_profile)));
|
||||
|
||||
BaseBottomSheetItem profileItem = new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setChecked(true)
|
||||
.setCompoundButtonColorId(profileColor)
|
||||
.setButtonTintList(ColorStateList.valueOf(getResolvedColor(profileColor)))
|
||||
.setDescription(BaseSettingsFragment.getAppModeDescription(context, profile))
|
||||
.setIcon(getIcon(profile.getIconRes(), profileColor))
|
||||
.setTitle(profile.toHumanString())
|
||||
.setBackground(new LayerDrawable(layers))
|
||||
.setLayoutId(R.layout.preference_profile_item_with_radio_btn)
|
||||
.create();
|
||||
items.add(profileItem);
|
||||
BaseBottomSheetItem profileItem = new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setChecked(true)
|
||||
.setCompoundButtonColorId(profileColor)
|
||||
.setButtonTintList(ColorStateList.valueOf(getResolvedColor(profileColor)))
|
||||
.setDescription(BaseSettingsFragment.getAppModeDescription(context, profile))
|
||||
.setIcon(getIcon(profile.getIconRes(), profileColor))
|
||||
.setTitle(profile.toHumanString())
|
||||
.setBackground(new LayerDrawable(layers))
|
||||
.setLayoutId(R.layout.preference_profile_item_with_radio_btn)
|
||||
.create();
|
||||
items.add(profileItem);
|
||||
}
|
||||
setupAdditionalItems();
|
||||
}
|
||||
|
||||
private void setupAdditionalItems() {
|
||||
if (!dataList.isEmpty()) {
|
||||
final View additionalDataView = inflater.inflate(R.layout.bottom_sheet_item_additional_data, null);
|
||||
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
|
||||
View additionalDataView = inflater.inflate(R.layout.bottom_sheet_item_additional_data, null);
|
||||
ExpandableListView listView = additionalDataView.findViewById(R.id.list);
|
||||
adapter = new ExportImportSettingsAdapter(app, nightMode, false);
|
||||
|
||||
View listHeader = inflater.inflate(R.layout.item_header_export_expand_list, null);
|
||||
final View topSwitchDivider = listHeader.findViewById(R.id.topSwitchDivider);
|
||||
final View bottomSwitchDivider = listHeader.findViewById(R.id.bottomSwitchDivider);
|
||||
|
@ -130,7 +169,7 @@ public class ExportProfileBottomSheet extends BasePreferenceBottomSheet {
|
|||
topSwitchDivider.setVisibility(includeAdditionalData ? View.VISIBLE : View.GONE);
|
||||
bottomSwitchDivider.setVisibility(includeAdditionalData ? View.VISIBLE : View.GONE);
|
||||
if (includeAdditionalData) {
|
||||
adapter.updateSettingsList(app.getSettingsHelper().getAdditionalData());
|
||||
adapter.updateSettingsList(app.getSettingsHelper().getAdditionalData(globalExport));
|
||||
adapter.selectAll(true);
|
||||
} else {
|
||||
adapter.selectAll(false);
|
||||
|
@ -207,9 +246,18 @@ public class ExportProfileBottomSheet extends BasePreferenceBottomSheet {
|
|||
}
|
||||
}
|
||||
|
||||
private void setGlobalExport(boolean globalExport) {
|
||||
this.globalExport = globalExport;
|
||||
}
|
||||
|
||||
private List<SettingsItem> prepareSettingsItemsForExport() {
|
||||
List<SettingsItem> settingsItems = new ArrayList<>();
|
||||
settingsItems.add(new ProfileSettingsItem(app, profile));
|
||||
if (!globalExport) {
|
||||
settingsItems.add(new ProfileSettingsItem(app, getAppMode()));
|
||||
}
|
||||
if (includeGlobalSettings) {
|
||||
settingsItems.add(new GlobalSettingsItem(app.getSettings()));
|
||||
}
|
||||
if (includeAdditionalData) {
|
||||
settingsItems.addAll(app.getSettingsHelper().prepareAdditionalSettingsItems(adapter.getData()));
|
||||
}
|
||||
|
@ -219,13 +267,25 @@ public class ExportProfileBottomSheet extends BasePreferenceBottomSheet {
|
|||
private void prepareFile() {
|
||||
if (app != null) {
|
||||
exportingProfile = true;
|
||||
exportStartTime = System.currentTimeMillis();
|
||||
showExportProgressDialog();
|
||||
File tempDir = FileUtils.getTempDir(app);
|
||||
String fileName = profile.toHumanString();
|
||||
String fileName = getFileName();
|
||||
app.getSettingsHelper().exportSettings(tempDir, fileName, getSettingsExportListener(), prepareSettingsItemsForExport(), true);
|
||||
}
|
||||
}
|
||||
|
||||
private String getFileName() {
|
||||
if (globalExport) {
|
||||
if (exportStartTime == 0) {
|
||||
exportStartTime = System.currentTimeMillis();
|
||||
}
|
||||
return "Export_" + DATE_FORMAT.format(new Date(exportStartTime));
|
||||
} else {
|
||||
return getAppMode().toHumanString();
|
||||
}
|
||||
}
|
||||
|
||||
private void showExportProgressDialog() {
|
||||
Context context = getContext();
|
||||
if (context == null) {
|
||||
|
@ -241,16 +301,16 @@ public class ExportProfileBottomSheet extends BasePreferenceBottomSheet {
|
|||
progress.show();
|
||||
}
|
||||
|
||||
private SettingsHelper.SettingsExportListener getSettingsExportListener() {
|
||||
private SettingsExportListener getSettingsExportListener() {
|
||||
if (exportListener == null) {
|
||||
exportListener = new SettingsHelper.SettingsExportListener() {
|
||||
exportListener = new SettingsExportListener() {
|
||||
|
||||
@Override
|
||||
public void onSettingsExportFinished(@NonNull File file, boolean succeed) {
|
||||
dismissExportProgressDialog();
|
||||
exportingProfile = false;
|
||||
if (succeed) {
|
||||
shareProfile(file, profile);
|
||||
shareProfile(file);
|
||||
} else {
|
||||
app.showToastMessage(R.string.export_profile_failed);
|
||||
}
|
||||
|
@ -269,7 +329,7 @@ public class ExportProfileBottomSheet extends BasePreferenceBottomSheet {
|
|||
app.getSettingsHelper().updateExportListener(file, getSettingsExportListener());
|
||||
} else if (file.exists()) {
|
||||
dismissExportProgressDialog();
|
||||
shareProfile(file, profile);
|
||||
shareProfile(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -283,15 +343,15 @@ public class ExportProfileBottomSheet extends BasePreferenceBottomSheet {
|
|||
|
||||
private File getExportFile() {
|
||||
File tempDir = FileUtils.getTempDir(app);
|
||||
String fileName = profile.toHumanString();
|
||||
String fileName = getFileName();
|
||||
return new File(tempDir, fileName + IndexConstants.OSMAND_SETTINGS_FILE_EXT);
|
||||
}
|
||||
|
||||
private void shareProfile(@NonNull File file, @NonNull ApplicationMode profile) {
|
||||
private void shareProfile(@NonNull File file) {
|
||||
try {
|
||||
final Intent sendIntent = new Intent();
|
||||
sendIntent.setAction(Intent.ACTION_SEND);
|
||||
sendIntent.putExtra(Intent.EXTRA_SUBJECT, profile.toHumanString() + IndexConstants.OSMAND_SETTINGS_FILE_EXT);
|
||||
sendIntent.putExtra(Intent.EXTRA_SUBJECT, file.getName());
|
||||
sendIntent.putExtra(Intent.EXTRA_STREAM, AndroidUtils.getUriForFile(getMyApplication(), file));
|
||||
sendIntent.setType("*/*");
|
||||
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
|
@ -304,11 +364,12 @@ public class ExportProfileBottomSheet extends BasePreferenceBottomSheet {
|
|||
}
|
||||
|
||||
public static boolean showInstance(@NonNull FragmentManager fragmentManager,
|
||||
Fragment target,
|
||||
@NonNull ApplicationMode appMode) {
|
||||
Fragment target, @NonNull ApplicationMode appMode,
|
||||
boolean globalExport) {
|
||||
try {
|
||||
ExportProfileBottomSheet fragment = new ExportProfileBottomSheet();
|
||||
fragment.setAppMode(appMode);
|
||||
fragment.setGlobalExport(globalExport);
|
||||
fragment.setTargetFragment(target, 0);
|
||||
fragment.show(fragmentManager, TAG);
|
||||
return true;
|
||||
|
|
|
@ -7,13 +7,12 @@ import android.widget.ImageView;
|
|||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
import androidx.preference.SwitchPreferenceCompat;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.SettingsGeneralActivity;
|
||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||
import net.osmand.plus.dialogs.SendAnalyticsBottomSheetDialogFragment;
|
||||
import net.osmand.plus.dialogs.SendAnalyticsBottomSheetDialogFragment.OnSendAnalyticsPrefsUpdate;
|
||||
import net.osmand.plus.dialogs.SpeedCamerasBottomSheet;
|
||||
|
@ -156,7 +155,7 @@ public class GlobalSettingsFragment extends BaseSettingsFragment
|
|||
preferredLocale.setIcon(getActiveIcon(R.drawable.ic_action_map_language));
|
||||
preferredLocale.setSummary(settings.PREFERRED_LOCALE.get());
|
||||
|
||||
Pair<String[], String[]> preferredLocaleInfo = SettingsGeneralActivity.getPreferredLocaleIdsAndValues(ctx);
|
||||
Pair<String[], String[]> preferredLocaleInfo = getPreferredLocaleIdsAndValues(ctx);
|
||||
if (preferredLocaleInfo != null) {
|
||||
preferredLocale.setEntries(preferredLocaleInfo.first);
|
||||
preferredLocale.setEntryValues(preferredLocaleInfo.second);
|
||||
|
@ -219,4 +218,147 @@ public class GlobalSettingsFragment extends BaseSettingsFragment
|
|||
}
|
||||
uninstallSpeedCameras.setTitle(uninstalled ? R.string.speed_cameras_removed_descr : R.string.uninstall_speed_cameras);
|
||||
}
|
||||
|
||||
public static Pair<String[], String[]> getPreferredLocaleIdsAndValues(Context ctx) {
|
||||
// See language list and statistics at: https://hosted.weblate.org/projects/osmand/main/
|
||||
// Hardy maintenance 2016-05-29:
|
||||
// - Include languages if their translation is >= ~10% (but any language will be visible if it is the device's system locale)
|
||||
// - Mark as "incomplete" if < ~80%
|
||||
String incompleteSuffix = " (" + ctx.getString(R.string.incomplete_locale) + ")";
|
||||
|
||||
// Add " (Device language)" to system default entry in Latin letters, so it can be more easily identified if a foreign language has been selected by mistake
|
||||
String latinSystemDefaultSuffix = " (" + ctx.getString(R.string.system_locale_no_translate) + ")";
|
||||
|
||||
//getResources().getAssets().getLocales();
|
||||
String[] entryValues = new String[] {
|
||||
"",
|
||||
"en",
|
||||
"af",
|
||||
"ar",
|
||||
"ast",
|
||||
"az",
|
||||
"be",
|
||||
//"be_BY",
|
||||
"bg",
|
||||
"ca",
|
||||
"cs",
|
||||
"cy",
|
||||
"da",
|
||||
"de",
|
||||
"el",
|
||||
"en_GB",
|
||||
"eo",
|
||||
"es",
|
||||
"es_AR",
|
||||
"es_US",
|
||||
"eu",
|
||||
"fa",
|
||||
"fi",
|
||||
"fr",
|
||||
"gl",
|
||||
"iw",
|
||||
"hr",
|
||||
"hsb",
|
||||
"hu",
|
||||
"hy",
|
||||
"is",
|
||||
"it",
|
||||
"ja",
|
||||
"ka",
|
||||
"kab",
|
||||
"kn",
|
||||
"ko",
|
||||
"lt",
|
||||
"lv",
|
||||
"ml",
|
||||
"mr",
|
||||
"nb",
|
||||
"nl",
|
||||
"nn",
|
||||
"oc",
|
||||
"pl",
|
||||
"pt",
|
||||
"pt_BR",
|
||||
"ro",
|
||||
"ru",
|
||||
"sc",
|
||||
"sk",
|
||||
"sl",
|
||||
"sr",
|
||||
"sr+Latn",
|
||||
"sv",
|
||||
"tr",
|
||||
"uk",
|
||||
"vi",
|
||||
"zh_CN",
|
||||
"zh_TW"};
|
||||
|
||||
String[] entries = new String[] {
|
||||
ctx.getString(R.string.system_locale) + latinSystemDefaultSuffix,
|
||||
ctx.getString(R.string.lang_en),
|
||||
ctx.getString(R.string.lang_af) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_ar),
|
||||
ctx.getString(R.string.lang_ast) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_az),
|
||||
ctx.getString(R.string.lang_be),
|
||||
// getString(R.string.lang_be_by),
|
||||
ctx.getString(R.string.lang_bg),
|
||||
ctx.getString(R.string.lang_ca),
|
||||
ctx.getString(R.string.lang_cs),
|
||||
ctx.getString(R.string.lang_cy) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_da),
|
||||
ctx.getString(R.string.lang_de),
|
||||
ctx.getString(R.string.lang_el),
|
||||
ctx.getString(R.string.lang_en_gb),
|
||||
ctx.getString(R.string.lang_eo),
|
||||
ctx.getString(R.string.lang_es),
|
||||
ctx.getString(R.string.lang_es_ar),
|
||||
ctx.getString(R.string.lang_es_us),
|
||||
ctx.getString(R.string.lang_eu),
|
||||
ctx.getString(R.string.lang_fa),
|
||||
ctx.getString(R.string.lang_fi) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_fr),
|
||||
ctx.getString(R.string.lang_gl),
|
||||
ctx.getString(R.string.lang_he),
|
||||
ctx.getString(R.string.lang_hr) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_hsb) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_hu),
|
||||
ctx.getString(R.string.lang_hy),
|
||||
ctx.getString(R.string.lang_is),
|
||||
ctx.getString(R.string.lang_it),
|
||||
ctx.getString(R.string.lang_ja),
|
||||
ctx.getString(R.string.lang_ka) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_kab) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_kn) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_ko),
|
||||
ctx.getString(R.string.lang_lt),
|
||||
ctx.getString(R.string.lang_lv),
|
||||
ctx.getString(R.string.lang_ml),
|
||||
ctx.getString(R.string.lang_mr) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_nb),
|
||||
ctx.getString(R.string.lang_nl),
|
||||
ctx.getString(R.string.lang_nn) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_oc) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_pl),
|
||||
ctx.getString(R.string.lang_pt),
|
||||
ctx.getString(R.string.lang_pt_br),
|
||||
ctx.getString(R.string.lang_ro) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_ru),
|
||||
ctx.getString(R.string.lang_sc),
|
||||
ctx.getString(R.string.lang_sk),
|
||||
ctx.getString(R.string.lang_sl),
|
||||
ctx.getString(R.string.lang_sr),
|
||||
ctx.getString(R.string.lang_sr_latn) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_sv),
|
||||
ctx.getString(R.string.lang_tr),
|
||||
ctx.getString(R.string.lang_uk),
|
||||
ctx.getString(R.string.lang_vi) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_zh_cn) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_zh_tw)};
|
||||
|
||||
String[] valuesPl = ConfigureMapMenu.getSortedMapNamesIds(ctx, entries, entries);
|
||||
String[] idsPl = ConfigureMapMenu.getSortedMapNamesIds(ctx, entryValues, entries);
|
||||
|
||||
return Pair.create(valuesPl, idsPl);
|
||||
}
|
||||
}
|
|
@ -15,16 +15,16 @@ import androidx.preference.PreferenceViewHolder;
|
|||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.settings.backend.backup.SettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.SettingsItemType;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment;
|
||||
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SelectProfileListener;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.settings.backend.backup.SettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.SettingsItemType;
|
||||
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -48,6 +48,7 @@ public class MainSettingsFragment extends BaseSettingsFragment {
|
|||
private static final String CREATE_PROFILE = "create_profile";
|
||||
private static final String IMPORT_PROFILE = "import_profile";
|
||||
private static final String REORDER_PROFILES = "reorder_profiles";
|
||||
private static final String EXPORT_PROFILES = "export_profiles";
|
||||
|
||||
private List<ApplicationMode> allAppModes;
|
||||
private Set<ApplicationMode> availableAppModes;
|
||||
|
@ -147,6 +148,13 @@ public class MainSettingsFragment extends BaseSettingsFragment {
|
|||
|
||||
});
|
||||
}
|
||||
} else if (EXPORT_PROFILES.equals(prefId)) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
ApplicationMode mode = getSelectedAppMode();
|
||||
FragmentManager fragmentManager = mapActivity.getSupportFragmentManager();
|
||||
ExportProfileBottomSheet.showInstance(fragmentManager, this, mode, true);
|
||||
}
|
||||
}
|
||||
return super.onPreferenceClick(preference);
|
||||
}
|
||||
|
@ -162,17 +170,20 @@ public class MainSettingsFragment extends BaseSettingsFragment {
|
|||
}
|
||||
|
||||
private void profileManagementPref() {
|
||||
int activeColorPrimaryResId = isNightMode() ? R.color.active_color_primary_dark
|
||||
int activeColorPrimaryResId = isNightMode() ? R.color.active_color_primary_dark
|
||||
: R.color.active_color_primary_light;
|
||||
|
||||
|
||||
Preference createProfile = findPreference(CREATE_PROFILE);
|
||||
createProfile.setIcon(app.getUIUtilities().getIcon(R.drawable.ic_action_plus, activeColorPrimaryResId));
|
||||
|
||||
|
||||
Preference importProfile = findPreference(IMPORT_PROFILE);
|
||||
importProfile.setIcon(app.getUIUtilities().getIcon(R.drawable.ic_action_import, activeColorPrimaryResId));
|
||||
|
||||
|
||||
Preference reorderProfiles = findPreference(REORDER_PROFILES);
|
||||
reorderProfiles.setIcon(app.getUIUtilities().getIcon(R.drawable.ic_action_edit_dark, activeColorPrimaryResId));
|
||||
|
||||
Preference exportProfiles = findPreference(EXPORT_PROFILES);
|
||||
exportProfiles.setIcon(app.getUIUtilities().getIcon(R.drawable.ic_action_export, activeColorPrimaryResId));
|
||||
}
|
||||
|
||||
private void setupAppProfiles(PreferenceCategory preferenceCategory) {
|
||||
|
|
|
@ -16,12 +16,16 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.settings.preferences.EditTextPreferenceEx;
|
||||
|
||||
import static net.osmand.plus.activities.SettingsGeneralActivity.IP_ADDRESS_PATTERN;
|
||||
|
||||
public class ProxySettingsFragment extends BaseSettingsFragment {
|
||||
|
||||
public static final String TAG = ProxySettingsFragment.class.getSimpleName();
|
||||
|
||||
private static final String IP_ADDRESS_PATTERN =
|
||||
"^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
|
||||
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
|
||||
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
|
||||
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])$";
|
||||
|
||||
@Override
|
||||
protected void setupPreferences() {
|
||||
Preference mapDuringNavigationInfo = findPreference("proxy_preferences_info");
|
||||
|
|
|
@ -24,20 +24,20 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
|
||||
import com.google.android.material.slider.Slider;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.StateChangedListener;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||
import net.osmand.plus.activities.SettingsNavigationActivity;
|
||||
import net.osmand.plus.routing.RouteProvider;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.settings.backend.BooleanPreference;
|
||||
import net.osmand.plus.settings.backend.CommonPreference;
|
||||
import net.osmand.plus.settings.backend.OsmandPreference;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.settings.bottomsheets.RecalculateRouteInDeviationBottomSheet;
|
||||
import net.osmand.plus.settings.preferences.ListPreferenceEx;
|
||||
import net.osmand.plus.settings.preferences.MultiSelectBooleanPreference;
|
||||
|
@ -65,8 +65,8 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
|||
private static final String ROUTE_PARAMETERS_IMAGE = "route_parameters_image";
|
||||
private static final String RELIEF_SMOOTHNESS_FACTOR = "relief_smoothness_factor";
|
||||
private static final String ROUTING_SHORT_WAY = "prouting_short_way";
|
||||
private static final String ROUTING_RECALC_DISTANCE= "routing_recalc_distance";
|
||||
private static final String ROUTING_RECALC_WRONG_DIRECTION= "disable_wrong_direction_recalc";
|
||||
private static final String ROUTING_RECALC_DISTANCE = "routing_recalc_distance";
|
||||
private static final String ROUTING_RECALC_WRONG_DIRECTION = "disable_wrong_direction_recalc";
|
||||
|
||||
public static final float DISABLE_MODE = -1.0f;
|
||||
public static final float DEFAULT_MODE = 0.0f;
|
||||
|
@ -158,7 +158,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
|||
|
||||
private void setupOsmLiveForPublicTransportPref() {
|
||||
SwitchPreferenceEx useOsmLiveForPublicTransport = createSwitchPreferenceEx(settings.USE_OSM_LIVE_FOR_PUBLIC_TRANSPORT.getId(),
|
||||
R.string.use_live_public_transport, R.layout.preference_with_descr_dialog_and_switch);
|
||||
R.string.use_live_public_transport, R.layout.preference_with_descr_dialog_and_switch);
|
||||
useOsmLiveForPublicTransport.setDescription(getString(R.string.use_osm_live_public_transport_description));
|
||||
useOsmLiveForPublicTransport.setSummaryOn(R.string.shared_string_enabled);
|
||||
useOsmLiveForPublicTransport.setSummaryOff(R.string.shared_string_disabled);
|
||||
|
@ -282,8 +282,8 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
|||
screen.addPreference(reliefFactorRouting);
|
||||
}
|
||||
for (RoutingParameter p : otherRoutingParameters) {
|
||||
String title = SettingsBaseActivity.getRoutingStringPropertyName(app, p.getId(), p.getName());
|
||||
String description = SettingsBaseActivity.getRoutingStringPropertyDescription(app, p.getId(), p.getDescription());
|
||||
String title = AndroidUtils.getRoutingStringPropertyName(app, p.getId(), p.getName());
|
||||
String description = AndroidUtils.getRoutingStringPropertyDescription(app, p.getId(), p.getDescription());
|
||||
|
||||
if (p.getType() == RoutingParameterType.BOOLEAN) {
|
||||
OsmandPreference pref = settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean());
|
||||
|
@ -426,9 +426,9 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
|||
}
|
||||
|
||||
private static void setupAngleSlider(final float[] angleValue,
|
||||
View sliderView,
|
||||
final boolean nightMode,
|
||||
final int activeColor) {
|
||||
View sliderView,
|
||||
final boolean nightMode,
|
||||
final int activeColor) {
|
||||
|
||||
final Slider angleBar = sliderView.findViewById(R.id.angle_slider);
|
||||
final TextView angleTv = sliderView.findViewById(R.id.angle_text);
|
||||
|
@ -536,7 +536,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
|||
List<RoutingParameter> routingParameters = DRIVING_STYLE.equals(prefId) ? drivingStyleParameters : reliefFactorParameters;
|
||||
for (RoutingParameter p : routingParameters) {
|
||||
String parameterId = p.getId();
|
||||
SettingsNavigationActivity.setRoutingParameterSelected(settings, appMode, parameterId, p.getDefaultBoolean(), parameterId.equals(selectedParameterId));
|
||||
setRoutingParameterSelected(settings, appMode, parameterId, p.getDefaultBoolean(), parameterId.equals(selectedParameterId));
|
||||
}
|
||||
recalculateRoute();
|
||||
} else if (ROUTING_SHORT_WAY.equals(prefId) && newValue instanceof Boolean) {
|
||||
|
@ -571,7 +571,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
|||
|
||||
private ListPreferenceEx createRoutingBooleanListPreference(String groupKey, List<RoutingParameter> routingParameters) {
|
||||
String defaultTitle = Algorithms.capitalizeFirstLetterAndLowercase(groupKey.replace('_', ' '));
|
||||
String title = SettingsBaseActivity.getRoutingStringPropertyName(app, groupKey, defaultTitle);
|
||||
String title = AndroidUtils.getRoutingStringPropertyName(app, groupKey, defaultTitle);
|
||||
ApplicationMode am = getSelectedAppMode();
|
||||
|
||||
Object[] entryValues = new Object[routingParameters.size()];
|
||||
|
@ -581,8 +581,8 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
|||
for (int i = 0; i < routingParameters.size(); i++) {
|
||||
RoutingParameter parameter = routingParameters.get(i);
|
||||
entryValues[i] = parameter.getId();
|
||||
entries[i] = SettingsNavigationActivity.getRoutinParameterTitle(app, parameter);
|
||||
if (SettingsNavigationActivity.isRoutingParameterSelected(settings, am, parameter)) {
|
||||
entries[i] = getRoutingParameterTitle(app, parameter);
|
||||
if (isRoutingParameterSelected(settings, am, parameter)) {
|
||||
selectedParameterId = parameter.getId();
|
||||
}
|
||||
}
|
||||
|
@ -614,7 +614,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
|||
RoutingParameter p = routingParameters.get(i);
|
||||
BooleanPreference booleanRoutingPref = (BooleanPreference) settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean());
|
||||
|
||||
entries[i] = SettingsBaseActivity.getRoutingStringPropertyName(app, p.getId(), p.getName());
|
||||
entries[i] = AndroidUtils.getRoutingStringPropertyName(app, p.getId(), p.getName());
|
||||
prefsIds[i] = booleanRoutingPref.getId();
|
||||
|
||||
if (booleanRoutingPref.getModeValue(selectedMode)) {
|
||||
|
@ -645,6 +645,29 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
|||
otherRoutingParameters.clear();
|
||||
}
|
||||
|
||||
private String getRoutingParameterTitle(Context context, RoutingParameter parameter) {
|
||||
return AndroidUtils.getRoutingStringPropertyName(context, parameter.getId(), parameter.getName());
|
||||
}
|
||||
|
||||
private boolean isRoutingParameterSelected(OsmandSettings settings, ApplicationMode mode, RoutingParameter parameter) {
|
||||
CommonPreference<Boolean> property = settings.getCustomRoutingBooleanProperty(parameter.getId(), parameter.getDefaultBoolean());
|
||||
if (mode != null) {
|
||||
return property.getModeValue(mode);
|
||||
} else {
|
||||
return property.get();
|
||||
}
|
||||
}
|
||||
|
||||
private void setRoutingParameterSelected(OsmandSettings settings, ApplicationMode mode,
|
||||
String parameterId, boolean defaultBoolean, boolean isChecked) {
|
||||
CommonPreference<Boolean> property = settings.getCustomRoutingBooleanProperty(parameterId, defaultBoolean);
|
||||
if (mode != null) {
|
||||
property.setModeValue(mode, isChecked);
|
||||
} else {
|
||||
property.set(isChecked);
|
||||
}
|
||||
}
|
||||
|
||||
private Drawable getRoutingPrefIcon(String prefId) {
|
||||
switch (prefId) {
|
||||
case GeneralRouter.ALLOW_PRIVATE:
|
||||
|
|
|
@ -1,16 +1,30 @@
|
|||
package net.osmand.plus.settings.fragments;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.google.android.material.slider.Slider;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.helpers.enums.SpeedConstants;
|
||||
import net.osmand.plus.routing.RouteProvider.RouteService;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
|
@ -20,13 +34,18 @@ import net.osmand.plus.settings.bottomsheets.VehicleSizeAssets;
|
|||
import net.osmand.plus.settings.preferences.ListPreferenceEx;
|
||||
import net.osmand.plus.settings.preferences.SizePreference;
|
||||
import net.osmand.router.GeneralRouter;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.router.GeneralRouter.GeneralRouterProfile;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static net.osmand.plus.activities.SettingsNavigationActivity.showSeekbarSettingsDialog;
|
||||
import static net.osmand.router.GeneralRouter.*;
|
||||
import static net.osmand.router.GeneralRouter.DEFAULT_SPEED;
|
||||
import static net.osmand.router.GeneralRouter.RoutingParameter;
|
||||
import static net.osmand.router.GeneralRouter.RoutingParameterType;
|
||||
import static net.osmand.router.GeneralRouter.VEHICLE_HEIGHT;
|
||||
import static net.osmand.router.GeneralRouter.VEHICLE_LENGTH;
|
||||
import static net.osmand.router.GeneralRouter.VEHICLE_WEIGHT;
|
||||
import static net.osmand.router.GeneralRouter.VEHICLE_WIDTH;
|
||||
|
||||
public class VehicleParametersFragment extends BaseSettingsFragment implements OnPreferenceChanged {
|
||||
|
||||
|
@ -62,13 +81,13 @@ public class VehicleParametersFragment extends BaseSettingsFragment implements O
|
|||
}
|
||||
|
||||
private void setupCustomRoutingPropertyPref(@Nullable RoutingParameter parameter,
|
||||
GeneralRouterProfile routerProfile) {
|
||||
GeneralRouterProfile routerProfile) {
|
||||
if (parameter == null) {
|
||||
return;
|
||||
}
|
||||
String parameterId = parameter.getId();
|
||||
String title = SettingsBaseActivity.getRoutingStringPropertyName(app, parameterId, parameter.getName());
|
||||
String description = SettingsBaseActivity.getRoutingStringPropertyDescription(app, parameterId,
|
||||
String title = AndroidUtils.getRoutingStringPropertyName(app, parameterId, parameter.getName());
|
||||
String description = AndroidUtils.getRoutingStringPropertyDescription(app, parameterId,
|
||||
parameter.getDescription());
|
||||
String defValue = parameter.getType() == RoutingParameterType.NUMERIC
|
||||
? ROUTING_PARAMETER_NUMERIC_DEFAULT : ROUTING_PARAMETER_SYMBOLIC_DEFAULT;
|
||||
|
@ -146,7 +165,10 @@ public class VehicleParametersFragment extends BaseSettingsFragment implements O
|
|||
if (preference.getKey().equals(DEFAULT_SPEED)) {
|
||||
RouteService routeService = getSelectedAppMode().getRouteService();
|
||||
boolean defaultSpeedOnly = routeService == RouteService.STRAIGHT || routeService == RouteService.DIRECT_TO;
|
||||
showSeekbarSettingsDialog(getActivity(), defaultSpeedOnly, getSelectedAppMode());
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity != null) {
|
||||
showSeekbarSettingsDialog(activity, defaultSpeedOnly);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return super.onPreferenceClick(preference);
|
||||
|
@ -178,6 +200,199 @@ public class VehicleParametersFragment extends BaseSettingsFragment implements O
|
|||
}
|
||||
}
|
||||
|
||||
private void showSeekbarSettingsDialog(@NonNull Activity activity, final boolean defaultSpeedOnly) {
|
||||
final ApplicationMode mode = getSelectedAppMode();
|
||||
|
||||
SpeedConstants units = app.getSettings().SPEED_SYSTEM.getModeValue(mode);
|
||||
String speedUnits = units.toShortString(activity);
|
||||
final float[] ratio = new float[1];
|
||||
switch (units) {
|
||||
case MILES_PER_HOUR:
|
||||
ratio[0] = 3600 / OsmAndFormatter.METERS_IN_ONE_MILE;
|
||||
break;
|
||||
case KILOMETERS_PER_HOUR:
|
||||
ratio[0] = 3600 / OsmAndFormatter.METERS_IN_KILOMETER;
|
||||
break;
|
||||
case MINUTES_PER_KILOMETER:
|
||||
ratio[0] = 3600 / OsmAndFormatter.METERS_IN_KILOMETER;
|
||||
speedUnits = activity.getString(R.string.km_h);
|
||||
break;
|
||||
case NAUTICALMILES_PER_HOUR:
|
||||
ratio[0] = 3600 / OsmAndFormatter.METERS_IN_ONE_NAUTICALMILE;
|
||||
break;
|
||||
case MINUTES_PER_MILE:
|
||||
ratio[0] = 3600 / OsmAndFormatter.METERS_IN_ONE_MILE;
|
||||
speedUnits = activity.getString(R.string.mile_per_hour);
|
||||
break;
|
||||
case METERS_PER_SECOND:
|
||||
ratio[0] = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
float settingsMinSpeed = mode.getMinSpeed();
|
||||
float settingsMaxSpeed = mode.getMaxSpeed();
|
||||
float settingsDefaultSpeed = mode.getDefaultSpeed();
|
||||
|
||||
final int[] defaultValue = {Math.round(settingsDefaultSpeed * ratio[0])};
|
||||
final int[] minValue = new int[1];
|
||||
final int[] maxValue = new int[1];
|
||||
final int min;
|
||||
final int max;
|
||||
|
||||
GeneralRouter router = app.getRouter(mode);
|
||||
if (defaultSpeedOnly || router == null) {
|
||||
minValue[0] = Math.round(Math.min(1, settingsDefaultSpeed) * ratio[0]);
|
||||
maxValue[0] = Math.round(Math.max(300, settingsDefaultSpeed) * ratio[0]);
|
||||
min = minValue[0];
|
||||
max = maxValue[0];
|
||||
} else {
|
||||
float minSpeedValue = settingsMinSpeed > 0 ? settingsMinSpeed : router.getMinSpeed();
|
||||
float maxSpeedValue = settingsMaxSpeed > 0 ? settingsMaxSpeed : router.getMaxSpeed();
|
||||
minValue[0] = Math.round(Math.min(minSpeedValue, settingsDefaultSpeed) * ratio[0]);
|
||||
maxValue[0] = Math.round(Math.max(maxSpeedValue, settingsDefaultSpeed) * ratio[0]);
|
||||
|
||||
min = Math.round(Math.min(minValue[0], router.getMinSpeed() * ratio[0] / 2f));
|
||||
max = Math.round(Math.max(maxValue[0], router.getMaxSpeed() * ratio[0] * 1.5f));
|
||||
}
|
||||
|
||||
boolean nightMode = !app.getSettings().isLightContentForMode(mode);
|
||||
Context themedContext = UiUtilities.getThemedContext(activity, nightMode);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(themedContext);
|
||||
View seekbarView = LayoutInflater.from(themedContext).inflate(R.layout.default_speed_dialog, null, false);
|
||||
builder.setView(seekbarView);
|
||||
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
mode.setDefaultSpeed(defaultValue[0] / ratio[0]);
|
||||
if (!defaultSpeedOnly) {
|
||||
mode.setMinSpeed(minValue[0] / ratio[0]);
|
||||
mode.setMaxSpeed(maxValue[0] / ratio[0]);
|
||||
}
|
||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
if (mode.equals(routingHelper.getAppMode()) && (routingHelper.isRouteCalculated() || routingHelper.isRouteBeingCalculated())) {
|
||||
routingHelper.recalculateRouteDueToSettingsChange();
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
builder.setNeutralButton(R.string.shared_string_revert, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
mode.resetDefaultSpeed();
|
||||
if (!defaultSpeedOnly) {
|
||||
mode.setMinSpeed(0f);
|
||||
mode.setMaxSpeed(0f);
|
||||
}
|
||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
if (mode.equals(routingHelper.getAppMode()) && (routingHelper.isRouteCalculated() || routingHelper.isRouteBeingCalculated())) {
|
||||
routingHelper.recalculateRouteDueToSettingsChange();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
int selectedModeColor = ContextCompat.getColor(app, mode.getIconColorInfo().getColor(nightMode));
|
||||
if (!defaultSpeedOnly) {
|
||||
setupSpeedSlider(SpeedSliderType.DEFAULT_SPEED, speedUnits, defaultValue, minValue, maxValue, min, max, seekbarView, selectedModeColor);
|
||||
setupSpeedSlider(SpeedSliderType.MIN_SPEED, speedUnits, defaultValue, minValue, maxValue, min, max, seekbarView, selectedModeColor);
|
||||
setupSpeedSlider(SpeedSliderType.MAX_SPEED, speedUnits, defaultValue, minValue, maxValue, min, max, seekbarView, selectedModeColor);
|
||||
} else {
|
||||
setupSpeedSlider(SpeedSliderType.DEFAULT_SPEED_ONLY, speedUnits, defaultValue, minValue, maxValue, min, max, seekbarView, selectedModeColor);
|
||||
seekbarView.findViewById(R.id.default_speed_div).setVisibility(View.GONE);
|
||||
seekbarView.findViewById(R.id.default_speed_container).setVisibility(View.GONE);
|
||||
seekbarView.findViewById(R.id.max_speed_div).setVisibility(View.GONE);
|
||||
seekbarView.findViewById(R.id.max_speed_container).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
builder.show();
|
||||
}
|
||||
|
||||
private enum SpeedSliderType {
|
||||
DEFAULT_SPEED_ONLY,
|
||||
DEFAULT_SPEED,
|
||||
MIN_SPEED,
|
||||
MAX_SPEED,
|
||||
}
|
||||
|
||||
private void setupSpeedSlider(final SpeedSliderType type, String speedUnits, final int[] defaultValue,
|
||||
final int[] minValue, final int[] maxValue, final int min, int max,
|
||||
View seekbarView, int activeColor) {
|
||||
View sliderLayout;
|
||||
int titleId;
|
||||
final int[] speedValue;
|
||||
switch (type) {
|
||||
case DEFAULT_SPEED_ONLY:
|
||||
speedValue = defaultValue;
|
||||
sliderLayout = seekbarView.findViewById(R.id.min_speed_layout);
|
||||
titleId = R.string.default_speed_setting_title;
|
||||
break;
|
||||
case MIN_SPEED:
|
||||
speedValue = minValue;
|
||||
sliderLayout = seekbarView.findViewById(R.id.min_speed_layout);
|
||||
titleId = R.string.shared_string_min_speed;
|
||||
break;
|
||||
case MAX_SPEED:
|
||||
speedValue = maxValue;
|
||||
sliderLayout = seekbarView.findViewById(R.id.max_speed_layout);
|
||||
titleId = R.string.shared_string_max_speed;
|
||||
break;
|
||||
default:
|
||||
speedValue = defaultValue;
|
||||
sliderLayout = seekbarView.findViewById(R.id.default_speed_layout);
|
||||
titleId = R.string.default_speed_setting_title;
|
||||
break;
|
||||
}
|
||||
final Slider slider = sliderLayout.findViewById(R.id.speed_slider);
|
||||
final TextView speedTitleTv = sliderLayout.findViewById(R.id.speed_title);
|
||||
final TextView speedMinTv = sliderLayout.findViewById(R.id.speed_seekbar_min_text);
|
||||
final TextView speedMaxTv = sliderLayout.findViewById(R.id.speed_seekbar_max_text);
|
||||
final TextView speedUnitsTv = sliderLayout.findViewById(R.id.speed_units);
|
||||
final TextView speedTv = sliderLayout.findViewById(R.id.speed_text);
|
||||
|
||||
speedTitleTv.setText(titleId);
|
||||
speedMinTv.setText(String.valueOf(min));
|
||||
speedMaxTv.setText(String.valueOf(max));
|
||||
speedTv.setText(String.valueOf(speedValue[0]));
|
||||
speedUnitsTv.setText(speedUnits);
|
||||
slider.setValueTo(max - min);
|
||||
slider.setValue(Math.max(speedValue[0] - min, 0));
|
||||
slider.addOnChangeListener(new Slider.OnChangeListener() {
|
||||
@Override
|
||||
public void onValueChange(@NonNull Slider slider, float val, boolean fromUser) {
|
||||
int progress = (int) val;
|
||||
int value = progress + min;
|
||||
switch (type) {
|
||||
case DEFAULT_SPEED:
|
||||
case DEFAULT_SPEED_ONLY:
|
||||
if (value > maxValue[0]) {
|
||||
value = maxValue[0];
|
||||
slider.setValue(Math.max(value - min, 0));
|
||||
} else if (value < minValue[0]) {
|
||||
value = minValue[0];
|
||||
slider.setValue(Math.max(value - min, 0));
|
||||
}
|
||||
break;
|
||||
case MIN_SPEED:
|
||||
if (value > defaultValue[0]) {
|
||||
value = defaultValue[0];
|
||||
slider.setValue(Math.max(value - min, 0));
|
||||
}
|
||||
break;
|
||||
case MAX_SPEED:
|
||||
if (value < defaultValue[0]) {
|
||||
value = defaultValue[0];
|
||||
slider.setValue(Math.max(value - min, 0));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
speedValue[0] = value;
|
||||
speedTv.setText(String.valueOf(value));
|
||||
}
|
||||
});
|
||||
UiUtilities.setupSlider(slider, isNightMode(), activeColor);
|
||||
}
|
||||
|
||||
private Drawable getPreferenceIcon(String prefId) {
|
||||
switch (prefId) {
|
||||
case DEFAULT_SPEED:
|
||||
|
|
|
@ -17,29 +17,30 @@ import androidx.preference.PreferenceViewHolder;
|
|||
import androidx.preference.SwitchPreferenceCompat;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.dialogs.SpeedCamerasBottomSheet;
|
||||
import net.osmand.plus.helpers.enums.MetricsConstants;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dialogs.SpeedCamerasBottomSheet;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.DownloadActivityType;
|
||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||
import net.osmand.plus.helpers.enums.MetricsConstants;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.settings.preferences.ListPreferenceEx;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static net.osmand.plus.settings.backend.OsmandSettings.VOICE_PROVIDER_NOT_USE;
|
||||
import static net.osmand.plus.UiUtilities.CompoundButtonType.TOOLBAR;
|
||||
import static net.osmand.plus.activities.SettingsNavigationActivity.MORE_VALUE;
|
||||
import static net.osmand.plus.settings.backend.OsmandSettings.VOICE_PROVIDER_NOT_USE;
|
||||
|
||||
public class VoiceAnnouncesFragment extends BaseSettingsFragment implements OnPreferenceChanged {
|
||||
|
||||
public static final String TAG = VoiceAnnouncesFragment.class.getSimpleName();
|
||||
|
||||
private static final String MORE_VALUE = "MORE_VALUE";
|
||||
|
||||
@Override
|
||||
protected void createToolbar(LayoutInflater inflater, View view) {
|
||||
super.createToolbar(inflater, view);
|
||||
|
@ -105,8 +106,8 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment implements OnPr
|
|||
|
||||
private void setupSpeedLimitExceedPref() {
|
||||
//array size must be equal!
|
||||
Float[] valuesKmh = new Float[]{-10f, -7f, -5f, 0f, 5f, 7f, 10f, 15f, 20f};
|
||||
Float[] valuesMph = new Float[]{-7f, -5f, -3f, 0f, 3f, 5f, 7f, 10f, 15f};
|
||||
Float[] valuesKmh = new Float[] {-10f, -7f, -5f, 0f, 5f, 7f, 10f, 15f, 20f};
|
||||
Float[] valuesMph = new Float[] {-7f, -5f, -3f, 0f, 3f, 5f, 7f, 10f, 15f};
|
||||
String[] names;
|
||||
if (settings.METRIC_SYSTEM.getModeValue(getSelectedAppMode()) == MetricsConstants.KILOMETERS_AND_METERS) {
|
||||
names = new String[valuesKmh.length];
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.srtmplugin;
|
|||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -11,7 +12,6 @@ import net.osmand.plus.settings.backend.CommonPreference;
|
|||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment;
|
||||
import net.osmand.plus.download.DownloadActivityType;
|
||||
import net.osmand.plus.download.DownloadIndexesThread;
|
||||
|
@ -66,7 +66,7 @@ public class ContourLinesMenu {
|
|||
final CommonPreference<String> densityPref;
|
||||
final RenderingRuleProperty contourWidthProp = app.getRendererRegistry().getCustomRenderingRuleProperty(CONTOUR_WIDTH_ATTR);
|
||||
if (contourWidthProp != null) {
|
||||
contourWidthName = SettingsActivity.getStringPropertyName(app, contourWidthProp.getAttrName(),
|
||||
contourWidthName = AndroidUtils.getRenderingStringPropertyName(app, contourWidthProp.getAttrName(),
|
||||
contourWidthProp.getName());
|
||||
widthPref = settings.getCustomRenderProperty(contourWidthProp.getAttrName());
|
||||
} else {
|
||||
|
@ -75,7 +75,7 @@ public class ContourLinesMenu {
|
|||
}
|
||||
final RenderingRuleProperty contourDensityProp = app.getRendererRegistry().getCustomRenderingRuleProperty(CONTOUR_DENSITY_ATTR);
|
||||
if (contourDensityProp != null) {
|
||||
contourDensityName = SettingsActivity.getStringPropertyName(app, contourDensityProp.getAttrName(),
|
||||
contourDensityName = AndroidUtils.getRenderingStringPropertyName(app, contourDensityProp.getAttrName(),
|
||||
contourDensityProp.getName());
|
||||
densityPref = settings.getCustomRenderProperty(contourDensityProp.getAttrName());
|
||||
} else {
|
||||
|
|
|
@ -24,7 +24,6 @@ import net.osmand.plus.settings.backend.OsmandSettings;
|
|||
import net.osmand.plus.settings.backend.CommonPreference;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||
import net.osmand.plus.download.DownloadActivityType;
|
||||
import net.osmand.plus.download.DownloadIndexesThread;
|
||||
|
@ -438,9 +437,9 @@ public class SRTMPlugin extends OsmandPlugin {
|
|||
|
||||
public String getPrefDescription(final Context ctx, final RenderingRuleProperty p, final CommonPreference<String> pref) {
|
||||
if (!Algorithms.isEmpty(pref.get())) {
|
||||
return SettingsActivity.getStringPropertyValue(ctx, pref.get());
|
||||
return AndroidUtils.getRenderingStringPropertyValue(ctx, pref.get());
|
||||
} else {
|
||||
return SettingsActivity.getStringPropertyValue(ctx, p.getDefaultValueDescription());
|
||||
return AndroidUtils.getRenderingStringPropertyValue(ctx, p.getDefaultValueDescription());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -448,7 +447,7 @@ public class SRTMPlugin extends OsmandPlugin {
|
|||
final RenderingRuleProperty p,
|
||||
final CommonPreference<String> pref,
|
||||
final Runnable callback) {
|
||||
final String propertyDescr = SettingsActivity.getStringPropertyDescription(activity,
|
||||
final String propertyDescr = AndroidUtils.getRenderingStringPropertyDescription(activity,
|
||||
p.getAttrName(), p.getName());
|
||||
boolean nightMode = isNightMode(activity, app);
|
||||
int themeRes = getThemeRes(activity, app);
|
||||
|
@ -467,11 +466,11 @@ public class SRTMPlugin extends OsmandPlugin {
|
|||
}
|
||||
|
||||
String[] possibleValuesString = new String[possibleValues.length + 1];
|
||||
possibleValuesString[0] = SettingsActivity.getStringPropertyValue(activity,
|
||||
possibleValuesString[0] = AndroidUtils.getRenderingStringPropertyValue(activity,
|
||||
p.getDefaultValueDescription());
|
||||
|
||||
for (int j = 0; j < possibleValues.length; j++) {
|
||||
possibleValuesString[j + 1] = SettingsActivity.getStringPropertyValue(activity,
|
||||
possibleValuesString[j + 1] = AndroidUtils.getRenderingStringPropertyValue(activity,
|
||||
possibleValues[j]);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import androidx.appcompat.app.AlertDialog;
|
|||
import androidx.appcompat.widget.SwitchCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -24,7 +25,6 @@ import net.osmand.plus.settings.backend.CommonPreference;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||
import net.osmand.render.RenderingRuleProperty;
|
||||
|
||||
|
@ -105,8 +105,7 @@ public class TransportLinesMenu {
|
|||
for (int i = 0; i < transportRules.size(); i++) {
|
||||
RenderingRuleProperty p = transportRules.get(i);
|
||||
String attrName = p.getAttrName();
|
||||
String propertyName = SettingsActivity
|
||||
.getStringPropertyName(themedCtx, attrName, p.getName());
|
||||
String propertyName = AndroidUtils.getRenderingStringPropertyName(themedCtx, attrName, p.getName());
|
||||
vals[i] = propertyName;
|
||||
Integer iconId = transportIcons.get(attrName);
|
||||
if (iconId != null) {
|
||||
|
|
|
@ -15,12 +15,11 @@ import android.widget.Toast;
|
|||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.settings.backend.OsmandPreference;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.plus.routing.VoiceRouter;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.settings.backend.OsmandPreference;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -215,16 +214,16 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
|
|||
speechAllowed = true;
|
||||
switch (mTts.isLanguageAvailable(newLocale)) {
|
||||
case TextToSpeech.LANG_MISSING_DATA:
|
||||
if (isSettingsActivity(act)) {
|
||||
AlertDialog.Builder builder = createAlertDialog(
|
||||
R.string.tts_missing_language_data_title,
|
||||
R.string.tts_missing_language_data,
|
||||
new IntentStarter(
|
||||
act,
|
||||
TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA),
|
||||
act);
|
||||
builder.show();
|
||||
}
|
||||
// if (isSettingsActivity(act)) {
|
||||
// AlertDialog.Builder builder = createAlertDialog(
|
||||
// R.string.tts_missing_language_data_title,
|
||||
// R.string.tts_missing_language_data,
|
||||
// new IntentStarter(
|
||||
// act,
|
||||
// TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA),
|
||||
// act);
|
||||
// builder.show();
|
||||
// }
|
||||
ttsVoiceStatus = newLocale.getDisplayName() + ": LANG_MISSING_DATA";
|
||||
ttsVoiceUsed = getVoiceUsed();
|
||||
break;
|
||||
|
@ -251,17 +250,17 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
|
|||
break;
|
||||
case TextToSpeech.LANG_NOT_SUPPORTED:
|
||||
//maybe weird, but I didn't want to introduce parameter in around 5 methods just to do this if condition
|
||||
if (isSettingsActivity(act)) {
|
||||
AlertDialog.Builder builder = createAlertDialog(
|
||||
R.string.tts_language_not_supported_title,
|
||||
R.string.tts_language_not_supported,
|
||||
new IntentStarter(
|
||||
act,
|
||||
Intent.ACTION_VIEW, Uri.parse("market://search?q=text to speech engine"
|
||||
)),
|
||||
act);
|
||||
builder.show();
|
||||
}
|
||||
// if (isSettingsActivity(act)) {
|
||||
// AlertDialog.Builder builder = createAlertDialog(
|
||||
// R.string.tts_language_not_supported_title,
|
||||
// R.string.tts_language_not_supported,
|
||||
// new IntentStarter(
|
||||
// act,
|
||||
// Intent.ACTION_VIEW, Uri.parse("market://search?q=text to speech engine"
|
||||
// )),
|
||||
// act);
|
||||
// builder.show();
|
||||
// }
|
||||
ttsVoiceStatus = newLocale.getDisplayName() + ": LANG_NOT_SUPPORTED";
|
||||
ttsVoiceUsed = getVoiceUsed();
|
||||
break;
|
||||
|
@ -269,10 +268,6 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isSettingsActivity(final Context ctx) {
|
||||
return ctx instanceof SettingsActivity;
|
||||
}
|
||||
|
||||
private String getVoiceUsed() {
|
||||
try {
|
||||
if (android.os.Build.VERSION.SDK_INT >= 21) {
|
||||
|
|
Loading…
Reference in a new issue