Merge branch 'r3.3'
This commit is contained in:
commit
b744f42095
11 changed files with 373 additions and 84 deletions
|
@ -78,9 +78,9 @@
|
|||
android:layout_height="@dimen/standard_icon_size"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_content_margin_small"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_content_margin_small"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
tools:src="@drawable/ic_action_info_dark" />
|
||||
|
||||
<TextView
|
||||
|
|
19
OsmAnd/res/layout/bottom_sheet_item_recyclerview.xml
Normal file
19
OsmAnd/res/layout/bottom_sheet_item_recyclerview.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="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:gravity="center_vertical"
|
||||
android:minHeight="@dimen/bottom_sheet_selected_item_title_height">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:orientation="horizontal"
|
||||
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/bottom_sheet_item_with_descr_56dp" />
|
||||
|
||||
</LinearLayout>
|
|
@ -62,7 +62,7 @@
|
|||
android:paddingLeft="@dimen/route_info_icon_padding_right"
|
||||
android:paddingRight="@dimen/route_info_icon_padding_right"
|
||||
android:src="@drawable/ic_action_arrow_down"
|
||||
android:tint="?attr/primary_icon_color" />
|
||||
android:tint="@color/description_font_and_bottom_sheet_icons" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?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:id="@+id/home_work_card"
|
||||
android:id="@+id/warning_card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
|
|
@ -80,7 +80,7 @@ public class UiUtilities {
|
|||
}
|
||||
|
||||
public Drawable getThemedIcon(@DrawableRes int id) {
|
||||
return getDrawable(id, app.getSettings().isLightContent() ? R.color.icon_color : 0);
|
||||
return getDrawable(id, R.color.description_font_and_bottom_sheet_icons);
|
||||
}
|
||||
|
||||
public Drawable getIcon(@DrawableRes int id) {
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
package net.osmand.plus.base.bottomsheetmenu;
|
||||
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
||||
public class HorizontalRecyclerBottomSheetItem extends BaseBottomSheetItem {
|
||||
|
||||
protected RecyclerView.Adapter adapter;
|
||||
|
||||
private RecyclerView recyclerView;
|
||||
|
||||
public HorizontalRecyclerBottomSheetItem(View customView,
|
||||
@LayoutRes int layoutId,
|
||||
Object tag,
|
||||
boolean disabled,
|
||||
View.OnClickListener onClickListener,
|
||||
int position,
|
||||
RecyclerView.Adapter adapter) {
|
||||
super(customView, layoutId, tag, disabled, onClickListener, position);
|
||||
this.adapter = adapter;
|
||||
}
|
||||
|
||||
protected HorizontalRecyclerBottomSheetItem() {
|
||||
|
||||
}
|
||||
|
||||
public void setAdapter(RecyclerView.Adapter adapter) {
|
||||
this.adapter = adapter;
|
||||
recyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inflate(OsmandApplication app, ViewGroup container, boolean nightMode) {
|
||||
super.inflate(app, container, nightMode);
|
||||
recyclerView = ((RecyclerView) view.findViewById(R.id.recycler_view));
|
||||
if (recyclerView != null && adapter != null) {
|
||||
recyclerView.setAdapter(adapter);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Builder extends BaseBottomSheetItem.Builder {
|
||||
|
||||
protected RecyclerView.Adapter adapter;
|
||||
|
||||
public HorizontalRecyclerBottomSheetItem.Builder setAdapter(RecyclerView.Adapter adapter) {
|
||||
this.adapter = adapter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public HorizontalRecyclerBottomSheetItem create() {
|
||||
return new HorizontalRecyclerBottomSheetItem(customView,
|
||||
layoutId,
|
||||
tag,
|
||||
disabled,
|
||||
onClickListener,
|
||||
position,
|
||||
adapter);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1257,8 +1257,9 @@ public class GpxUiHelper {
|
|||
chart.setExtraRightOffset(16);
|
||||
chart.setExtraLeftOffset(16);
|
||||
|
||||
yl.setTextColor(ContextCompat.getColor(app, nightMode ? R.color.primary_text_dark : R.color.primary_text_light));
|
||||
yr.setTextColor(ContextCompat.getColor(app, nightMode ? R.color.primary_text_dark : R.color.primary_text_light));
|
||||
int mainFontColor = ContextCompat.getColor(app, nightMode ? R.color.main_font_dark : R.color.main_font_light);
|
||||
yl.setTextColor(mainFontColor);
|
||||
yr.setTextColor(mainFontColor);
|
||||
|
||||
chart.setFitBars(true);
|
||||
|
||||
|
|
|
@ -1,30 +1,41 @@
|
|||
package net.osmand.plus.routepreparationmenu;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.SpannableString;
|
||||
import android.util.Pair;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.HorizontalRecyclerBottomSheetItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import net.osmand.plus.helpers.MapMarkerDialogHelper;
|
||||
import net.osmand.plus.helpers.WaypointDialogHelper;
|
||||
|
@ -33,10 +44,9 @@ import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu.PointType;
|
|||
import net.osmand.plus.search.QuickSearchDialogFragment;
|
||||
import net.osmand.plus.widgets.style.CustomTypefaceSpan;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.data.PointDescription.POINT_TYPE_MY_LOCATION;
|
||||
|
||||
public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
||||
|
||||
public static final String TAG = "AddPointBottomSheetDialog";
|
||||
|
@ -44,6 +54,8 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
|||
|
||||
public static final int ADD_FAVOURITE_TO_ROUTE_REQUEST_CODE = 1;
|
||||
|
||||
public static final String FAVOURITES = "favourites";
|
||||
|
||||
private PointType pointType = PointType.START;
|
||||
|
||||
@Override
|
||||
|
@ -81,27 +93,27 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
|||
case START:
|
||||
createMyLocItem();
|
||||
createSelectOnTheMapItem();
|
||||
createFavouritesItem();
|
||||
createFavouritesScrollItem();
|
||||
createMarkersItem();
|
||||
items.add(new DividerHalfItem(getContext()));
|
||||
createSwitchStartAndEndItem();
|
||||
break;
|
||||
case TARGET:
|
||||
createSelectOnTheMapItem();
|
||||
createFavouritesItem();
|
||||
createFavouritesScrollItem();
|
||||
createMarkersItem();
|
||||
items.add(new DividerHalfItem(getContext()));
|
||||
createSwitchStartAndEndItem();
|
||||
break;
|
||||
case INTERMEDIATE:
|
||||
createSelectOnTheMapItem();
|
||||
createFavouritesItem();
|
||||
createFavouritesScrollItem();
|
||||
createMarkersItem();
|
||||
break;
|
||||
case HOME:
|
||||
case WORK:
|
||||
createSelectOnTheMapItem();
|
||||
createFavouritesItem();
|
||||
createFavouritesScrollItem();
|
||||
createMarkersItem();
|
||||
break;
|
||||
default:
|
||||
|
@ -245,30 +257,6 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
|||
items.add(selectOnTheMapItem);
|
||||
}
|
||||
|
||||
private void createFavouritesItem() {
|
||||
BaseBottomSheetItem favouritesItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_fav_dark))
|
||||
.setTitle(getString(R.string.shared_string_favorites))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple_56dp)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MapActivity mapActivity = (MapActivity) getActivity();
|
||||
if (mapActivity != null) {
|
||||
FragmentManager fragmentManager = mapActivity.getSupportFragmentManager();
|
||||
FavouritesBottomSheetMenuFragment fragment = new FavouritesBottomSheetMenuFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(FavouritesBottomSheetMenuFragment.POINT_TYPE_KEY, pointType.name());
|
||||
fragment.setTargetFragment(AddPointBottomSheetDialog.this, ADD_FAVOURITE_TO_ROUTE_REQUEST_CODE);
|
||||
fragment.setArguments(args);
|
||||
fragment.show(fragmentManager, FavouritesBottomSheetMenuFragment.TAG);
|
||||
}
|
||||
}
|
||||
})
|
||||
.create();
|
||||
items.add(favouritesItem);
|
||||
}
|
||||
|
||||
private void createMarkersItem() {
|
||||
final OsmandApplication app = getMyApplication();
|
||||
if (app == null) {
|
||||
|
@ -352,4 +340,249 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
|||
}).create();
|
||||
items.add(switchStartAndEndItem);
|
||||
}
|
||||
|
||||
private void loadFavoritesItems(List<Object> items, FavouritesDbHelper helper) {
|
||||
items.clear();
|
||||
addMainScrollItems(items);
|
||||
items.addAll(helper.getVisibleFavouritePoints());
|
||||
if (items.isEmpty()) {
|
||||
items.addAll(helper.getFavouritePoints());
|
||||
}
|
||||
}
|
||||
|
||||
private void addMainScrollItems(List<Object> items) {
|
||||
items.add(FAVOURITES);
|
||||
items.add(PointType.HOME);
|
||||
items.add(PointType.WORK);
|
||||
}
|
||||
|
||||
private void createFavouritesScrollItem() {
|
||||
final OsmandApplication app = getMyApplication();
|
||||
if (app != null) {
|
||||
List<Object> items = new ArrayList<>();
|
||||
final FavouritesItemsAdapter adapter = new FavouritesItemsAdapter(app, items);
|
||||
adapter.setItemClickListener(getAdapterOnClickListener(items));
|
||||
final FavouritesDbHelper helper = app.getFavorites();
|
||||
if (helper.isFavoritesLoaded()) {
|
||||
loadFavoritesItems(items, helper);
|
||||
} else {
|
||||
addMainScrollItems(items);
|
||||
helper.addListener(new FavouritesDbHelper.FavoritesListener() {
|
||||
@Override
|
||||
public void onFavoritesLoaded() {
|
||||
MapActivity mapActivity = (MapActivity) getActivity();
|
||||
if (mapActivity != null) {
|
||||
loadFavoritesItems(adapter.items, helper);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
BaseBottomSheetItem scrollItem = new HorizontalRecyclerBottomSheetItem.Builder()
|
||||
.setAdapter(adapter)
|
||||
.setLayoutId(R.layout.bottom_sheet_item_recyclerview)
|
||||
.create();
|
||||
this.items.add(scrollItem);
|
||||
}
|
||||
}
|
||||
|
||||
private View.OnClickListener getAdapterOnClickListener(final List<Object> items) {
|
||||
return new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MapActivity mapActivity = (MapActivity) getActivity();
|
||||
RecyclerView.ViewHolder viewHolder = (RecyclerView.ViewHolder) v.getTag();
|
||||
int position = viewHolder != null ? viewHolder.getAdapterPosition() : RecyclerView.NO_POSITION;
|
||||
if (mapActivity == null || position == RecyclerView.NO_POSITION) {
|
||||
return;
|
||||
}
|
||||
Object item = items.get(position);
|
||||
if (item.equals(FAVOURITES)) {
|
||||
openFavouritesDialog();
|
||||
} else {
|
||||
TargetPointsHelper helper = mapActivity.getMyApplication().getTargetPointsHelper();
|
||||
Pair<LatLon, PointDescription> pair = getLocationAndDescrFromItem(item, helper);
|
||||
LatLon ll = pair.first;
|
||||
PointDescription name = pair.second;
|
||||
if (ll == null) {
|
||||
if (item instanceof PointType) {
|
||||
AddPointBottomSheetDialog.showInstance(mapActivity, (PointType) item);
|
||||
} else {
|
||||
dismiss();
|
||||
}
|
||||
} else {
|
||||
switch (pointType) {
|
||||
case START:
|
||||
helper.setStartPoint(ll, true, name);
|
||||
break;
|
||||
case TARGET:
|
||||
helper.navigateToPoint(ll, true, -1, name);
|
||||
break;
|
||||
case INTERMEDIATE:
|
||||
helper.navigateToPoint(ll, true, helper.getIntermediatePoints().size(), name);
|
||||
break;
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private Pair<LatLon, PointDescription> getLocationAndDescrFromItem(Object item, TargetPointsHelper helper) {
|
||||
PointDescription name = null;
|
||||
LatLon ll = null;
|
||||
if (item instanceof FavouritePoint) {
|
||||
FavouritePoint point = (FavouritePoint) item;
|
||||
ll = new LatLon(point.getLatitude(), point.getLongitude());
|
||||
name = point.getPointDescription();
|
||||
} else if (item instanceof PointType) {
|
||||
TargetPointsHelper.TargetPoint point = null;
|
||||
if (item == PointType.HOME) {
|
||||
point = helper.getHomePoint();
|
||||
} else if (item == PointType.WORK) {
|
||||
point = helper.getWorkPoint();
|
||||
}
|
||||
if (point != null) {
|
||||
ll = new LatLon(point.getLatitude(), point.getLongitude());
|
||||
name = point.getOriginalPointDescription();
|
||||
}
|
||||
}
|
||||
return new Pair<>(ll, name);
|
||||
}
|
||||
|
||||
private void openFavouritesDialog() {
|
||||
MapActivity mapActivity = (MapActivity) getActivity();
|
||||
if (mapActivity != null) {
|
||||
FragmentManager fragmentManager = mapActivity.getSupportFragmentManager();
|
||||
FavouritesBottomSheetMenuFragment fragment = new FavouritesBottomSheetMenuFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(FavouritesBottomSheetMenuFragment.POINT_TYPE_KEY, pointType.name());
|
||||
fragment.setTargetFragment(AddPointBottomSheetDialog.this, ADD_FAVOURITE_TO_ROUTE_REQUEST_CODE);
|
||||
fragment.setArguments(args);
|
||||
fragment.show(fragmentManager, FavouritesBottomSheetMenuFragment.TAG);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean showInstance(@NonNull MapActivity mapActivity, PointType pointType) {
|
||||
return showInstance(mapActivity, pointType, true);
|
||||
}
|
||||
|
||||
public static boolean showInstance(@NonNull MapActivity mapActivity, PointType pointType, boolean usedOnMap) {
|
||||
try {
|
||||
if (mapActivity.isActivityDestroyed()) {
|
||||
return false;
|
||||
}
|
||||
Bundle args = new Bundle();
|
||||
args.putString(AddPointBottomSheetDialog.POINT_TYPE_KEY, pointType.name());
|
||||
AddPointBottomSheetDialog fragment = new AddPointBottomSheetDialog();
|
||||
fragment.setArguments(args);
|
||||
fragment.setUsedOnMap(usedOnMap);
|
||||
fragment.show(mapActivity.getSupportFragmentManager(), TAG);
|
||||
return true;
|
||||
} catch (RuntimeException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class FavouritesItemsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final List<Object> items;
|
||||
private OsmandApplication app;
|
||||
private View.OnClickListener listener;
|
||||
|
||||
public FavouritesItemsAdapter(OsmandApplication app, List<Object> items) {
|
||||
this.app = app;
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
|
||||
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.bottom_sheet_item_with_descr_56dp, viewGroup, false);
|
||||
view.setOnClickListener(listener);
|
||||
Activity activity = getActivity();
|
||||
if (activity != null) {
|
||||
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
|
||||
if (AndroidUiHelper.isOrientationPortrait(getActivity())) {
|
||||
layoutParams.width = AndroidUtils.getScreenWidth(activity) / 2;
|
||||
} else {
|
||||
// 11.5dp is the shadow width
|
||||
layoutParams.width = (getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width) / 2) - AndroidUtils.dpToPx(activity, 11.5f);
|
||||
}
|
||||
view.setLayoutParams(layoutParams);
|
||||
}
|
||||
FavouritesViewHolder viewHolder = new FavouritesViewHolder(view);
|
||||
view.setTag(viewHolder);
|
||||
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if (holder instanceof FavouritesViewHolder) {
|
||||
Object item = getItem(position);
|
||||
FavouritesViewHolder favouritesViewHolder = (FavouritesViewHolder) holder;
|
||||
if (item.equals(FAVOURITES)) {
|
||||
favouritesViewHolder.title.setText(R.string.shared_string_favorites);
|
||||
favouritesViewHolder.icon.setImageDrawable(getContentIcon(R.drawable.ic_action_fav_dark));
|
||||
favouritesViewHolder.description.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (item instanceof PointType) {
|
||||
final TargetPointsHelper helper = app.getTargetPointsHelper();
|
||||
TargetPointsHelper.TargetPoint point = null;
|
||||
if (item == PointType.HOME) {
|
||||
point = helper.getHomePoint();
|
||||
favouritesViewHolder.title.setText(getString(R.string.home_button));
|
||||
favouritesViewHolder.icon.setImageDrawable(getContentIcon(R.drawable.ic_action_home_dark));
|
||||
} else if (item == PointType.WORK) {
|
||||
point = helper.getWorkPoint();
|
||||
favouritesViewHolder.title.setText(getString(R.string.work_button));
|
||||
favouritesViewHolder.icon.setImageDrawable(getContentIcon(R.drawable.ic_action_work));
|
||||
}
|
||||
favouritesViewHolder.description.setText(point != null ? point.getPointDescription(app).getSimpleName(app, false) : getString(R.string.shared_string_add));
|
||||
} else if (item instanceof FavouritePoint) {
|
||||
FavouritePoint point = (FavouritePoint) getItem(position);
|
||||
favouritesViewHolder.title.setText(point.getName());
|
||||
if (point.getCategory().equals("")) {
|
||||
favouritesViewHolder.description.setText(R.string.shared_string_favorites);
|
||||
} else {
|
||||
favouritesViewHolder.description.setText(point.getCategory());
|
||||
}
|
||||
int pointColor = point.getColor();
|
||||
int color = pointColor == 0 || pointColor == Color.BLACK ? ContextCompat.getColor(app, R.color.color_favorite) : pointColor;
|
||||
favouritesViewHolder.icon.setImageDrawable(app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_fav_dark, color));
|
||||
}
|
||||
favouritesViewHolder.description.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return items.size();
|
||||
}
|
||||
|
||||
private Object getItem(int position) {
|
||||
return items.get(position);
|
||||
}
|
||||
|
||||
public void setItemClickListener(View.OnClickListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
class FavouritesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
final TextView title;
|
||||
final TextView description;
|
||||
final ImageView icon;
|
||||
|
||||
public FavouritesViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
title = (TextView) itemView.findViewById(R.id.title);
|
||||
description = (TextView) itemView.findViewById(R.id.description);
|
||||
icon = (ImageView) itemView.findViewById(R.id.icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@ import android.content.DialogInterface.OnDismissListener;
|
|||
import android.graphics.PointF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.NonNull;
|
||||
|
@ -1224,6 +1223,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
container.findViewById(R.id.title_divider).setVisibility(View.GONE);
|
||||
}
|
||||
routeOptionTV.setText(title);
|
||||
routeOptionTV.setTextColor(ContextCompat.getColor(app, R.color.description_font_and_bottom_sheet_icons));
|
||||
routeOptionImageView.setImageDrawable(app.getUIUtilities().getIcon(iconId, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light));
|
||||
container.setOnClickListener(listener);
|
||||
|
||||
|
@ -1345,7 +1345,10 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
toLayout.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openAddPointDialog(PointType.TARGET);
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
AddPointBottomSheetDialog.showInstance(mapActivity, PointType.TARGET);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1376,9 +1379,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
toButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
OsmandApplication app = getApp();
|
||||
if (app != null) {
|
||||
openAddPointDialog(app.getTargetPointsHelper().getPointToNavigate() == null ? PointType.TARGET : PointType.INTERMEDIATE);
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
AddPointBottomSheetDialog.showInstance(mapActivity, mapActivity.getMyApplication().getTargetPointsHelper().getPointToNavigate() == null ? PointType.TARGET : PointType.INTERMEDIATE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1419,7 +1422,10 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
fromLayout.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openAddPointDialog(PointType.START);
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
AddPointBottomSheetDialog.showInstance(mapActivity, PointType.START);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1635,17 +1641,6 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
}
|
||||
}
|
||||
|
||||
private void openAddPointDialog(PointType pointType) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(AddPointBottomSheetDialog.POINT_TYPE_KEY, pointType.name());
|
||||
AddPointBottomSheetDialog fragment = new AddPointBottomSheetDialog();
|
||||
fragment.setArguments(args);
|
||||
fragment.show(mapActivity.getSupportFragmentManager(), AddPointBottomSheetDialog.TAG);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isLight() {
|
||||
return !nightMode;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package net.osmand.plus.routepreparationmenu.cards;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -40,7 +39,7 @@ public class HomeWorkCard extends BaseCard {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
if (homePoint == null) {
|
||||
openAddPointDialog(mapActivity, true);
|
||||
AddPointBottomSheetDialog.showInstance(mapActivity, PointType.HOME);
|
||||
} else {
|
||||
targetPointsHelper.navigateToPoint(homePoint.point, true, -1, homePoint.getOriginalPointDescription());
|
||||
}
|
||||
|
@ -49,7 +48,7 @@ public class HomeWorkCard extends BaseCard {
|
|||
homeButton.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
openAddPointDialog(mapActivity, true);
|
||||
AddPointBottomSheetDialog.showInstance(mapActivity, PointType.HOME);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -59,7 +58,7 @@ public class HomeWorkCard extends BaseCard {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
if (workPoint == null) {
|
||||
openAddPointDialog(mapActivity, false);
|
||||
AddPointBottomSheetDialog.showInstance(mapActivity, PointType.WORK);
|
||||
} else {
|
||||
targetPointsHelper.navigateToPoint(workPoint.point, true, -1, workPoint.getOriginalPointDescription());
|
||||
}
|
||||
|
@ -68,18 +67,9 @@ public class HomeWorkCard extends BaseCard {
|
|||
workButton.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
openAddPointDialog(mapActivity, false);
|
||||
AddPointBottomSheetDialog.showInstance(mapActivity, PointType.WORK);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void openAddPointDialog(MapActivity mapActivity, boolean home) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(AddPointBottomSheetDialog.POINT_TYPE_KEY, home ? PointType.HOME.name() : PointType.WORK.name());
|
||||
AddPointBottomSheetDialog fragment = new AddPointBottomSheetDialog();
|
||||
fragment.setArguments(args);
|
||||
fragment.setUsedOnMap(true);
|
||||
fragment.show(mapActivity.getSupportFragmentManager(), AddPointBottomSheetDialog.TAG);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,7 @@ package net.osmand.plus.routepreparationmenu.cards;
|
|||
|
||||
import android.graphics.Typeface;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextPaint;
|
||||
|
@ -78,7 +76,7 @@ public class WarningCard extends BaseCard {
|
|||
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
openAddPointDialog();
|
||||
AddPointBottomSheetDialog.showInstance(mapActivity, PointType.INTERMEDIATE);
|
||||
}
|
||||
};
|
||||
text.setSpan(clickableSpan, 0, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
@ -88,16 +86,4 @@ public class WarningCard extends BaseCard {
|
|||
warningDescr.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
private void openAddPointDialog() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(AddPointBottomSheetDialog.POINT_TYPE_KEY, PointType.INTERMEDIATE.name());
|
||||
AddPointBottomSheetDialog fragment = new AddPointBottomSheetDialog();
|
||||
fragment.setArguments(args);
|
||||
fragment.setUsedOnMap(true);
|
||||
fragment.show(mapActivity.getSupportFragmentManager(), AddPointBottomSheetDialog.TAG);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue