diff --git a/OsmAnd/res/layout/fragment_selected_profile.xml b/OsmAnd/res/layout/fragment_selected_profile.xml index c62a3ca642..d55d6f6b2a 100644 --- a/OsmAnd/res/layout/fragment_selected_profile.xml +++ b/OsmAnd/res/layout/fragment_selected_profile.xml @@ -9,6 +9,7 @@ android:layout_height="match_parent" > + diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java index 3ebe6835b0..211b03c8ab 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java @@ -21,6 +21,7 @@ import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; +import net.osmand.PlatformUtil; import net.osmand.plus.ApplicationMode; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuItem; @@ -46,10 +47,11 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; +import org.apache.commons.logging.Log; public class SettingsNavigationActivity extends SettingsBaseActivity { - + private static final Log LOG = PlatformUtil.getLog(SettingsNavigationActivity.class); public static final String MORE_VALUE = "MORE_VALUE"; private Preference avoidRouting; @@ -75,7 +77,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { ((OsmandApplication) getApplication()).applyTheme(this); super.onCreate(savedInstanceState); getToolbar().setTitle(R.string.routing_settings); - + createUI(); } @@ -84,7 +86,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { PreferenceScreen screen = getPreferenceScreen(); settings = getMyApplication().getSettings(); routerServicePreference = (ListPreference) screen.findPreference(settings.ROUTER_SERVICE.getId()); - + RouteService[] vls = RouteService.getAvailableRouters(getMyApplication()); String[] entries = new String[vls.length]; for(int i=0; i screenHeight * 0.15) { buttonsLayout.setVisibility(View.GONE); + setMargins(scrollContainer, 0, 0, 0, (int) (marginHide * d)); } else { buttonsLayout.setVisibility(View.VISIBLE); + setMargins(scrollContainer, 0, 0, 0, (int) (marginShow * d)); } } }); @@ -421,16 +435,38 @@ public class EditProfileFragment extends BaseOsmAndFragment { return view; } + void activateMode(ApplicationMode mode) { + if (!ApplicationMode.values(app).contains(mode)) { + StringBuilder s = new StringBuilder(ApplicationMode.DEFAULT.getStringKey() + ","); + for (ApplicationMode am : ApplicationMode.values(app)) { + s.append(am.getStringKey()).append(","); + } + s.append(mode.getStringKey()).append(","); + if (getSettings() != null) { + getSettings().AVAILABLE_APP_MODES.set(s.toString()); + } + } + + } + private void setupBaseProfileView(String stringKey) { for(ApplicationMode am : ApplicationMode.getDefaultValues()) { if (am.getStringKey().equals(stringKey)) { baseModeIcon.setImageDrawable(app.getUIUtilities().getIcon(am.getSmallIconDark(), R.color.icon_color)); baseModeTitle.setText(Algorithms.capitalizeFirstLetter(am.toHumanString(app))); - isDataChanged = true; + isDataChanged = false; } } } + private void setMargins(View v, int l, int t, int r, int b) { + if (v.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) { + ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) v.getLayoutParams(); + p.setMargins(l, t, r, b); + v.requestLayout(); + } + } + private boolean saveNewProfile() { if (isUserProfile && !isNew) { @@ -562,7 +598,6 @@ public class EditProfileFragment extends BaseOsmAndFragment { Map inputProfiles = getMyApplication().getDefaultRoutingConfig().getAllRoutes(); for (Entry e : inputProfiles.entrySet()) { String name; -// String description = getResources().getString(R.string.osmand_default_routing); String description = ""; int iconRes; switch (e.getKey()) { @@ -594,7 +629,7 @@ public class EditProfileFragment extends BaseOsmAndFragment { iconRes = R.drawable.ic_action_world_globe; name = Algorithms .capitalizeFirstLetterAndLowercase(e.getKey().replace("_", " ")); - description = "Custom profile"; //todo add filename + description = "Custom profile"; break; } profilesObjects.add(new RoutingProfile(e.getKey(), name, description, iconRes, false, e.getValue().getFilename())); diff --git a/OsmAnd/src/net/osmand/plus/profiles/SettingsProfileFragment.java b/OsmAnd/src/net/osmand/plus/profiles/SettingsProfileFragment.java index 969ce40f17..5ed43c932f 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/SettingsProfileFragment.java +++ b/OsmAnd/src/net/osmand/plus/profiles/SettingsProfileFragment.java @@ -60,7 +60,7 @@ public class SettingsProfileFragment extends BaseOsmAndFragment { listener = new ProfileListener() { @Override public void changeProfileStatus(ApplicationMode item, boolean isSelected) { - StringBuilder vls = new StringBuilder(ApplicationMode.DEFAULT.getStringKey()+","); + StringBuilder vls = new StringBuilder(ApplicationMode.DEFAULT.getStringKey() + ","); ApplicationMode mode = null; for (ApplicationMode sam : allAppModes) { if (sam.getStringKey().equals(item.getStringKey())) { @@ -72,6 +72,9 @@ public class SettingsProfileFragment extends BaseOsmAndFragment { availableAppModes.add(mode); } else if (mode != null) { availableAppModes.remove(mode); + if (getSettings() != null && getSettings().APPLICATION_MODE.get() == mode) { + getSettings().APPLICATION_MODE.set(ApplicationMode.DEFAULT); + } } for (ApplicationMode sam : availableAppModes) {