forked from organicmaps/organicmaps
[android] Added displaying traffic and compass buttons in PP and Search mode
This commit is contained in:
parent
e1a3334e1a
commit
c011bf379f
8 changed files with 41 additions and 9 deletions
|
@ -8,4 +8,4 @@
|
|||
|
||||
<item android:drawable="@drawable/ic_traffic_download_3"
|
||||
android:duration="@integer/anim_traffic_loading_item"/>
|
||||
</animation-list>
|
||||
</animation-list>
|
||||
|
|
|
@ -8,4 +8,4 @@
|
|||
|
||||
<item android:drawable="@drawable/ic_traffic_download_night_3"
|
||||
android:duration="@integer/anim_traffic_loading_item"/>
|
||||
</animation-list>
|
||||
</animation-list>
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -10,4 +10,4 @@
|
|||
<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>
|
||||
|
|
|
@ -140,7 +140,6 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
private View mNavZoomIn;
|
||||
private View mNavZoomOut;
|
||||
private MyPositionButton mNavMyPosition;
|
||||
@Nullable
|
||||
private TrafficButton mTraffic;
|
||||
@Nullable
|
||||
private NavigationButtonsAnimationController mNavAnimationController;
|
||||
|
@ -1121,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
|
||||
|
@ -1147,6 +1147,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
Animations.appearSliding(mNavZoomOut, Animations.RIGHT, null);
|
||||
Animations.appearSliding(mNavZoomIn, Animations.RIGHT, null);
|
||||
mNavMyPosition.show();
|
||||
mTraffic.show();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1400,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;
|
||||
|
@ -1427,7 +1428,10 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
completionListener.run();
|
||||
|
||||
if (mRoutingPlanInplaceController.getHeight() > 0)
|
||||
{
|
||||
setNavButtonsTopLimit(mRoutingPlanInplaceController.getHeight());
|
||||
adjustCompassAndTraffic(mRoutingPlanInplaceController.getHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1441,11 +1445,18 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
completionListener.run();
|
||||
|
||||
setNavButtonsTopLimit(0);
|
||||
adjustCompassAndTraffic(UiUtils.getStatusBarHeight(getApplicationContext()));
|
||||
}
|
||||
|
||||
mPlacePage.refreshViews();
|
||||
}
|
||||
|
||||
private void adjustCompassAndTraffic(int offset)
|
||||
{
|
||||
adjustCompass(offset);
|
||||
mTraffic.setTopOffset(offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onToggle(boolean state)
|
||||
{
|
||||
|
@ -1453,6 +1464,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
return;
|
||||
|
||||
setNavButtonsTopLimit(mRoutingPlanInplaceController.getHeight());
|
||||
adjustCompassAndTraffic(mRoutingPlanInplaceController.getHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1462,6 +1474,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
return;
|
||||
|
||||
setNavButtonsTopLimit(visible ? mSearchController.getToolbar().getHeight() : 0);
|
||||
adjustCompassAndTraffic(visible ? mSearchController.getToolbar().getHeight(): UiUtils.getStatusBarHeight(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -54,7 +54,7 @@ class NavigationButtonsAnimationController
|
|||
});
|
||||
}
|
||||
|
||||
void setTopLimit(float limit)
|
||||
void setTopLimit(int limit)
|
||||
{
|
||||
mTop = limit + mMargin;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ 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;
|
||||
|
||||
|
@ -20,9 +21,12 @@ public class TrafficButton
|
|||
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
|
||||
|
@ -34,7 +38,6 @@ public class TrafficButton
|
|||
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) button.getLayoutParams();
|
||||
params.setMargins(0, UiUtils.getStatusBarHeight(context), 0, 0);
|
||||
button.setLayoutParams(params);
|
||||
//TODO: set default value(state) here
|
||||
button.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
@ -74,4 +77,21 @@ public class TrafficButton
|
|||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue