[android] Added the traffic button in the navigation menu

This commit is contained in:
alexzatsepin 2016-12-01 19:19:55 +03:00
parent 961d4749e3
commit 064cecb098
13 changed files with 66 additions and 29 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 812 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -42,47 +42,58 @@
app:secondaryProgressColor="@color/bg_routing_progress"
app:secondaryProgressThickness="@dimen/nav_progress"/>
<FrameLayout
<LinearLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_menu_content_height"
android:clipChildren="false"
android:clipToPadding="false"
android:paddingLeft="@dimen/nav_bottom_gap"
android:paddingStart="@dimen/nav_bottom_gap"
android:paddingRight="@dimen/nav_bottom_gap"
android:paddingEnd="@dimen/nav_bottom_gap"
android:orientation="horizontal"
android:gravity="center_vertical"
tools:background="#300000FF">
<ImageView
android:id="@+id/tts_volume"
android:layout_weight="0.2"
android:layout_width="0dp"
android:layout_height="@dimen/nav_icon_size"
android:scaleType="center"
android:src="@drawable/ic_voice_on"
android:background="?selectableItemBackgroundBorderless"/>
<ImageView
android:id="@+id/traffic"
android:layout_weight="0.2"
android:layout_width="0dp"
android:layout_height="@dimen/nav_icon_size"
android:scaleType="center"
android:src="@drawable/ic_setting_traffic_on"
android:background="?selectableItemBackgroundBorderless"/>
<ImageView
android:id="@+id/settings"
android:layout_width="@dimen/nav_icon_size"
android:layout_weight="0.2"
android:layout_width="0dp"
android:layout_height="@dimen/nav_icon_size"
android:layout_marginRight="@dimen/nav_bottom_gap"
android:layout_marginEnd="@dimen/nav_bottom_gap"
android:layout_gravity="center_vertical"
android:scaleType="center"
android:src="@drawable/ic_menu_settings"
android:background="?selectableItemBackgroundBorderless"
android:tint="?iconTint"/>
<Button
android:id="@+id/stop"
android:layout_width="@dimen/nav_button_width"
android:layout_height="@dimen/nav_button_height"
android:layout_gravity="center"
android:background="?redButtonBackground"
android:text="@string/current_location_unknown_stop_button"
android:fontFamily="@string/robotoMedium"
android:textAppearance="@style/MwmTextAppearance.Button.Red"
tools:ignore="UnusedAttribute"/>
<ImageView
android:id="@+id/tts_volume"
android:layout_width="@dimen/nav_icon_size"
android:layout_height="@dimen/nav_icon_size"
android:scaleType="center"
android:layout_gravity="center_vertical|end"
android:src="@drawable/ic_voice_on"
android:background="?selectableItemBackgroundBorderless"/>
</FrameLayout>
</LinearLayout>
android:id="@+id/stop"
android:layout_weight="0.4"
android:layout_width="0dp"
android:minWidth="@dimen/start_button_width"
android:layout_height="@dimen/nav_button_height"
android:background="?redButtonBackground"
android:text="@string/current_location_unknown_stop_button"
android:fontFamily="@string/robotoMedium"
android:textAppearance="@style/MwmTextAppearance.Button.Red"
tools:ignore="UnusedAttribute"/>
</LinearLayout>
</LinearLayout>

View file

@ -81,7 +81,7 @@ public class NavigationController
}
});
mNavMenu = createNavMenu();
mNavMenu.refreshTts();
mNavMenu.refresh();
// Top frame
View topFrame = mFrame.findViewById(R.id.nav_top_frame);
@ -154,6 +154,10 @@ public class NavigationController
Statistics.INSTANCE.trackEvent(Statistics.EventName.ROUTING_CLOSE);
AlohaHelper.logClick(AlohaHelper.ROUTING_CLOSE);
break;
case TRAFFIC:
mNavMenu.refreshTraffic();
//TODO: Add statistics reporting (in separate task)
break;
case TOGGLE:
mNavMenu.toggle(true);
parent.refreshFade();

View file

@ -1,6 +1,7 @@
package com.mapswithme.maps.widget.menu;
import android.animation.ValueAnimator;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
@ -16,14 +17,18 @@ import com.mapswithme.util.UiUtils;
public class NavMenu extends BaseMenu
{
private final RotateDrawable mToggleImage;
@NonNull
private final ImageView mTts;
@NonNull
private final ImageView mTraffic;
public enum Item implements BaseMenu.Item
{
TOGGLE(R.id.toggle),
TTS_VOLUME(R.id.tts_volume),
STOP(R.id.stop),
SETTINGS(R.id.settings);
SETTINGS(R.id.settings),
TRAFFIC(R.id.traffic);
private final int mViewId;
@ -56,13 +61,20 @@ public class NavMenu extends BaseMenu
mapItem(Item.SETTINGS, mFrame);
mTts = (ImageView) mapItem(Item.TTS_VOLUME, mFrame);
mTraffic = (ImageView) mapItem(Item.TRAFFIC, mFrame);
}
@Override
public void onResume(@Nullable Runnable procAfterMeasurement)
{
super.onResume(procAfterMeasurement);
refresh();
}
public void refresh()
{
refreshTts();
refreshTraffic();
}
public void refreshTts()
@ -72,6 +84,14 @@ public class NavMenu extends BaseMenu
: Graphics.tint(mFrame.getContext(), R.drawable.ic_voice_off));
}
public void refreshTraffic()
{
//TODO: Read the real value of this setting (in separate task)
mTraffic.setImageDrawable(true ? Graphics.tint(mFrame.getContext(), R.drawable.ic_setting_traffic_on,
R.attr.colorAccent)
: Graphics.tint(mFrame.getContext(), R.drawable.ic_setting_traffic_off));
}
@Override
protected void setToggleState(boolean open, boolean animate)
{
@ -111,7 +131,9 @@ public class NavMenu extends BaseMenu
{
super.show(show);
measureContent(null);
UiUtils.showIf(show && Framework.nativeGetRouter() != Framework.ROUTER_TYPE_PEDESTRIAN, mTts);
@Framework.RouterType
int routerType = Framework.nativeGetRouter();
UiUtils.showIf(show && routerType != Framework.ROUTER_TYPE_PEDESTRIAN, mTts);
UiUtils.showIf(show && routerType == Framework.ROUTER_TYPE_VEHICLE, mTraffic);
}
}