Disable drawer for route menu

This commit is contained in:
Chumva 2018-12-20 14:42:45 +02:00
parent ecc39707e4
commit b43379f63f
5 changed files with 174 additions and 161 deletions

View file

@ -29,9 +29,10 @@
android:id="@+id/fab_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_gravity="right"
android:layout_marginBottom="@dimen/map_button_margin"
android:layout_marginRight="@dimen/map_button_margin">
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding">
<ImageButton
android:id="@+id/map_my_location_button"
@ -45,7 +46,6 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="@dimen/map_button_spacing"
android:orientation="vertical">
@ -74,8 +74,7 @@
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_gravity="bottom"
android:layout_marginTop="@dimen/content_padding" />
android:layout_gravity="bottom" />
</LinearLayout>

View file

@ -51,6 +51,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment {
private boolean portrait;
private boolean nightMode;
private boolean wasDrawerDisabled;
@Nullable
@Override
@ -59,96 +60,94 @@ public class ChooseRouteFragment extends BaseOsmAndFragment {
nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
map = getMapActivity().getMapView();
view = inflater.inflate(R.layout.fragment_show_all_routes, null);
AndroidUtils.addStatusBarPadding21v(mapActivity, view);
viewPager = view.findViewById(R.id.pager);
final List<PublicTransportCard> routeCards = new ArrayList<>();
List<TransportRoutePlanner.TransportRouteResult> routes = getMyApplication().getTransportRoutingHelper().getRoutes();
for (int i = 0; i < routes.size(); i++) {
PublicTransportCard card = new PublicTransportCard(mapActivity, routes.get(i), i);
card.setSecondButtonVisible(true);
card.setShowTopShadow(false);
card.setShowBottomShadow(false);
routeCards.add(card);
}
if (routes != null && !routes.isEmpty()) {
view = inflater.inflate(R.layout.fragment_show_all_routes, null);
viewPager = view.findViewById(R.id.pager);
viewPager.setClipToPadding(false);
final ViewsPagerAdapter pagerAdapter = new ViewsPagerAdapter(mapActivity, routeCards);
viewPager.setAdapter(pagerAdapter);
viewPager.setSwipeLocked(routeCards.size() < 2);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
public void onPageScrollStateChanged(int state) {
AndroidUtils.addStatusBarPadding21v(mapActivity, view);
final List<PublicTransportCard> routeCards = new ArrayList<>();
for (int i = 0; i < routes.size(); i++) {
PublicTransportCard card = new PublicTransportCard(mapActivity, routes.get(i), i);
card.setSecondButtonVisible(true);
card.setShowTopShadow(false);
card.setShowBottomShadow(false);
routeCards.add(card);
}
viewPager.setClipToPadding(false);
final ViewsPagerAdapter pagerAdapter = new ViewsPagerAdapter(mapActivity, routeCards);
viewPager.setAdapter(pagerAdapter);
viewPager.setSwipeLocked(routeCards.size() < 2);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
public void onPageScrollStateChanged(int state) {
}
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
public void onPageSelected(int position) {
mapActivity.getMyApplication().getTransportRoutingHelper().setCurrentRoute(routeCards.get(position).getRouteId());
mapActivity.refreshMap();
}
});
if (!portrait) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, AndroidUtils.dpToPx(getMyApplication(), 200f));
params.gravity = Gravity.BOTTOM;
viewPager.setLayoutParams(params);
}
ImageButton backButtonView = (ImageButton) view.findViewById(R.id.back_button);
backButtonView.setImageDrawable(getContentIcon(R.drawable.ic_arrow_back));
AndroidUtils.setBackground(mapActivity, backButtonView, nightMode, R.drawable.btn_circle_trans, R.drawable.btn_circle_night);
backButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss(mapActivity);
}
});
View fabButtonsView = view.findViewById(R.id.fab_container);
ImageButton zoomInButtonView = (ImageButton) view.findViewById(R.id.map_zoom_in_button);
ImageButton zoomOutButtonView = (ImageButton) view.findViewById(R.id.map_zoom_out_button);
myLocButtonView = (ImageButton) view.findViewById(R.id.map_my_location_button);
if (portrait) {
updateImageButton(zoomInButtonView, R.drawable.map_zoom_in, R.drawable.map_zoom_in_night,
R.drawable.btn_circle_trans, R.drawable.btn_circle_night, nightMode);
updateImageButton(zoomOutButtonView, R.drawable.map_zoom_out, R.drawable.map_zoom_out_night,
R.drawable.btn_circle_trans, R.drawable.btn_circle_night, nightMode);
zoomInButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
doZoomIn();
public void onPageSelected(int position) {
mapActivity.getMyApplication().getTransportRoutingHelper().setCurrentRoute(routeCards.get(position).getRouteId());
mapActivity.refreshMap();
}
});
zoomOutButtonView.setOnClickListener(new View.OnClickListener() {
if (!portrait) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, AndroidUtils.dpToPx(getMyApplication(), 200f));
params.gravity = Gravity.BOTTOM;
viewPager.setLayoutParams(params);
}
ImageButton backButtonView = (ImageButton) view.findViewById(R.id.back_button);
backButtonView.setImageDrawable(getIcon(R.drawable.ic_arrow_back, R.color.icon_color));
AndroidUtils.setBackground(mapActivity, backButtonView, nightMode, R.drawable.btn_circle, R.drawable.btn_circle_night);
backButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
doZoomOut();
dismiss(mapActivity);
}
});
myLocButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
} else {
ActivityCompat.requestPermissions(mapActivity,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
OsmAndLocationProvider.REQUEST_LOCATION_PERMISSION);
View fabButtonsView = view.findViewById(R.id.fab_container);
ImageButton zoomInButtonView = (ImageButton) view.findViewById(R.id.map_zoom_in_button);
ImageButton zoomOutButtonView = (ImageButton) view.findViewById(R.id.map_zoom_out_button);
myLocButtonView = (ImageButton) view.findViewById(R.id.map_my_location_button);
if (portrait) {
updateImageButton(zoomInButtonView, R.drawable.map_zoom_in, R.drawable.map_zoom_in_night,
R.drawable.btn_circle_trans, R.drawable.btn_circle_night, nightMode);
updateImageButton(zoomOutButtonView, R.drawable.map_zoom_out, R.drawable.map_zoom_out_night,
R.drawable.btn_circle_trans, R.drawable.btn_circle_night, nightMode);
zoomInButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
doZoomIn();
}
}
});
fabButtonsView.setVisibility(View.VISIBLE);
} else {
fabButtonsView.setVisibility(View.GONE);
});
zoomOutButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
doZoomOut();
}
});
myLocButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
} else {
ActivityCompat.requestPermissions(mapActivity,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
OsmAndLocationProvider.REQUEST_LOCATION_PERMISSION);
}
}
});
fabButtonsView.setVisibility(View.VISIBLE);
} else {
fabButtonsView.setVisibility(View.GONE);
}
updateMyLocation(mapActivity.getRoutingHelper());
}
updateMyLocation(mapActivity.getRoutingHelper());
return view;
}
@ -206,11 +205,18 @@ public class ChooseRouteFragment extends BaseOsmAndFragment {
super.onResume();
getMapActivity().getMapLayers().getMapControlsLayer().showMapControlsIfHidden();
MapRouteInfoMenu.chooseRoutesVisible = true;
wasDrawerDisabled = getMapActivity().isDrawerDisabled();
if (!wasDrawerDisabled) {
getMapActivity().disableDrawer();
}
}
public void onPause() {
super.onPause();
MapRouteInfoMenu.chooseRoutesVisible = false;
if (!wasDrawerDisabled) {
getMapActivity().enableDrawer();
}
}
@Override
@ -224,12 +230,12 @@ public class ChooseRouteFragment extends BaseOsmAndFragment {
boolean tracked = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
if (!enabled) {
myLocButtonView.setImageDrawable(getContentIcon(R.drawable.map_my_location));
AndroidUtils.setBackground(mapActivity, myLocButtonView, nightMode, R.drawable.btn_circle_trans, R.drawable.btn_circle_night);
myLocButtonView.setImageDrawable(getIcon(R.drawable.map_my_location, R.color.icon_color));
AndroidUtils.setBackground(mapActivity, myLocButtonView, nightMode, R.drawable.btn_circle, R.drawable.btn_circle_night);
myLocButtonView.setContentDescription(mapActivity.getString(R.string.unknown_location));
} else if (tracked) {
myLocButtonView.setImageDrawable(getIcon(R.drawable.map_my_location, R.color.color_myloc_distance));
AndroidUtils.setBackground(mapActivity, myLocButtonView, nightMode, R.drawable.btn_circle_trans, R.drawable.btn_circle_night);
AndroidUtils.setBackground(mapActivity, myLocButtonView, nightMode, R.drawable.btn_circle, R.drawable.btn_circle_night);
} else {
myLocButtonView.setImageResource(R.drawable.map_my_location);
AndroidUtils.setBackground(mapActivity, myLocButtonView, nightMode, R.drawable.btn_circle_blue, R.drawable.btn_circle_blue);

View file

@ -65,6 +65,7 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
private boolean moving;
private boolean forceUpdateLayout;
private boolean initLayout = true;
private boolean wasDrawerDisabled;
private int menuFullHeight;
private int minHalfY;
@ -311,17 +312,24 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
((View) parent).addOnLayoutChangeListener(containerLayoutListener);
}
getMapActivity().getMapLayers().getMapControlsLayer().showMapControlsIfHidden();
wasDrawerDisabled = getMapActivity().isDrawerDisabled();
if (!wasDrawerDisabled) {
getMapActivity().disableDrawer();
}
}
@Override
public void onPause() {
super.onPause();
if (view != null) {
ViewParent parent = view.getParent();
if (parent != null && containerLayoutListener != null) {
((View) parent).removeOnLayoutChangeListener(containerLayoutListener);
}
}
super.onPause();
if (!wasDrawerDisabled) {
getMapActivity().enableDrawer();
}
}
@Override

View file

@ -46,6 +46,39 @@ public class PublicTransportCard extends BaseRouteCard {
this.routeId = routeId;
}
@Override
public int getCardLayoutId() {
return R.layout.transport_route_card;
}
@Override
public void update() {
if (view != null) {
view.setBackgroundColor(ContextCompat.getColor(app, nightMode ? R.color.route_info_bg_dark : R.color.route_info_bg_light));
List<TransportRouteResultSegment> segments = routeResult.getSegments();
createRouteBadges(segments);
TextView fromLine = (TextView) view.findViewById(R.id.from_line);
TextView wayLine = (TextView) view.findViewById(R.id.way_line);
fromLine.setText(getFirstLineDescrSpan());
wayLine.setText(getSecondLineDescrSpan());
view.findViewById(R.id.details_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
app.getTransportRoutingHelper().setCurrentRoute(routeId);
getMapActivity().refreshMap();
}
});
view.findViewById(R.id.bottom_shadow).setVisibility(showBottomShadow ? View.VISIBLE : View.GONE);
view.findViewById(R.id.card_divider).setVisibility(showTopShadow ? View.VISIBLE : View.GONE);
applyDayNightMode();
}
}
public int getRouteId() {
return routeId;
}
@ -230,37 +263,4 @@ public class PublicTransportCard extends BaseRouteCard {
private double getWalkTime(double walkDist, double walkSpeed) {
return walkDist / walkSpeed;
}
@Override
public int getCardLayoutId() {
return R.layout.transport_route_card;
}
@Override
public void update() {
if (view != null) {
view.setBackgroundColor(ContextCompat.getColor(app, nightMode ? R.color.route_info_bg_dark : R.color.route_info_bg_light));
List<TransportRouteResultSegment> segments = routeResult.getSegments();
createRouteBadges(segments);
TextView fromLine = (TextView) view.findViewById(R.id.from_line);
TextView wayLine = (TextView) view.findViewById(R.id.way_line);
fromLine.setText(getFirstLineDescrSpan());
wayLine.setText(getSecondLineDescrSpan());
view.findViewById(R.id.details_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
app.getTransportRoutingHelper().setCurrentRoute(routeId);
getMapActivity().refreshMap();
}
});
view.findViewById(R.id.bottom_shadow).setVisibility(showBottomShadow ? View.VISIBLE : View.GONE);
view.findViewById(R.id.card_divider).setVisibility(showTopShadow ? View.VISIBLE : View.GONE);
applyDayNightMode();
}
}
}

View file

@ -37,49 +37,6 @@ public class SimpleRouteCard extends BaseRouteCard {
this.gpx = gpx;
}
protected void applyDayNightMode() {
FrameLayout detailsButton = view.findViewById(R.id.details_button);
AndroidUtils.setBackground(app, detailsButton, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, view.findViewById(R.id.details_button_descr), nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
} else {
AndroidUtils.setBackground(app, view.findViewById(R.id.details_button_descr), nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
}
int color = ContextCompat.getColor(mapActivity, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
AndroidUtils.setBackground(app, view.findViewById(R.id.dividerToDropDown), nightMode, R.color.divider_light, R.color.divider_dark);
AndroidUtils.setBackground(app, view.findViewById(R.id.info_divider), nightMode, R.color.activity_background_light, R.color.route_info_cancel_button_color_dark);
AndroidUtils.setBackground(app, view.findViewById(R.id.route_info_details_card), nightMode, R.color.activity_background_light, R.color.route_info_cancel_button_color_dark);
AndroidUtils.setBackground(app, view.findViewById(R.id.RouteInfoControls), nightMode, R.color.route_info_bg_light, R.color.route_info_bg_dark);
((TextView) view.findViewById(R.id.details_button_descr)).setTextColor(color);
}
private void buildHeader(View headerView) {
final LineChart mChart = (LineChart) headerView.findViewById(R.id.chart);
final GPXUtilities.GPXTrackAnalysis analysis = gpx.getAnalysis(0);
GpxUiHelper.setupGPXChart(mChart, 4, 4f, 4f, !nightMode, false);
GpxUiHelper.OrderedLineDataSet elevationDataSet;
GpxUiHelper.OrderedLineDataSet slopeDataSet;
if (analysis.hasElevationData) {
List<ILineDataSet> dataSets = new ArrayList<>();
elevationDataSet = GpxUiHelper.createGPXElevationDataSet(app, mChart, analysis,
GpxUiHelper.GPXDataSetAxisType.DISTANCE, false, true);
if (elevationDataSet != null) {
dataSets.add(elevationDataSet);
}
slopeDataSet = GpxUiHelper.createGPXSlopeDataSet(app, mChart, analysis,
GpxUiHelper.GPXDataSetAxisType.DISTANCE, elevationDataSet.getValues(), true, true);
if (slopeDataSet != null) {
dataSets.add(slopeDataSet);
}
mChart.setData(new LineData(dataSets));
mChart.setVisibility(View.VISIBLE);
} else {
mChart.setVisibility(View.GONE);
}
}
@Override
public int getCardLayoutId() {
return R.layout.route_info_statistic;
@ -150,4 +107,47 @@ public class SimpleRouteCard extends BaseRouteCard {
applyDayNightMode();
}
}
protected void applyDayNightMode() {
FrameLayout detailsButton = view.findViewById(R.id.details_button);
AndroidUtils.setBackground(app, detailsButton, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, view.findViewById(R.id.details_button_descr), nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
} else {
AndroidUtils.setBackground(app, view.findViewById(R.id.details_button_descr), nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
}
int color = ContextCompat.getColor(mapActivity, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
AndroidUtils.setBackground(app, view.findViewById(R.id.dividerToDropDown), nightMode, R.color.divider_light, R.color.divider_dark);
AndroidUtils.setBackground(app, view.findViewById(R.id.info_divider), nightMode, R.color.activity_background_light, R.color.route_info_cancel_button_color_dark);
AndroidUtils.setBackground(app, view.findViewById(R.id.route_info_details_card), nightMode, R.color.activity_background_light, R.color.route_info_cancel_button_color_dark);
AndroidUtils.setBackground(app, view.findViewById(R.id.RouteInfoControls), nightMode, R.color.route_info_bg_light, R.color.route_info_bg_dark);
((TextView) view.findViewById(R.id.details_button_descr)).setTextColor(color);
}
private void buildHeader(View headerView) {
final LineChart mChart = (LineChart) headerView.findViewById(R.id.chart);
final GPXUtilities.GPXTrackAnalysis analysis = gpx.getAnalysis(0);
GpxUiHelper.setupGPXChart(mChart, 4, 4f, 4f, !nightMode, false);
GpxUiHelper.OrderedLineDataSet elevationDataSet;
GpxUiHelper.OrderedLineDataSet slopeDataSet;
if (analysis.hasElevationData) {
List<ILineDataSet> dataSets = new ArrayList<>();
elevationDataSet = GpxUiHelper.createGPXElevationDataSet(app, mChart, analysis,
GpxUiHelper.GPXDataSetAxisType.DISTANCE, false, true);
if (elevationDataSet != null) {
dataSets.add(elevationDataSet);
}
slopeDataSet = GpxUiHelper.createGPXSlopeDataSet(app, mChart, analysis,
GpxUiHelper.GPXDataSetAxisType.DISTANCE, elevationDataSet.getValues(), true, true);
if (slopeDataSet != null) {
dataSets.add(slopeDataSet);
}
mChart.setData(new LineData(dataSets));
mChart.setVisibility(View.VISIBLE);
} else {
mChart.setVisibility(View.GONE);
}
}
}