Added pages control to route details
This commit is contained in:
parent
e1c79037cf
commit
4cea208b95
13 changed files with 178 additions and 6 deletions
8
OsmAnd/res/drawable/pages_active_dark.xml
Normal file
8
OsmAnd/res/drawable/pages_active_dark.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="@color/active_buttons_and_links_dark"/>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
8
OsmAnd/res/drawable/pages_active_light.xml
Normal file
8
OsmAnd/res/drawable/pages_active_light.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="@color/active_buttons_and_links_light"/>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
12
OsmAnd/res/drawable/pages_bg_dark.xml
Normal file
12
OsmAnd/res/drawable/pages_bg_dark.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<nine-patch android:src="@drawable/bg_route_indicator"/>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<solid android:color="@color/card_and_list_background_dark"/>
|
||||
<corners android:radius="6dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
12
OsmAnd/res/drawable/pages_bg_light.xml
Normal file
12
OsmAnd/res/drawable/pages_bg_light.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<nine-patch android:src="@drawable/bg_route_indicator"/>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<solid android:color="@color/card_and_list_background_light"/>
|
||||
<corners android:radius="6dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
8
OsmAnd/res/drawable/pages_inactive_dark.xml
Normal file
8
OsmAnd/res/drawable/pages_inactive_dark.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="@color/inactive_buttons_and_links_dark"/>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
8
OsmAnd/res/drawable/pages_inactive_light.xml
Normal file
8
OsmAnd/res/drawable/pages_inactive_light.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="@color/inactive_buttons_and_links_light"/>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
|
@ -35,11 +35,11 @@
|
|||
android:id="@+id/back_button_flow"
|
||||
android:layout_width="@dimen/route_info_toolbar_button_size"
|
||||
android:layout_height="@dimen/route_info_toolbar_button_size"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="@drawable/btn_circle_transparent_full"
|
||||
android:contentDescription="@string/shared_string_back"
|
||||
android:src="@drawable/ic_arrow_back"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:tint="?attr/primary_icon_color" />
|
||||
|
||||
<LinearLayout
|
||||
|
@ -210,6 +210,31 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/pages_control"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:background="?attr/pages_bg"
|
||||
android:gravity="center">
|
||||
|
||||
<View
|
||||
android:layout_width="@dimen/pages_item_size"
|
||||
android:layout_height="@dimen/pages_item_size"
|
||||
android:layout_marginLeft="@dimen/pages_item_margin"
|
||||
android:layout_marginRight="@dimen/pages_item_padding"
|
||||
android:background="@drawable/pages_active_dark" />
|
||||
|
||||
<View
|
||||
android:layout_width="@dimen/pages_item_size"
|
||||
android:layout_height="@dimen/pages_item_size"
|
||||
android:layout_marginRight="@dimen/pages_item_margin"
|
||||
android:background="@drawable/pages_inactive_dark" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/map_hud_controls"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -113,6 +113,7 @@
|
|||
<attr name="active_color_basic" format="reference" />
|
||||
<attr name="card_and_list_background_basic" format="reference" />
|
||||
<attr name="activity_background_basic" format="reference" />
|
||||
<attr name="pages_bg" format="reference"/>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="PagerSlidingTabStrip">
|
||||
|
|
|
@ -473,6 +473,8 @@
|
|||
<color name="additional_description_light">#b3b3b3</color>
|
||||
<color name="active_buttons_and_links_light">#237bff</color>
|
||||
<color name="active_buttons_and_links_dark">#d28521</color>
|
||||
<color name="inactive_buttons_and_links_light">#cccccc</color>
|
||||
<color name="inactive_buttons_and_links_dark">#505050</color>
|
||||
<color name="active_buttons_and_links_trans_light">#66237bff</color>
|
||||
<color name="active_buttons_and_links_trans_dark">#66d28521</color>
|
||||
|
||||
|
|
|
@ -331,4 +331,9 @@
|
|||
|
||||
<dimen name="text_button_letter_spacing" format="float">0.01</dimen>
|
||||
<dimen name="text_button_line_spacing_multiplier" format="float">1.2</dimen>
|
||||
|
||||
<dimen name="pages_item_size">4dp</dimen>
|
||||
<dimen name="pages_item_padding">3dp</dimen>
|
||||
<dimen name="pages_item_margin">4dp</dimen>
|
||||
|
||||
</resources>
|
|
@ -245,6 +245,7 @@
|
|||
<item name="active_color_basic">@color/active_buttons_and_links_light</item>
|
||||
<item name="card_and_list_background_basic">@color/card_and_list_background_light</item>
|
||||
<item name="activity_background_basic">@color/activity_background_light</item>
|
||||
<item name="pages_bg">@drawable/pages_bg_light</item>
|
||||
</style>
|
||||
|
||||
<style name="OverflowMenuButton" parent="@style/Widget.AppCompat.ActionButton.Overflow">
|
||||
|
@ -476,6 +477,7 @@
|
|||
<item name="active_color_basic">@color/active_buttons_and_links_dark</item>
|
||||
<item name="card_and_list_background_basic">@color/card_and_list_background_dark</item>
|
||||
<item name="activity_background_basic">@color/activity_background_dark</item>
|
||||
<item name="pages_bg">@drawable/pages_bg_dark</item>
|
||||
</style>
|
||||
|
||||
<style name="FreeVersionBanner" parent="OsmandDarkTheme">
|
||||
|
|
|
@ -600,7 +600,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
|
|||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
int height = getMenuStatePosY(getCurrentMenuState());
|
||||
return viewHeight - height - AndroidUtils.getStatusBarHeight(mapActivity);
|
||||
return viewHeight - height - statusBarHeight;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.routepreparationmenu;
|
|||
import android.Manifest;
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
|
@ -27,6 +28,7 @@ import android.view.ViewGroup;
|
|||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.GPXUtilities;
|
||||
|
@ -86,11 +88,14 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
private View zoomButtonsView;
|
||||
@Nullable
|
||||
private ImageButton myLocButtonView;
|
||||
@Nullable
|
||||
private ViewGroup pagesView;
|
||||
|
||||
private boolean portrait;
|
||||
private boolean nightMode;
|
||||
private boolean wasDrawerDisabled;
|
||||
private int currentMenuState;
|
||||
private int routesCount;
|
||||
|
||||
private boolean publicTransportMode;
|
||||
private int routeInfoMenuState = -1;
|
||||
|
@ -113,7 +118,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
routeInfoMenuState = args.getInt(ROUTE_INFO_STATE_KEY, -1);
|
||||
initialMenuState = args.getInt(INITIAL_MENU_STATE_KEY, initialMenuState);
|
||||
}
|
||||
int routesCount = 1;
|
||||
routesCount = 1;
|
||||
if (routes != null && !routes.isEmpty()) {
|
||||
publicTransportMode = true;
|
||||
routesCount = routes.size();
|
||||
|
@ -152,9 +157,11 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
|
||||
public void onPageSelected(int position) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
View view = getView();
|
||||
if (mapActivity != null && view != null) {
|
||||
mapActivity.getMyApplication().getTransportRoutingHelper().setCurrentRoute(position);
|
||||
mapActivity.refreshMap();
|
||||
buildPagesControl(view);
|
||||
List<WeakReference<RouteDetailsFragment>> routeDetailsFragments = ChooseRouteFragment.this.routeDetailsFragments;
|
||||
for (WeakReference<RouteDetailsFragment> ref : routeDetailsFragments) {
|
||||
RouteDetailsFragment f = ref.get();
|
||||
|
@ -165,12 +172,15 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
}
|
||||
if (f == getCurrentFragment()) {
|
||||
updateZoomButtonsPos(f, f.getViewY(), true);
|
||||
updatePagesViewPos(f, f.getViewY(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
this.pagesView = (ViewGroup) view.findViewById(R.id.pages_control);
|
||||
buildPagesControl(view);
|
||||
buildZoomButtons(view);
|
||||
buildMenuButtons(view);
|
||||
return view;
|
||||
|
@ -269,6 +279,41 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
}
|
||||
}
|
||||
|
||||
private void buildPagesControl(@NonNull View view) {
|
||||
ViewGroup pagesView = this.pagesView;
|
||||
if (pagesView != null) {
|
||||
pagesView.removeAllViews();
|
||||
LockableViewPager viewPager = this.viewPager;
|
||||
if (portrait && routesCount > 1 && viewPager != null) {
|
||||
int itemSize = getResources().getDimensionPixelSize(R.dimen.pages_item_size);
|
||||
int itemMargin = getResources().getDimensionPixelSize(R.dimen.pages_item_margin);
|
||||
int itemPadding = getResources().getDimensionPixelSize(R.dimen.pages_item_padding);
|
||||
for (int i = 0; i < routesCount; i++) {
|
||||
boolean active = i == viewPager.getCurrentItem();
|
||||
Context ctx = view.getContext();
|
||||
View itemView = new View(ctx);
|
||||
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(itemSize, itemSize);
|
||||
AndroidUtils.setBackground(ctx, itemView, nightMode,
|
||||
active ? R.drawable.pages_active_light : R.drawable.pages_inactive_light,
|
||||
active ? R.drawable.pages_active_dark : R.drawable.pages_inactive_dark);
|
||||
if (i == 0) {
|
||||
layoutParams.setMargins(itemMargin, 0, itemPadding, 0);
|
||||
} else if (i == routesCount - 1) {
|
||||
layoutParams.setMargins(0, 0, itemMargin, 0);
|
||||
} else {
|
||||
layoutParams.setMargins(0, 0, itemPadding, 0);
|
||||
}
|
||||
itemView.setLayoutParams(layoutParams);
|
||||
pagesView.addView(itemView);
|
||||
}
|
||||
pagesView.requestLayout();
|
||||
pagesView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
pagesView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buildZoomButtons(@NonNull View view) {
|
||||
OsmandApplication app = requireMyApplication();
|
||||
// Zoom buttons
|
||||
|
@ -379,6 +424,26 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
}
|
||||
}
|
||||
|
||||
private void updatePagesViewVisibility(int menuState) {
|
||||
View pagesView = this.pagesView;
|
||||
if (pagesView != null) {
|
||||
if (menuState != MenuState.FULL_SCREEN) {
|
||||
if (pagesView.getVisibility() != View.VISIBLE) {
|
||||
pagesView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
if (pagesView.getVisibility() == View.VISIBLE) {
|
||||
pagesView.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getPagesViewHeight() {
|
||||
ViewGroup pagesView = this.pagesView;
|
||||
return pagesView != null ? pagesView.getHeight() : 0;
|
||||
}
|
||||
|
||||
private int getZoomButtonsHeight() {
|
||||
View zoomButtonsView = this.zoomButtonsView;
|
||||
return zoomButtonsView != null ? zoomButtonsView.getHeight() : 0;
|
||||
|
@ -672,10 +737,24 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
}
|
||||
}
|
||||
|
||||
public void updatePagesViewPos(@NonNull ContextMenuFragment fragment, int y, boolean animated) {
|
||||
ViewGroup pagesView = this.pagesView;
|
||||
if (pagesView != null) {
|
||||
int pagesY = y - getPagesViewHeight() + fragment.getShadowHeight() +
|
||||
(Build.VERSION.SDK_INT >= 21 ? AndroidUtils.getStatusBarHeight(pagesView.getContext()) : 0);
|
||||
if (animated) {
|
||||
fragment.animateView(pagesView, pagesY);
|
||||
} else {
|
||||
pagesView.setY(pagesY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateZoomButtonsPos(@NonNull ContextMenuFragment fragment, int y, boolean animated) {
|
||||
View zoomButtonsView = this.zoomButtonsView;
|
||||
if (zoomButtonsView != null) {
|
||||
int zoomY = y - getZoomButtonsHeight();
|
||||
int zoomY = y - getZoomButtonsHeight() +
|
||||
(Build.VERSION.SDK_INT >= 21 ? AndroidUtils.getStatusBarHeight(zoomButtonsView.getContext()) : 0);
|
||||
if (animated) {
|
||||
fragment.animateView(zoomButtonsView, zoomY);
|
||||
} else {
|
||||
|
@ -704,6 +783,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
public void onContextMenuYPosChanged(@NonNull ContextMenuFragment fragment, int y, boolean needMapAdjust, boolean animated) {
|
||||
if (fragment == getCurrentFragment()) {
|
||||
updateToolbars(fragment, y, animated);
|
||||
updatePagesViewPos(fragment, y, animated);
|
||||
updateZoomButtonsPos(fragment, y, animated);
|
||||
updateViewPager(fragment.getViewY());
|
||||
}
|
||||
|
@ -723,6 +803,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
f.openMenuScreen(menuState, false);
|
||||
}
|
||||
if (f == current) {
|
||||
updatePagesViewVisibility(menuState);
|
||||
updateZoomButtonsVisibility(menuState);
|
||||
updateViewPager(fragment.getViewY());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue