Profile details edit - work in progress
This commit is contained in:
parent
7cbd9bd8c8
commit
6c6ec759f1
7 changed files with 69 additions and 38 deletions
|
@ -7,12 +7,17 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="top">
|
||||
>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
|
@ -330,8 +335,12 @@
|
|||
android:src="@drawable/bg_shadow_list_bottom"/>
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -11,6 +11,11 @@
|
|||
Thx - Hardy
|
||||
|
||||
-->
|
||||
|
||||
-->
|
||||
<string name="osmand_default_routing">OsmAnd routing</string>
|
||||
<string name="application_profiles_descr">Select the profiles to be visible in the app.</string>
|
||||
<string name="application_profiles">Application profiles</string>
|
||||
<string name="routing_attr_avoid_tram_name">Avoid trams</string>
|
||||
<string name="routing_attr_avoid_tram_description">Avoid trams</string>
|
||||
<string name="routing_attr_avoid_bus_name">Avoid buses</string>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -26,10 +26,11 @@ public class NavTypeBottomSheetDialogFragment extends BottomSheetDialogFragment
|
|||
|
||||
List<RoutingProfile> 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<ItemViewHolder> {
|
||||
private final Context context;
|
||||
private final List<RoutingProfile> items;
|
||||
private final boolean isNightMode;
|
||||
private NavTypeDialogListener listener;
|
||||
private int previousSelection;
|
||||
|
||||
public NavTypeAdapter(@NonNull Context context, @NonNull List<RoutingProfile> objects,
|
||||
public NavTypeAdapter(@NonNull List<RoutingProfile> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<RoutingProfile> routings;
|
||||
ApplicationMode profile = null;
|
||||
ArrayList<RoutingProfile> 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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue