Merge pull request #4836 from alexzatsepin/MAPSME-3076-navigation-buttons-refactoring

Mapsme 3076 navigation buttons refactoring
This commit is contained in:
Roman Kuznetsov 2016-12-01 13:08:43 +03:00 committed by GitHub
commit f742008d52
95 changed files with 259 additions and 47 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 988 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 941 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 654 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 609 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 619 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 649 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 644 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 703 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 756 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 699 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 874 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 723 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 735 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 765 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 762 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 888 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,015 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_traffic_download_1"
android:duration="@integer/anim_traffic_loading_item"/>
<item android:drawable="@drawable/ic_traffic_download_2"
android:duration="@integer/anim_traffic_loading_item"/>
<item android:drawable="@drawable/ic_traffic_download_3"
android:duration="@integer/anim_traffic_loading_item"/>
</animation-list>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_traffic_download_night_1"
android:duration="@integer/anim_traffic_loading_item"/>
<item android:drawable="@drawable/ic_traffic_download_night_2"
android:duration="@integer/anim_traffic_loading_item"/>
<item android:drawable="@drawable/ic_traffic_download_night_3"
android:duration="@integer/anim_traffic_loading_item"/>
</animation-list>

View file

@ -7,6 +7,14 @@
android:padding="@dimen/nav_frame_padding"
android:theme="?navButtonsTheme">
<ImageButton
android:id="@+id/traffic"
style="@style/MwmWidget.MapButton.Traffic"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:visibility="invisible"/>
<ImageButton
android:id="@+id/nav_zoom_out"
style="@style/MwmWidget.MapButton"

View file

@ -37,6 +37,9 @@
<ImageView
android:id="@+id/search_fuel"
android:layout_marginTop="@dimen/margin_half_plus"
android:layout_marginStart="@dimen/margin_half_plus"
android:layout_marginLeft="@dimen/margin_half_plus"
style="@style/MwmWidget.SearchNavigationButton"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
@ -45,7 +48,7 @@
<ImageView
android:id="@+id/search_parking"
style="@style/MwmWidget.SearchNavigationButton"
android:layout_marginTop="30dp"
android:layout_marginTop="@dimen/margin_double"
android:layout_toEndOf="@id/search_fuel"
android:layout_toRightOf="@id/search_fuel"
android:src="@drawable/ic_routing_parking_on"/>
@ -55,6 +58,8 @@
style="@style/MwmWidget.SearchNavigationButton"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="@dimen/margin_half_plus"
android:layout_marginRight="@dimen/margin_half_plus"
android:layout_centerVertical="true"
android:src="@drawable/ic_routing_food_on"/>
@ -62,7 +67,7 @@
android:id="@+id/search_shop"
style="@style/MwmWidget.SearchNavigationButton"
android:layout_alignParentBottom="true"
android:layout_marginBottom="30dp"
android:layout_marginBottom="@dimen/margin_double"
android:layout_toEndOf="@id/search_fuel"
android:layout_toRightOf="@id/search_fuel"
android:src="@drawable/ic_routing_shop_on"/>
@ -70,6 +75,9 @@
<ImageView
android:id="@+id/search_atm"
style="@style/MwmWidget.SearchNavigationButton"
android:layout_marginBottom="@dimen/margin_half_plus"
android:layout_marginStart="@dimen/margin_half_plus"
android:layout_marginLeft="@dimen/margin_half_plus"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="@drawable/ic_routing_atm_on"/>
@ -81,6 +89,8 @@
style="@style/MwmWidget.SearchNavigationButton"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginStart="@dimen/margin_eighth"
android:layout_marginLeft="@dimen/margin_eighth"
android:layout_below="@id/anchor_center"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/nav_frame_padding"
@ -12,13 +13,21 @@
android:layout_height="0dp"
android:layout_centerInParent="true"/>
<ImageButton
android:id="@+id/traffic"
style="@style/MwmWidget.MapButton.Traffic"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:visibility="invisible"
tools:src="@drawable/anim_traffic_loading"/>
<ImageButton
android:id="@+id/nav_zoom_out"
style="@style/MwmWidget.MapButton"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@id/anchor_center"
android:background="?nav_background"
android:src="@drawable/ic_zoom_out"/>
<ImageButton
@ -27,7 +36,6 @@
android:layout_above="@id/anchor_center"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:background="?nav_background"
android:src="@drawable/ic_zoom_in"/>
<ImageButton
@ -37,7 +45,6 @@
android:layout_alignParentRight="true"
android:layout_below="@id/nav_zoom_out"
android:layout_marginTop="@dimen/margin_double"
android:background="?nav_background"
android:contentDescription="@string/my_position"
android:tint="@null"/>
</RelativeLayout>

View file

@ -7,7 +7,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="8dp"
android:clipToPadding="false">
<FrameLayout android:layout_width="match_parent"
android:layout_height="wrap_content">

View file

@ -7,6 +7,7 @@
<integer name="anim_menu">200</integer>
<integer name="anim_location_pending_item">50</integer>
<integer name="anim_spinner_pending_item">50</integer>
<integer name="anim_traffic_loading_item">900</integer>
<integer name="anim_slots_swap">@integer/anim_default</integer>
<integer name="anim_slots_toggle">@integer/anim_default</integer>
</resources>
</resources>

View file

@ -59,10 +59,10 @@
<dimen name="direction_frame_min_height">36dp</dimen>
<!-- map widgets -->
<dimen name="margin_compass_left">32dp</dimen>
<dimen name="margin_compass_bottom">80dp</dimen>
<dimen name="margin_ruler_right">8dp</dimen>
<dimen name="margin_ruler_bottom">56dp</dimen>
<dimen name="margin_compass">34dp</dimen>
<dimen name="margin_compass_top">28dp</dimen>
<dimen name="margin_ruler_left">10dp</dimen>
<dimen name="margin_ruler_bottom">58dp</dimen>
<!-- routing layout -->
<dimen name="routing_info_height">48dp</dimen>
@ -109,9 +109,10 @@
<dimen name="nav_icon_size">48dp</dimen>
<dimen name="nav_bottom_gap">12dp</dimen>
<dimen name="nav_frame_padding">@dimen/margin_half</dimen>
<dimen name="nav_frame_padding">@dimen/margin_eighth</dimen>
<dimen name="nav_button">28dp</dimen>
<dimen name="nav_zoom_bottom">160dp</dimen>
<dimen name="nav_button_top_limit">68dp</dimen>
<dimen name="panel_elevation">12dp</dimen>
<dimen name="appbar_elevation">4dp</dimen>
@ -157,9 +158,6 @@
<!-- Rating-->
<dimen name="placepage_margin_rating">20dp</dimen>
<!-- Compass offset-->
<dimen name="compass_navigation_landscape_offset">-54dp</dimen>
<!-- Banner-->
<dimen name="placepage_banner_height">46dp</dimen>
<dimen name="placepage_banner_icon_size">22dp</dimen>

View file

@ -24,6 +24,10 @@
<item name="android:tint">?iconTint</item>
</style>
<style name="MwmWidget.MapButton.Traffic">
<item name="android:tint">@null</item>
</style>
<style name="MwmWidget.Button">
<item name="android:layout_width">@dimen/button_width</item>
<item name="android:layout_height">@dimen/height_block_base</item>

View file

@ -56,6 +56,7 @@
<attr name="myPositionButtonAnimation" format="reference"/>
<attr name="wheelPendingAnimation" format="reference"/>
<attr name="trafficLoadingAnimation" format="reference"/>
<attr name="navButtonsTheme" format="reference"/>
<attr name="downloaderTheme" format="reference"/>

View file

@ -67,6 +67,7 @@
<item name="myPositionButtonAnimation">@drawable/anim_myposition_pending</item>
<item name="wheelPendingAnimation">@drawable/anim_spinner_pending</item>
<item name="trafficLoadingAnimation">@drawable/anim_traffic_loading</item>
<item name="navButtonsTheme">@style/MwmTheme.NavButtons</item>
<item name="downloaderTheme">@style/MwmTheme.Downloader</item>
@ -155,6 +156,7 @@
<item name="myPositionButtonAnimation">@drawable/anim_myposition_pending_night</item>
<item name="wheelPendingAnimation">@drawable/anim_spinner_pending</item>
<item name="trafficLoadingAnimation">@drawable/anim_traffic_loading_night</item>
<item name="navButtonsTheme">@style/MwmTheme.NavButtons.Night</item>
<item name="downloaderTheme">@style/MwmTheme.Downloader.Night</item>

View file

@ -72,16 +72,16 @@ public class MapFragment extends BaseMwmFragment
if (!sWasCopyrightDisplayed)
{
nativeSetupWidget(WIDGET_COPYRIGHT,
mWidth - UiUtils.dimen(R.dimen.margin_ruler_right),
UiUtils.dimen(R.dimen.margin_ruler_left),
mHeight - UiUtils.dimen(R.dimen.margin_ruler_bottom),
ANCHOR_RIGHT_BOTTOM);
ANCHOR_LEFT_BOTTOM);
sWasCopyrightDisplayed = true;
}
nativeSetupWidget(WIDGET_RULER,
mWidth - UiUtils.dimen(R.dimen.margin_ruler_right),
UiUtils.dimen(R.dimen.margin_ruler_left),
mHeight - UiUtils.dimen(R.dimen.margin_ruler_bottom),
ANCHOR_RIGHT_BOTTOM);
ANCHOR_LEFT_BOTTOM);
if (BuildConfig.DEBUG)
{
@ -91,14 +91,14 @@ public class MapFragment extends BaseMwmFragment
ANCHOR_LEFT_TOP);
}
setupCompass(0, UiUtils.getCompassYOffset(getContext()), false);
setupCompass(UiUtils.getCompassYOffset(getContext()), false);
}
void setupCompass(int offsetX, int offsetY, boolean forceRedraw)
void setupCompass(int offsetY, boolean forceRedraw)
{
nativeSetupWidget(WIDGET_COMPASS,
UiUtils.dimen(R.dimen.margin_compass_left) + offsetX,
mHeight - UiUtils.dimen(R.dimen.margin_compass_bottom) + offsetY,
mWidth - UiUtils.dimen(R.dimen.margin_compass),
offsetY + UiUtils.dimen(R.dimen.margin_compass_top),
ANCHOR_CENTER);
if (forceRedraw && mContextCreated)
nativeApplyWidgets();
@ -107,9 +107,9 @@ public class MapFragment extends BaseMwmFragment
void setupRuler(int offsetX, int offsetY, boolean forceRedraw)
{
nativeSetupWidget(WIDGET_RULER,
mWidth - UiUtils.dimen(R.dimen.margin_ruler_right) + offsetX,
UiUtils.dimen(R.dimen.margin_ruler_left) + offsetX,
mHeight - UiUtils.dimen(R.dimen.margin_ruler_bottom) + offsetY,
ANCHOR_RIGHT_BOTTOM);
ANCHOR_LEFT_BOTTOM);
if (forceRedraw && mContextCreated)
nativeApplyWidgets();
}

View file

@ -21,6 +21,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.ImageButton;
import com.mapswithme.maps.Framework.MapObjectListener;
import com.mapswithme.maps.activity.CustomNavigateUpListener;
@ -67,6 +68,7 @@ import com.mapswithme.maps.settings.StoragePathManager;
import com.mapswithme.maps.settings.UnitLocale;
import com.mapswithme.maps.sound.TtsPlayer;
import com.mapswithme.maps.widget.FadeView;
import com.mapswithme.maps.widget.TrafficButton;
import com.mapswithme.maps.widget.menu.BaseMenu;
import com.mapswithme.maps.widget.menu.MainMenu;
import com.mapswithme.maps.widget.menu.MyPositionButton;
@ -138,6 +140,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
private View mNavZoomIn;
private View mNavZoomOut;
private MyPositionButton mNavMyPosition;
private TrafficButton mTraffic;
@Nullable
private NavigationButtonsAnimationController mNavAnimationController;
@ -534,6 +537,9 @@ public class MwmActivity extends BaseMwmFragmentActivity
mNavZoomOut.setOnClickListener(this);
View myPosition = frame.findViewById(R.id.my_position);
mNavMyPosition = new MyPositionButton(myPosition);
ImageButton traffic = (ImageButton) frame.findViewById(R.id.traffic);
mTraffic = new TrafficButton(this, traffic);
mTraffic.setLoading(true);
mNavAnimationController = new NavigationButtonsAnimationController(mNavZoomIn, mNavZoomOut, myPosition,
frame.findViewById(R.id.anchor_center));
}
@ -1099,7 +1105,6 @@ public class MwmActivity extends BaseMwmFragmentActivity
public void run()
{
final int menuHeight = menu.getFrame().getHeight();
adjustCompass(0, menuHeight);
adjustRuler(0, menuHeight);
mIsFullscreenAnimating = false;
@ -1115,6 +1120,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
Animations.disappearSliding(mNavZoomOut, Animations.RIGHT, null);
Animations.disappearSliding(mNavZoomIn, Animations.RIGHT, null);
mNavMyPosition.hide();
mTraffic.hide();
}
}
else
@ -1133,7 +1139,6 @@ public class MwmActivity extends BaseMwmFragmentActivity
@Override
public void run()
{
adjustCompass(0, 0);
adjustRuler(0, 0);
}
});
@ -1142,6 +1147,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
Animations.appearSliding(mNavZoomOut, Animations.RIGHT, null);
Animations.appearSliding(mNavZoomIn, Animations.RIGHT, null);
mNavMyPosition.show();
mTraffic.show();
}
}
@ -1304,12 +1310,12 @@ public class MwmActivity extends BaseMwmFragmentActivity
}
}
void adjustCompass(int offsetX, int offsetY)
void adjustCompass(int offsetY)
{
if (mMapFragment == null || !mMapFragment.isAdded())
return;
mMapFragment.setupCompass((mPanelAnimator != null && mPanelAnimator.isVisible()) ? offsetX : 0, offsetY, true);
mMapFragment.setupCompass(offsetY, true);
CompassData compass = LocationHelper.INSTANCE.getCompassData();
if (compass != null)
@ -1395,7 +1401,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
mMainMenu.showLineFrame(true);
}
private void setNavButtonsTopLimit(float limit)
private void setNavButtonsTopLimit(int limit)
{
if (mNavAnimationController == null)
return;
@ -1421,8 +1427,12 @@ public class MwmActivity extends BaseMwmFragmentActivity
if (completionListener != null)
completionListener.run();
if (mRoutingPlanInplaceController.getHeight() > 0)
setNavButtonsTopLimit(mRoutingPlanInplaceController.getHeight());
int routingPlanPanelHeight = mRoutingPlanInplaceController.getHeight();
if (routingPlanPanelHeight > 0)
{
adjustCompassAndTraffic(routingPlanPanelHeight);
setNavButtonsTopLimit(routingPlanPanelHeight);
}
}
}
else
@ -1435,19 +1445,28 @@ public class MwmActivity extends BaseMwmFragmentActivity
if (completionListener != null)
completionListener.run();
adjustCompassAndTraffic(UiUtils.getStatusBarHeight(getApplicationContext()));
setNavButtonsTopLimit(0);
}
mPlacePage.refreshViews();
}
private void adjustCompassAndTraffic(int offset)
{
adjustCompass(offset);
mTraffic.setTopOffset(offset);
}
@Override
public void onToggle(boolean state)
{
if (mNavAnimationController == null)
return;
setNavButtonsTopLimit(mRoutingPlanInplaceController.getHeight());
int routingPlanPanelHeight = mRoutingPlanInplaceController.getHeight();
adjustCompassAndTraffic(routingPlanPanelHeight);
setNavButtonsTopLimit(routingPlanPanelHeight);
}
@Override
@ -1456,7 +1475,9 @@ public class MwmActivity extends BaseMwmFragmentActivity
if (mNavAnimationController == null)
return;
setNavButtonsTopLimit(visible ? mSearchController.getToolbar().getHeight() : 0);
int toolbarHeight = mSearchController.getToolbar().getHeight();
adjustCompassAndTraffic(visible ? toolbarHeight: UiUtils.getStatusBarHeight(this));
setNavButtonsTopLimit(visible ? toolbarHeight : 0);
}
@Override
@ -1466,7 +1487,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
mPlacePage.refreshViews();
mNavigationController.show(show);
mOnmapDownloader.updateState(false);
adjustCompass(0, UiUtils.getCompassYOffset(this));
adjustCompass(UiUtils.getCompassYOffset(this));
}
@Override

View file

@ -6,11 +6,15 @@ import android.support.annotation.Nullable;
import android.view.View;
import com.mapswithme.maps.routing.RoutingController;
import com.mapswithme.maps.widget.placepage.PlacePageView;
import com.mapswithme.util.Animations;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.log.DebugLogger;
class NavigationButtonsAnimationController
{
private static final DebugLogger LOGGER =
new DebugLogger(NavigationButtonsAnimationController.class.getSimpleName());
@NonNull
private final View mZoomIn;
@NonNull
@ -26,6 +30,7 @@ class NavigationButtonsAnimationController
private boolean mIsZoomAnimate;
private boolean mIsMyPosAnimate;
private float mLastPlacePageY;
NavigationButtonsAnimationController(@NonNull View zoomIn, @NonNull View zoomOut,
@NonNull View myPosition, @Nullable View center)
@ -35,7 +40,8 @@ class NavigationButtonsAnimationController
mMyPosition = myPosition;
mCenter = center;
Resources res = mZoomIn.getResources();
mMargin = res.getDimension(R.dimen.margin_base_plus);
mMargin = res.getDimension(R.dimen.nav_button_top_limit);
mLastPlacePageY = res.getDisplayMetrics().heightPixels;
calculateLimitTranslations();
}
@ -48,13 +54,13 @@ class NavigationButtonsAnimationController
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom)
{
mBottom = bottom + mMargin;
mBottom = bottom;
mMyPosition.removeOnLayoutChangeListener(this);
}
});
}
void setTopLimit(float limit)
void setTopLimit(int limit)
{
mTop = limit + mMargin;
}
@ -130,8 +136,44 @@ class NavigationButtonsAnimationController
if (mCenter == null || mBottom == 0)
return;
final float translation = translationY - mBottom;
update(translation <= 0 ? translation : 0);
float translation = translationY - mBottom;
if (shouldMoveNavButtons(translationY, translation))
update(translation);
else
update(0);
mLastPlacePageY = translationY;
}
private boolean shouldMoveNavButtons(float ppTranslationY, float translation)
{
if (ppTranslationY == mLastPlacePageY)
{
LOGGER.d("Start of movement. Nav buttons are no needed to be moved");
return false;
}
boolean isMoveUp = ppTranslationY < mLastPlacePageY;
if (isMoveUp)
{
if (translation > 0)
{
LOGGER.d("Move up. Bottom limit hasn't been reached yet.");
return false;
}
LOGGER.d("Move up. PP follows the nav buttons.");
return true;
}
if (translation <= 0)
{
LOGGER.d("Move down. Bottom limit hasn't been reached yet.");
return true;
}
LOGGER.d("Move down. Nav buttons follow PP.");
return false;
}
void update()

View file

@ -95,7 +95,7 @@ class PanelAnimator
listener.onTrackStarted(true);
mAnimationTrackListeners.finishIterate();
mActivity.adjustCompass(WIDTH, UiUtils.getCompassYOffset(mActivity));
mActivity.adjustCompass(UiUtils.getCompassYOffset(mActivity));
}
});
@ -137,7 +137,7 @@ class PanelAnimator
listener.onTrackStarted(false);
mAnimationTrackListeners.finishIterate();
mActivity.adjustCompass(0, UiUtils.getCompassYOffset(mActivity));
mActivity.adjustCompass(UiUtils.getCompassYOffset(mActivity));
if (completionListener != null)
completionListener.run();

View file

@ -571,7 +571,7 @@ public class RoutingPlanController extends ToolbarController
Statistics.INSTANCE.trackUber(from, to, location, isUberInstalled);
}
public float getHeight()
public int getHeight()
{
return mFrame.getHeight();
}

View file

@ -0,0 +1,97 @@
package com.mapswithme.maps.widget;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.AnimationDrawable;
import android.os.Build;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import com.mapswithme.maps.R;
import com.mapswithme.util.Animations;
import com.mapswithme.util.ThemeUtils;
import com.mapswithme.util.UiUtils;
public class TrafficButton
{
@NonNull
private final AnimationDrawable mLoadingAnim;
@NonNull
private final ImageButton mButton;
@NonNull
private final Context mContext;
public TrafficButton(@NonNull Context context, @NonNull ImageButton button)
{
mContext = context;
mButton = button;
Resources rs = context.getResources();
@DrawableRes
final int loadingAnimRes = ThemeUtils.getResource(context, R.attr.trafficLoadingAnimation);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
mLoadingAnim = (AnimationDrawable) rs.getDrawable(loadingAnimRes, context.getTheme());
else
mLoadingAnim = (AnimationDrawable) rs.getDrawable(loadingAnimRes);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) button.getLayoutParams();
params.setMargins(0, UiUtils.getStatusBarHeight(context), 0, 0);
//TODO: set default value(state) here
button.setVisibility(View.VISIBLE);
}
//TODO: handle the traffic state coming from the core here
public void update(int state)
{
//TODO: soon
}
private void turnOff()
{
//TODO: soon
}
private void turnOn()
{
//TODO: soon
}
private void onTrafficOutdated()
{
//TODO: soon
}
public void setLoading(boolean isLoading)
{
if (isLoading)
{
mLoadingAnim.start();
mButton.setImageDrawable(mLoadingAnim);
}
else
{
mLoadingAnim.stop();
mButton.setImageDrawable(null);
}
mButton.invalidate();
}
public void setTopOffset(int offset)
{
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mButton.getLayoutParams();
params.setMargins(0, offset, 0, 0);
mButton.requestLayout();
}
public void show()
{
Animations.appearSliding(mButton, Animations.LEFT, null);
}
public void hide()
{
Animations.disappearSliding(mButton, Animations.LEFT, null);
}
}

View file

@ -8,6 +8,7 @@ import android.support.annotation.Nullable;
import android.support.v4.view.GestureDetectorCompat;
import android.support.v7.widget.Toolbar;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
@ -499,6 +500,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle
@Override
public void onAnimationUpdate(ValueAnimator animation)
{
// FIXME: This translation adds a weird jumping up at end of PP closing
mPlacePage.setTranslationY((Float) animation.getAnimatedValue());
notifyProgress();
}

View file

@ -366,7 +366,7 @@ public final class UiUtils
return viewRect.contains(x, y);
}
private static int getStatusBarHeight(@NonNull Context context)
public static int getStatusBarHeight(@NonNull Context context)
{
int result = 0;
Resources res = context.getResources();
@ -443,9 +443,7 @@ public final class UiUtils
public static int getCompassYOffset(@NonNull Context context)
{
return isLandscape(context) && RoutingController.get().isNavigating()
? (int)context.getResources()
.getDimension(R.dimen.compass_navigation_landscape_offset) : 0;
return getStatusBarHeight(context);
}
// utility class