From 4812fa58f44df819c46a40cd0ff036fe71214026 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Thu, 28 Nov 2019 15:33:57 +0200 Subject: [PATCH 001/231] MainSettingsFragment new UI with profiles list --- OsmAnd/res/values/strings.xml | 2 + OsmAnd/res/xml/settings_main_screen.xml | 36 +++++-- .../plus/settings/MainSettingsFragment.java | 102 +++++++++++++----- 3 files changed, 105 insertions(+), 35 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 9010c03e24..2487d77655 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,8 @@ Thx - Hardy --> + Reorder + Selected profile Node networks Show node network cycle routes Join segments diff --git a/OsmAnd/res/xml/settings_main_screen.xml b/OsmAnd/res/xml/settings_main_screen.xml index 77fa3843d3..93739098bf 100644 --- a/OsmAnd/res/xml/settings_main_screen.xml +++ b/OsmAnd/res/xml/settings_main_screen.xml @@ -18,9 +18,9 @@ android:selectable="false" /> + android:title="@string/selected_profile" /> + + + + + android:title="@string/new_profile" + tools:icon="@drawable/ic_action_plus" /> + + + + allAppModes; + private Set availableAppModes; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + allAppModes = new ArrayList<>(ApplicationMode.allPossibleValues()); + allAppModes.remove(ApplicationMode.DEFAULT); + availableAppModes = new LinkedHashSet<>(ApplicationMode.values(getMyApplication())); + availableAppModes.remove(ApplicationMode.DEFAULT); + } @Override @ColorRes @@ -30,9 +53,13 @@ public class MainSettingsFragment extends BaseSettingsFragment { protected void setupPreferences() { Preference globalSettings = findPreference("global_settings"); globalSettings.setIcon(getContentIcon(R.drawable.ic_action_settings)); - + PreferenceCategory selectedProfile = (PreferenceCategory) findPreference(SELECTED_PROFILE); + selectedProfile.setIconSpaceReserved(false); setupConfigureProfilePref(); - setupManageProfilesPref(); + PreferenceCategory appProfiles = (PreferenceCategory) findPreference(APP_PROFILES); + appProfiles.setIconSpaceReserved(false); + setupAppProfiles(appProfiles); + profileManagementPref(); } @Override @@ -41,41 +68,60 @@ public class MainSettingsFragment extends BaseSettingsFragment { String key = preference.getKey(); if (CONFIGURE_PROFILE.equals(key)) { - View iconContainer = holder.itemView.findViewById(R.id.icon_container); - if (iconContainer != null) { - int profileColor = getActiveProfileColor(); - int bgColor = UiUtilities.getColorWithAlpha(profileColor, 0.1f); - Drawable backgroundDrawable; - - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) { - int selectedColor = UiUtilities.getColorWithAlpha(profileColor, 0.3f); - Drawable background = getPaintedIcon(R.drawable.circle_background_light, bgColor); - Drawable ripple = getPaintedIcon(R.drawable.ripple_circle, selectedColor); - backgroundDrawable = new LayerDrawable(new Drawable[] {background, ripple}); - } else { - backgroundDrawable = getPaintedIcon(R.drawable.circle_background_light, bgColor); - } - AndroidUtils.setBackground(iconContainer, backgroundDrawable); + View selectedProfile = holder.itemView.findViewById(R.id.selectable_list_item); + if (selectedProfile != null) { + int activeProfileColor = getActiveProfileColor(); + Drawable backgroundDrawable = new ColorDrawable(UiUtilities.getColorWithAlpha(activeProfileColor, 0.15f)); + AndroidUtils.setBackground(selectedProfile, backgroundDrawable); } } } - private void setupManageProfilesPref() { - Preference manageProfiles = findPreference("manage_profiles"); - manageProfiles.setIcon(getContentIcon(R.drawable.ic_action_manage_profiles)); - manageProfiles.setFragment(SettingsProfileFragment.class.getName()); - } - private void setupConfigureProfilePref() { ApplicationMode selectedMode = getSelectedAppMode(); - String title = selectedMode.toHumanString(getContext()); String profileType = getAppModeDescription(getContext(), selectedMode); int iconRes = selectedMode.getIconRes(); - Preference configureProfile = findPreference(CONFIGURE_PROFILE); configureProfile.setIcon(getPaintedIcon(iconRes, getActiveProfileColor())); configureProfile.setTitle(title); configureProfile.setSummary(profileType); } + + private void profileManagementPref() { + Preference createProfile = findPreference(CREATE_PROFILE); + createProfile.setIcon(app.getUIUtilities().getIcon(R.drawable.ic_action_plus, + isNightMode() ? R.color.active_color_primary_dark : R.color.active_color_primary_light)); + Preference importProfile = findPreference(IMPORT_PROFILE); + importProfile.setIcon(app.getUIUtilities().getIcon(R.drawable.ic_action_import, + isNightMode() ? R.color.active_color_primary_dark : R.color.active_color_primary_light)); + Preference reorderProfiles = findPreference(REORDER_PROFILES); + reorderProfiles.setIcon(app.getUIUtilities().getIcon(R.drawable.ic_action_edit_dark, + isNightMode() ? R.color.active_color_primary_dark : R.color.active_color_primary_light)); + } + + private void setupAppProfiles(PreferenceCategory preferenceCategory) { + OsmandApplication app = getMyApplication(); + if (app == null) { + return; + } + for (ApplicationMode applicationMode : allAppModes) { + boolean isAppProfileEnabled = availableAppModes.contains(applicationMode); + SwitchPreferenceCompat pref = new SwitchPreferenceCompat(app); + pref.setPersistent(false); + pref.setKey(applicationMode.getStringKey()); + pref.setIcon(getAppProfilesIcon(applicationMode, isAppProfileEnabled)); + pref.setTitle(applicationMode.toHumanString(getContext())); + pref.setSummary(getAppModeDescription(getContext(), applicationMode)); + pref.setChecked(isAppProfileEnabled); + pref.setLayoutResource(R.layout.preference_with_descr_dialog_and_switch); + preferenceCategory.addPreference(pref); + } + } + + private Drawable getAppProfilesIcon(ApplicationMode applicationMode, boolean appProfileEnabled) { + int iconResId = applicationMode.getIconRes(); + return appProfileEnabled ? app.getUIUtilities().getIcon(applicationMode.getIconRes(), applicationMode.getIconColorInfo().getColor(isNightMode())) + : getIcon(iconResId, isNightMode() ? R.color.icon_color_secondary_dark : R.color.icon_color_secondary_light); + } } \ No newline at end of file From 913559a40ad9b403fc4d88f9cb5b68b6d20a8f46 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Thu, 28 Nov 2019 17:20:33 +0200 Subject: [PATCH 002/231] MainSettingsFragment->ConfigureProfileFragment for every profile. --- OsmAnd/src/net/osmand/plus/activities/MapActivity.java | 2 +- .../src/net/osmand/plus/settings/BaseSettingsFragment.java | 6 +++++- .../src/net/osmand/plus/settings/MainSettingsFragment.java | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index b344304e6a..3c97df19c7 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -2092,7 +2092,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven String fragmentName = pref.getFragment(); Fragment fragment = Fragment.instantiate(this, fragmentName); if (caller instanceof BaseSettingsFragment) { - fragment.setArguments(((BaseSettingsFragment) caller).buildArguments()); + fragment.setArguments(((BaseSettingsFragment) caller).buildArguments(pref.getKey())); } getSupportFragmentManager().beginTransaction() .replace(R.id.fragmentContainer, fragment, fragment.getClass().getName()) diff --git a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java index 4317ebefe4..75c29cb377 100644 --- a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java @@ -319,8 +319,12 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl } public Bundle buildArguments() { + return buildArguments(appMode.getStringKey()); + } + + public Bundle buildArguments(String key) { Bundle args = new Bundle(); - args.putString(APP_MODE_KEY, appMode.getStringKey()); + args.putString(APP_MODE_KEY, key); return args; } diff --git a/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java index 001be21ebe..23fca293e3 100644 --- a/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java @@ -115,6 +115,7 @@ public class MainSettingsFragment extends BaseSettingsFragment { pref.setSummary(getAppModeDescription(getContext(), applicationMode)); pref.setChecked(isAppProfileEnabled); pref.setLayoutResource(R.layout.preference_with_descr_dialog_and_switch); + pref.setFragment(ConfigureProfileFragment.class.getName()); preferenceCategory.addPreference(pref); } } From bc4528497b97a2c6ba650aac3757eeef0b30f4dd Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 29 Nov 2019 12:56:43 +0200 Subject: [PATCH 003/231] Implement switch onPreferenceChange --- .../plus/settings/MainSettingsFragment.java | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java index 23fca293e3..63acf0bc05 100644 --- a/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java @@ -7,7 +7,6 @@ import android.support.annotation.ColorRes; import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceCategory; import android.support.v7.preference.PreferenceViewHolder; -import android.support.v7.preference.SwitchPreferenceCompat; import android.view.View; import net.osmand.AndroidUtils; @@ -15,6 +14,7 @@ import net.osmand.plus.ApplicationMode; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; +import net.osmand.plus.settings.preferences.SwitchPreferenceEx; import java.util.ArrayList; import java.util.LinkedHashSet; @@ -77,6 +77,29 @@ public class MainSettingsFragment extends BaseSettingsFragment { } } + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + String key = preference.getKey(); + ApplicationMode applicationMode = getAppMode(key); + if (applicationMode != null) { + if (newValue instanceof Boolean) { + boolean isChecked = (Boolean) newValue; + onProfileSelected(applicationMode, isChecked); + preference.setIcon(getAppProfilesIcon(applicationMode, isChecked)); + } + } + return super.onPreferenceChange(preference, newValue); + } + + ApplicationMode getAppMode(String key) { + for (ApplicationMode applicationMode : allAppModes) { + if (applicationMode.getStringKey().equals(key)) { + return applicationMode; + } + } + return null; + } + private void setupConfigureProfilePref() { ApplicationMode selectedMode = getSelectedAppMode(); String title = selectedMode.toHumanString(getContext()); @@ -107,7 +130,7 @@ public class MainSettingsFragment extends BaseSettingsFragment { } for (ApplicationMode applicationMode : allAppModes) { boolean isAppProfileEnabled = availableAppModes.contains(applicationMode); - SwitchPreferenceCompat pref = new SwitchPreferenceCompat(app); + SwitchPreferenceEx pref = new SwitchPreferenceEx(app); pref.setPersistent(false); pref.setKey(applicationMode.getStringKey()); pref.setIcon(getAppProfilesIcon(applicationMode, isAppProfileEnabled)); @@ -120,6 +143,15 @@ public class MainSettingsFragment extends BaseSettingsFragment { } } + public void onProfileSelected(ApplicationMode item, boolean isChecked) { + if (isChecked) { + availableAppModes.add(item); + } else { + availableAppModes.remove(item); + } + ApplicationMode.changeProfileAvailability(item, isChecked, getMyApplication()); + } + private Drawable getAppProfilesIcon(ApplicationMode applicationMode, boolean appProfileEnabled) { int iconResId = applicationMode.getIconRes(); return appProfileEnabled ? app.getUIUtilities().getIcon(applicationMode.getIconRes(), applicationMode.getIconColorInfo().getColor(isNightMode())) From 22e64f1ae9774930179ea606c51689bf3ea48ed9 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 29 Nov 2019 15:07:31 +0200 Subject: [PATCH 004/231] Change toolbar layout in ConfigureProfileFragment, add switch to disable profile --- ...profile_preference_toolbar_with_switch.xml | 38 +++++++++---- .../plus/settings/BaseSettingsFragment.java | 2 +- .../settings/ConfigureProfileFragment.java | 54 ++++++++++++++----- .../plus/settings/MainSettingsFragment.java | 8 +-- 4 files changed, 75 insertions(+), 27 deletions(-) diff --git a/OsmAnd/res/layout/profile_preference_toolbar_with_switch.xml b/OsmAnd/res/layout/profile_preference_toolbar_with_switch.xml index e98e25ba7f..2e1a63b7c8 100644 --- a/OsmAnd/res/layout/profile_preference_toolbar_with_switch.xml +++ b/OsmAnd/res/layout/profile_preference_toolbar_with_switch.xml @@ -30,18 +30,38 @@ android:src="@drawable/ic_action_mode_back" android:tint="?attr/default_icon_color" /> - + android:background="?attr/card_and_list_background_basic" + android:orientation="vertical"> + + + + + = Build.VERSION_CODES.LOLLIPOP) { float letterSpacing = AndroidUtils.getFloatValueFromRes(view.getContext(), R.dimen.title_letter_spacing); toolbarTitle.setLetterSpacing(letterSpacing); } - TextView profileType = (TextView) view.findViewById(R.id.profile_type); - profileType.setVisibility(View.VISIBLE); + + TextView toolbarSubtitle = view.findViewById(R.id.toolbar_subtitle); + toolbarSubtitle.setText(R.string.configure_profile); + toolbarSubtitle.setVisibility(View.VISIBLE); + + view.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ApplicationMode selectedMode = getSelectedAppMode(); + List availableAppModes = ApplicationMode.values(getMyApplication()); + boolean isChecked = availableAppModes.contains(selectedMode); + if (!isChecked) { + availableAppModes.add(selectedMode); + } else { + availableAppModes.remove(selectedMode); + } + ApplicationMode.changeProfileAvailability(selectedMode, !isChecked, getMyApplication()); + updateToolbarSwitch(); + } + }); + } + + private void updateToolbarSwitch() { + View view = getView(); + if (view == null) { + return; + } + boolean isChecked = ApplicationMode.values(getMyApplication()).contains(getSelectedAppMode()); + int color = isChecked ? getActiveProfileColor() : ContextCompat.getColor(app, R.color.preference_top_switch_off); + View switchContainer = view.findViewById(R.id.toolbar_switch_container); + AndroidUtils.setBackground(switchContainer, new ColorDrawable(color)); + + SwitchCompat switchView = switchContainer.findViewById(R.id.switchWidget); + switchView.setChecked(isChecked); + + TextView title = switchContainer.findViewById(R.id.switchButtonText); + title.setText(isChecked ? R.string.shared_string_on : R.string.shared_string_off); } @Override protected void updateToolbar() { super.updateToolbar(); - - View view = getView(); - if (view != null) { - ApplicationMode selectedMode = getSelectedAppMode(); - String appModeType = getAppModeDescription(view.getContext(), selectedMode); - - TextView profileType = (TextView) view.findViewById(R.id.profile_type); - profileType.setText(appModeType); - } + updateToolbarSwitch(); } private RecyclerView.ItemDecoration createDividerItemDecoration() { diff --git a/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java index 63acf0bc05..f9e142589d 100644 --- a/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java @@ -37,10 +37,6 @@ public class MainSettingsFragment extends BaseSettingsFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - allAppModes = new ArrayList<>(ApplicationMode.allPossibleValues()); - allAppModes.remove(ApplicationMode.DEFAULT); - availableAppModes = new LinkedHashSet<>(ApplicationMode.values(getMyApplication())); - availableAppModes.remove(ApplicationMode.DEFAULT); } @Override @@ -51,6 +47,10 @@ public class MainSettingsFragment extends BaseSettingsFragment { @Override protected void setupPreferences() { + allAppModes = new ArrayList<>(ApplicationMode.allPossibleValues()); + allAppModes.remove(ApplicationMode.DEFAULT); + availableAppModes = new LinkedHashSet<>(ApplicationMode.values(getMyApplication())); + availableAppModes.remove(ApplicationMode.DEFAULT); Preference globalSettings = findPreference("global_settings"); globalSettings.setIcon(getContentIcon(R.drawable.ic_action_settings)); PreferenceCategory selectedProfile = (PreferenceCategory) findPreference(SELECTED_PROFILE); From b29d720c548f404c152cd25da24a50061926c60b Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 29 Nov 2019 18:40:45 +0200 Subject: [PATCH 005/231] Add profile appearance, fix when selected appMode profile turn off switch to default. --- OsmAnd/res/values/strings.xml | 2 + OsmAnd/res/xml/configure_profile.xml | 11 ++++- .../settings/ConfigureProfileFragment.java | 47 +++++++++++++------ .../plus/settings/MainSettingsFragment.java | 2 +- 4 files changed, 44 insertions(+), 18 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 2487d77655..1ea71adf6b 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,8 @@ Thx - Hardy --> + Profile appearance + Choose icon, color and name Reorder Selected profile Node networks diff --git a/OsmAnd/res/xml/configure_profile.xml b/OsmAnd/res/xml/configure_profile.xml index 5b8574fd79..6e803e37bd 100644 --- a/OsmAnd/res/xml/configure_profile.xml +++ b/OsmAnd/res/xml/configure_profile.xml @@ -8,8 +8,7 @@ android:key="configure_profile_info" android:layout="@layout/preference_info_descr" android:persistent="false" - android:selectable="false" - android:title="@string/configure_profile_info" /> + android:selectable="false"/> + + diff --git a/OsmAnd/src/net/osmand/plus/settings/ConfigureProfileFragment.java b/OsmAnd/src/net/osmand/plus/settings/ConfigureProfileFragment.java index e9f446326b..06935c9abd 100644 --- a/OsmAnd/src/net/osmand/plus/settings/ConfigureProfileFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/ConfigureProfileFragment.java @@ -41,6 +41,7 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.PluginActivity; import net.osmand.plus.helpers.FontCache; import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin; +import net.osmand.plus.profiles.EditProfileFragment; import net.osmand.plus.settings.preferences.SwitchPreferenceEx; import net.osmand.plus.skimapsplugin.SkiMapsPlugin; @@ -66,6 +67,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment { private static final String CONFIGURE_MAP = "configure_map"; private static final String CONFIGURE_SCREEN = "configure_screen"; private static final String EXPORT_PROFILE = "export_profile"; + private static final String PROFILE_APPEARANCE = "profile_appearance"; @ColorRes protected int getBackgroundColorRes() { @@ -97,21 +99,25 @@ public class ConfigureProfileFragment extends BaseSettingsFragment { toolbarSubtitle.setText(R.string.configure_profile); toolbarSubtitle.setVisibility(View.VISIBLE); - view.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - ApplicationMode selectedMode = getSelectedAppMode(); - List availableAppModes = ApplicationMode.values(getMyApplication()); - boolean isChecked = availableAppModes.contains(selectedMode); - if (!isChecked) { - availableAppModes.add(selectedMode); - } else { - availableAppModes.remove(selectedMode); - } - ApplicationMode.changeProfileAvailability(selectedMode, !isChecked, getMyApplication()); - updateToolbarSwitch(); - } - }); + if (!getSelectedAppMode().equals(ApplicationMode.DEFAULT)) { + view.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ApplicationMode selectedMode = getSelectedAppMode(); + List availableAppModes = ApplicationMode.values(getMyApplication()); + boolean isChecked = availableAppModes.contains(selectedMode); + if (!isChecked) { + availableAppModes.add(selectedMode); + } else { + availableAppModes.remove(selectedMode); + } + ApplicationMode.changeProfileAvailability(selectedMode, !isChecked, getMyApplication()); + updateToolbarSwitch(); + } + }); + } else { + view.findViewById(R.id.switchWidget).setVisibility(View.GONE); + } } private void updateToolbarSwitch() { @@ -192,6 +198,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment { setupNavigationSettingsPref(); setupConfigureMapPref(); setupConfigureScreenPref(); + setupProfileAppearancePref(); PreferenceCategory pluginSettings = (PreferenceCategory) findPreference(PLUGIN_SETTINGS); pluginSettings.setIconSpaceReserved(false); @@ -239,6 +246,16 @@ public class ConfigureProfileFragment extends BaseSettingsFragment { configureMap.setIntent(intent); } + private void setupProfileAppearancePref() { + Context ctx = getContext(); + if (ctx == null) { + return; + } + Preference configureMap = findPreference(PROFILE_APPEARANCE); + configureMap.setIcon(getContentIcon(R.drawable.ic_action_offroad)); + configureMap.setFragment(EditProfileFragment.class.getName()); + } + private void setupExportProfilePref() { Preference exportProfile = findPreference(EXPORT_PROFILE); exportProfile.setIcon(app.getUIUtilities().getIcon(R.drawable.ic_action_app_configuration, diff --git a/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java index f9e142589d..08f1698b18 100644 --- a/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java @@ -101,7 +101,7 @@ public class MainSettingsFragment extends BaseSettingsFragment { } private void setupConfigureProfilePref() { - ApplicationMode selectedMode = getSelectedAppMode(); + ApplicationMode selectedMode = app.getSettings().APPLICATION_MODE.get(); String title = selectedMode.toHumanString(getContext()); String profileType = getAppModeDescription(getContext(), selectedMode); int iconRes = selectedMode.getIconRes(); From d25c32404aad8bfe0a3d76600f9848865ba7dd48 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Mon, 2 Dec 2019 10:59:21 +0200 Subject: [PATCH 006/231] Small refactoring. Used existed method ApplicationMode.valueOfStringKey --- .../osmand/plus/settings/MainSettingsFragment.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java index 08f1698b18..809d4e4b4d 100644 --- a/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java @@ -79,8 +79,7 @@ public class MainSettingsFragment extends BaseSettingsFragment { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { - String key = preference.getKey(); - ApplicationMode applicationMode = getAppMode(key); + ApplicationMode applicationMode = ApplicationMode.valueOfStringKey(preference.getKey(), null); if (applicationMode != null) { if (newValue instanceof Boolean) { boolean isChecked = (Boolean) newValue; @@ -91,15 +90,6 @@ public class MainSettingsFragment extends BaseSettingsFragment { return super.onPreferenceChange(preference, newValue); } - ApplicationMode getAppMode(String key) { - for (ApplicationMode applicationMode : allAppModes) { - if (applicationMode.getStringKey().equals(key)) { - return applicationMode; - } - } - return null; - } - private void setupConfigureProfilePref() { ApplicationMode selectedMode = app.getSettings().APPLICATION_MODE.get(); String title = selectedMode.toHumanString(getContext()); From 7340ccabce5e241e31d58a96022f965e66dc2870 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 6 Dec 2019 09:32:49 +0200 Subject: [PATCH 007/231] Add navigation type preference to Navigation setting --- OsmAnd/res/xml/navigation_settings_new.xml | 18 +++++++++++++----- .../plus/settings/NavigationFragment.java | 2 ++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/OsmAnd/res/xml/navigation_settings_new.xml b/OsmAnd/res/xml/navigation_settings_new.xml index dd1c6b0294..c2eca13dcf 100644 --- a/OsmAnd/res/xml/navigation_settings_new.xml +++ b/OsmAnd/res/xml/navigation_settings_new.xml @@ -5,12 +5,20 @@ android:title="@string/routing_settings_2"> + android:summary="@string/rendering_value_car_name" + android:title="@string/nav_type_hint" + app:fragment="net.osmand.plus.settings.SelectProfileBottomSheetDialogFragment" + tools:icon="@drawable/ic_action_car_dark" /> + + Date: Wed, 11 Dec 2019 10:23:40 +0200 Subject: [PATCH 008/231] Add select navigation type on the Navigation setting fragment --- OsmAnd/res/values/strings.xml | 1 + ...electProfileBottomSheetDialogFragment.java | 1 + .../plus/settings/NavigationFragment.java | 33 ++++++++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index f953705bba..ace59e8333 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,7 @@ Thx - Hardy --> + Navigation type affects the rules for route calculations. Add new profile \'%1$s\'? Include heading Save heading to each trackpoint while recording. diff --git a/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java index 9eba440a90..c5d0609bfd 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java @@ -135,6 +135,7 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo } else if (type.equals(TYPE_NAV_PROFILE)){ items.add(new TitleItem(getString(R.string.select_nav_profile_dialog_title))); + items.add(new LongDescriptionItem(getString(R.string.select_nav_profile_dialog_message))); for (int i = 0; i < profiles.size(); i++) { final int pos = i; final ProfileDataObject profile = profiles.get(i); diff --git a/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java b/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java index 218fe96aa9..abb6aecd49 100644 --- a/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java @@ -1,11 +1,19 @@ package net.osmand.plus.settings; +import android.os.Bundle; import android.support.v7.preference.Preference; import android.support.v7.preference.SwitchPreferenceCompat; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.profiles.EditProfileFragment.RoutingProfilesResources; +import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment; import net.osmand.plus.settings.preferences.SwitchPreferenceEx; +import net.osmand.router.GeneralRouter; + +import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.DIALOG_TYPE; +import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SELECTED_KEY; +import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.TYPE_NAV_PROFILE; public class NavigationFragment extends BaseSettingsFragment { @@ -20,7 +28,10 @@ public class NavigationFragment extends BaseSettingsFragment { SwitchPreferenceCompat turnScreenOn = (SwitchPreferenceCompat) findPreference(settings.TURN_SCREEN_ON_ENABLED.getId()); SwitchPreferenceEx animateMyLocation = (SwitchPreferenceEx) findPreference(settings.ANIMATE_MY_LOCATION.getId()); - navigationType.setIcon(getContentIcon(R.drawable.ic_action_car_dark)); + GeneralRouter gr = app.getRoutingConfig().getRouter(getSelectedAppMode().getRoutingProfile()); + RoutingProfilesResources routingProfilesResources = RoutingProfilesResources.valueOf(gr.getProfileName().toUpperCase()); + navigationType.setSummary(routingProfilesResources.getStringRes()); + navigationType.setIcon(getContentIcon(routingProfilesResources.getIconRes())); routeParameters.setIcon(getContentIcon(R.drawable.ic_action_route_distance)); showRoutingAlarms.setIcon(getContentIcon(R.drawable.ic_action_alert)); speakRoutingAlarms.setIcon(getContentIcon(R.drawable.ic_action_volume_up)); @@ -42,6 +53,26 @@ public class NavigationFragment extends BaseSettingsFragment { return super.onPreferenceChange(preference, newValue); } + @Override + public boolean onPreferenceClick(Preference preference) { + if (preference.getKey().equals("navigation_type")) { + if (getSelectedAppMode().isCustomProfile()) { + final SelectProfileBottomSheetDialogFragment dialog = new SelectProfileBottomSheetDialogFragment(); + Bundle bundle = new Bundle(); + if (getSelectedAppMode() != null) { + bundle.putString(SELECTED_KEY, getSelectedAppMode().getRoutingProfile()); + } + bundle.putString(DIALOG_TYPE, TYPE_NAV_PROFILE); + dialog.setArguments(bundle); + if (getActivity() != null) { + getActivity().getSupportFragmentManager().beginTransaction() + .add(dialog, "select_nav_type").commitAllowingStateLoss(); + } + } + } + return true; + } + private void setupVehicleParametersPref() { Preference vehicleParameters = findPreference("vehicle_parameters"); int iconRes = getSelectedAppMode().getIconRes(); From 9d918f6bab6af8bcb43493549f25a68d8cc56fb7 Mon Sep 17 00:00:00 2001 From: Chumva Date: Wed, 11 Dec 2019 16:04:22 +0200 Subject: [PATCH 009/231] Add ability to save and change default app modes --- .../src/net/osmand/plus/ApplicationMode.java | 105 ++++++++++++------ .../src/net/osmand/plus/OsmandSettings.java | 3 + .../src/net/osmand/plus/SettingsHelper.java | 2 +- .../AppModesBottomSheetDialogFragment.java | 4 +- .../plus/profiles/EditProfileFragment.java | 2 +- .../profiles/SettingsProfileFragment.java | 4 +- 6 files changed, 78 insertions(+), 42 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/ApplicationMode.java b/OsmAnd/src/net/osmand/plus/ApplicationMode.java index b157428939..5eaa3b107d 100644 --- a/OsmAnd/src/net/osmand/plus/ApplicationMode.java +++ b/OsmAnd/src/net/osmand/plus/ApplicationMode.java @@ -50,6 +50,7 @@ public class ApplicationMode { private static Map> widgetsAvailabilityMap = new LinkedHashMap<>(); private static List defaultValues = new ArrayList<>(); + private static List customValues = new ArrayList<>(); private static List values = new ArrayList<>(); private static List cachedFilteredValues = new ArrayList<>(); @@ -209,6 +210,7 @@ public class ApplicationMode { m.locationIconDayLost = m.parentAppMode.locationIconDayLost; m.locationIconNightLost = m.parentAppMode.locationIconNightLost; values.add(applicationMode); + customValues.add(applicationMode); return applicationMode; } @@ -354,6 +356,11 @@ public class ApplicationMode { return create(parent, -1, stringKey).userProfileTitle(userProfileTitle); } + public static ApplicationModeBuilder changeBaseMode(ApplicationMode applicationMode) { + ApplicationModeBuilder builder = new ApplicationModeBuilder(); + builder.applicationMode = applicationMode; + return builder; + } public static List values(OsmandApplication app) { if (customizationListener == null) { @@ -396,6 +403,10 @@ public class ApplicationMode { return defaultValues; } + public static List getCustomValues() { + return customValues; + } + // returns modifiable ! Set to exclude non-wanted derived public static Set regWidgetVisibility(String widgetId, ApplicationMode... am) { HashSet set = new HashSet<>(); @@ -611,6 +622,7 @@ public class ApplicationMode { public static void onApplicationStart(OsmandApplication app) { // load for default profiles to initialize later custom modes + initDefaultModesParams(app); initDefaultSpeed(app); initCustomModes(app); initDefaultSpeed(app); @@ -651,6 +663,25 @@ public class ApplicationMode { return gson.toJson(mb); } + private static void initDefaultModesParams(OsmandApplication app) { + Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); + Type t = new TypeToken>() {}.getType(); + List defaultAppModeBeans = gson.fromJson(app.getSettings().DEFAULT_APP_PROFILES.get(), t); + + if (!Algorithms.isEmpty(defaultAppModeBeans)) { + for (ApplicationModeBean modeBean : defaultAppModeBeans) { + ApplicationMode applicationMode = ApplicationMode.valueOfStringKey(modeBean.stringKey, null); + if (applicationMode != null) { + applicationMode.userProfileName = modeBean.userProfileName; + applicationMode.iconResName = modeBean.iconName; + applicationMode.iconColor = modeBean.iconColor; + applicationMode.routingProfile = modeBean.routingProfile; + applicationMode.routeService = modeBean.routeService; + } + } + } + } + private static void initCustomModes(OsmandApplication app){ Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); Type t = new TypeToken>() {}.getType(); @@ -669,46 +700,51 @@ public class ApplicationMode { } - private static void saveCustomModeToSettings(OsmandSettings settings){ - List customModes = new ArrayList<>(); - for (ApplicationMode mode : values) { - if (mode.parentAppMode != null) { - ApplicationModeBean mb = new ApplicationModeBean(); - mb.userProfileName = mode.userProfileName; - mb.iconColor = mode.iconColor; - mb.iconName = mode.iconResName; - mb.parent = mode.parentAppMode.getStringKey(); - mb.stringKey = mode.stringKey; - mb.routeService = mode.routeService; - mb.routingProfile = mode.routingProfile; - customModes.add(mb); - } - } + private static void saveAppModesToSettings(OsmandSettings settings, boolean saveCustomModes) { + List appModes = saveCustomModes ? customValues : defaultValues; + List modeBeans = createApplicationModeBeans(appModes); + Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); - String profiles = gson.toJson(customModes); - settings.CUSTOM_APP_PROFILES.set(profiles); + String profiles = gson.toJson(modeBeans); + if (saveCustomModes) { + settings.CUSTOM_APP_PROFILES.set(profiles); + } else { + settings.DEFAULT_APP_PROFILES.set(profiles); + } } - public static ApplicationMode saveCustomProfile(ApplicationModeBuilder builder, OsmandApplication app) { - ApplicationMode mode = null; - for(ApplicationMode m : values) { - if(m.stringKey.equals(builder.applicationMode.stringKey)) { - mode = m; - mode.iconResName = builder.applicationMode.iconResName; - mode.iconRes = builder.applicationMode.iconRes; - mode.userProfileName = builder.applicationMode.userProfileName; - mode.parentAppMode = builder.applicationMode.parentAppMode; - mode.routingProfile = builder.applicationMode.routingProfile; - mode.routeService = builder.applicationMode.routeService; - mode.iconColor = builder.applicationMode.iconColor; - break; - } + private static List createApplicationModeBeans(List applicationModes) { + List modeBeans = new ArrayList<>(); + for (ApplicationMode mode : applicationModes) { + ApplicationModeBean mb = new ApplicationModeBean(); + mb.userProfileName = mode.userProfileName; + mb.iconColor = mode.iconColor; + mb.iconName = mode.iconResName; + mb.parent = mode.parentAppMode.getStringKey(); + mb.stringKey = mode.stringKey; + mb.routeService = mode.routeService; + mb.routingProfile = mode.routingProfile; + modeBeans.add(mb); } - if(mode == null) { + + return modeBeans; + } + + public static ApplicationMode saveProfile(ApplicationModeBuilder builder, OsmandApplication app) { + ApplicationMode mode = ApplicationMode.valueOfStringKey(builder.applicationMode.stringKey, null); + if (mode != null) { + mode.iconResName = builder.applicationMode.iconResName; + mode.iconRes = builder.applicationMode.iconRes; + mode.userProfileName = builder.applicationMode.userProfileName; + mode.parentAppMode = builder.applicationMode.parentAppMode; + mode.routingProfile = builder.applicationMode.routingProfile; + mode.routeService = builder.applicationMode.routeService; + mode.iconColor = builder.applicationMode.iconColor; + } else { mode = builder.customReg(); initRegVisibility(); } - saveCustomModeToSettings(app.getSettings()); + saveAppModesToSettings(app.getSettings(), mode.isCustomProfile()); return mode; } @@ -721,8 +757,9 @@ public class ApplicationMode { it.remove(); } } + customValues.remove(md); cachedFilteredValues.remove(md); - saveCustomModeToSettings(app.getSettings()); + saveAppModesToSettings(app.getSettings(), md.isCustomProfile()); } public static boolean changeProfileAvailability(ApplicationMode mode, boolean isSelected, OsmandApplication app) { diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 53f33b7afe..454f11ac4a 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -3224,6 +3224,9 @@ public class OsmandSettings { RateUsBottomSheetDialog.RateUsState.INITIAL_STATE, RateUsBottomSheetDialog.RateUsState.values()) .makeGlobal(); + public final CommonPreference DEFAULT_APP_PROFILES = + new StringPreference("default_app_profiles", "").makeGlobal().cache(); + public final CommonPreference CUSTOM_APP_PROFILES = new StringPreference("custom_app_profiles", "").makeGlobal().cache(); diff --git a/OsmAnd/src/net/osmand/plus/SettingsHelper.java b/OsmAnd/src/net/osmand/plus/SettingsHelper.java index 806231eac9..c95a8d5312 100644 --- a/OsmAnd/src/net/osmand/plus/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/SettingsHelper.java @@ -453,7 +453,7 @@ public class SettingsHelper { @Override public void apply() { if (appMode.isCustomProfile()) { - appMode = ApplicationMode.saveCustomProfile(builder, getSettings().getContext()); + appMode = ApplicationMode.saveProfile(builder, getSettings().getContext()); } } diff --git a/OsmAnd/src/net/osmand/plus/profiles/AppModesBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/profiles/AppModesBottomSheetDialogFragment.java index 2254cd909f..3952016a87 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/AppModesBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/profiles/AppModesBottomSheetDialogFragment.java @@ -81,9 +81,7 @@ public abstract class AppModesBottomSheetDialogFragment Date: Wed, 11 Dec 2019 16:11:17 +0000 Subject: [PATCH 010/231] Translated using Weblate (Turkish) Currently translated at 100.0% (3081 of 3081 strings) --- OsmAnd/res/values-tr/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-tr/strings.xml b/OsmAnd/res/values-tr/strings.xml index 518cae8e98..7886f28585 100644 --- a/OsmAnd/res/values-tr/strings.xml +++ b/OsmAnd/res/values-tr/strings.xml @@ -3350,4 +3350,7 @@ \'%1$s\' yeni profil ekle\? Başlığı dahil et Kayıt sırasında her bir izleme noktasının başlığını kaydet. + %1$s • %2$s + %1$s, %2$s + Kişisel \ No newline at end of file From 0af8ebe7fbed026b95dd0f3318ebf794a1e6c314 Mon Sep 17 00:00:00 2001 From: Philippe de FRANCLIEU Date: Wed, 11 Dec 2019 14:59:39 +0000 Subject: [PATCH 011/231] Translated using Weblate (English (United Kingdom)) Currently translated at 1.2% (37 of 3081 strings) --- OsmAnd/res/values-en-rGB/strings.xml | 184 +++++++++++++-------------- 1 file changed, 92 insertions(+), 92 deletions(-) diff --git a/OsmAnd/res/values-en-rGB/strings.xml b/OsmAnd/res/values-en-rGB/strings.xml index 0371f1ea85..e8ca75a7af 100644 --- a/OsmAnd/res/values-en-rGB/strings.xml +++ b/OsmAnd/res/values-en-rGB/strings.xml @@ -1,95 +1,95 @@ - - - - GPX colour - GPX colour - Colour - Old \'Mapnik\'-style default rendering style. Key features: colours are similar to \'Mapnik\' style. - High detail style for touring purposes. Includes all configuration options of default style, in addition: Displays as much detail as possible, in particular all roads, paths, and other ways to travel. Clear visual distinction between all different road types, reminiscent of many touring atlases. High contrast colour scheme for outdoor use, day and night mode. - Modification of the default style to increase contrast of pedestrian and bicycle roads. Uses legacy Mapnik colours. - Select a Favourite category to add to the markers. - Favourites category - You can import groups from favourites or track waypoints. - You can import favourite groups or track waypoints as markers. - Add Favourites - Add favourites on the map or import them from a file. - can be imported as Favourites points, or as track file. - Import as Favourites - Search favourites - Favourite information - Save as group of favourites - Add favourite - Change colour - Colour scheme - towards - Default colour - Colouring according to route scope - Colouring according to OSMC - Favourite - Favourites - Add to Favourites - My Favourites - Railway crossing - Pedestrian crossing - Railway crossings - Pedestrian crossings - Underground routes - The favourite point name has been modified to %1$s to facilitate properly saving the string with emoticons to a file. - Favourite point name duplicate - Specified favourite name already in use, was changed to %1$s to avoid duplication. - Nearby Favourites - Colour-code buildings by type - Display colour - Select favourite - Select a road colour scheme: - Road colour scheme - Favourites search - File with previously exported favourites already exists. Do you want to replace it? - Favourites… - Favourite point(s) deleted successfully. - You are going to delete %1$d favourite(s) and %2$d favourite group(s). Are you sure? - Favourites successfully imported - Favourites successfully saved to {0} - No favourite points to save - Favourites shared via OsmAnd - Favourite point was edited - No favourite points exist - Enter favourite name - Favourite - Favourite point \'\'{0}\'\' was added successfully. - Add favourite - Edit favourite - Delete favourite - Delete favourite point \'%s\'? - Favourite point {0} was successfully deleted. - Are you sure you want to replace favourite %1$s? - - Display position always in centre - Auto-centre map view - Auto-centre nav only - Auto-centre map view only while navigating. - Auto-centre map view in use. - Current map centre - Search near current map centre - Centre - Total distance %1$s, travelling time %2$d h %3$d m. - Contour lines colour scheme - Tapping the action button will add a destination at the screen centre location. - Tapping the action button will replace the destination with the screen centre location. - Tapping the action button will add a first intermediate point at the screen centre location. - Tapping the action button will add a parking place at the screen centre location. - Tapping the action button will add an OSM note at the screen centre location. - Tapping the action button will add a POI at the screen centre location. - Tapping the action button will add a map marker at the screen centre location. - Tapping the action button will add a GPX waypoint at the screen centre location. - Tapping the action button will show or hide the favourite points on the map. - Show/hide favourites - Show Favourites - Hide Favourites - Select the category to save the favourite in. - Analyse on map -You have cancelled your OsmAnd Live subscription - + GPX colour + GPX colour + Colour + Old \'Mapnik\'-style default rendering style. Key features: colours are similar to \'Mapnik\' style. + High detail style for touring purposes. Includes all configuration options of default style, in addition: Displays as much detail as possible, in particular all roads, paths, and other ways to travel. Clear visual distinction between all different road types, reminiscent of many touring atlases. High contrast colour scheme for outdoor use, day and night mode. + Modification of the default style to increase contrast of pedestrian and bicycle roads. Uses legacy Mapnik colours. + Select a Favourite category to add to the markers. + Favourites category + You can import groups from favourites or track waypoints. + You can import favourite groups or track waypoints as markers. + Add Favourites + Add favourites on the map or import them from a file. + can be imported as Favourites points, or as track file. + Import as Favourites + Search favourites + Favourite information + Save as group of favourites + Add favourite + Change colour + Colour scheme + towards + Default colour + Colouring according to route scope + Colouring according to OSMC + Favourite + Favourites + Add to Favourites + My Favourites + Railway crossing + Pedestrian crossing + Railway crossings + Pedestrian crossings + Underground routes + The favourite point name has been modified to %1$s to facilitate properly saving the string with emoticons to a file. + Favourite point name duplicate + Specified favourite name already in use, was changed to %1$s to avoid duplication. + Nearby Favourites + Colour-code buildings by type + Display colour + Select favourite + Select a road colour scheme: + Road colour scheme + Favourites search + File with previously exported favourites already exists. Do you want to replace it? + Favourites… + Favourite point(s) deleted successfully. + You are going to delete %1$d favourite(s) and %2$d favourite group(s). Are you sure? + Favourites successfully imported + Favourites successfully saved to {0} + No favourite points to save + Favourites shared via OsmAnd + Favourite point was edited + No favourite points exist + Enter favourite name + Favourite + Favourite point \'\'{0}\'\' was added successfully. + Add favourite + Edit favourite + Delete favourite + Delete favourite point \'%s\'? + Favourite point {0} was successfully deleted. + Are you sure you want to replace favourite %1$s? + Display position always in centre + Auto-centre map view + Auto-centre nav only + Auto-centre map view only while navigating. + Auto-centre map view in use. + Current map centre + Search near current map centre + Centre + Total distance %1$s, travelling time %2$d h %3$d m. + Contour lines colour scheme + Tapping the action button will add a destination at the screen centre location. + Tapping the action button will replace the destination with the screen centre location. + Tapping the action button will add a first intermediate point at the screen centre location. + Tapping the action button will add a parking place at the screen centre location. + Tapping the action button will add an OSM note at the screen centre location. + Tapping the action button will add a POI at the screen centre location. + Tapping the action button will add a map marker at the screen centre location. + Tapping the action button will add a GPX waypoint at the screen centre location. + Tapping the action button will show or hide the favourite points on the map. + Show/hide favourites + Show Favourites + Hide Favourites + Select the category to save the favourite in. + Analyse on map + You have cancelled your OsmAnd Live subscription + Show transparency slider + \ No newline at end of file From 269ba49dc7b2437dd4e411d65d7d3a6ee97bca15 Mon Sep 17 00:00:00 2001 From: Philippe de FRANCLIEU Date: Wed, 11 Dec 2019 15:09:19 +0000 Subject: [PATCH 012/231] Translated using Weblate (French) Currently translated at 99.9% (3077 of 3081 strings) --- OsmAnd/res/values-fr/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index 19618ff37d..ba7a19a3d2 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -1882,7 +1882,7 @@ Mémoire proportionnelle %4$s Mo (limite Android %5$s Mo, Dalvik %6$s Mo).Merci pour votre soutien à OsmAnd ! \nPour activer toutes les nouvelles fonctionnalités, merci de redémarrer OsmAnd. Paramétrage de l\'abonnement - Afficher la barre de recherche transparente + Afficher curseur de réglage de la transparence Recalculer l\'itinéraire Mémoire partagée Barre supérieure From 30aaeefe22c4b76dfe1be1caf7af04516d1c7368 Mon Sep 17 00:00:00 2001 From: Rpnpif Date: Wed, 11 Dec 2019 17:10:45 +0000 Subject: [PATCH 013/231] Translated using Weblate (French) Currently translated at 99.9% (3077 of 3081 strings) --- OsmAnd/res/values-fr/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index ba7a19a3d2..8e6816933b 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -3370,4 +3370,7 @@ représentant la zone : %1$s x %2$s Ajouter le profil \'%1$s\' \? Inclure l\'entête Enregistrer l\'entête avec chaque point lors de l\'enregistrement d\'une trace. + Montre des itinéraires cyclables de réseau de nœud + Réseaux de nœud + Personnel \ No newline at end of file From e98d5899314e1b1b5d3affd2862d5a69cb55302d Mon Sep 17 00:00:00 2001 From: ace shadow Date: Wed, 11 Dec 2019 19:57:48 +0000 Subject: [PATCH 014/231] Translated using Weblate (Slovak) Currently translated at 87.7% (2703 of 3081 strings) --- OsmAnd/res/values-sk/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-sk/strings.xml b/OsmAnd/res/values-sk/strings.xml index 249bf82965..d5a06b7bdc 100644 --- a/OsmAnd/res/values-sk/strings.xml +++ b/OsmAnd/res/values-sk/strings.xml @@ -3388,4 +3388,7 @@ Zodpovedá oblasti: %1$s x %2$s Pridať nový profil \'%1$s\'\? Pridať nadpis Pridať nadpis ku každému bodu trasy pri zázname. + %1$s • %2$s + %1$s, %2$s + Osobné \ No newline at end of file From 732e1c65eac47c43a255464062a4993d0256ac06 Mon Sep 17 00:00:00 2001 From: Rpnpif Date: Wed, 11 Dec 2019 17:30:10 +0000 Subject: [PATCH 015/231] Translated using Weblate (French) Currently translated at 98.0% (3672 of 3748 strings) --- OsmAnd/res/values-fr/phrases.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-fr/phrases.xml b/OsmAnd/res/values-fr/phrases.xml index 1fc70799e3..2ba62961c6 100644 --- a/OsmAnd/res/values-fr/phrases.xml +++ b/OsmAnd/res/values-fr/phrases.xml @@ -3690,4 +3690,6 @@ Lac Accès à cheval : forestiers seuls Accès piétonnier : riverains + Accès aux remorques : non + Accès aux transports publics ou taxis : oui \ No newline at end of file From 349212bbc7d5d737af25b463e6870b418c7418dc Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Thu, 12 Dec 2019 13:37:31 +0200 Subject: [PATCH 016/231] Add possibility to change navigation type for all profiles --- .../res/layout/profile_preference_toolbar.xml | 8 -- OsmAnd/res/xml/navigation_settings_new.xml | 1 - .../src/net/osmand/plus/ApplicationMode.java | 2 +- .../osmand/plus/activities/MapActivity.java | 2 +- .../plus/profiles/EditProfileFragment.java | 2 +- ...electProfileBottomSheetDialogFragment.java | 7 +- .../plus/settings/BaseSettingsFragment.java | 2 +- .../plus/settings/MainSettingsFragment.java | 10 ++ .../plus/settings/NavigationFragment.java | 92 +++++++++++++++---- 9 files changed, 93 insertions(+), 33 deletions(-) diff --git a/OsmAnd/res/layout/profile_preference_toolbar.xml b/OsmAnd/res/layout/profile_preference_toolbar.xml index 125581fdb7..a86b981894 100644 --- a/OsmAnd/res/layout/profile_preference_toolbar.xml +++ b/OsmAnd/res/layout/profile_preference_toolbar.xml @@ -37,14 +37,6 @@ android:textSize="@dimen/dialog_header_text_size" osmand:typeface="@string/font_roboto_medium" tools:text="@string/routing_settings_2" /> - - - \ No newline at end of file diff --git a/OsmAnd/res/xml/navigation_settings_new.xml b/OsmAnd/res/xml/navigation_settings_new.xml index c2eca13dcf..27fe337ccc 100644 --- a/OsmAnd/res/xml/navigation_settings_new.xml +++ b/OsmAnd/res/xml/navigation_settings_new.xml @@ -9,7 +9,6 @@ android:layout="@layout/preference_with_descr" android:summary="@string/rendering_value_car_name" android:title="@string/nav_type_hint" - app:fragment="net.osmand.plus.settings.SelectProfileBottomSheetDialogFragment" tools:icon="@drawable/ic_action_car_dark" /> getRoutingProfiles(OsmandApplication context) { + public static List getRoutingProfiles(OsmandApplication context) { List profilesObjects = new ArrayList<>(); profilesObjects.add(new RoutingProfileDataObject( RoutingProfilesResources.STRAIGHT_LINE_MODE.name(), diff --git a/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java index c5d0609bfd..9017ca3229 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java @@ -17,6 +17,7 @@ import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton; import net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; +import net.osmand.plus.settings.NavigationFragment; import org.apache.commons.logging.Log; @@ -223,6 +224,7 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo FragmentManager fragmentManager = activity.getSupportFragmentManager(); EditProfileFragment editProfileFragment = (EditProfileFragment) fragmentManager.findFragmentByTag(EditProfileFragment.TAG); SettingsProfileFragment settingsProfileFragment = (SettingsProfileFragment) fragmentManager.findFragmentByTag(SettingsProfileFragment.class.getName()); + NavigationFragment navigationFragment = (NavigationFragment) fragmentManager.findFragmentByTag(NavigationFragment.class.getName()); if (editProfileFragment != null) { switch (type) { @@ -231,6 +233,7 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo break; case TYPE_NAV_PROFILE: listener = editProfileFragment.getNavProfileListener(); + break; case TYPE_ICON: listener = editProfileFragment.getIconListener(); @@ -238,6 +241,8 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo } } else if (settingsProfileFragment != null) { listener = settingsProfileFragment.getBaseProfileListener(); + } else if (navigationFragment != null) { + listener = navigationFragment.getNavProfileListener(); } } } @@ -272,7 +277,7 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo return icons; } - interface SelectProfileListener { + public interface SelectProfileListener { void onSelectedType(int pos, String stringRes); } diff --git a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java index 74a20d1264..39947cdfc0 100644 --- a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java @@ -88,7 +88,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl CONFIGURE_PROFILE(ConfigureProfileFragment.class.getName(), true, R.xml.configure_profile, R.layout.profile_preference_toolbar_with_switch), PROXY_SETTINGS(ProxySettingsFragment.class.getName(), false, R.xml.proxy_preferences, R.layout.global_preferences_toolbar_with_switch), GENERAL_PROFILE(GeneralProfileSettingsFragment.class.getName(), true, R.xml.general_profile_settings, R.layout.profile_preference_toolbar_big), - NAVIGATION(NavigationFragment.class.getName(), true, R.xml.navigation_settings_new, R.layout.profile_preference_toolbar_big), + NAVIGATION(NavigationFragment.class.getName(), true, R.xml.navigation_settings_new, R.layout.profile_preference_toolbar), COORDINATES_FORMAT(CoordinatesFormatFragment.class.getName(), true, R.xml.coordinates_format, R.layout.profile_preference_toolbar), ROUTE_PARAMETERS(RouteParametersFragment.class.getName(), true, R.xml.route_parameters, R.layout.profile_preference_toolbar), SCREEN_ALERTS(ScreenAlertsFragment.class.getName(), true, R.xml.screen_alerts, R.layout.profile_preference_toolbar_with_switch), diff --git a/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java index 809d4e4b4d..b5bbb5da9d 100644 --- a/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java @@ -90,6 +90,16 @@ public class MainSettingsFragment extends BaseSettingsFragment { return super.onPreferenceChange(preference, newValue); } + @Override + public boolean onPreferenceClick(Preference preference) { + String prefId = preference.getKey(); + if (APP_PROFILES.equals(preference.getParent().getKey())) { + BaseSettingsFragment.showInstance(getActivity(), SettingsScreenType.CONFIGURE_PROFILE, ApplicationMode.valueOfStringKey(prefId, null)); + return true; + } + return super.onPreferenceClick(preference); + } + private void setupConfigureProfilePref() { ApplicationMode selectedMode = app.getSettings().APPLICATION_MODE.get(); String title = selectedMode.toHumanString(getContext()); diff --git a/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java b/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java index abb6aecd49..a05584afb9 100644 --- a/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java @@ -4,13 +4,19 @@ import android.os.Bundle; import android.support.v7.preference.Preference; import android.support.v7.preference.SwitchPreferenceCompat; +import net.osmand.plus.ApplicationMode; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.profiles.EditProfileFragment; import net.osmand.plus.profiles.EditProfileFragment.RoutingProfilesResources; +import net.osmand.plus.profiles.RoutingProfileDataObject; import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment; +import net.osmand.plus.routing.RouteProvider; import net.osmand.plus.settings.preferences.SwitchPreferenceEx; import net.osmand.router.GeneralRouter; +import java.util.List; + import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.DIALOG_TYPE; import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SELECTED_KEY; import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.TYPE_NAV_PROFILE; @@ -18,20 +24,30 @@ import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.TY public class NavigationFragment extends BaseSettingsFragment { public static final String TAG = NavigationFragment.class.getSimpleName(); + private SelectProfileBottomSheetDialogFragment.SelectProfileListener navTypeListener; + List routingProfileDataObjects; + private Preference navigationType; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + routingProfileDataObjects = EditProfileFragment.getRoutingProfiles(app); + } @Override protected void setupPreferences() { - Preference navigationType = findPreference("navigation_type"); + navigationType = findPreference("navigation_type"); Preference routeParameters = findPreference("route_parameters"); SwitchPreferenceCompat showRoutingAlarms = (SwitchPreferenceCompat) findPreference(settings.SHOW_ROUTING_ALARMS.getId()); SwitchPreferenceCompat speakRoutingAlarms = (SwitchPreferenceCompat) findPreference(settings.VOICE_MUTE.getId()); SwitchPreferenceCompat turnScreenOn = (SwitchPreferenceCompat) findPreference(settings.TURN_SCREEN_ON_ENABLED.getId()); SwitchPreferenceEx animateMyLocation = (SwitchPreferenceEx) findPreference(settings.ANIMATE_MY_LOCATION.getId()); - - GeneralRouter gr = app.getRoutingConfig().getRouter(getSelectedAppMode().getRoutingProfile()); - RoutingProfilesResources routingProfilesResources = RoutingProfilesResources.valueOf(gr.getProfileName().toUpperCase()); - navigationType.setSummary(routingProfilesResources.getStringRes()); - navigationType.setIcon(getContentIcon(routingProfilesResources.getIconRes())); + if (getSelectedAppMode().getRoutingProfile() != null) { + GeneralRouter gr = app.getRoutingConfig().getRouter(getSelectedAppMode().getRoutingProfile()); + RoutingProfilesResources routingProfilesResources = RoutingProfilesResources.valueOf(gr.getProfileName().toUpperCase()); + navigationType.setSummary(routingProfilesResources.getStringRes()); + navigationType.setIcon(getContentIcon(routingProfilesResources.getIconRes())); + } routeParameters.setIcon(getContentIcon(R.drawable.ic_action_route_distance)); showRoutingAlarms.setIcon(getContentIcon(R.drawable.ic_action_alert)); speakRoutingAlarms.setIcon(getContentIcon(R.drawable.ic_action_volume_up)); @@ -56,21 +72,59 @@ public class NavigationFragment extends BaseSettingsFragment { @Override public boolean onPreferenceClick(Preference preference) { if (preference.getKey().equals("navigation_type")) { - if (getSelectedAppMode().isCustomProfile()) { - final SelectProfileBottomSheetDialogFragment dialog = new SelectProfileBottomSheetDialogFragment(); - Bundle bundle = new Bundle(); - if (getSelectedAppMode() != null) { - bundle.putString(SELECTED_KEY, getSelectedAppMode().getRoutingProfile()); - } - bundle.putString(DIALOG_TYPE, TYPE_NAV_PROFILE); - dialog.setArguments(bundle); - if (getActivity() != null) { - getActivity().getSupportFragmentManager().beginTransaction() - .add(dialog, "select_nav_type").commitAllowingStateLoss(); - } + final SelectProfileBottomSheetDialogFragment dialog = new SelectProfileBottomSheetDialogFragment(); + Bundle bundle = new Bundle(); + if (getSelectedAppMode() != null) { + bundle.putString(SELECTED_KEY, getSelectedAppMode().getRoutingProfile()); + } + bundle.putString(DIALOG_TYPE, TYPE_NAV_PROFILE); + dialog.setArguments(bundle); + if (getActivity() != null) { + getActivity().getSupportFragmentManager().beginTransaction() + .add(dialog, "select_nav_type").commitAllowingStateLoss(); } } - return true; + return false; + } + + public SelectProfileBottomSheetDialogFragment.SelectProfileListener getNavProfileListener() { + if (navTypeListener == null) { + navTypeListener = new SelectProfileBottomSheetDialogFragment.SelectProfileListener() { + @Override + public void onSelectedType(int pos, String stringRes) { + updateRoutingProfile(pos); + } + }; + } + return navTypeListener; + } + + void updateRoutingProfile(int pos) { + for (int i = 0; i < routingProfileDataObjects.size(); i++) { + if (i == pos) { + routingProfileDataObjects.get(i).setSelected(true); + } else { + routingProfileDataObjects.get(i).setSelected(false); + } + } + RoutingProfileDataObject selectedRoutingProfileDataObject = routingProfileDataObjects.get(pos); + navigationType.setSummary(selectedRoutingProfileDataObject.getName()); + navigationType.setIcon(getContentIcon(selectedRoutingProfileDataObject.getIconRes())); + ApplicationMode.ApplicationModeBuilder builder = ApplicationMode.changeBaseMode(getSelectedAppMode()); + if (selectedRoutingProfileDataObject.getStringKey().equals( + RoutingProfilesResources.STRAIGHT_LINE_MODE.name())) { + builder.setRouteService(RouteProvider.RouteService.STRAIGHT); + } else if (selectedRoutingProfileDataObject.getStringKey().equals( + RoutingProfilesResources.BROUTER_MODE.name())) { + builder.setRouteService(RouteProvider.RouteService.BROUTER); + } else { + builder.setRoutingProfile(selectedRoutingProfileDataObject.getStringKey()); + } + + ApplicationMode mode = ApplicationMode.saveProfile(builder, app); + if (!ApplicationMode.values(app).contains(mode)) { + ApplicationMode.changeProfileAvailability(mode, true, app); + } } private void setupVehicleParametersPref() { From d453b1e6fc7df967e0b22ee0486aebf270e8f6cb Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 12 Dec 2019 14:05:56 +0200 Subject: [PATCH 017/231] Reorder app modes initial commit --- .../layout/edit_profiles_list_fragment.xml | 72 +++++++++ OsmAnd/res/values/strings.xml | 1 + OsmAnd/res/xml/settings_main_screen.xml | 1 + .../src/net/osmand/plus/ApplicationMode.java | 68 +++++++-- .../osmand/plus/profiles/ProfilesAdapter.java | 137 ++++++++++++++++++ .../ProfilesItemTouchHelperCallback.java | 57 ++++++++ .../plus/settings/EditProfilesFragment.java | 120 +++++++++++++++ 7 files changed, 442 insertions(+), 14 deletions(-) create mode 100644 OsmAnd/res/layout/edit_profiles_list_fragment.xml create mode 100644 OsmAnd/src/net/osmand/plus/profiles/ProfilesAdapter.java create mode 100644 OsmAnd/src/net/osmand/plus/profiles/ProfilesItemTouchHelperCallback.java create mode 100644 OsmAnd/src/net/osmand/plus/settings/EditProfilesFragment.java diff --git a/OsmAnd/res/layout/edit_profiles_list_fragment.xml b/OsmAnd/res/layout/edit_profiles_list_fragment.xml new file mode 100644 index 0000000000..53d992555a --- /dev/null +++ b/OsmAnd/res/layout/edit_profiles_list_fragment.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 8ee63b8ae0..b3a650da0e 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,7 @@ Thx - Hardy --> + Edit profiles Navigation type affects the rules for route calculations. %1$s • %2$s %1$s, %2$s diff --git a/OsmAnd/res/xml/settings_main_screen.xml b/OsmAnd/res/xml/settings_main_screen.xml index 93739098bf..46c9009625 100644 --- a/OsmAnd/res/xml/settings_main_screen.xml +++ b/OsmAnd/res/xml/settings_main_screen.xml @@ -58,6 +58,7 @@ android:layout="@layout/preference_button" android:persistent="false" android:title="@string/reorder_profiles" + app:fragment="net.osmand.plus.settings.EditProfilesFragment" tools:icon="@drawable/ic_action_edit_dark" /> comparator = new Comparator() { + @Override + public int compare(ApplicationMode o1, ApplicationMode o2) { + return (o1.order < o2.order) ? -1 : ((o1.order == o2.order) ? 0 : 1); + } + }; + Collections.sort(values, comparator); + Collections.sort(customValues, comparator); + Collections.sort(defaultValues, comparator); + Collections.sort(cachedFilteredValues, comparator); + } + public static ApplicationModeBuilder fromJson(OsmandApplication app, String json) { Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); ApplicationModeBean mb = gson.fromJson(json, ApplicationModeBean.class); @@ -677,6 +705,7 @@ public class ApplicationMode { applicationMode.iconColor = modeBean.iconColor; applicationMode.routingProfile = modeBean.routingProfile; applicationMode.routeService = modeBean.routeService; + applicationMode.order = modeBean.order; } } } @@ -689,15 +718,29 @@ public class ApplicationMode { if (!Algorithms.isEmpty(customProfiles)) { for (ApplicationModeBean m : customProfiles) { - ApplicationModeBuilder b = createCustomMode(valueOfStringKey(m.parent, CAR), - m.userProfileName, m.stringKey); - b.setRouteService(m.routeService).setRoutingProfile(m.routingProfile); - b.icon(app, m.iconName); - b.setColor(m.iconColor); - b.customReg(); + ApplicationMode parentMode = valueOfStringKey(m.parent, CAR); + createCustomMode(parentMode, m.userProfileName, m.stringKey) + .setRouteService(m.routeService) + .setRoutingProfile(m.routingProfile) + .icon(app, m.iconName) + .setColor(m.iconColor) + .setOrder(m.order) + .customReg(); } } + } + public static void saveAppModesToSettings(OsmandSettings settings) { + Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); + + List defaultModeBeans = createApplicationModeBeans(defaultValues); + List customModeBeans = createApplicationModeBeans(customValues); + + String defaultProfiles = gson.toJson(defaultModeBeans); + String customProfiles = gson.toJson(customModeBeans); + + settings.DEFAULT_APP_PROFILES.set(defaultProfiles); + settings.CUSTOM_APP_PROFILES.set(customProfiles); } private static void saveAppModesToSettings(OsmandSettings settings, boolean saveCustomModes) { @@ -724,6 +767,7 @@ public class ApplicationMode { mb.stringKey = mode.stringKey; mb.routeService = mode.routeService; mb.routingProfile = mode.routingProfile; + mb.order = mode.order; modeBeans.add(mb); } @@ -740,6 +784,7 @@ public class ApplicationMode { mode.routingProfile = builder.applicationMode.routingProfile; mode.routeService = builder.applicationMode.routeService; mode.iconColor = builder.applicationMode.iconColor; + mode.order = builder.applicationMode.order; } else { mode = builder.customReg(); initRegVisibility(); @@ -807,12 +852,7 @@ public class ApplicationMode { } public int getColor(boolean nightMode) { - if (nightMode) { - return nightColor; - } else { - return dayColor; - } + return nightMode ? nightColor : dayColor; } - } - + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/profiles/ProfilesAdapter.java b/OsmAnd/src/net/osmand/plus/profiles/ProfilesAdapter.java new file mode 100644 index 0000000000..9cac42f24b --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/profiles/ProfilesAdapter.java @@ -0,0 +1,137 @@ +package net.osmand.plus.profiles; + +import android.graphics.drawable.Drawable; +import android.support.annotation.NonNull; +import android.support.v4.content.ContextCompat; +import android.support.v4.view.MotionEventCompat; +import android.support.v7.widget.RecyclerView; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; + +import net.osmand.AndroidUtils; +import net.osmand.plus.ApplicationMode; +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.settings.BaseSettingsFragment; + +import java.util.Collections; +import java.util.List; + +public class ProfilesAdapter extends AbstractProfileMenuAdapter + implements ProfilesItemTouchHelperCallback.ItemTouchHelperAdapter { + + private OsmandApplication app; + private List applicationModes; + private ProfilesAdapterListener listener; + + private boolean nightMode; + + public ProfilesAdapter(MapActivity mapActivity, List applicationModes) { + setHasStableIds(true); + app = mapActivity.getMyApplication(); + this.applicationModes = applicationModes; + nightMode = !mapActivity.getMyApplication().getSettings().isLightContent(); + } + + public void setAdapterListener(ProfilesAdapterListener listener) { + this.listener = listener; + } + + @NonNull + @Override + public SelectProfileViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { + View itemView = UiUtilities.getInflater(viewGroup.getContext(), nightMode).inflate(R.layout.profile_list_item, null); + itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + listener.onItemClick(view); + } + }); + return new SelectProfileViewHolder(itemView); + } + + @Override + public void onBindViewHolder(final SelectProfileViewHolder holder, final int pos) { + ApplicationMode mode = applicationModes.get(pos); + + holder.icon.setVisibility(View.VISIBLE); + holder.descr.setVisibility(View.VISIBLE); + holder.switcher.setVisibility(View.GONE); + holder.menuIcon.setVisibility(View.VISIBLE); + + holder.title.setText(mode.toHumanString(app)); + holder.descr.setText(BaseSettingsFragment.getAppModeDescription(app, mode)); + + //set up cell color + int profileColorResId = mode.getIconColorInfo().getColor(nightMode); + int colorNoAlpha = ContextCompat.getColor(app, profileColorResId); + Drawable drawable = UiUtilities.getColoredSelectableDrawable(app, colorNoAlpha, 0.3f); + + AndroidUtils.setBackground(holder.profileOptions, drawable); + + updateViewHolder(holder, mode); + + holder.menuIcon.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent event) { + if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { + listener.onDragStarted(holder); + } + return false; + } + }); + } + + @Override + public int getItemCount() { + return applicationModes.size(); + } + + @Override + public boolean onItemMove(int from, int to) { + Collections.swap(applicationModes, from, to); + notifyItemMoved(from, to); + return true; + } + + @Override + public long getItemId(int position) { + return applicationModes.get(position).hashCode(); + } + + @Override + public void onItemDismiss(RecyclerView.ViewHolder holder) { + listener.onDragOrSwipeEnded(holder); + } + + private void updateViewHolder(SelectProfileViewHolder holder, ApplicationMode mode) { + int iconRes = mode.getIconRes(); + if (iconRes == 0 || iconRes == -1) { + iconRes = R.drawable.ic_action_world_globe; + } + int selectedIconColorRes = mode.getIconColorInfo().getColor(nightMode); + holder.icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, selectedIconColorRes)); + } + + public ApplicationMode getItem(int position) { + return applicationModes.get(position); + } + + class SelectProfileViewHolder extends ProfileAbstractViewHolder { + SelectProfileViewHolder(View itemView) { + super(itemView); + } + } + + public interface ProfilesAdapterListener { + + void onItemClick(View view); + + void onDragStarted(RecyclerView.ViewHolder holder); + + void onDragOrSwipeEnded(RecyclerView.ViewHolder holder); + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/profiles/ProfilesItemTouchHelperCallback.java b/OsmAnd/src/net/osmand/plus/profiles/ProfilesItemTouchHelperCallback.java new file mode 100644 index 0000000000..bfbb075c8e --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/profiles/ProfilesItemTouchHelperCallback.java @@ -0,0 +1,57 @@ +package net.osmand.plus.profiles; + +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.helper.ItemTouchHelper; + +public class ProfilesItemTouchHelperCallback extends ItemTouchHelper.Callback { + + private ProfilesItemTouchHelperCallback.ItemTouchHelperAdapter adapter; + + public ProfilesItemTouchHelperCallback(ProfilesItemTouchHelperCallback.ItemTouchHelperAdapter adapter) { + this.adapter = adapter; + } + + @Override + public boolean isLongPressDragEnabled() { + return false; + } + + @Override + public boolean isItemViewSwipeEnabled() { + return false; + } + + @Override + public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { + + } + + @Override + public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { + final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; + return makeMovementFlags(dragFlags, 0); + } + + @Override + public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder source, RecyclerView.ViewHolder target) { + int from = source.getAdapterPosition(); + int to = target.getAdapterPosition(); + if (from == RecyclerView.NO_POSITION || to == RecyclerView.NO_POSITION) { + return false; + } + return adapter.onItemMove(from, to); + } + + @Override + public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { + super.clearView(recyclerView, viewHolder); + adapter.onItemDismiss(viewHolder); + } + + interface ItemTouchHelperAdapter { + + boolean onItemMove(int from, int to); + + void onItemDismiss(RecyclerView.ViewHolder holder); + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/EditProfilesFragment.java b/OsmAnd/src/net/osmand/plus/settings/EditProfilesFragment.java new file mode 100644 index 0000000000..b1c8d0b598 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/settings/EditProfilesFragment.java @@ -0,0 +1,120 @@ +package net.osmand.plus.settings; + +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v4.app.FragmentActivity; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.helper.ItemTouchHelper; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageButton; +import android.widget.TextView; + +import net.osmand.AndroidUtils; +import net.osmand.plus.ApplicationMode; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.base.BaseOsmAndFragment; +import net.osmand.plus.profiles.ProfilesAdapter; +import net.osmand.plus.profiles.ProfilesItemTouchHelperCallback; + +import java.util.ArrayList; +import java.util.List; + +public class EditProfilesFragment extends BaseOsmAndFragment { + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + MapActivity mapActivity = (MapActivity) getActivity(); + View mainView = inflater.inflate(R.layout.edit_profiles_list_fragment, container, false); + AndroidUtils.addStatusBarPadding21v(getContext(), mainView); + + ImageButton closeButton = mainView.findViewById(R.id.close_button); + closeButton.setImageResource(R.drawable.ic_action_remove_dark); + closeButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + FragmentActivity fragmentActivity = getActivity(); + if (fragmentActivity != null) { + fragmentActivity.onBackPressed(); + } + } + }); + + TextView toolbarTitle = mainView.findViewById(R.id.toolbar_title); + toolbarTitle.setText(R.string.edit_profiles); + + RecyclerView recyclerView = mainView.findViewById(R.id.profiles_list); + recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); + + final List applicationModes = new ArrayList<>(ApplicationMode.allPossibleValues()); + final ProfilesAdapter adapter = new ProfilesAdapter(mapActivity, applicationModes); + final ItemTouchHelper touchHelper = new ItemTouchHelper(new ProfilesItemTouchHelperCallback(adapter)); + + touchHelper.attachToRecyclerView(recyclerView); + adapter.setAdapterListener(new ProfilesAdapter.ProfilesAdapterListener() { + + private int fromPosition; + private int toPosition; + + @Override + public void onItemClick(View view) { + + } + + @Override + public void onDragStarted(RecyclerView.ViewHolder holder) { + fromPosition = holder.getAdapterPosition(); + touchHelper.startDrag(holder); + } + + @Override + public void onDragOrSwipeEnded(RecyclerView.ViewHolder holder) { + toPosition = holder.getAdapterPosition(); + if (toPosition >= 0 && fromPosition >= 0 && toPosition != fromPosition) { + adapter.notifyDataSetChanged(); + } + } + }); + + recyclerView.setAdapter(adapter); + + View cancelButton = mainView.findViewById(R.id.cancel_button); + UiUtilities.setupDialogButton(false, cancelButton, UiUtilities.DialogButtonType.SECONDARY, R.string.shared_string_cancel); + cancelButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + FragmentActivity fragmentActivity = getActivity(); + if (fragmentActivity != null) { + fragmentActivity.onBackPressed(); + } + } + }); + + View applyButton = mainView.findViewById(R.id.apply_button); + UiUtilities.setupDialogButton(false, applyButton, UiUtilities.DialogButtonType.PRIMARY, R.string.shared_string_apply); + applyButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + MapActivity mapActivity = (MapActivity) getActivity(); + if (mapActivity != null) { + OsmandSettings settings = mapActivity.getMyApplication().getSettings(); + for (int i = 0; i < applicationModes.size(); i++) { + ApplicationMode mode = applicationModes.get(i); + mode.setOrder(i); + } + ApplicationMode.reorderAppModes(); + ApplicationMode.saveAppModesToSettings(settings); + mapActivity.onBackPressed(); + } + } + }); + + return mainView; + } +} \ No newline at end of file From 521a6911445ae3c398570420f97b253d75ced848 Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 12 Dec 2019 16:00:31 +0200 Subject: [PATCH 018/231] Add base reorder item touch helper callback --- .../MeasurementToolFragment.java | 4 +- .../adapter/MeasurementToolAdapter.java | 3 +- ...easurementToolItemTouchHelperCallback.java | 53 ------------- .../osmand/plus/profiles/ProfilesAdapter.java | 2 +- ...va => ReorderItemTouchHelperCallback.java} | 46 ++++++------ .../QuickActionItemTouchHelperCallback.java | 74 +++++-------------- .../quickaction/QuickActionListFragment.java | 39 ++++------ .../plus/quickaction/SwitchableAction.java | 28 +++---- .../plus/settings/EditProfilesFragment.java | 4 +- 9 files changed, 76 insertions(+), 177 deletions(-) delete mode 100644 OsmAnd/src/net/osmand/plus/measurementtool/adapter/MeasurementToolItemTouchHelperCallback.java rename OsmAnd/src/net/osmand/plus/profiles/{ProfilesItemTouchHelperCallback.java => ReorderItemTouchHelperCallback.java} (60%) diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index c1fe3d0ed2..907779eb4b 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -63,12 +63,12 @@ import net.osmand.plus.measurementtool.SelectedPointBottomSheetDialogFragment.Se import net.osmand.plus.measurementtool.SnapToRoadBottomSheetDialogFragment.SnapToRoadFragmentListener; import net.osmand.plus.measurementtool.adapter.MeasurementToolAdapter; import net.osmand.plus.measurementtool.adapter.MeasurementToolAdapter.MeasurementAdapterListener; -import net.osmand.plus.measurementtool.adapter.MeasurementToolItemTouchHelperCallback; import net.osmand.plus.measurementtool.command.AddPointCommand; import net.osmand.plus.measurementtool.command.ClearPointsCommand; import net.osmand.plus.measurementtool.command.MovePointCommand; import net.osmand.plus.measurementtool.command.RemovePointCommand; import net.osmand.plus.measurementtool.command.ReorderPointCommand; +import net.osmand.plus.profiles.ReorderItemTouchHelperCallback; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; @@ -452,7 +452,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment { } else { pointsRv = new RecyclerView(getActivity()); } - final ItemTouchHelper touchHelper = new ItemTouchHelper(new MeasurementToolItemTouchHelperCallback(adapter)); + ItemTouchHelper touchHelper = new ItemTouchHelper(new ReorderItemTouchHelperCallback(adapter)); touchHelper.attachToRecyclerView(pointsRv); adapter.setAdapterListener(createMeasurementAdapterListener(touchHelper)); pointsRv.setLayoutManager(new LinearLayoutManager(getContext())); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/adapter/MeasurementToolAdapter.java b/OsmAnd/src/net/osmand/plus/measurementtool/adapter/MeasurementToolAdapter.java index a1c8d5f471..cd5fb5c3de 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/adapter/MeasurementToolAdapter.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/adapter/MeasurementToolAdapter.java @@ -20,12 +20,13 @@ import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.measurementtool.NewGpxData.ActionType; +import net.osmand.plus.profiles.ReorderItemTouchHelperCallback; import java.util.Collections; import java.util.List; public class MeasurementToolAdapter extends RecyclerView.Adapter - implements MeasurementToolItemTouchHelperCallback.ItemTouchHelperAdapter { + implements ReorderItemTouchHelperCallback.OnItemMoveCallback { private final MapActivity mapActivity; private final List points; diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/adapter/MeasurementToolItemTouchHelperCallback.java b/OsmAnd/src/net/osmand/plus/measurementtool/adapter/MeasurementToolItemTouchHelperCallback.java deleted file mode 100644 index 5c5c4d1e7c..0000000000 --- a/OsmAnd/src/net/osmand/plus/measurementtool/adapter/MeasurementToolItemTouchHelperCallback.java +++ /dev/null @@ -1,53 +0,0 @@ -package net.osmand.plus.measurementtool.adapter; - -import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.helper.ItemTouchHelper; - - -public class MeasurementToolItemTouchHelperCallback extends ItemTouchHelper.Callback { - - private final ItemTouchHelperAdapter adapter; - - public MeasurementToolItemTouchHelperCallback(ItemTouchHelperAdapter adapter) { - this.adapter = adapter; - } - - @Override - public boolean isLongPressDragEnabled() { - return false; - } - - @Override - public boolean isItemViewSwipeEnabled() { - return false; - } - - @Override - public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { - final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; - return makeMovementFlags(dragFlags, 0); - } - - @Override - public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder source, RecyclerView.ViewHolder target) { - return adapter.onItemMove(source.getAdapterPosition(), target.getAdapterPosition()); - } - - @Override - public void onSwiped(RecyclerView.ViewHolder viewHolder, int i) { - - } - - @Override - public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { - super.clearView(recyclerView, viewHolder); - adapter.onItemDismiss(viewHolder); - } - - interface ItemTouchHelperAdapter { - - boolean onItemMove(int from, int to); - - void onItemDismiss(RecyclerView.ViewHolder holder); - } -} diff --git a/OsmAnd/src/net/osmand/plus/profiles/ProfilesAdapter.java b/OsmAnd/src/net/osmand/plus/profiles/ProfilesAdapter.java index 9cac42f24b..c754eba79c 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/ProfilesAdapter.java +++ b/OsmAnd/src/net/osmand/plus/profiles/ProfilesAdapter.java @@ -21,7 +21,7 @@ import java.util.Collections; import java.util.List; public class ProfilesAdapter extends AbstractProfileMenuAdapter - implements ProfilesItemTouchHelperCallback.ItemTouchHelperAdapter { + implements ReorderItemTouchHelperCallback.OnItemMoveCallback { private OsmandApplication app; private List applicationModes; diff --git a/OsmAnd/src/net/osmand/plus/profiles/ProfilesItemTouchHelperCallback.java b/OsmAnd/src/net/osmand/plus/profiles/ReorderItemTouchHelperCallback.java similarity index 60% rename from OsmAnd/src/net/osmand/plus/profiles/ProfilesItemTouchHelperCallback.java rename to OsmAnd/src/net/osmand/plus/profiles/ReorderItemTouchHelperCallback.java index bfbb075c8e..0dce4ca014 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/ProfilesItemTouchHelperCallback.java +++ b/OsmAnd/src/net/osmand/plus/profiles/ReorderItemTouchHelperCallback.java @@ -3,12 +3,13 @@ package net.osmand.plus.profiles; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.helper.ItemTouchHelper; -public class ProfilesItemTouchHelperCallback extends ItemTouchHelper.Callback { - private ProfilesItemTouchHelperCallback.ItemTouchHelperAdapter adapter; +public class ReorderItemTouchHelperCallback extends ItemTouchHelper.Callback { - public ProfilesItemTouchHelperCallback(ProfilesItemTouchHelperCallback.ItemTouchHelperAdapter adapter) { - this.adapter = adapter; + private OnItemMoveCallback itemMoveCallback; + + public ReorderItemTouchHelperCallback(OnItemMoveCallback itemMoveCallback) { + this.itemMoveCallback = itemMoveCallback; } @Override @@ -21,34 +22,35 @@ public class ProfilesItemTouchHelperCallback extends ItemTouchHelper.Callback { return false; } + @Override + public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { + int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; + int swipeFlags = 0; + return makeMovementFlags(dragFlags, swipeFlags); + } + + @Override + public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { + int from = viewHolder.getAdapterPosition(); + int to = target.getAdapterPosition(); + if (from == RecyclerView.NO_POSITION || to == RecyclerView.NO_POSITION) { + return false; + } + return itemMoveCallback.onItemMove(from, to); + } + @Override public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { } - @Override - public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { - final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; - return makeMovementFlags(dragFlags, 0); - } - - @Override - public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder source, RecyclerView.ViewHolder target) { - int from = source.getAdapterPosition(); - int to = target.getAdapterPosition(); - if (from == RecyclerView.NO_POSITION || to == RecyclerView.NO_POSITION) { - return false; - } - return adapter.onItemMove(from, to); - } - @Override public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { super.clearView(recyclerView, viewHolder); - adapter.onItemDismiss(viewHolder); + itemMoveCallback.onItemDismiss(viewHolder); } - interface ItemTouchHelperAdapter { + public interface OnItemMoveCallback { boolean onItemMove(int from, int to); diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionItemTouchHelperCallback.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionItemTouchHelperCallback.java index 9d1897028c..dcd129375c 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionItemTouchHelperCallback.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionItemTouchHelperCallback.java @@ -1,67 +1,33 @@ package net.osmand.plus.quickaction; import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.helper.ItemTouchHelper; + +import net.osmand.plus.profiles.ReorderItemTouchHelperCallback; /** * Created by okorsun on 21.12.16. */ -public class QuickActionItemTouchHelperCallback extends ItemTouchHelper.Callback { +public class QuickActionItemTouchHelperCallback extends ReorderItemTouchHelperCallback { - private OnItemMoveCallback itemMoveCallback; + QuickActionItemTouchHelperCallback(OnItemMoveCallback itemMoveCallback) { + super(itemMoveCallback); + } - public QuickActionItemTouchHelperCallback() { - } + @Override + public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { + return !isaHeaderType(viewHolder) ? super.getMovementFlags(recyclerView, viewHolder) : 0; + } - public QuickActionItemTouchHelperCallback(OnItemMoveCallback itemMoveCallback) { - this.itemMoveCallback = itemMoveCallback; - } + @Override + public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { + if (isaHeaderType(viewHolder) || isaHeaderType(target)) { + return false; + } + return super.onMove(recyclerView, viewHolder, target); + } - public void setItemMoveCallback(OnItemMoveCallback itemMoveCallback) { - this.itemMoveCallback = itemMoveCallback; - } - - @Override - public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { - int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; - int swipeFlags = 0; - return !isaHeaderType(viewHolder) ? makeMovementFlags(dragFlags, swipeFlags) : 0; - - } - - @Override - public boolean isItemViewSwipeEnabled() { - return false; - } - - @Override - public boolean isLongPressDragEnabled() { - return false; - } - - @Override - public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { - super.clearView(recyclerView, viewHolder); - itemMoveCallback.onViewDropped(recyclerView, viewHolder); - } - - @Override - public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { - return itemMoveCallback.onMove(recyclerView, viewHolder, target); - } - - @Override - public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { - - } - - private boolean isaHeaderType(RecyclerView.ViewHolder viewHolder) { - return viewHolder.getItemViewType() == QuickActionListFragment.QuickActionAdapter.SCREEN_HEADER_TYPE; - } - - interface OnItemMoveCallback { - boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target); - void onViewDropped(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder); - } + private boolean isaHeaderType(RecyclerView.ViewHolder viewHolder) { + return viewHolder.getItemViewType() == QuickActionListFragment.QuickActionAdapter.SCREEN_HEADER_TYPE; + } } diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java index 86532e7aee..d4bb874bb9 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java @@ -363,35 +363,26 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick } @Override - public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { - if (viewHolder.getItemViewType() == SCREEN_HEADER_TYPE || target.getItemViewType() == SCREEN_HEADER_TYPE) - return false; - else { - int selectedPosition = viewHolder.getAdapterPosition(); - int targetPosition = target.getAdapterPosition(); - Log.v(TAG, "selected: " + selectedPosition + ", target: " + targetPosition); + public boolean onItemMove(int selectedPosition, int targetPosition) { + Log.v(TAG, "selected: " + selectedPosition + ", target: " + targetPosition); - if (selectedPosition < 0 || targetPosition < 0) - return false; - - Collections.swap(itemsList, selectedPosition, targetPosition); - if (selectedPosition - targetPosition < -1) { - notifyItemMoved(selectedPosition, targetPosition); - notifyItemMoved(targetPosition - 1, selectedPosition); - } else if (selectedPosition - targetPosition > 1) { - notifyItemMoved(selectedPosition, targetPosition); - notifyItemMoved(targetPosition + 1, selectedPosition); - } else { - notifyItemMoved(selectedPosition, targetPosition); - } - notifyItemChanged(selectedPosition); - notifyItemChanged(targetPosition); - return true; + Collections.swap(itemsList, selectedPosition, targetPosition); + if (selectedPosition - targetPosition < -1) { + notifyItemMoved(selectedPosition, targetPosition); + notifyItemMoved(targetPosition - 1, selectedPosition); + } else if (selectedPosition - targetPosition > 1) { + notifyItemMoved(selectedPosition, targetPosition); + notifyItemMoved(targetPosition + 1, selectedPosition); + } else { + notifyItemMoved(selectedPosition, targetPosition); } + notifyItemChanged(selectedPosition); + notifyItemChanged(targetPosition); + return true; } @Override - public void onViewDropped(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { + public void onItemDismiss(RecyclerView.ViewHolder holder) { saveQuickActions(); } diff --git a/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java b/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java index 76a3ce9e57..f3258317c7 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java @@ -33,6 +33,8 @@ public abstract class SwitchableAction extends QuickAction { private transient EditText title; + private transient ItemTouchHelper touchHelper; + protected SwitchableAction(int type) { super(type); } @@ -56,20 +58,17 @@ public abstract class SwitchableAction extends QuickAction { if (!getParams().isEmpty()) { showDialog.setChecked(Boolean.valueOf(getParams().get(KEY_DIALOG))); } - - final RecyclerView list = (RecyclerView) view.findViewById(R.id.list); - final QuickActionItemTouchHelperCallback touchHelperCallback = new QuickActionItemTouchHelperCallback(); - final ItemTouchHelper touchHelper = new ItemTouchHelper(touchHelperCallback); - - final Adapter adapter = new Adapter(activity, new QuickActionListFragment.OnStartDragListener() { + RecyclerView list = (RecyclerView) view.findViewById(R.id.list); + Adapter adapter = new Adapter(activity, new QuickActionListFragment.OnStartDragListener() { @Override public void onStartDrag(RecyclerView.ViewHolder viewHolder) { touchHelper.startDrag(viewHolder); } }); - touchHelperCallback.setItemMoveCallback(adapter); + QuickActionItemTouchHelperCallback touchHelperCallback = new QuickActionItemTouchHelperCallback(adapter); + touchHelper = new ItemTouchHelper(touchHelperCallback); touchHelper.attachToRecyclerView(list); if (!getParams().isEmpty()) { @@ -215,17 +214,9 @@ public abstract class SwitchableAction extends QuickAction { } @Override - public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { - - int selectedPosition = viewHolder.getAdapterPosition(); - int targetPosition = target.getAdapterPosition(); - - if (selectedPosition < 0 || targetPosition < 0) { - return false; - } - + public boolean onItemMove(int selectedPosition, int targetPosition) { String oldTitle = getTitle(itemsList); - String defaultName = recyclerView.getContext().getString(getNameRes()); + String defaultName = context.getString(getNameRes()); Collections.swap(itemsList, selectedPosition, targetPosition); if (selectedPosition - targetPosition < -1) { @@ -256,7 +247,8 @@ public abstract class SwitchableAction extends QuickAction { } @Override - public void onViewDropped(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { + public void onItemDismiss(RecyclerView.ViewHolder holder) { + } public class ItemHolder extends RecyclerView.ViewHolder { diff --git a/OsmAnd/src/net/osmand/plus/settings/EditProfilesFragment.java b/OsmAnd/src/net/osmand/plus/settings/EditProfilesFragment.java index b1c8d0b598..5e71071ab2 100644 --- a/OsmAnd/src/net/osmand/plus/settings/EditProfilesFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/EditProfilesFragment.java @@ -20,7 +20,7 @@ import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.profiles.ProfilesAdapter; -import net.osmand.plus.profiles.ProfilesItemTouchHelperCallback; +import net.osmand.plus.profiles.ReorderItemTouchHelperCallback; import java.util.ArrayList; import java.util.List; @@ -54,7 +54,7 @@ public class EditProfilesFragment extends BaseOsmAndFragment { final List applicationModes = new ArrayList<>(ApplicationMode.allPossibleValues()); final ProfilesAdapter adapter = new ProfilesAdapter(mapActivity, applicationModes); - final ItemTouchHelper touchHelper = new ItemTouchHelper(new ProfilesItemTouchHelperCallback(adapter)); + final ItemTouchHelper touchHelper = new ItemTouchHelper(new ReorderItemTouchHelperCallback(adapter)); touchHelper.attachToRecyclerView(recyclerView); adapter.setAdapterListener(new ProfilesAdapter.ProfilesAdapterListener() { From a57480406d22d50e2e74fbe533d4abad2c18dc6c Mon Sep 17 00:00:00 2001 From: max-klaus Date: Thu, 12 Dec 2019 17:42:18 +0300 Subject: [PATCH 019/231] Added free Huawei build --- OsmAnd/AndroidManifest-freehuawei.xml | 25 +++++++++++++++++++ OsmAnd/build.gradle | 4 +++ .../osmand/plus/helpers/DiscountHelper.java | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 OsmAnd/AndroidManifest-freehuawei.xml diff --git a/OsmAnd/AndroidManifest-freehuawei.xml b/OsmAnd/AndroidManifest-freehuawei.xml new file mode 100644 index 0000000000..9fe9a01ccf --- /dev/null +++ b/OsmAnd/AndroidManifest-freehuawei.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/build.gradle b/OsmAnd/build.gradle index 95424a01d6..2841dfcff3 100644 --- a/OsmAnd/build.gradle +++ b/OsmAnd/build.gradle @@ -189,6 +189,10 @@ android { dimension "version" applicationId "net.osmand.plus.huawei" } + freehuawei { + dimension "version" + applicationId "net.osmand.huawei" + } // CoreVersion legacy { diff --git a/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java b/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java index 0baafab662..cc1867fded 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java @@ -80,7 +80,7 @@ public class DiscountHelper { public static void checkAndDisplay(final MapActivity mapActivity) { OsmandApplication app = mapActivity.getMyApplication(); OsmandSettings settings = app.getSettings(); - if (settings.DO_NOT_SHOW_STARTUP_MESSAGES.get() || !settings.INAPPS_READ.get()) { + if (settings.DO_NOT_SHOW_STARTUP_MESSAGES.get() || !settings.INAPPS_READ.get() || Version.isHuawei(app)) { return; } if (mBannerVisible) { From 8e173260e1f83de225ab74755b70b9570bc17fbd Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 12 Dec 2019 19:10:11 +0200 Subject: [PATCH 020/231] Reorder screen ui polishing first part --- OsmAnd/res/layout/profile_edit_list_item.xml | 90 +++++++++++++++++++ OsmAnd/res/values/strings.xml | 1 + OsmAnd/res/xml/settings_main_screen.xml | 2 +- .../EditProfilesFragment.java | 9 +- .../osmand/plus/profiles/ProfilesAdapter.java | 87 ++++++++++-------- .../ReorderItemTouchHelperCallback.java | 4 +- .../QuickActionItemTouchHelperCallback.java | 6 +- 7 files changed, 147 insertions(+), 52 deletions(-) create mode 100644 OsmAnd/res/layout/profile_edit_list_item.xml rename OsmAnd/src/net/osmand/plus/{settings => profiles}/EditProfilesFragment.java (95%) diff --git a/OsmAnd/res/layout/profile_edit_list_item.xml b/OsmAnd/res/layout/profile_edit_list_item.xml new file mode 100644 index 0000000000..180ebbad6f --- /dev/null +++ b/OsmAnd/res/layout/profile_edit_list_item.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 01f6c91871..5a31278996 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -12,6 +12,7 @@ --> Downloading %s + You can’t delete default OsmAnd profiles, but you can disable them in previous screen, or move them to the bottom. Edit profiles Navigation type affects the rules for route calculations. %1$s • %2$s diff --git a/OsmAnd/res/xml/settings_main_screen.xml b/OsmAnd/res/xml/settings_main_screen.xml index 46c9009625..bfadaaa473 100644 --- a/OsmAnd/res/xml/settings_main_screen.xml +++ b/OsmAnd/res/xml/settings_main_screen.xml @@ -58,7 +58,7 @@ android:layout="@layout/preference_button" android:persistent="false" android:title="@string/reorder_profiles" - app:fragment="net.osmand.plus.settings.EditProfilesFragment" + app:fragment="net.osmand.plus.profiles.EditProfilesFragment" tools:icon="@drawable/ic_action_edit_dark" /> +public class ProfilesAdapter extends RecyclerView.Adapter implements ReorderItemTouchHelperCallback.OnItemMoveCallback { private OsmandApplication app; + private UiUtilities uiUtilities; private List applicationModes; private ProfilesAdapterListener listener; private boolean nightMode; - public ProfilesAdapter(MapActivity mapActivity, List applicationModes) { + public ProfilesAdapter(MapActivity mapActivity, List appModes) { setHasStableIds(true); app = mapActivity.getMyApplication(); - this.applicationModes = applicationModes; + uiUtilities = app.getUIUtilities(); + applicationModes = appModes; nightMode = !mapActivity.getMyApplication().getSettings().isLightContent(); } @@ -42,39 +49,23 @@ public class ProfilesAdapter extends AbstractProfileMenuAdapter Date: Thu, 12 Dec 2019 13:55:25 +0000 Subject: [PATCH 021/231] Translated using Weblate (Hungarian) Currently translated at 86.0% (2649 of 3082 strings) --- OsmAnd/res/values-hu/strings.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OsmAnd/res/values-hu/strings.xml b/OsmAnd/res/values-hu/strings.xml index 9807e2edcc..d487a63db3 100644 --- a/OsmAnd/res/values-hu/strings.xml +++ b/OsmAnd/res/values-hu/strings.xml @@ -3234,4 +3234,9 @@ Kérlek adj meg egy teljes kódot Párbeszédablakok és értesítések OsmAnd használata közben megjelenő felugró üzenetek, párbeszédablakok és értesítések beállításai. Javasolt térképek + Hozzáadod az új \'%1$s\' profilt\? + %1$s • %2$s + %1$s, %2$s + Személyes + %s letöltés \ No newline at end of file From c42b2aabec469f5ff47eb3f0070a7786742989da Mon Sep 17 00:00:00 2001 From: Mr-Update Date: Wed, 11 Dec 2019 22:06:25 +0000 Subject: [PATCH 022/231] Translated using Weblate (German) Currently translated at 100.0% (3082 of 3082 strings) --- OsmAnd/res/values-de/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index 46564c5c84..4b49c2fa7c 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -3404,4 +3404,8 @@ Lon %2$s Neues Profil \'%1$s\' hinzufügen\? Überschrift einbeziehen Überschrift zu jedem Trackpoint während der Aufnahme speichern. + %1$s • %2$s + %1$s, %2$s + Persönlich + %s herunterladen \ No newline at end of file From aa2ee02be807795746bdf3a937af174f0aab1b0c Mon Sep 17 00:00:00 2001 From: Enol P Date: Thu, 12 Dec 2019 18:47:47 +0000 Subject: [PATCH 023/231] Translated using Weblate (Asturian) Currently translated at 40.0% (1233 of 3082 strings) --- OsmAnd/res/values-b+ast/strings.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-b+ast/strings.xml b/OsmAnd/res/values-b+ast/strings.xml index 1c5b261a78..0b6c15ae19 100644 --- a/OsmAnd/res/values-b+ast/strings.xml +++ b/OsmAnd/res/values-b+ast/strings.xml @@ -696,8 +696,8 @@ %1$.2f %2$s/mes La soscripción actual %1$.2f %2$s - Esbilla\'l periodu de pagu más afayadizu pa ti: - Parte de los ingresos van pa los collaboradores d\'OpenStreetMap. + Intervalu de pagu: + Les donaciones ayuden a financiar la cartografía d\'OpenStreetMap ¿Desaniciar el marcador «%s» del mapa\? Aplicación de terceros Unvia una captura d\'esti avisu a support@osmand.net, por favor @@ -1394,4 +1394,6 @@ Tolos axustes qu\'apaecen darréu afeuten únicamente al perfil escoyíu. Exemplu Hora d\'activamientu + Z-A + A-Z \ No newline at end of file From 78195ee7939e6796a3556a521a265a1b91ef3785 Mon Sep 17 00:00:00 2001 From: josep constanti Date: Thu, 12 Dec 2019 20:16:13 +0000 Subject: [PATCH 024/231] Translated using Weblate (Catalan) Currently translated at 88.5% (2727 of 3082 strings) --- OsmAnd/res/values-ca/strings.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OsmAnd/res/values-ca/strings.xml b/OsmAnd/res/values-ca/strings.xml index 9720e43149..8dbf85b19b 100644 --- a/OsmAnd/res/values-ca/strings.xml +++ b/OsmAnd/res/values-ca/strings.xml @@ -3397,4 +3397,10 @@ Abasta l\'àrea: %1$s x %2$s Voleu netejar %1$s\? Diàlegs i notificacions Emergents de control, diàlegs i notificacions que surten a OsmAnd mentre s\'utilitza. + Uneix segments + Voleu afegir el perfil nou \'%1$s\'\? + %1$s • %2$s + %1$s, %2$s + Personal + S\'està baixant %s \ No newline at end of file From 03d83a03fc8edc2d951b1d453bd2da380e7d3c3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Babos=20G=C3=A1bor?= Date: Thu, 12 Dec 2019 21:19:04 +0000 Subject: [PATCH 025/231] Translated using Weblate (Hungarian) Currently translated at 86.0% (2649 of 3082 strings) --- OsmAnd/res/values-hu/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-hu/strings.xml b/OsmAnd/res/values-hu/strings.xml index d487a63db3..d97830a66f 100644 --- a/OsmAnd/res/values-hu/strings.xml +++ b/OsmAnd/res/values-hu/strings.xml @@ -3238,5 +3238,5 @@ Kérlek adj meg egy teljes kódot %1$s • %2$s %1$s, %2$s Személyes - %s letöltés + %s letöltése \ No newline at end of file From 3379d91fe96da80c35efc5825c89bda9a3d49f1f Mon Sep 17 00:00:00 2001 From: Software In Interlingua Date: Thu, 12 Dec 2019 04:12:43 +0000 Subject: [PATCH 026/231] Translated using Weblate (Interlingua) Currently translated at 0.1% (2 of 3082 strings) --- OsmAnd/res/values-ia/strings.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-ia/strings.xml b/OsmAnd/res/values-ia/strings.xml index a6b3daec93..f2bfe4caa2 100644 --- a/OsmAnd/res/values-ia/strings.xml +++ b/OsmAnd/res/values-ia/strings.xml @@ -1,2 +1,5 @@ - \ No newline at end of file + + Adder nove profilo \'%1$s\'\? + Discargante %s + \ No newline at end of file From d7647b58416572a10bb88b3c170dfd04f7ad30bf Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Thu, 12 Dec 2019 05:26:36 +0000 Subject: [PATCH 027/231] Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (3082 of 3082 strings) --- OsmAnd/res/values-zh-rTW/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml index 6e50460057..1c36afb205 100644 --- a/OsmAnd/res/values-zh-rTW/strings.xml +++ b/OsmAnd/res/values-zh-rTW/strings.xml @@ -3386,4 +3386,8 @@ 新增新的設定檔「%1$s」? 包含標題 在錄製時將標題儲存到每個追蹤點。 + %1$s • %2$s + %1$s, %2$s + 個人 + 正在下載 %s \ No newline at end of file From 36e13eccf352f7f3d86898083026c8a1c6ee65bf Mon Sep 17 00:00:00 2001 From: Mr-Update Date: Wed, 11 Dec 2019 22:14:12 +0000 Subject: [PATCH 028/231] Translated using Weblate (German) Currently translated at 100.0% (3748 of 3748 strings) --- OsmAnd/res/values-de/phrases.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-de/phrases.xml b/OsmAnd/res/values-de/phrases.xml index 16deab90be..32efd45c70 100644 --- a/OsmAnd/res/values-de/phrases.xml +++ b/OsmAnd/res/values-de/phrases.xml @@ -1337,7 +1337,7 @@ Rettungsstation Mini-Kreisverkehr Bahnübergang - Vögelbeobachtungspunkt + Vogelbeobachtungspunkt Garten Heide Gras From 39cad2275356498615f77f74ce30be113b49f40f Mon Sep 17 00:00:00 2001 From: Mr-Update Date: Thu, 12 Dec 2019 21:35:13 +0000 Subject: [PATCH 029/231] Translated using Weblate (German) Currently translated at 100.0% (3082 of 3082 strings) --- OsmAnd/res/values-de/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index 4b49c2fa7c..e7d08b3706 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -3402,8 +3402,8 @@ Lon %2$s Diese Karten sind für die Verwendung mit dem Plugin erforderlich Segmente verbinden Neues Profil \'%1$s\' hinzufügen\? - Überschrift einbeziehen - Überschrift zu jedem Trackpoint während der Aufnahme speichern. + Richtung einbeziehen + Richtung zu jedem Trackpunkt während der Aufnahme speichern. %1$s • %2$s %1$s, %2$s Persönlich From cc52eb9fa05e82696344b74fef02d776219c7bd8 Mon Sep 17 00:00:00 2001 From: nautilusx Date: Thu, 12 Dec 2019 21:44:49 +0000 Subject: [PATCH 030/231] Translated using Weblate (German) Currently translated at 100.0% (3082 of 3082 strings) --- OsmAnd/res/values-de/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index e7d08b3706..5e6a911b98 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -3251,7 +3251,7 @@ Lon %2$s Karte während der Navigation auf Sperrbildschirm anzeigen. Einstellungen für die Routenplanung des gewählten Profils „%1$s“. Aufwachzeit - Einheiten und Formate + Einheiten & Formate Aussehen Kartendarstellung Kartendarstellung From ea6ed705c4c12a6d9f9ad9e4a0bbcb56d841c9f2 Mon Sep 17 00:00:00 2001 From: nautilusx Date: Thu, 12 Dec 2019 21:44:24 +0000 Subject: [PATCH 031/231] Translated using Weblate (German) Currently translated at 99.2% (254 of 256 strings) Translation: OsmAnd/Telegram Translate-URL: https://hosted.weblate.org/projects/osmand/telegram/de/ --- OsmAnd-telegram/res/values-de/strings.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OsmAnd-telegram/res/values-de/strings.xml b/OsmAnd-telegram/res/values-de/strings.xml index 918ebcbaf6..9a1bdda2b1 100644 --- a/OsmAnd-telegram/res/values-de/strings.xml +++ b/OsmAnd-telegram/res/values-de/strings.xml @@ -251,4 +251,9 @@ Anwenden Dauer der Anzeige auswählen Gespeicherte Nachrichten + Zeitzone + Einheiten & Formate + Längeneinheiten + Geschwindigkeitseinheit festlegen. + Geschwindigkeitseinheit \ No newline at end of file From c93859b117c795056bc04203735df5395bb6e380 Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 13 Dec 2019 15:56:59 +0200 Subject: [PATCH 032/231] Remove unnecessary item touch helper --- OsmAnd/res/values/strings.xml | 1 + .../ReorderItemTouchHelperCallback.java | 18 +++++++++- .../QuickActionItemTouchHelperCallback.java | 33 ------------------- .../quickaction/QuickActionListFragment.java | 8 +++-- .../plus/quickaction/SwitchableAction.java | 5 +-- .../settings/RouteParametersFragment.java | 6 ++-- 6 files changed, 29 insertions(+), 42 deletions(-) delete mode 100644 OsmAnd/src/net/osmand/plus/quickaction/QuickActionItemTouchHelperCallback.java diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 5a31278996..d3fbbe47fb 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,7 @@ Thx - Hardy --> + After you tap Apply, deleted profiles will be lost completely. Downloading %s You can’t delete default OsmAnd profiles, but you can disable them in previous screen, or move them to the bottom. Edit profiles diff --git a/OsmAnd/src/net/osmand/plus/profiles/ReorderItemTouchHelperCallback.java b/OsmAnd/src/net/osmand/plus/profiles/ReorderItemTouchHelperCallback.java index d81efb9ee2..4b24954760 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/ReorderItemTouchHelperCallback.java +++ b/OsmAnd/src/net/osmand/plus/profiles/ReorderItemTouchHelperCallback.java @@ -2,6 +2,7 @@ package net.osmand.plus.profiles; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.helper.ItemTouchHelper; +import android.view.View; public class ReorderItemTouchHelperCallback extends ItemTouchHelper.Callback { @@ -24,6 +25,9 @@ public class ReorderItemTouchHelperCallback extends ItemTouchHelper.Callback { @Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { + if (isImmobileViewHolder(viewHolder)) { + return 0; + } int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; int swipeFlags = 0; return makeMovementFlags(dragFlags, swipeFlags); @@ -33,12 +37,17 @@ public class ReorderItemTouchHelperCallback extends ItemTouchHelper.Callback { public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder source, RecyclerView.ViewHolder target) { int from = source.getAdapterPosition(); int to = target.getAdapterPosition(); - if (from == RecyclerView.NO_POSITION || to == RecyclerView.NO_POSITION) { + if (from == RecyclerView.NO_POSITION || to == RecyclerView.NO_POSITION + || isImmobileViewHolder(source) || isImmobileViewHolder(target)) { return false; } return itemMoveCallback.onItemMove(from, to); } + private boolean isImmobileViewHolder(RecyclerView.ViewHolder viewHolder) { + return viewHolder instanceof ImmobileViewHolder; + } + @Override public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { @@ -56,4 +65,11 @@ public class ReorderItemTouchHelperCallback extends ItemTouchHelper.Callback { void onItemDismiss(RecyclerView.ViewHolder holder); } + + public static class ImmobileViewHolder extends RecyclerView.ViewHolder { + + public ImmobileViewHolder(View itemView) { + super(itemView); + } + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionItemTouchHelperCallback.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionItemTouchHelperCallback.java deleted file mode 100644 index 4e9ff399b5..0000000000 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionItemTouchHelperCallback.java +++ /dev/null @@ -1,33 +0,0 @@ -package net.osmand.plus.quickaction; - -import android.support.v7.widget.RecyclerView; - -import net.osmand.plus.profiles.ReorderItemTouchHelperCallback; - -/** - * Created by okorsun on 21.12.16. - */ - -public class QuickActionItemTouchHelperCallback extends ReorderItemTouchHelperCallback { - - QuickActionItemTouchHelperCallback(OnItemMoveCallback itemMoveCallback) { - super(itemMoveCallback); - } - - @Override - public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { - return !isaHeaderType(viewHolder) ? super.getMovementFlags(recyclerView, viewHolder) : 0; - } - - @Override - public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder source, RecyclerView.ViewHolder target) { - if (isaHeaderType(source) || isaHeaderType(target)) { - return false; - } - return super.onMove(recyclerView, source, target); - } - - private boolean isaHeaderType(RecyclerView.ViewHolder viewHolder) { - return viewHolder.getItemViewType() == QuickActionListFragment.QuickActionAdapter.SCREEN_HEADER_TYPE; - } -} diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java index d4bb874bb9..72be7ca32a 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java @@ -28,6 +28,7 @@ import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.BaseOsmAndFragment; +import net.osmand.plus.profiles.ReorderItemTouchHelperCallback; import java.util.ArrayList; import java.util.Collections; @@ -93,7 +94,7 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick quickActionRV.setAdapter(adapter); quickActionRV.setLayoutManager(new LinearLayoutManager(getContext())); - ItemTouchHelper.Callback touchHelperCallback = new QuickActionItemTouchHelperCallback(adapter); + ItemTouchHelper.Callback touchHelperCallback = new ReorderItemTouchHelperCallback(adapter); touchHelper = new ItemTouchHelper(touchHelperCallback); touchHelper.attachToRecyclerView(quickActionRV); adapter.addItems(quickActionRegistry.getFilteredQuickActions()); @@ -187,7 +188,7 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick adapter.addItems(quickActionRegistry.getFilteredQuickActions()); } - public class QuickActionAdapter extends RecyclerView.Adapter implements QuickActionItemTouchHelperCallback.OnItemMoveCallback { + public class QuickActionAdapter extends RecyclerView.Adapter implements ReorderItemTouchHelperCallback.OnItemMoveCallback { public static final int SCREEN_ITEM_TYPE = 1; public static final int SCREEN_HEADER_TYPE = 2; @@ -411,7 +412,8 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick } } - public class QuickActionHeaderVH extends RecyclerView.ViewHolder { + public class QuickActionHeaderVH extends ReorderItemTouchHelperCallback.ImmobileViewHolder { + public TextView headerName; public QuickActionHeaderVH(View itemView) { diff --git a/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java b/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java index f3258317c7..abad8a7432 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java @@ -20,6 +20,7 @@ import android.widget.TextView; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.dialogs.SelectMapViewQuickActionsBottomSheet; +import net.osmand.plus.profiles.ReorderItemTouchHelperCallback; import java.util.ArrayList; import java.util.Collections; @@ -67,7 +68,7 @@ public abstract class SwitchableAction extends QuickAction { } }); - QuickActionItemTouchHelperCallback touchHelperCallback = new QuickActionItemTouchHelperCallback(adapter); + ReorderItemTouchHelperCallback touchHelperCallback = new ReorderItemTouchHelperCallback(adapter); touchHelper = new ItemTouchHelper(touchHelperCallback); touchHelper.attachToRecyclerView(list); @@ -116,7 +117,7 @@ public abstract class SwitchableAction extends QuickAction { fragment.show(fm, SelectMapViewQuickActionsBottomSheet.TAG); } - protected class Adapter extends RecyclerView.Adapter implements QuickActionItemTouchHelperCallback.OnItemMoveCallback { + protected class Adapter extends RecyclerView.Adapter implements ReorderItemTouchHelperCallback.OnItemMoveCallback { private List itemsList = new ArrayList<>(); private final QuickActionListFragment.OnStartDragListener onStartDragListener; diff --git a/OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java index b23081f31c..80bb914eb0 100644 --- a/OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java @@ -77,9 +77,9 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP protected void setupPreferences() { setupRouteParametersImage(); - Preference vehicleParametersInfo = findPreference(ROUTE_PARAMETERS_INFO); - vehicleParametersInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark)); - vehicleParametersInfo.setTitle(getString(R.string.route_parameters_info, getSelectedAppMode().toHumanString(getContext()))); + Preference routeParametersInfo = findPreference(ROUTE_PARAMETERS_INFO); + routeParametersInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark)); + routeParametersInfo.setTitle(getString(R.string.route_parameters_info, getSelectedAppMode().toHumanString(getContext()))); setupRoutingPrefs(); setupTimeConditionalRoutingPref(); From c3c65068e10cc045bfa83276d1824029f9948ed3 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 13 Dec 2019 17:26:10 +0200 Subject: [PATCH 033/231] Add profile appearance incomplete --- .../layout/preference_cancel_save_button.xml | 42 ++++ .../res/layout/preference_dropdown_list.xml | 54 +++++ OsmAnd/res/layout/preference_text_field.xml | 29 +++ OsmAnd/res/layout/preferences_screen.xml | 2 +- .../res/layout/profile_preference_toolbar.xml | 8 + OsmAnd/res/values/strings.xml | 4 +- OsmAnd/res/xml/profile_appeariance.xml | 72 +++++++ .../plus/profiles/EditProfileFragment.java | 2 +- ...electProfileBottomSheetDialogFragment.java | 6 +- .../profiles/SettingsProfileFragment.java | 2 +- .../plus/settings/BaseSettingsFragment.java | 3 +- .../settings/ConfigureProfileFragment.java | 56 +++-- .../plus/settings/NavigationFragment.java | 13 +- .../settings/ProfileAppearanceFragment.java | 202 ++++++++++++++++++ 14 files changed, 456 insertions(+), 39 deletions(-) create mode 100644 OsmAnd/res/layout/preference_cancel_save_button.xml create mode 100644 OsmAnd/res/layout/preference_dropdown_list.xml create mode 100644 OsmAnd/res/layout/preference_text_field.xml create mode 100644 OsmAnd/res/xml/profile_appeariance.xml create mode 100644 OsmAnd/src/net/osmand/plus/settings/ProfileAppearanceFragment.java diff --git a/OsmAnd/res/layout/preference_cancel_save_button.xml b/OsmAnd/res/layout/preference_cancel_save_button.xml new file mode 100644 index 0000000000..e1ba07d9d2 --- /dev/null +++ b/OsmAnd/res/layout/preference_cancel_save_button.xml @@ -0,0 +1,42 @@ + + + +