Selecting options and saving results. Work in progrss.
This commit is contained in:
parent
7e6817f333
commit
b010456963
12 changed files with 518 additions and 40 deletions
|
@ -0,0 +1,81 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/bottom_sheet_large_list_item_height"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingEnd="@dimen/content_padding_small"
|
||||||
|
android:paddingLeft="@dimen/content_padding"
|
||||||
|
android:paddingRight="@dimen/content_padding_small"
|
||||||
|
android:paddingStart="@dimen/content_padding"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||||
|
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||||
|
tools:src="@drawable/ic_action_coordinates_latitude"
|
||||||
|
android:tint="?attr/primary_icon_color"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginEnd="@dimen/content_padding"
|
||||||
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textColor="?attr/main_font_color_basic"
|
||||||
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
|
tools:text="Item Title"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/subtitle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
tools:text="Item additional desription"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/compound_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@null"
|
||||||
|
android:clickable="false"
|
||||||
|
android:focusable="false"
|
||||||
|
android:saveEnabled="false"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_marginStart="64dp"
|
||||||
|
android:layout_marginLeft="64dp"
|
||||||
|
android:background="?android:attr/listDivider"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
47
OsmAnd/res/layout/bottom_sheet_nav_type_fragment.xml
Normal file
47
OsmAnd/res/layout/bottom_sheet_nav_type_fragment.xml
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="?attr/bg_color">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="?attr/main_font_color_basic"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:layout_marginLeft="@dimen/list_content_padding"
|
||||||
|
android:layout_marginStart="@dimen/list_content_padding"
|
||||||
|
android:layout_marginTop="@dimen/list_content_padding"
|
||||||
|
android:layout_marginBottom="@dimen/list_content_padding"
|
||||||
|
android:text="Select navigation type"/>
|
||||||
|
|
||||||
|
|
||||||
|
<android.support.v7.widget.RecyclerView
|
||||||
|
android:id="@+id/menu_list_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
</android.support.v7.widget.RecyclerView>
|
||||||
|
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/bottom_row_divider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="?attr/dashboard_divider"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/buttons_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -77,22 +77,27 @@
|
||||||
android:id="@+id/profile_name_et"
|
android:id="@+id/profile_name_et"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:maxLines="1"
|
||||||
|
|
||||||
tools:text="@string/lorem_ipsum"/>
|
tools:text="@string/lorem_ipsum"/>
|
||||||
|
|
||||||
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
|
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
<net.osmand.plus.widgets.OsmandTextFieldBoxes
|
|
||||||
android:id="@+id/navigation_type_otfb"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="@dimen/list_content_padding"
|
android:layout_marginBottom="@dimen/list_content_padding"
|
||||||
android:layout_marginStart="@dimen/list_content_padding"
|
android:layout_marginStart="@dimen/list_content_padding"
|
||||||
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">
|
||||||
|
<net.osmand.plus.widgets.OsmandTextFieldBoxes
|
||||||
|
android:id="@+id/navigation_type_otfb"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
|
||||||
app:labelText="Type">
|
app:labelText="Type">
|
||||||
|
|
||||||
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
||||||
|
@ -102,10 +107,21 @@
|
||||||
android:drawableEnd="@drawable/ic_action_arrow_drop_down"
|
android:drawableEnd="@drawable/ic_action_arrow_drop_down"
|
||||||
android:drawableRight="@drawable/ic_action_arrow_drop_down"
|
android:drawableRight="@drawable/ic_action_arrow_drop_down"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:textSize="@dimen/default_list_text_size"
|
||||||
tools:text="Car"/>
|
android:maxLines="1"
|
||||||
|
tools:text="Car"
|
||||||
|
android:focusable="false"/>
|
||||||
|
|
||||||
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
|
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/select_nav_type_btn"
|
||||||
|
android:clickable="true"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:focusable="true"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -240,6 +240,7 @@
|
||||||
<dimen name="bottom_sheet_title_height">52dp</dimen>
|
<dimen name="bottom_sheet_title_height">52dp</dimen>
|
||||||
<dimen name="bottom_sheet_descr_height">44dp</dimen>
|
<dimen name="bottom_sheet_descr_height">44dp</dimen>
|
||||||
<dimen name="bottom_sheet_list_item_height">48dp</dimen>
|
<dimen name="bottom_sheet_list_item_height">48dp</dimen>
|
||||||
|
<dimen name="bottom_sheet_large_list_item_height">64dp</dimen>
|
||||||
<dimen name="bottom_sheet_icon_margin">24dp</dimen>
|
<dimen name="bottom_sheet_icon_margin">24dp</dimen>
|
||||||
<dimen name="bottom_sheet_divider_margin_top">7dp</dimen>
|
<dimen name="bottom_sheet_divider_margin_top">7dp</dimen>
|
||||||
<dimen name="bottom_sheet_divider_margin_bottom">8dp</dimen>
|
<dimen name="bottom_sheet_divider_margin_bottom">8dp</dimen>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
Thx - Hardy
|
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_descr">Select the profiles to be visible in the app.</string>
|
||||||
<string name="application_profiles">Application profiles</string>
|
<string name="application_profiles">Application profiles</string>
|
||||||
<string name="shared_string_degrees">Degrees</string>
|
<string name="shared_string_degrees">Degrees</string>
|
||||||
|
|
|
@ -8,13 +8,12 @@ public class AppProfile implements Parcelable {
|
||||||
private String title;
|
private String title;
|
||||||
private String navType;
|
private String navType;
|
||||||
private boolean isSelected;
|
private boolean isSelected;
|
||||||
private boolean isAppDefault;
|
|
||||||
|
|
||||||
public AppProfile(int iconRes, String title, String descr, boolean isAppDefault) {
|
|
||||||
|
public AppProfile(int iconRes, String title, String descr) {
|
||||||
this.iconRes = iconRes;
|
this.iconRes = iconRes;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.navType = descr;
|
this.navType = descr;
|
||||||
this.isAppDefault = isAppDefault;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,20 +50,12 @@ public class AppProfile implements Parcelable {
|
||||||
this.isSelected = isSelected;
|
this.isSelected = isSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAppDefault() {
|
|
||||||
return isAppDefault;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAppDefault(boolean appDefault) {
|
|
||||||
isAppDefault = appDefault;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected AppProfile(Parcel in) {
|
protected AppProfile(Parcel in) {
|
||||||
iconRes = in.readInt();
|
iconRes = in.readInt();
|
||||||
title = in.readString();
|
title = in.readString();
|
||||||
navType = in.readString();
|
navType = in.readString();
|
||||||
isSelected = in.readByte() != 0;
|
isSelected = in.readByte() != 0;
|
||||||
isAppDefault = in.readByte() != 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<AppProfile> CREATOR = new Creator<AppProfile>() {
|
public static final Creator<AppProfile> CREATOR = new Creator<AppProfile>() {
|
||||||
|
@ -90,8 +81,8 @@ public class AppProfile implements Parcelable {
|
||||||
dest.writeString(title);
|
dest.writeString(title);
|
||||||
dest.writeString(navType);
|
dest.writeString(navType);
|
||||||
dest.writeByte((byte) (isSelected ? 1 : 0));
|
dest.writeByte((byte) (isSelected ? 1 : 0));
|
||||||
dest.writeByte((byte) (isAppDefault ? 1 : 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package net.osmand.plus.profiles;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import net.osmand.plus.base.BottomSheetDialogFragment;
|
||||||
|
import net.osmand.plus.dashboard.DashBaseFragment;
|
||||||
|
|
||||||
|
public class IconSelectBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,160 @@
|
||||||
|
package net.osmand.plus.profiles;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.view.ContextThemeWrapper;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.RadioButton;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.base.BottomSheetDialogFragment;
|
||||||
|
import net.osmand.router.GeneralRouter.GeneralRouterProfile;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
public class NavTypeBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
||||||
|
|
||||||
|
private static final Log LOG = PlatformUtil.getLog(NavTypeBottomSheetDialogFragment.class);
|
||||||
|
|
||||||
|
List<RoutingProfile> routingProfiles;
|
||||||
|
NavTypeDialogListener listener;
|
||||||
|
RecyclerView recyclerView;
|
||||||
|
NavTypeAdapter adapter;
|
||||||
|
|
||||||
|
public void setListener(NavTypeDialogListener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
Bundle args = getArguments();
|
||||||
|
if (args != null) {
|
||||||
|
routingProfiles = args.getParcelableArrayList("routing_profiles");
|
||||||
|
}
|
||||||
|
|
||||||
|
final int themeRes = getMyApplication().getSettings().isLightContent() ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
|
||||||
|
View view = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.bottom_sheet_nav_type_fragment, null);
|
||||||
|
view.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
listener = new NavTypeDialogListener() {
|
||||||
|
@Override
|
||||||
|
public void selectedNavType(int pos) {
|
||||||
|
// for (int i = 0; i < routingProfiles.size(); i++) {
|
||||||
|
// if (i == pos) {
|
||||||
|
// routingProfiles.get(i).setSelected(true);
|
||||||
|
// } else {
|
||||||
|
// routingProfiles.get(i).setSelected(false);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// adapter.updateData(routingProfiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
recyclerView = view.findViewById(R.id.menu_list_view);
|
||||||
|
adapter = new NavTypeAdapter(getContext(), routingProfiles, isNightMode(getMyApplication()), listener);
|
||||||
|
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isNightMode(OsmandApplication ctx) {
|
||||||
|
return !ctx.getSettings().isLightContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
class NavTypeAdapter extends RecyclerView.Adapter<ItemViewHolder> {
|
||||||
|
private final Context context;
|
||||||
|
private final List<RoutingProfile> items;
|
||||||
|
private final boolean isNightMode;
|
||||||
|
private NavTypeDialogListener listener;
|
||||||
|
|
||||||
|
public NavTypeAdapter(@NonNull Context context, @NonNull List<RoutingProfile> objects,
|
||||||
|
@NonNull boolean isNightMode, NavTypeDialogListener listener) {
|
||||||
|
this.context = context;
|
||||||
|
this.items = objects;
|
||||||
|
this.isNightMode = isNightMode;
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateData(List<RoutingProfile> newItems) {
|
||||||
|
items.clear();
|
||||||
|
items.addAll(newItems);
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public ItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
return new ItemViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.bottom_sheet_item_with_descr_and_radio_btn, parent, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull final ItemViewHolder holder, int position) {
|
||||||
|
final int pos = position;
|
||||||
|
final RoutingProfile item = items.get(position);
|
||||||
|
holder.title.setText(item.getName());
|
||||||
|
holder.descr.setText(item.getOrigin());
|
||||||
|
holder.icon.setImageDrawable(getIcon(item.getIconRes(), isNightMode
|
||||||
|
? R.color.active_buttons_and_links_dark
|
||||||
|
: R.color.active_buttons_and_links_light));
|
||||||
|
if(item.isSelected()) {
|
||||||
|
holder.radioButton.setEnabled(true);
|
||||||
|
}
|
||||||
|
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(false);
|
||||||
|
} else {
|
||||||
|
routingProfiles.get(i).setSelected(true);
|
||||||
|
}
|
||||||
|
notifyItemChanged(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return items.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ItemViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
TextView title, descr;
|
||||||
|
RadioButton radioButton;
|
||||||
|
ImageView icon;
|
||||||
|
|
||||||
|
public ItemViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
title = itemView.findViewById(R.id.title);
|
||||||
|
descr = itemView.findViewById(R.id.subtitle);
|
||||||
|
radioButton = itemView.findViewById(R.id.compound_button);
|
||||||
|
icon = itemView.findViewById(R.id.icon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface NavTypeDialogListener {
|
||||||
|
void selectedNavType(int pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -20,7 +20,7 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
|
||||||
|
|
||||||
private List<AppProfile> items;
|
private List<AppProfile> items;
|
||||||
private ProfileListener listener = null;
|
private ProfileListener listener = null;
|
||||||
OsmandApplication app;
|
private final OsmandApplication app;
|
||||||
|
|
||||||
|
|
||||||
public ProfileMenuAdapter(List<AppProfile> items, OsmandApplication app, ProfileListener listener) {
|
public ProfileMenuAdapter(List<AppProfile> items, OsmandApplication app, ProfileListener listener) {
|
||||||
|
@ -58,7 +58,6 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
|
||||||
holder.title.setText(item.getTitle());
|
holder.title.setText(item.getTitle());
|
||||||
holder.title.setTextColor(app.getResources().getColor(isNightMode(app) ? R.color.main_font_dark : R.color.main_font_light));
|
holder.title.setTextColor(app.getResources().getColor(isNightMode(app) ? R.color.main_font_dark : R.color.main_font_light));
|
||||||
holder.descr.setText(String.format("Type: %s", item.getNavType()));
|
holder.descr.setText(String.format("Type: %s", item.getNavType()));
|
||||||
Drawable drawable = app.getUIUtilities().getThemedIcon(item.getIconRes());
|
|
||||||
holder.icon.setImageDrawable(app.getUIUtilities().getIcon(item.getIconRes(), isNightMode(app) ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light));
|
holder.icon.setImageDrawable(app.getUIUtilities().getIcon(item.getIconRes(), isNightMode(app) ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light));
|
||||||
holder.aSwitch.setChecked(item.isSelected());
|
holder.aSwitch.setChecked(item.isSelected());
|
||||||
holder.aSwitch.setOnClickListener(new OnClickListener() {
|
holder.aSwitch.setOnClickListener(new OnClickListener() {
|
||||||
|
|
71
OsmAnd/src/net/osmand/plus/profiles/RoutingProfile.java
Normal file
71
OsmAnd/src/net/osmand/plus/profiles/RoutingProfile.java
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
package net.osmand.plus.profiles;
|
||||||
|
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
public class RoutingProfile implements Parcelable {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String origin;
|
||||||
|
private int iconRes;
|
||||||
|
private boolean isSelected;
|
||||||
|
|
||||||
|
public RoutingProfile(String name, String origin, int iconRes, boolean isSelected) {
|
||||||
|
this.name = name;
|
||||||
|
this.origin = origin;
|
||||||
|
this.iconRes = iconRes;
|
||||||
|
this.isSelected = isSelected;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOrigin() {
|
||||||
|
return origin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIconRes() {
|
||||||
|
return iconRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSelected() {
|
||||||
|
return isSelected;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelected(boolean selected) {
|
||||||
|
isSelected = selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected RoutingProfile(Parcel in) {
|
||||||
|
name = in.readString();
|
||||||
|
origin = in.readString();
|
||||||
|
iconRes = in.readInt();
|
||||||
|
isSelected = in.readByte() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Creator<RoutingProfile> CREATOR = new Creator<RoutingProfile>() {
|
||||||
|
@Override
|
||||||
|
public RoutingProfile createFromParcel(Parcel in) {
|
||||||
|
return new RoutingProfile(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RoutingProfile[] newArray(int size) {
|
||||||
|
return new RoutingProfile[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
dest.writeString(name);
|
||||||
|
dest.writeString(origin);
|
||||||
|
dest.writeInt(iconRes);
|
||||||
|
dest.writeByte((byte) (isSelected ? 1 : 0));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package net.osmand.plus.profiles;
|
package net.osmand.plus.profiles;
|
||||||
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.graphics.drawable.GradientDrawable;
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
@ -10,20 +9,30 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import java.util.ArrayList;
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||||
|
import net.osmand.plus.profiles.NavTypeBottomSheetDialogFragment.NavTypeDialogListener;
|
||||||
import net.osmand.plus.widgets.OsmandTextFieldBoxes;
|
import net.osmand.plus.widgets.OsmandTextFieldBoxes;
|
||||||
|
import net.osmand.router.GeneralRouter.GeneralRouterProfile;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
import studio.carbonylgroup.textfieldboxes.ExtendedEditText;
|
import studio.carbonylgroup.textfieldboxes.ExtendedEditText;
|
||||||
|
|
||||||
public class SelectedProfileFragment extends BaseOsmAndFragment {
|
public class SelectedProfileFragment extends BaseOsmAndFragment {
|
||||||
|
|
||||||
|
private static final Log LOG = PlatformUtil.getLog(SelectedProfileFragment.class);
|
||||||
|
|
||||||
AppProfile profile = null;
|
AppProfile profile = null;
|
||||||
|
ArrayList<RoutingProfile> routings;
|
||||||
OsmandApplication app;
|
OsmandApplication app;
|
||||||
|
|
||||||
|
private NavTypeDialogListener navTypeDialogListener = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -31,40 +40,101 @@ public class SelectedProfileFragment extends BaseOsmAndFragment {
|
||||||
if (getArguments() != null) {
|
if (getArguments() != null) {
|
||||||
profile = getArguments().getParcelable("profile");
|
profile = getArguments().getParcelable("profile");
|
||||||
}
|
}
|
||||||
|
routings = getRoutingProfiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||||
|
@Nullable Bundle savedInstanceState) {
|
||||||
boolean isNightMode = !app.getSettings().isLightContent();
|
boolean isNightMode = !app.getSettings().isLightContent();
|
||||||
|
|
||||||
View view = inflater.inflate(R.layout.fragment_selected_profile, container, false);
|
View view = inflater.inflate(R.layout.fragment_selected_profile, container, false);
|
||||||
|
|
||||||
ImageView profileIcon = view.findViewById(R.id.select_icon_btn_img);
|
|
||||||
LinearLayout profileIconBtn = view.findViewById(R.id.profile_icon_layout);
|
|
||||||
ExtendedEditText profileNameEt = view.findViewById(R.id.profile_name_et);
|
|
||||||
OsmandTextFieldBoxes profileNameTextBox = view.findViewById(R.id.profile_name_otfb);
|
|
||||||
ExtendedEditText navTypeEt = view.findViewById(R.id.navigation_type_et);
|
|
||||||
OsmandTextFieldBoxes navTypeTextBox= view.findViewById(R.id.navigation_type_otfb);
|
|
||||||
|
|
||||||
|
final ImageView profileIcon = view.findViewById(R.id.select_icon_btn_img);
|
||||||
|
final LinearLayout profileIconBtn = view.findViewById(R.id.profile_icon_layout);
|
||||||
|
final ExtendedEditText profileNameEt = view.findViewById(R.id.profile_name_et);
|
||||||
|
final OsmandTextFieldBoxes profileNameTextBox = view.findViewById(R.id.profile_name_otfb);
|
||||||
|
final ExtendedEditText navTypeEt = view.findViewById(R.id.navigation_type_et);
|
||||||
|
final OsmandTextFieldBoxes navTypeTextBox = view.findViewById(R.id.navigation_type_otfb);
|
||||||
|
final FrameLayout select_nav_type_btn = view.findViewById(R.id.select_nav_type_btn);
|
||||||
|
|
||||||
profileIconBtn.setBackgroundResource(R.drawable.rounded_background_3dp);
|
profileIconBtn.setBackgroundResource(R.drawable.rounded_background_3dp);
|
||||||
GradientDrawable selectIconBtnBackground = (GradientDrawable) profileIconBtn.getBackground();
|
GradientDrawable selectIconBtnBackground = (GradientDrawable) profileIconBtn
|
||||||
|
.getBackground();
|
||||||
|
|
||||||
profileIcon.setImageDrawable(app.getUIUtilities().getIcon(profile.getIconRes(),
|
profileIcon.setImageDrawable(app.getUIUtilities().getIcon(profile.getIconRes(),
|
||||||
isNightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light));
|
isNightMode ? R.color.active_buttons_and_links_dark
|
||||||
|
: R.color.active_buttons_and_links_light));
|
||||||
|
|
||||||
if (isNightMode) {
|
if (isNightMode) {
|
||||||
profileNameTextBox.setPrimaryColor(ContextCompat.getColor(app, R.color.color_dialog_buttons_dark));
|
profileNameTextBox
|
||||||
navTypeTextBox.setPrimaryColor(ContextCompat.getColor(app, R.color.color_dialog_buttons_dark));
|
.setPrimaryColor(ContextCompat.getColor(app, R.color.color_dialog_buttons_dark));
|
||||||
selectIconBtnBackground.setColor(app.getResources().getColor(R.color.text_field_box_dark));
|
navTypeTextBox
|
||||||
|
.setPrimaryColor(ContextCompat.getColor(app, R.color.color_dialog_buttons_dark));
|
||||||
|
selectIconBtnBackground
|
||||||
|
.setColor(app.getResources().getColor(R.color.text_field_box_dark));
|
||||||
} else {
|
} else {
|
||||||
selectIconBtnBackground.setColor(app.getResources().getColor(R.color.text_field_box_light));
|
selectIconBtnBackground
|
||||||
|
.setColor(app.getResources().getColor(R.color.text_field_box_light));
|
||||||
}
|
}
|
||||||
|
|
||||||
//((OsmandTextFieldBoxes) textBox).setPrimaryColor(ContextCompat.getColor(app, R.color.color_dialog_buttons_dark));
|
select_nav_type_btn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
final NavTypeBottomSheetDialogFragment fragment = new NavTypeBottomSheetDialogFragment();
|
||||||
|
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putParcelableArrayList("routing_profiles", routings);
|
||||||
|
fragment.setArguments(bundle);
|
||||||
|
getActivity().getSupportFragmentManager().beginTransaction().add(fragment, "tag")
|
||||||
|
.commitAllowingStateLoss();
|
||||||
|
|
||||||
|
// navTypeEt.setText("Car");
|
||||||
|
// navTypeEt.setCursorVisible(false);
|
||||||
|
// navTypeEt.setTextIsSelectable(false);
|
||||||
|
// navTypeEt.clearFocus();
|
||||||
|
// navTypeEt.requestFocus(EditText.FOCUS_UP);
|
||||||
|
// LOG.debug("click on text");
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
return view;
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For now there are only default nav profiles todo: add profiles from custom routing xml-s
|
||||||
|
*/
|
||||||
|
private ArrayList<RoutingProfile> getRoutingProfiles() {
|
||||||
|
ArrayList<RoutingProfile> routingProfiles = new ArrayList<>();
|
||||||
|
for (GeneralRouterProfile navProfileName : GeneralRouterProfile.values()) {
|
||||||
|
String name = "";
|
||||||
|
int iconRes = -1;
|
||||||
|
switch (navProfileName) {
|
||||||
|
case CAR:
|
||||||
|
iconRes = R.drawable.ic_action_car_dark;
|
||||||
|
name = getString(R.string.rendering_value_car_name);
|
||||||
|
break;
|
||||||
|
case PEDESTRIAN:
|
||||||
|
iconRes = R.drawable.map_action_pedestrian_dark;
|
||||||
|
name = getString(R.string.rendering_value_pedestrian_name);
|
||||||
|
break;
|
||||||
|
case BICYCLE:
|
||||||
|
iconRes = R.drawable.map_action_bicycle_dark;
|
||||||
|
name = getString(R.string.rendering_value_bicycle_name);
|
||||||
|
break;
|
||||||
|
case PUBLIC_TRANSPORT:
|
||||||
|
iconRes = R.drawable.map_action_bus_dark;
|
||||||
|
name = getString(R.string.app_mode_public_transport);
|
||||||
|
break;
|
||||||
|
case BOAT:
|
||||||
|
iconRes = R.drawable.map_action_sail_boat_dark;
|
||||||
|
name = getString(R.string.app_mode_boat);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
routingProfiles
|
||||||
|
.add(new RoutingProfile(name, getString(R.string.osmand_default_routing), iconRes, false));
|
||||||
|
}
|
||||||
|
return routingProfiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.osmand.plus.profiles;
|
package net.osmand.plus.profiles;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
@ -39,21 +40,21 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Context ctx = getMyApplication().getApplicationContext();
|
||||||
profilesList = new ArrayList<>();
|
profilesList = new ArrayList<>();
|
||||||
allDefaultModes = ApplicationMode.allPossibleValues();
|
allDefaultModes = ApplicationMode.allPossibleValues();
|
||||||
allDefaultModes.remove(ApplicationMode.DEFAULT);
|
allDefaultModes.remove(ApplicationMode.DEFAULT);
|
||||||
allDefaultModes.remove(ApplicationMode.AIRCRAFT);
|
allDefaultModes.remove(ApplicationMode.AIRCRAFT);
|
||||||
allDefaultModes.remove(ApplicationMode.MOTORCYCLE);
|
|
||||||
allDefaultModes.remove(ApplicationMode.HIKING);
|
allDefaultModes.remove(ApplicationMode.HIKING);
|
||||||
allDefaultModes.remove(ApplicationMode.TRAIN);
|
allDefaultModes.remove(ApplicationMode.TRAIN);
|
||||||
selectedDefaultModes = new LinkedHashSet<>(ApplicationMode.values(getMyApplication()));
|
selectedDefaultModes = new LinkedHashSet<>(ApplicationMode.values(getMyApplication()));
|
||||||
selectedDefaultModes.remove(ApplicationMode.DEFAULT);
|
selectedDefaultModes.remove(ApplicationMode.DEFAULT);
|
||||||
for (ApplicationMode am : allDefaultModes) {
|
for (ApplicationMode am : allDefaultModes) {
|
||||||
|
|
||||||
AppProfile profileItem = new AppProfile(
|
AppProfile profileItem = new AppProfile(
|
||||||
am.getSmallIconDark(),
|
am.getSmallIconDark(),
|
||||||
am.toHumanStringCtx(getMyApplication().getApplicationContext()),
|
am.toHumanStringCtx(getMyApplication().getApplicationContext()),
|
||||||
am.toHumanStringCtx(getMyApplication().getApplicationContext()),
|
getNavType(am, ctx));
|
||||||
true);
|
|
||||||
if (selectedDefaultModes.contains(am)) {
|
if (selectedDefaultModes.contains(am)) {
|
||||||
profileItem.setSelected(true);
|
profileItem.setSelected(true);
|
||||||
}
|
}
|
||||||
|
@ -61,6 +62,26 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getNavType(ApplicationMode am, Context ctx) {
|
||||||
|
if (am.getParent() != null) {
|
||||||
|
return getNavType(am.getParent(), ctx);
|
||||||
|
} else {
|
||||||
|
switch(am.getStringKey()) {
|
||||||
|
case "car":
|
||||||
|
return ctx.getResources().getString(R.string.rendering_value_car_name);
|
||||||
|
case "bicycle":
|
||||||
|
return ctx.getResources().getString(R.string.rendering_value_bicycle_name);
|
||||||
|
case "pedestrian":
|
||||||
|
return ctx.getResources().getString(R.string.rendering_value_pedestrian_name);
|
||||||
|
case "public_transport":
|
||||||
|
return ctx.getResources().getString(R.string.app_mode_public_transport);
|
||||||
|
case "boat":
|
||||||
|
return ctx.getResources().getString(R.string.app_mode_boat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||||
|
|
Loading…
Reference in a new issue