This commit is contained in:
madwasp79 2019-05-09 19:09:56 +03:00
parent e722fc3d07
commit a64173640a
6 changed files with 122 additions and 79 deletions

View file

@ -4,13 +4,15 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:background="?attr/ctx_menu_info_view_bg"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
> >
<ScrollView <ScrollView
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"
android:layout_marginBottom="@dimen/setting_profile_item_height">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -62,7 +64,6 @@
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle" android:textAppearance="@style/TextAppearance.ListItemTitle"
android:textColor="?attr/main_font_color_basic"
android:text="Base Profile"/> android:text="Base Profile"/>
<TextView <TextView
@ -72,12 +73,13 @@
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:textSize="16sp" android:textSize="16sp"
android:textColor="?attr/main_font_color_basic"
tools:text="Item additional desription"/> tools:text="Item additional desription"/>
</LinearLayout> </LinearLayout>
<ImageView <ImageView
android:id="@+id/type_down_arrow" android:id="@+id/type_down_arrow2"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0" android:layout_weight="0"
@ -89,17 +91,29 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/list_content_padding"> android:layout_height="wrap_content"
android:background="?attr/ctx_menu_info_view_bg"
android:orientation="vertical">
<ImageView <ImageView
android:id="@+id/bottom_shadow"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="5dp" android:layout_height="wrap_content"
android:scaleType="fitXY" android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom"/> android:src="@drawable/bg_shadow_list_bottom"/>
<View
android:layout_width="match_parent"
android:layout_height="10dp"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_top"/>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -171,6 +185,7 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<FrameLayout <FrameLayout
android:id="@+id/click_block_layout" android:id="@+id/click_block_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -187,6 +202,16 @@
android:layout_marginEnd="@dimen/list_content_padding" android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginLeft="@dimen/list_content_padding" android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"> android:layout_marginRight="@dimen/list_content_padding">
<ImageView
android:id="@+id/type_down_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:paddingRight="@dimen/content_padding"
android:tint="@color/settings_divider"
android:src="@drawable/ic_action_arrow_drop_down"/>
<net.osmand.plus.widgets.OsmandTextFieldBoxes <net.osmand.plus.widgets.OsmandTextFieldBoxes
android:id="@+id/navigation_type_otfb" android:id="@+id/navigation_type_otfb"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -230,17 +255,30 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/list_content_padding"> android:layout_height="wrap_content"
android:background="?attr/ctx_menu_info_view_bg"
android:orientation="vertical">
<ImageView <ImageView
android:id="@+id/bottom_shadow1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="5dp" android:layout_height="wrap_content"
android:scaleType="fitXY" android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom"/> android:src="@drawable/bg_shadow_list_bottom"/>
<View
android:layout_width="match_parent"
android:layout_height="10dp"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_top"/>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -412,17 +450,11 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/list_content_padding">
<ImageView
android:id="@+id/bottom_shadow2" <include layout="@layout/list_shadow_footer"/>
android:layout_width="match_parent"
android:layout_height="5dp"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom"/>
</LinearLayout>
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -2,6 +2,7 @@ package net.osmand.plus.profiles;
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.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener; import android.content.DialogInterface.OnDismissListener;
import android.content.Intent; import android.content.Intent;
@ -63,7 +64,6 @@ public class EditProfileFragment extends BaseOsmAndFragment {
ArrayList<RoutingProfile> routingProfiles; ArrayList<RoutingProfile> routingProfiles;
OsmandApplication app; OsmandApplication app;
RoutingProfile selectedRoutingProfile = null; RoutingProfile selectedRoutingProfile = null;
float defSpeed = 0f;
private boolean isNew = false; private boolean isNew = false;
private boolean isUserProfile = false; private boolean isUserProfile = false;
@ -250,8 +250,16 @@ public class EditProfileFragment extends BaseOsmAndFragment {
@Override @Override
public void onSelectedType(int pos) { public void onSelectedType(int pos) {
isDataChanged = true; isDataChanged = true;
for (int i = 0; i < routingProfiles.size(); i++) {
if (i == pos) {
routingProfiles.get(i).setSelected(true);
} else {
routingProfiles.get(i).setSelected(false);
}
}
selectedRoutingProfile = routingProfiles.get(pos); selectedRoutingProfile = routingProfiles.get(pos);
navTypeEt.setText(selectedRoutingProfile.getName()); navTypeEt.setText(selectedRoutingProfile.getName());
LOG.debug(routingProfiles);
profile.setRoutingProfile(selectedRoutingProfile); profile.setRoutingProfile(selectedRoutingProfile);
} }
}; };
@ -299,8 +307,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
fragment.setArguments(bundle); fragment.setArguments(bundle);
if (getActivity() != null) { if (getActivity() != null) {
getActivity().getSupportFragmentManager().beginTransaction() getActivity().getSupportFragmentManager().beginTransaction()
.add(fragment, "select_nav_type") .add(fragment, "select_nav_type").commitAllowingStateLoss();
.commitAllowingStateLoss();
} }
navTypeEt.setCursorVisible(false); navTypeEt.setCursorVisible(false);
@ -333,8 +340,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
public void onClick(View v) { public void onClick(View v) {
if (isDataChanged) { if (isDataChanged) {
needSaveDialog(); needSaveDialog();
} else { } else if (getSettings() != null) {
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);
@ -349,7 +355,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
public void onClick(View v) { public void onClick(View v) {
if (isDataChanged) { if (isDataChanged) {
needSaveDialog(); needSaveDialog();
} else { } else if (getSettings() != null) {
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);
@ -364,7 +370,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
public void onClick(View v) { public void onClick(View v) {
if (isDataChanged) { if (isDataChanged) {
needSaveDialog(); needSaveDialog();
} else { } else if (getSettings() != null) {
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(OPEN_CONFIG_ON_MAP, NAV_CONFIG); i.putExtra(OPEN_CONFIG_ON_MAP, NAV_CONFIG);
@ -425,16 +431,6 @@ public class EditProfileFragment extends BaseOsmAndFragment {
} }
} }
private void needSaveDialog() {
if (getActivity() != null) {
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity());
bld.setTitle("Save Changes");
bld.setMessage("You need to save changes to Profile before proceed");
bld.setNegativeButton(R.string.shared_string_ok, null);
bld.show();
}
}
private boolean saveNewProfile() { private boolean saveNewProfile() {
if (isUserProfile && !isNew) { if (isUserProfile && !isNew) {
@ -442,27 +438,20 @@ public class EditProfileFragment extends BaseOsmAndFragment {
} }
if (profile.getRoutingProfile() == null && getActivity() != null) { if (profile.getRoutingProfile() == null && getActivity() != null) {
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity()); showSaveWarningDialog(
bld.setTitle("Select Routing Type"); "Select Routing Type",
bld.setMessage("You need to select Routing Type to create New Application Profile"); "You need to select Routing Type to create New Application Profile",
bld.setNegativeButton(R.string.shared_string_dismiss, null); getActivity());
bld.show();
return false; return false;
} else if (profile.getUserProfileTitle().isEmpty() && getActivity() != null) { } else if (getActivity() != null && profile.getUserProfileTitle().isEmpty()
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity()); || profile.getUserProfileTitle().replace(" ", "").length() < 1) {
bld.setTitle("Enter Profile Name"); showSaveWarningDialog(
bld.setMessage("Profile name shouldn't be empty!"); "Enter Profile Name",
bld.setNegativeButton(R.string.shared_string_dismiss, "Profile name shouldn't be empty!",
new DialogInterface.OnClickListener() { getActivity()
@Override );
public void onClick(DialogInterface dialog, int which) {
navTypeEt.requestFocus();
}
});
bld.show();
return false; return false;
} }
for (ApplicationMode m : ApplicationMode.allPossibleValues()) { for (ApplicationMode m : ApplicationMode.allPossibleValues()) {
if (m.getUserProfileName() != null && m.getUserProfileName().equals(profile.getUserProfileTitle()) if (m.getUserProfileName() != null && m.getUserProfileName().equals(profile.getUserProfileTitle())
&& getActivity() != null) { && getActivity() != null) {
@ -528,6 +517,24 @@ public class EditProfileFragment extends BaseOsmAndFragment {
return true; return true;
} }
private void needSaveDialog() {
if (getActivity() != null) {
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity());
bld.setTitle("Save Changes");
bld.setMessage("You need to save changes to Profile before proceed");
bld.setNegativeButton(R.string.shared_string_ok, null);
bld.show();
}
}
private void showSaveWarningDialog(String title, String message, Activity activity) {
AlertDialog.Builder bld = new AlertDialog.Builder(activity);
bld.setTitle(title);
bld.setMessage(message);
bld.setNegativeButton(R.string.shared_string_dismiss, null);
bld.show();
}
void onDeleteProfileClick() { void onDeleteProfileClick() {
if (getActivity() != null) { if (getActivity() != null) {
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity()); AlertDialog.Builder bld = new AlertDialog.Builder(getActivity());
@ -552,8 +559,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
private ArrayList<RoutingProfile> getRoutingProfiles() { private ArrayList<RoutingProfile> getRoutingProfiles() {
ArrayList<RoutingProfile> routingProfiles = new ArrayList<>(); ArrayList<RoutingProfile> routingProfiles = new ArrayList<>();
Map<String, GeneralRouter> routingProfilesNames = getMyApplication() Map<String, GeneralRouter> routingProfilesNames = getMyApplication().getDefaultRoutingConfig().getAllRoutes();
.getDefaultRoutingConfig().getAllRoutes();
for (Entry<String, GeneralRouter> e : routingProfilesNames.entrySet()) { for (Entry<String, GeneralRouter> e : routingProfilesNames.entrySet()) {
String name; String name;
String description = getResources().getString(R.string.osmand_default_routing); String description = getResources().getString(R.string.osmand_default_routing);
@ -579,6 +585,10 @@ public class EditProfileFragment extends BaseOsmAndFragment {
iconRes = R.drawable.map_action_sail_boat_dark; iconRes = R.drawable.map_action_sail_boat_dark;
name = getString(R.string.app_mode_boat); name = getString(R.string.app_mode_boat);
break; break;
case "geocoding":
iconRes = R.drawable.ic_action_world_globe;
name = "Geocoding";
break;
default: default:
iconRes = R.drawable.ic_action_world_globe; iconRes = R.drawable.ic_action_world_globe;
name = Algorithms name = Algorithms
@ -586,10 +596,8 @@ public class EditProfileFragment extends BaseOsmAndFragment {
description = "Custom profile"; //todo add filename description = "Custom profile"; //todo add filename
break; break;
} }
routingProfiles.add(new RoutingProfile(e.getKey(), name, description, iconRes, false)); routingProfiles.add(new RoutingProfile(e.getKey(), name, description, iconRes, false));
} }
return routingProfiles; return routingProfiles;
} }

View file

@ -146,11 +146,11 @@ public class ProfileBottomSheetDialogFragment extends BottomSheetDialogFragment
final ProfileDataObject item = items.get(position); final ProfileDataObject item = items.get(position);
holder.title.setText(item.getName()); holder.title.setText(item.getName());
if (item.isSelected()) { if (item.isSelected()) {
holder.icon.setImageDrawable(getIcon(item.getIconRes(), isNightMode holder.icon.setImageDrawable(getIcon(item.getIconRes(), isNightMode
? R.color.active_buttons_and_links_dark ? R.color.active_buttons_and_links_dark
: R.color.active_buttons_and_links_light)); : R.color.active_buttons_and_links_light));
} else { } else {
holder.icon.setImageDrawable(getIcon(item.getIconRes(), R.color.icon_color)); holder.icon.setImageDrawable(getIcon(item.getIconRes(), R.color.icon_color));
} }
holder.itemView.setOnClickListener(new View.OnClickListener() { holder.itemView.setOnClickListener(new View.OnClickListener() {
@ -167,18 +167,15 @@ public class ProfileBottomSheetDialogFragment extends BottomSheetDialogFragment
} }
} }
}); });
if (item instanceof RoutingProfile) {
holder.descr.setText(Algorithms holder.descr.setText(item.getDescription());
.capitalizeFirstLetterAndLowercase(item.getDescription())); if (item.isSelected()) {
if (item.isSelected()) { holder.radioButton.setChecked(true);
holder.radioButton.setChecked(true); previousSelection = position;
previousSelection = position;
} else {
holder.radioButton.setChecked(false);
}
} else { } else {
holder.descr.setText(item.getDescription()); holder.radioButton.setChecked(false);
} }
} }
@Override @Override

View file

@ -30,6 +30,8 @@ public class SelectIconBottomSheetDialogFragment extends BottomSheetDialogFragme
private IconIdListener listListener; private IconIdListener listListener;
private RecyclerView recyclerView; private RecyclerView recyclerView;
private IconIdAdapter adapter; private IconIdAdapter adapter;
private TextView title;
public void setIconIdListener(IconIdListener listener) { public void setIconIdListener(IconIdListener listener) {
this.listener = listener; this.listener = listener;
@ -75,10 +77,13 @@ public class SelectIconBottomSheetDialogFragment extends BottomSheetDialogFragme
} }
}; };
recyclerView = view.findViewById(R.id.menu_list_view); recyclerView = view.findViewById(R.id.menu_list_view);
title = view.findViewById(R.id.dialog_title);
title.setText("Select icon");
adapter = new IconIdAdapter(icons, isNightMode(getMyApplication()), listListener); adapter = new IconIdAdapter(icons, isNightMode(getMyApplication()), listListener);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);
Button cancelBtn = view.findViewById(R.id.cancel_selection); Button cancelBtn = view.findViewById(R.id.cancel_selection);
cancelBtn.setOnClickListener(new View.OnClickListener() { cancelBtn.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -119,15 +124,18 @@ public class SelectIconBottomSheetDialogFragment extends BottomSheetDialogFragme
final int pos = position; final int pos = position;
final IconResWithDescr item = items.get(position); final IconResWithDescr item = items.get(position);
holder.title.setText(item.getTitleId()); holder.title.setText(item.getTitleId());
holder.icon.setImageDrawable(getIcon(item.getResId(), isNightMode if (item.isSelected) {
? R.color.active_buttons_and_links_dark holder.icon.setImageDrawable(getIcon(item.getResId(), isNightMode
: R.color.active_buttons_and_links_light)); ? R.color.active_buttons_and_links_dark
if(item.isSelected()) { : R.color.active_buttons_and_links_light));
holder.radioButton.setChecked(true); holder.radioButton.setChecked(true);
previousSelection = position; previousSelection = position;
} else { } else {
holder.radioButton.setChecked(false); holder.radioButton.setChecked(false);
holder.icon.setImageDrawable(getIcon(item.getResId(), R.color.icon_color));
} }
holder.itemView.setOnClickListener(new View.OnClickListener() { holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

View file

@ -120,7 +120,6 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putParcelableArrayList(TYPE_APP_PROFILE, baseProfiles); bundle.putParcelableArrayList(TYPE_APP_PROFILE, baseProfiles);
dialog.setArguments(bundle); dialog.setArguments(bundle);
if (getActivity() != null) { if (getActivity() != null) {
getActivity().getSupportFragmentManager().beginTransaction() getActivity().getSupportFragmentManager().beginTransaction()
.add(dialog, "select_base_type").commitAllowingStateLoss(); .add(dialog, "select_base_type").commitAllowingStateLoss();

View file

@ -687,7 +687,6 @@ public class RouteProvider {
GeneralRouterProfile p ; GeneralRouterProfile p ;
if (params.mode.getRoutingProfile() != null ) { if (params.mode.getRoutingProfile() != null ) {
//todo get assigned routing profile from ApplicationMode
p = GeneralRouterProfile.CUSTOM; p = GeneralRouterProfile.CUSTOM;
} else if (params.mode.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) { } else if (params.mode.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) {
p = GeneralRouterProfile.BICYCLE; p = GeneralRouterProfile.BICYCLE;