fix swithcing between settings screen with selecting appropriate profiles.
ui fixes.
This commit is contained in:
parent
bd34a38e7d
commit
7e98dd6d6e
4 changed files with 50 additions and 10 deletions
|
@ -9,6 +9,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
>
|
>
|
||||||
<ScrollView
|
<ScrollView
|
||||||
|
android:id="@+id/scroll_view_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="top"
|
android:layout_gravity="top"
|
||||||
|
@ -456,9 +457,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="64dp"/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
|
@ -21,6 +21,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
import net.osmand.plus.ContextMenuItem;
|
import net.osmand.plus.ContextMenuItem;
|
||||||
|
@ -46,10 +47,11 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
|
||||||
public class SettingsNavigationActivity extends SettingsBaseActivity {
|
public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
|
private static final Log LOG = PlatformUtil.getLog(SettingsNavigationActivity.class);
|
||||||
public static final String MORE_VALUE = "MORE_VALUE";
|
public static final String MORE_VALUE = "MORE_VALUE";
|
||||||
|
|
||||||
private Preference avoidRouting;
|
private Preference avoidRouting;
|
||||||
|
@ -75,7 +77,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
((OsmandApplication) getApplication()).applyTheme(this);
|
((OsmandApplication) getApplication()).applyTheme(this);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
getToolbar().setTitle(R.string.routing_settings);
|
getToolbar().setTitle(R.string.routing_settings);
|
||||||
|
|
||||||
createUI();
|
createUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +86,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
PreferenceScreen screen = getPreferenceScreen();
|
PreferenceScreen screen = getPreferenceScreen();
|
||||||
settings = getMyApplication().getSettings();
|
settings = getMyApplication().getSettings();
|
||||||
routerServicePreference = (ListPreference) screen.findPreference(settings.ROUTER_SERVICE.getId());
|
routerServicePreference = (ListPreference) screen.findPreference(settings.ROUTER_SERVICE.getId());
|
||||||
|
|
||||||
RouteService[] vls = RouteService.getAvailableRouters(getMyApplication());
|
RouteService[] vls = RouteService.getAvailableRouters(getMyApplication());
|
||||||
String[] entries = new String[vls.length];
|
String[] entries = new String[vls.length];
|
||||||
for(int i=0; i<entries.length; i++){
|
for(int i=0; i<entries.length; i++){
|
||||||
|
@ -179,6 +181,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
|
|
||||||
|
|
||||||
if(getIntent() != null && getIntent().hasExtra(INTENT_SKIP_DIALOG)) {
|
if(getIntent() != null && getIntent().hasExtra(INTENT_SKIP_DIALOG)) {
|
||||||
|
LOG.debug("AppMode in settings: " + settings.getApplicationMode().getStringKey());
|
||||||
setSelectedAppMode(settings.getApplicationMode());
|
setSelectedAppMode(settings.getApplicationMode());
|
||||||
} else {
|
} else {
|
||||||
profileDialog();
|
profileDialog();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.osmand.plus.profiles;
|
package net.osmand.plus.profiles;
|
||||||
|
|
||||||
|
import static net.osmand.plus.activities.SettingsNavigationActivity.INTENT_SKIP_DIALOG;
|
||||||
import static net.osmand.plus.profiles.ProfileBottomSheetDialogFragment.TYPE_APP_PROFILE;
|
import static net.osmand.plus.profiles.ProfileBottomSheetDialogFragment.TYPE_APP_PROFILE;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
@ -26,6 +27,7 @@ import android.widget.Button;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
@ -89,6 +91,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
private LinearLayout typeSelectionBtn;
|
private LinearLayout typeSelectionBtn;
|
||||||
private ImageView baseModeIcon;
|
private ImageView baseModeIcon;
|
||||||
private TextView baseModeTitle;
|
private TextView baseModeTitle;
|
||||||
|
private ScrollView scrollContainer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
@ -129,6 +132,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
typeSelectionBtn = view.findViewById(R.id.type_selection_button);
|
typeSelectionBtn = view.findViewById(R.id.type_selection_button);
|
||||||
baseModeIcon = view.findViewById(R.id.mode_icon);
|
baseModeIcon = view.findViewById(R.id.mode_icon);
|
||||||
baseModeTitle = view.findViewById(R.id.mode_title);
|
baseModeTitle = view.findViewById(R.id.mode_title);
|
||||||
|
scrollContainer = view.findViewById(R.id.scroll_view_container);
|
||||||
|
|
||||||
profileNameEt.setFocusable(true);
|
profileNameEt.setFocusable(true);
|
||||||
profileNameEt.setSelectAllOnFocus(true);
|
profileNameEt.setSelectAllOnFocus(true);
|
||||||
|
@ -155,6 +159,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
title = profile.getUserProfileTitle();
|
title = profile.getUserProfileTitle();
|
||||||
profileNameEt.setText(title);
|
profileNameEt.setText(title);
|
||||||
startIconId = profile.iconId;
|
startIconId = profile.iconId;
|
||||||
|
isDataChanged = false;
|
||||||
} else if (isNew) {
|
} else if (isNew) {
|
||||||
isDataChanged = true;
|
isDataChanged = true;
|
||||||
title = String.format("Custom %s", getResources().getString(profile.parent.getStringResource()));
|
title = String.format("Custom %s", getResources().getString(profile.parent.getStringResource()));
|
||||||
|
@ -341,6 +346,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
if (isDataChanged) {
|
if (isDataChanged) {
|
||||||
needSaveDialog();
|
needSaveDialog();
|
||||||
} else if (getSettings() != null) {
|
} else if (getSettings() != null) {
|
||||||
|
activateMode(mode);
|
||||||
getSettings().APPLICATION_MODE.set(mode);
|
getSettings().APPLICATION_MODE.set(mode);
|
||||||
Intent i = new Intent(getActivity(), MapActivity.class);
|
Intent i = new Intent(getActivity(), MapActivity.class);
|
||||||
i.putExtra(OPEN_CONFIG_ON_MAP, MAP_CONFIG);
|
i.putExtra(OPEN_CONFIG_ON_MAP, MAP_CONFIG);
|
||||||
|
@ -356,6 +362,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
if (isDataChanged) {
|
if (isDataChanged) {
|
||||||
needSaveDialog();
|
needSaveDialog();
|
||||||
} else if (getSettings() != null) {
|
} else if (getSettings() != null) {
|
||||||
|
activateMode(mode);
|
||||||
getSettings().APPLICATION_MODE.set(mode);
|
getSettings().APPLICATION_MODE.set(mode);
|
||||||
Intent i = new Intent(getActivity(), MapActivity.class);
|
Intent i = new Intent(getActivity(), MapActivity.class);
|
||||||
i.putExtra(OPEN_CONFIG_ON_MAP, SCREEN_CONFIG);
|
i.putExtra(OPEN_CONFIG_ON_MAP, SCREEN_CONFIG);
|
||||||
|
@ -371,8 +378,10 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
if (isDataChanged) {
|
if (isDataChanged) {
|
||||||
needSaveDialog();
|
needSaveDialog();
|
||||||
} else if (getSettings() != null) {
|
} else if (getSettings() != null) {
|
||||||
|
activateMode(mode);
|
||||||
getSettings().APPLICATION_MODE.set(mode);
|
getSettings().APPLICATION_MODE.set(mode);
|
||||||
Intent i = new Intent(getActivity(), SettingsNavigationActivity.class);
|
Intent i = new Intent(getActivity(), SettingsNavigationActivity.class);
|
||||||
|
i.putExtra(INTENT_SKIP_DIALOG, true);
|
||||||
i.putExtra(OPEN_CONFIG_ON_MAP, NAV_CONFIG);
|
i.putExtra(OPEN_CONFIG_ON_MAP, NAV_CONFIG);
|
||||||
i.putExtra(SELECTED_PROFILE, profile.getStringKey());
|
i.putExtra(SELECTED_PROFILE, profile.getStringKey());
|
||||||
startActivity(i);
|
startActivity(i);
|
||||||
|
@ -401,14 +410,19 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
view.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
|
view.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onGlobalLayout() {
|
public void onGlobalLayout() {
|
||||||
|
int marginShow = 66;
|
||||||
|
int marginHide = 2;
|
||||||
|
float d = getResources().getDisplayMetrics().density;
|
||||||
Rect r = new Rect();
|
Rect r = new Rect();
|
||||||
view.getWindowVisibleDisplayFrame(r);
|
view.getWindowVisibleDisplayFrame(r);
|
||||||
int screenHeight = view.getRootView().getHeight();
|
int screenHeight = view.getRootView().getHeight();
|
||||||
int keypadHeight = screenHeight - r.bottom;
|
int keypadHeight = screenHeight - r.bottom;
|
||||||
if (keypadHeight > screenHeight * 0.15) {
|
if (keypadHeight > screenHeight * 0.15) {
|
||||||
buttonsLayout.setVisibility(View.GONE);
|
buttonsLayout.setVisibility(View.GONE);
|
||||||
|
setMargins(scrollContainer, 0, 0, 0, (int) (marginHide * d));
|
||||||
} else {
|
} else {
|
||||||
buttonsLayout.setVisibility(View.VISIBLE);
|
buttonsLayout.setVisibility(View.VISIBLE);
|
||||||
|
setMargins(scrollContainer, 0, 0, 0, (int) (marginShow * d));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -421,16 +435,38 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
return view;
|
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) {
|
private void setupBaseProfileView(String stringKey) {
|
||||||
for(ApplicationMode am : ApplicationMode.getDefaultValues()) {
|
for(ApplicationMode am : ApplicationMode.getDefaultValues()) {
|
||||||
if (am.getStringKey().equals(stringKey)) {
|
if (am.getStringKey().equals(stringKey)) {
|
||||||
baseModeIcon.setImageDrawable(app.getUIUtilities().getIcon(am.getSmallIconDark(), R.color.icon_color));
|
baseModeIcon.setImageDrawable(app.getUIUtilities().getIcon(am.getSmallIconDark(), R.color.icon_color));
|
||||||
baseModeTitle.setText(Algorithms.capitalizeFirstLetter(am.toHumanString(app)));
|
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() {
|
private boolean saveNewProfile() {
|
||||||
|
|
||||||
if (isUserProfile && !isNew) {
|
if (isUserProfile && !isNew) {
|
||||||
|
@ -562,7 +598,6 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
Map<String, GeneralRouter> inputProfiles = getMyApplication().getDefaultRoutingConfig().getAllRoutes();
|
Map<String, GeneralRouter> inputProfiles = getMyApplication().getDefaultRoutingConfig().getAllRoutes();
|
||||||
for (Entry<String, GeneralRouter> e : inputProfiles.entrySet()) {
|
for (Entry<String, GeneralRouter> e : inputProfiles.entrySet()) {
|
||||||
String name;
|
String name;
|
||||||
// String description = getResources().getString(R.string.osmand_default_routing);
|
|
||||||
String description = "";
|
String description = "";
|
||||||
int iconRes;
|
int iconRes;
|
||||||
switch (e.getKey()) {
|
switch (e.getKey()) {
|
||||||
|
@ -594,7 +629,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
iconRes = R.drawable.ic_action_world_globe;
|
iconRes = R.drawable.ic_action_world_globe;
|
||||||
name = Algorithms
|
name = Algorithms
|
||||||
.capitalizeFirstLetterAndLowercase(e.getKey().replace("_", " "));
|
.capitalizeFirstLetterAndLowercase(e.getKey().replace("_", " "));
|
||||||
description = "Custom profile"; //todo add filename
|
description = "Custom profile";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
profilesObjects.add(new RoutingProfile(e.getKey(), name, description, iconRes, false, e.getValue().getFilename()));
|
profilesObjects.add(new RoutingProfile(e.getKey(), name, description, iconRes, false, e.getValue().getFilename()));
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
|
||||||
listener = new ProfileListener() {
|
listener = new ProfileListener() {
|
||||||
@Override
|
@Override
|
||||||
public void changeProfileStatus(ApplicationMode item, boolean isSelected) {
|
public void changeProfileStatus(ApplicationMode item, boolean isSelected) {
|
||||||
StringBuilder vls = new StringBuilder(ApplicationMode.DEFAULT.getStringKey()+",");
|
StringBuilder vls = new StringBuilder(ApplicationMode.DEFAULT.getStringKey() + ",");
|
||||||
ApplicationMode mode = null;
|
ApplicationMode mode = null;
|
||||||
for (ApplicationMode sam : allAppModes) {
|
for (ApplicationMode sam : allAppModes) {
|
||||||
if (sam.getStringKey().equals(item.getStringKey())) {
|
if (sam.getStringKey().equals(item.getStringKey())) {
|
||||||
|
@ -72,6 +72,9 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
|
||||||
availableAppModes.add(mode);
|
availableAppModes.add(mode);
|
||||||
} else if (mode != null) {
|
} else if (mode != null) {
|
||||||
availableAppModes.remove(mode);
|
availableAppModes.remove(mode);
|
||||||
|
if (getSettings() != null && getSettings().APPLICATION_MODE.get() == mode) {
|
||||||
|
getSettings().APPLICATION_MODE.set(ApplicationMode.DEFAULT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ApplicationMode sam : availableAppModes) {
|
for (ApplicationMode sam : availableAppModes) {
|
||||||
|
|
Loading…
Reference in a new issue