diff --git a/OsmAnd/res/layout/fragment_selected_profile.xml b/OsmAnd/res/layout/fragment_selected_profile.xml
index 42f1fa604d..8c1a34bc43 100644
--- a/OsmAnd/res/layout/fragment_selected_profile.xml
+++ b/OsmAnd/res/layout/fragment_selected_profile.xml
@@ -7,12 +7,17 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
>
+
+ >
+
+
+
+ -->
+ OsmAnd routing
+ Select the profiles to be visible in the app.
+ Application profiles
Avoid trams
Avoid trams
Avoid buses
diff --git a/OsmAnd/src/net/osmand/plus/ApplicationMode.java b/OsmAnd/src/net/osmand/plus/ApplicationMode.java
index edc6c146fd..89ad94ef27 100644
--- a/OsmAnd/src/net/osmand/plus/ApplicationMode.java
+++ b/OsmAnd/src/net/osmand/plus/ApplicationMode.java
@@ -406,7 +406,7 @@ public class ApplicationMode {
private final int key;
private final String stringKey;
-
+ private String userName;
private ApplicationMode parent;
private int mapIconId = R.drawable.map_world_globe_dark;
private int smallIconDark = R.drawable.ic_world_globe_dark;
diff --git a/OsmAnd/src/net/osmand/plus/profiles/NavTypeBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/profiles/NavTypeBottomSheetDialogFragment.java
index 680a0b0ef9..6ef7ff231f 100644
--- a/OsmAnd/src/net/osmand/plus/profiles/NavTypeBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/profiles/NavTypeBottomSheetDialogFragment.java
@@ -26,10 +26,11 @@ public class NavTypeBottomSheetDialogFragment extends BottomSheetDialogFragment
List routingProfiles;
NavTypeDialogListener listener;
+ NavTypeDialogListener listListener;
RecyclerView recyclerView;
NavTypeAdapter adapter;
- public void setListener(NavTypeDialogListener listener) {
+ public void setNavTypeListener(NavTypeDialogListener listener) {
this.listener = listener;
}
@@ -50,18 +51,14 @@ public class NavTypeBottomSheetDialogFragment extends BottomSheetDialogFragment
dismiss();
}
});
- listener = new NavTypeDialogListener() {
+ listListener = new NavTypeDialogListener() {
@Override
public void selectedNavType(int pos) {
- for (int i = 0; i < routingProfiles.size(); i++) {
- routingProfiles.get(i).setSelected(false);
- }
- routingProfiles.get(pos).setSelected(true);
-
+ listener.selectedNavType(pos);
}
};
recyclerView = view.findViewById(R.id.menu_list_view);
- adapter = new NavTypeAdapter(getContext(), routingProfiles, isNightMode(getMyApplication()), listener);
+ adapter = new NavTypeAdapter(routingProfiles, isNightMode(getMyApplication()), listListener);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(adapter);
@@ -73,14 +70,13 @@ public class NavTypeBottomSheetDialogFragment extends BottomSheetDialogFragment
}
class NavTypeAdapter extends RecyclerView.Adapter {
- private final Context context;
private final List items;
private final boolean isNightMode;
private NavTypeDialogListener listener;
+ private int previousSelection;
- public NavTypeAdapter(@NonNull Context context, @NonNull List objects,
+ public NavTypeAdapter(@NonNull List objects,
@NonNull boolean isNightMode, NavTypeDialogListener listener) {
- this.context = context;
this.items = objects;
this.isNightMode = isNightMode;
this.listener = listener;
@@ -99,8 +95,7 @@ public class NavTypeBottomSheetDialogFragment extends BottomSheetDialogFragment
}
@Override
- public void onBindViewHolder(@NonNull final ItemViewHolder holder, int position) {
- final int pos = position;
+ public void onBindViewHolder(@NonNull final ItemViewHolder holder, final int position) {
final RoutingProfile item = items.get(position);
holder.title.setText(item.getName());
holder.descr.setText(item.getOrigin());
@@ -108,20 +103,22 @@ public class NavTypeBottomSheetDialogFragment extends BottomSheetDialogFragment
? R.color.active_buttons_and_links_dark
: R.color.active_buttons_and_links_light));
if(item.isSelected()) {
- holder.radioButton.setEnabled(true);
+ holder.radioButton.setChecked(true);
+ previousSelection = position;
+ } else {
+ holder.radioButton.setChecked(false);
}
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- listener.selectedNavType(pos);
- for (int i = 0; i < routingProfiles.size(); i++) {
- if (!routingProfiles.get(i).equals(item)) {
- routingProfiles.get(i).setSelected(true);
- } else {
- routingProfiles.get(i).setSelected(false);
- }
- notifyItemChanged(i);
- }
+ listener.selectedNavType(position);
+ holder.radioButton.setChecked(true);
+ items.get(position).setSelected(true);
+ items.get(previousSelection).setSelected(false);
+ notifyItemChanged(previousSelection);
+
+ previousSelection = position;
+
}
});
}
@@ -150,5 +147,8 @@ public class NavTypeBottomSheetDialogFragment extends BottomSheetDialogFragment
interface NavTypeDialogListener {
void selectedNavType(int pos);
}
+ interface IconIdListener {
+ void selecedIconId(int iconRes);
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/profiles/SelectedProfileActivity.java b/OsmAnd/src/net/osmand/plus/profiles/SelectedProfileActivity.java
index 1a5fd22186..2dbcd46435 100644
--- a/OsmAnd/src/net/osmand/plus/profiles/SelectedProfileActivity.java
+++ b/OsmAnd/src/net/osmand/plus/profiles/SelectedProfileActivity.java
@@ -5,6 +5,7 @@ import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.MenuItem;
+
import net.osmand.plus.R;
import net.osmand.plus.activities.OsmandActionBarActivity;
@@ -15,11 +16,12 @@ public class SelectedProfileActivity extends OsmandActionBarActivity {
getMyApplication().applyTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.single_fragment_layout);
-
Intent intent = getIntent();
if (intent.getExtras() != null) {
+ String stringKey = intent.getStringExtra("stringKey");
+ String title = stringKey == null ? "New Profile" : stringKey.toUpperCase(); //todo need normal title
if (getSupportActionBar() != null) {
-// getSupportActionBar().setTitle(((AppProfile) intent.getParcelableExtra("profile")).getTitle());
+ getSupportActionBar().setTitle(title);
getSupportActionBar().setElevation(5.0f);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/profiles/SelectedProfileFragment.java b/OsmAnd/src/net/osmand/plus/profiles/SelectedProfileFragment.java
index a84b0fe14f..41e4c044d0 100644
--- a/OsmAnd/src/net/osmand/plus/profiles/SelectedProfileFragment.java
+++ b/OsmAnd/src/net/osmand/plus/profiles/SelectedProfileFragment.java
@@ -14,10 +14,12 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import java.util.ArrayList;
import net.osmand.PlatformUtil;
+import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.profiles.NavTypeBottomSheetDialogFragment.NavTypeDialogListener;
+import net.osmand.plus.profiles.NavTypeBottomSheetDialogFragment.IconIdListener;
import net.osmand.plus.widgets.OsmandTextFieldBoxes;
import net.osmand.router.GeneralRouter.GeneralRouterProfile;
import org.apache.commons.logging.Log;
@@ -27,20 +29,24 @@ public class SelectedProfileFragment extends BaseOsmAndFragment {
private static final Log LOG = PlatformUtil.getLog(SelectedProfileFragment.class);
- AppProfile profile = null;
- ArrayList routings;
+ ApplicationMode profile = null;
+ ArrayList routingProfiles;
OsmandApplication app;
+ boolean isDataChanged = false;
+
private NavTypeDialogListener navTypeDialogListener = null;
+ private IconIdListener iconIdListener = null;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = getMyApplication();
if (getArguments() != null) {
- profile = getArguments().getParcelable("profile");
+ String modeName = getArguments().getString("stringKey");
+ profile = ApplicationMode.valueOfStringKey(modeName, ApplicationMode.CAR);
}
- routings = getRoutingProfiles();
+ routingProfiles = getRoutingProfiles();
}
@Nullable
@@ -63,7 +69,7 @@ public class SelectedProfileFragment extends BaseOsmAndFragment {
GradientDrawable selectIconBtnBackground = (GradientDrawable) profileIconBtn
.getBackground();
- profileIcon.setImageDrawable(app.getUIUtilities().getIcon(profile.getIconRes(),
+ profileIcon.setImageDrawable(app.getUIUtilities().getIcon(profile.getSmallIconDark(),
isNightMode ? R.color.active_buttons_and_links_dark
: R.color.active_buttons_and_links_light));
@@ -79,17 +85,25 @@ public class SelectedProfileFragment extends BaseOsmAndFragment {
.setColor(app.getResources().getColor(R.color.text_field_box_light));
}
+ navTypeDialogListener = new NavTypeDialogListener() {
+ @Override
+ public void selectedNavType(int pos) {
+ navTypeEt.setText(routingProfiles.get(pos).getName());
+ }
+ };
+
select_nav_type_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final NavTypeBottomSheetDialogFragment fragment = new NavTypeBottomSheetDialogFragment();
-
+ fragment.setNavTypeListener(navTypeDialogListener);
Bundle bundle = new Bundle();
- bundle.putParcelableArrayList("routing_profiles", routings);
+ bundle.putParcelableArrayList("routing_profiles", routingProfiles);
fragment.setArguments(bundle);
- getActivity().getSupportFragmentManager().beginTransaction().add(fragment, "tag")
+ getActivity().getSupportFragmentManager().beginTransaction().add(fragment, "select_nav_type")
.commitAllowingStateLoss();
+
// navTypeEt.setText("Car");
// navTypeEt.setCursorVisible(false);
// navTypeEt.setTextIsSelectable(false);
diff --git a/OsmAnd/src/net/osmand/plus/profiles/SettingsProfileFragment.java b/OsmAnd/src/net/osmand/plus/profiles/SettingsProfileFragment.java
index 53e1075c29..0c7431f00a 100644
--- a/OsmAnd/src/net/osmand/plus/profiles/SettingsProfileFragment.java
+++ b/OsmAnd/src/net/osmand/plus/profiles/SettingsProfileFragment.java
@@ -1,6 +1,7 @@
package net.osmand.plus.profiles;
import android.content.Context;
+import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@@ -108,9 +109,9 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
@Override
public void editProfile(ApplicationMode item) {
-// Intent intent = new Intent(getActivity(), SelectedProfileActivity.class);
-// intent.putExtra("profile", item);
-// startActivity(intent);
+ Intent intent = new Intent(getActivity(), SelectedProfileActivity.class);
+ intent.putExtra("stringKey", item.getStringKey());
+ startActivity(intent);
}
};
adapter = new ProfileMenuAdapter(allAppModes, availableAppModes, getMyApplication(), listener);