[android] add: Navigation menu.

TODO: Fix nav menu.
This commit is contained in:
Alexander Marchuk 2016-07-28 00:30:10 +03:00
parent 13cd983b73
commit cb4a8c2362
32 changed files with 807 additions and 531 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/bg_nav_panel"/>
<solid android:color="@color/bg_menu"/>
<corners android:radius="4dp"/>
</shape>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/bg_nav_panel_night"/>
<solid android:color="@color/bg_menu_night"/>
<corners android:radius="4dp"/>
</shape>

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size android:width="7dp"
android:height="7dp"/>
<size android:width="4dp"
android:height="4dp"/>
<solid android:color="@color/news_marker_active"/>
</shape>

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size android:width="7dp"
android:height="7dp"/>
<size android:width="4dp"
android:height="4dp"/>
<solid android:color="@color/news_marker_active_night"/>
</shape>

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size android:width="7dp"
android:height="7dp"/>
<size android:width="4dp"
android:height="4dp"/>
<solid android:color="@color/news_marker_inactive"/>
</shape>

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size android:width="7dp"
android:height="7dp"/>
<size android:width="4dp"
android:height="4dp"/>
<solid android:color="@color/news_marker_inactive_night"/>
</shape>

View file

@ -0,0 +1,147 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_menu_height"
android:orientation="horizontal"
android:paddingLeft="@dimen/nav_numbers_margin"
android:layout_marginRight="@dimen/nav_toggle"
tools:background="#3000FF00">
<!-- Speed -->
<LinearLayout
android:id="@+id/speed_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:minWidth="@dimen/nav_numbers_side_min_width"
android:orientation="horizontal"
android:paddingLeft="@dimen/nav_numbers_margin"
android:paddingRight="@dimen/nav_numbers_margin"
android:paddingTop="@dimen/margin_eighth"
android:gravity="center_horizontal"
android:background="?clickableBackground"
tools:background="#20FF0000">
<TextView
android:id="@+id/speed_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="@style/MwmTextAppearance.RoutingNumber"
tools:text="999"/>
<TextView
android:id="@+id/speed_dimen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="@style/MwmTextAppearance.RoutingDimension.Inline"
tools:text="km/h"/>
</LinearLayout>
<Space android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>
<!-- Time -->
<LinearLayout
android:id="@+id/time_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="@dimen/nav_numbers_center_min_width"
android:orientation="vertical"
android:paddingTop="@dimen/margin_eighth"
android:gravity="center_horizontal"
android:background="?clickableBackground"
tools:background="#20FF0000">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center_horizontal">
<TextView
android:id="@+id/time_hour_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="@style/MwmTextAppearance.RoutingNumber"
tools:text="999"/>
<TextView
android:id="@+id/time_hour_dimen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/margin_quarter"
android:singleLine="true"
android:textAppearance="@style/MwmTextAppearance.RoutingDimension.Inline"
tools:text="h"/>
<TextView
android:id="@+id/time_minute_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="@style/MwmTextAppearance.RoutingNumber"
tools:text="99"/>
<TextView
android:id="@+id/time_minute_dimen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="@style/MwmTextAppearance.RoutingDimension.Inline"
tools:text="m"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/dot_estimate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
tools:src="@drawable/news_marker_active"/>
<ImageView
android:id="@+id/dot_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:src="@drawable/news_marker_inactive"/>
</LinearLayout>
</LinearLayout>
<Space android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>
<!-- Distance -->
<LinearLayout
android:id="@+id/distance_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:minWidth="@dimen/nav_numbers_side_min_width"
android:orientation="horizontal"
android:paddingLeft="@dimen/nav_numbers_margin"
android:paddingRight="@dimen/nav_numbers_margin"
android:paddingTop="@dimen/margin_eighth"
android:gravity="center_horizontal"
android:background="?clickableBackground"
tools:background="#20FF0000">
<TextView
android:id="@+id/distance_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="@style/MwmTextAppearance.RoutingNumber"
tools:text="99999"/>
<TextView
android:id="@+id/distance_dimen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="@style/MwmTextAppearance.RoutingDimension.Inline"
tools:text="km"/>
</LinearLayout>
</LinearLayout>

View file

@ -1,122 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?panel"
android:clipToPadding="false"
android:elevation="@dimen/appbar_elevation"
android:paddingTop="@dimen/margin_eighth">
<com.mapswithme.maps.widget.FlatProgressView
android:id="@+id/fp__route_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:headRadius="2dp"
app:progressColor="@color/routing_progress"
app:headColor="@color/routing_progress"
app:progressThickness="2dp"
app:secondaryProgressColor="@color/divider"
app:secondaryProgressThickness="2dp"/>
<ImageView
android:id="@+id/btn__close"
android:layout_width="@dimen/height_block_base"
android:layout_height="@dimen/height_block_base"
android:layout_centerVertical="true"
android:layout_marginBottom="@dimen/margin_base_plus"
android:layout_marginLeft="@dimen/margin_quarter"
android:layout_marginRight="@dimen/margin_base"
android:layout_marginTop="@dimen/margin_base_plus"
android:background="?attr/selectableItemBackgroundBorderless"
android:scaleType="center"
android:tint="?iconTint"
android:src="@drawable/ic_cancel"/>
<FrameLayout
android:id="@+id/turn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_base"
android:layout_marginLeft="@dimen/margin_double_plus"
android:layout_marginTop="@dimen/margin_base"
android:layout_toRightOf="@id/btn__close">
<com.mapswithme.maps.widget.ArrowView
android:id="@+id/iv__turn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tint="?colorAccent"
tools:src="@drawable/ic_turn_round"/>
<TextView
android:id="@+id/tv__exit_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAppearance="@style/MwmTextAppearance.Title"
android:textColor="?colorAccent"
android:visibility="gone"
tools:text="2"
tools:visibility="visible"/>
</FrameLayout>
<TextView
android:id="@+id/tv__turn_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_base"
android:layout_toRightOf="@id/turn"
android:textAppearance="@style/MwmTextAppearance.RoutingDirection"
tools:text="300 m"/>
<TextView
android:id="@+id/tv__next_street"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/tv__turn_distance"
android:layout_alignParentRight="true"
android:layout_below="@id/tv__turn_distance"
android:maxLines="2"
android:textAppearance="@style/MwmTextAppearance.Body2"
android:textSize="@dimen/text_size_title"
tools:text="Oxford str."
tools:visibility="visible"/>
<TextView
android:id="@+id/tv__total_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@id/tv__turn_distance"
android:layout_marginRight="@dimen/margin_base"
android:gravity="center_vertical"
android:textAppearance="@style/MwmTextAppearance.RoutingNumber"
tools:text="1,5 min"/>
<TextView
android:id="@+id/tv__arrival_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/tv__total_time"
android:layout_marginRight="@dimen/margin_base"
android:layout_marginTop="@dimen/margin_eighth"
android:gravity="center_vertical"
android:textAppearance="@style/MwmTextAppearance.RoutingNumber"
tools:text="1:00"/>
<TextView
android:id="@+id/tv__total_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/tv__arrival_time"
android:layout_marginRight="@dimen/margin_base"
android:layout_toLeftOf="@id/tv__arrival_time"
android:gravity="center_vertical"
android:textAppearance="@style/MwmTextAppearance.RoutingNumber"
tools:text="1.4 km"/>
</RelativeLayout>

View file

@ -44,8 +44,7 @@
<include
layout="@layout/layout_nav"
android:layout_width="@dimen/panel_width"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_half"
android:layout_height="match_parent"
android:visibility="gone"
tools:visibility="visible"/>

View file

@ -33,7 +33,7 @@
<include
layout="@layout/layout_nav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"
android:paddingBottom="@dimen/margin_base"
android:visibility="gone"/>

View file

@ -1,10 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/nav_bottom_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="bottom"
>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/nav_bottom_frame"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:clickable="true"
android:visibility="invisible"
tools:visibility="visible">
<FrameLayout
android:id="@+id/line_frame"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_menu_height">
<include layout="@layout/layout_nav_bottom_numbers"/>
<ImageView
android:id="@+id/toggle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right|center_vertical"
android:background="?attr/selectableItemBackgroundBorderless"
android:scaleType="center"
android:tint="?iconTint"
tools:src="@drawable/ic_menu_close"/>
</FrameLayout>
<com.mapswithme.maps.widget.FlatProgressView
android:id="@+id/progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:headRadius="@dimen/nav_progress"
app:progressColor="?colorAccent"
app:headColor="?colorAccent"
app:progressThickness="@dimen/nav_progress"
app:secondaryProgressColor="@color/bg_routing_progress"
app:secondaryProgressThickness="@dimen/nav_progress"/>
<LinearLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="64dp"
android:orientation="horizontal"
tools:background="#300000FF">
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,148 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_menu_height"
android:orientation="horizontal"
android:paddingLeft="@dimen/nav_numbers_margin"
android:layout_marginRight="@dimen/nav_toggle"
tools:background="#3000FF00">
<!-- Speed -->
<LinearLayout
android:id="@+id/speed_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:minWidth="@dimen/nav_numbers_side_min_width"
android:orientation="vertical"
android:paddingLeft="@dimen/nav_numbers_margin"
android:paddingRight="@dimen/nav_numbers_margin"
android:paddingTop="@dimen/margin_eighth"
android:gravity="center_horizontal"
android:background="?clickableBackground"
tools:background="#20FF0000">
<TextView
android:id="@+id/speed_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="@style/MwmTextAppearance.RoutingNumber"
tools:text="999"/>
<TextView
android:id="@+id/speed_dimen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="@style/MwmTextAppearance.RoutingDimension"
tools:text="km/h"/>
</LinearLayout>
<Space android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>
<!-- Time -->
<LinearLayout
android:id="@+id/time_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:minWidth="@dimen/nav_numbers_center_min_width"
android:orientation="vertical"
android:paddingTop="@dimen/margin_eighth"
android:gravity="center_horizontal"
android:background="?clickableBackground"
tools:background="#20FF0000">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_horizontal">
<TextView
android:id="@+id/time_hour_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="@style/MwmTextAppearance.RoutingNumber"
tools:text="999"/>
<TextView
android:id="@+id/time_hour_dimen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/margin_quarter"
android:singleLine="true"
android:textAppearance="@style/MwmTextAppearance.RoutingDimension.Inline"
tools:text="h"/>
<TextView
android:id="@+id/time_minute_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="@style/MwmTextAppearance.RoutingNumber"
tools:text="99"/>
<TextView
android:id="@+id/time_minute_dimen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="@style/MwmTextAppearance.RoutingDimension.Inline"
tools:text="m"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="@dimen/margin_quarter">
<ImageView
android:id="@+id/dot_estimate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
tools:src="@drawable/news_marker_active"/>
<ImageView
android:id="@+id/dot_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:src="@drawable/news_marker_inactive"/>
</LinearLayout>
</LinearLayout>
<Space android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>
<!-- Distance -->
<LinearLayout
android:id="@+id/distance_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:minWidth="@dimen/nav_numbers_side_min_width"
android:orientation="vertical"
android:paddingLeft="@dimen/nav_numbers_margin"
android:paddingRight="@dimen/nav_numbers_margin"
android:paddingTop="@dimen/margin_eighth"
android:gravity="center_horizontal"
android:background="?clickableBackground"
tools:background="#20FF0000">
<TextView
android:id="@+id/distance_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="@style/MwmTextAppearance.RoutingNumber"
tools:text="99999"/>
<TextView
android:id="@+id/distance_dimen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="@style/MwmTextAppearance.RoutingDimension"
tools:text="km"/>
</LinearLayout>
</LinearLayout>

View file

@ -11,7 +11,7 @@
android:layout_width="match_parent"
android:layout_height="@dimen/nav_street_height"
android:elevation="@dimen/nav_elevation"
android:background="?navPanel">
android:background="?menuBackground">
<TextView
android:id="@+id/street"
style="@style/MwmWidget.TextView.NavStreet"

View file

@ -1,54 +0,0 @@
<?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="@dimen/panel_width"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:padding="@dimen/routing_turns_padding">
<FrameLayout
android:id="@+id/turn"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.mapswithme.maps.widget.ArrowView
android:id="@+id/iv__turn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tint="?colorAccent"
tools:src="@drawable/ic_turn_round"/>
<TextView
android:id="@+id/tv__exit_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAppearance="@style/MwmTextAppearance.Title"
android:textColor="?colorAccent"
android:visibility="gone"
tools:text="2"
tools:visibility="visible"/>
</FrameLayout>
<TextView
android:id="@+id/tv__turn_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_base"
android:layout_toRightOf="@+id/turn"
android:textAppearance="@style/MwmTextAppearance.RoutingDirection"
tools:text="300 m"/>
<TextView
android:id="@+id/tv__next_street"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/tv__turn_distance"
android:layout_below="@id/tv__turn_distance"
android:maxLines="2"
android:textAppearance="@style/MwmTextAppearance.Body2"
android:textSize="@dimen/text_size_title"
tools:text="Oxford str."
tools:visibility="visible"/>
</RelativeLayout>

View file

@ -1,73 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="?panel"
android:elevation="@dimen/appbar_elevation">
<LinearLayout
android:id="@+id/time_distance"
android:layout_width="match_parent"
android:layout_height="@dimen/routing_info_height"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/margin_quarter">
<ImageView
android:id="@+id/btn__close"
android:layout_width="@dimen/height_block_base"
android:layout_height="@dimen/height_block_base"
android:layout_weight="0"
android:background="?selectableItemBackgroundBorderless"
android:tint="?iconTint"
android:scaleType="center"
android:src="@drawable/ic_cancel"/>
<TextView
android:id="@+id/tv__total_distance"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:textAppearance="@style/MwmTextAppearance.RoutingNumber"
tools:text="100.4 km"/>
<TextView
android:id="@+id/tv__total_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:textAppearance="@style/MwmTextAppearance.RoutingNumber"
tools:text="10h 40min"/>
<TextView
android:id="@+id/tv__arrival_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:textAppearance="@style/MwmTextAppearance.RoutingNumber"
android:textSize="@dimen/text_size_routing_number"
tools:text="23:59"/>
</LinearLayout>
<com.mapswithme.maps.widget.FlatProgressView
android:id="@+id/fp__route_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:headRadius="2dp"
app:progressColor="@color/routing_progress"
app:headColor="@color/routing_progress"
app:progressThickness="2dp"
app:secondaryProgressColor="@color/divider"
app:secondaryProgressThickness="2dp"/>
<include
layout="@layout/layout_turn_and_street"
android:layout_width="@dimen/panel_width"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"/>
</LinearLayout>

View file

@ -35,15 +35,7 @@
<ImageView
android:id="@+id/toggle"
style="@style/MwmTheme.Menu.Line.Button"
android:tint="@null"
android:layout_width="@dimen/menu_line_button_width_edge"
android:layout_height="@dimen/menu_line_height"
android:layout_gravity="right"
android:paddingLeft="@dimen/margin_half_plus"
android:paddingRight="@dimen/margin_half"
android:src="@drawable/ic_menu_open"
android:background="@drawable/menu_button_right"
style="@style/MwmTheme.Menu.Line.Button.Toggle"
tools:layout_marginTop="60dp"/>
<include

View file

@ -7,6 +7,8 @@
<dimen name="menu_line_button_width">88dp</dimen>
<!-- Nav menu -->
<dimen name="nav_menu_height">40dp</dimen>
<dimen name="nav_menu_height">36dp</dimen>
<dimen name="nav_zoom_bottom">80dp</dimen>
<dimen name="nav_toggle_margin">16dp</dimen>
<dimen name="nav_numbers_margin">16dp</dimen>
</resources>

View file

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Nav menu -->
<dimen name="nav_menu_height">44dp</dimen>
<dimen name="nav_menu_height">36dp</dimen>
<dimen name="nav_progress">8dp</dimen>
<dimen name="nav_numbers_margin">32dp</dimen>
</resources>

View file

@ -12,4 +12,6 @@
<dimen name="nav_frame_padding">@dimen/margin_base</dimen>
<dimen name="nav_zoom_bottom">250dp</dimen>
<dimen name="nav_toggle_margin">16dp</dimen>
<dimen name="nav_numbers_margin">16dp</dimen>
</resources>

View file

@ -37,16 +37,14 @@
<color name="bg_panel_night">@color/bg_window_night</color>
<color name="bg_side_panel">@color/bg_cards</color>
<color name="bg_side_panel_night">@color/bg_panel_night</color>
<color name="bg_nav_panel">#CCFFFFFF</color>
<color name="bg_nav_panel_night">#CC2D3237</color>
<color name="bg_dialog_translucent">#BB000000</color>
<color name="bg_text_translucent">#99FFFFFF</color>
<color name="bg_menu">#CCFFFFFF</color>
<color name="bg_menu_night">#CC2D3237</color>
<color name="bg_menu_open">#FFFFFFFF</color>
<color name="bg_menu_open_night">#FF2D3237</color>
<color name="bg_menu_closed">#CCFFFFFF</color>
<color name="bg_menu_closed_night">#CC2D3237</color>
<color name="bg_statusbar">#FF197E46</color>
<color name="bg_statusbar_night">#FF000000</color>
@ -84,7 +82,7 @@
<color name="downloader_gray">#FF999999</color>
<!-- Routing-->
<color name="routing_progress">#FF757575</color>
<color name="bg_routing_progress">#1F000000</color>
<color name="routing_slot_background">#FFFFFFFF</color>
<color name="routing_slot_background_night">@color/bg_panel_night</color>
<color name="routing_slot_background_pressed">#FFF0F0F0</color>

View file

@ -92,7 +92,13 @@
<dimen name="nav_next_turn_space">6dp</dimen>
<dimen name="nav_next_turn_sign">64dp</dimen>
<dimen name="nav_next_next_turn_frame">32dp</dimen>
<dimen name="nav_menu_height">52dp</dimen>
<dimen name="nav_menu_height">48dp</dimen>
<dimen name="nav_numbers_margin">8dp</dimen>
<dimen name="nav_numbers_side_min_width">90dp</dimen>
<dimen name="nav_numbers_center_min_width">130dp</dimen>
<dimen name="nav_progress">4dp</dimen>
<dimen name="nav_toggle">40dp</dimen>
<dimen name="nav_toggle_margin">8dp</dimen>
<dimen name="nav_frame_padding">@dimen/margin_half</dimen>
<dimen name="nav_button">28dp</dimen>

View file

@ -31,8 +31,9 @@
<!-- -->
<dimen name="text_size_routing_number">20sp</dimen>
<dimen name="text_size_routing_dimension">14sp</dimen>
<dimen name="text_size_routing_number">24sp</dimen>
<dimen name="text_size_routing_dimension">12sp</dimen>
<dimen name="text_size_routing_dimension_inline">20sp</dimen>
<dimen name="text_size_routing_plan_detail">18sp</dimen>
<dimen name="text_size_routing_plan_detail_arrival">14sp</dimen>
<dimen name="text_size_time_picker">56sp</dimen>

View file

@ -12,6 +12,17 @@
<item name="android:tint">?iconTint</item>
</style>
<style name="MwmTheme.Menu.Line.Button.Toggle">
<item name="android:layout_width">@dimen/menu_line_button_width_edge</item>
<item name="android:layout_height">@dimen/menu_line_height</item>
<item name="android:layout_gravity">right</item>
<item name="android:paddingLeft">@dimen/margin_half_plus</item>
<item name="android:paddingRight">@dimen/margin_half</item>
<item name="android:src">@drawable/ic_menu_close</item>
<item name="android:background">@drawable/menu_button_right</item>
<item name="android:tint">@null</item>
</style>
<style name="MwmTheme.Menu.Content.ListItem"
parent="MwmTextAppearance.Body1">
<item name="android:layout_width">match_parent</item>

View file

@ -98,15 +98,21 @@
<style name="MwmTextAppearance.RoutingNumber">
<item name="android:textSize">@dimen/text_size_routing_number</item>
<item name="android:textColor">?android:textColorSecondary</item>
<item name="android:textColor">?android:textColorPrimary</item>
<item name="android:textStyle">bold</item>
</style>
<style name="MwmTextAppearance.RoutingDirection">
<item name="android:textSize">@dimen/text_size_display_2</item>
<item name="android:textColor">?colorAccent</item>
<style name="MwmTextAppearance.RoutingDimension">
<item name="android:textSize">@dimen/text_size_routing_dimension</item>
<item name="android:textColor">?android:textColorSecondary</item>
<item name="android:textStyle">bold</item>
</style>
<style name="MwmTextAppearance.RoutingDimension.Inline"
parent="MwmTextAppearance.RoutingNumber">
<item name="android:textSize">@dimen/text_size_routing_dimension_inline</item>
</style>
<style name="MwmTextAppearance.RoutingDetail">
<item name="android:textSize">@dimen/text_size_routing_plan_detail</item>
<item name="android:fontFamily" tools:ignore="NewApi">@string/robotoMedium</item>

View file

@ -28,7 +28,6 @@
<attr name="routingSlot" format="reference"/>
<attr name="routingSlotPressed" format="reference"/>
<attr name="routingSlotMarker" format="reference"/>
<attr name="navPanel" format="color"/>
<attr name="navNextTurnFrame" format="reference"/>
<attr name="navNextNextTurnFrame" format="reference"/>
@ -42,7 +41,7 @@
<attr name="circleAccent" format="reference"/>
<attr name="menuBackgroundClosed" format="color"/>
<attr name="menuBackground" format="color"/>
<attr name="menuBackgroundOpen" format="color"/>
<attr name="myPositionButtonAnimation" format="reference"/>

View file

@ -44,7 +44,6 @@
<item name="routingSlot">@drawable/routing_slot_background</item>
<item name="routingSlotPressed">@drawable/routing_slot_background_pressed</item>
<item name="routingSlotMarker">@drawable/routing_slot_marker</item>
<item name="navPanel">@color/bg_nav_panel</item>
<item name="navNextTurnFrame">@drawable/bg_nav_next_turn</item>
<item name="navNextNextTurnFrame">@drawable/bg_nav_next_next_turn</item>
@ -58,7 +57,7 @@
<item name="circleAccent">@drawable/circle_accent</item>
<item name="menuBackgroundClosed">@color/bg_menu_closed</item>
<item name="menuBackground">@color/bg_menu</item>
<item name="menuBackgroundOpen">@color/bg_menu_open</item>
<item name="myPositionButtonAnimation">@drawable/anim_myposition_pending</item>
@ -114,7 +113,6 @@
<item name="routingSlot">@drawable/routing_slot_background_night</item>
<item name="routingSlotPressed">@drawable/routing_slot_background_pressed_night</item>
<item name="routingSlotMarker">@drawable/routing_slot_marker_night</item>
<item name="navPanel">@color/bg_nav_panel_night</item>
<item name="navNextTurnFrame">@drawable/bg_nav_next_turn_night</item>
<item name="navNextNextTurnFrame">@drawable/bg_nav_next_next_turn_night</item>
@ -128,7 +126,7 @@
<item name="circleAccent">@drawable/circle_accent_night</item>
<item name="menuBackgroundClosed">@color/bg_menu_closed_night</item>
<item name="menuBackground">@color/bg_menu_night</item>
<item name="menuBackgroundOpen">@color/bg_menu_open_night</item>
<item name="myPositionButtonAnimation">@drawable/anim_myposition_pending_night</item>

View file

@ -1,7 +1,6 @@
package com.mapswithme.maps;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
@ -20,7 +19,6 @@ import android.support.v7.widget.Toolbar;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageButton;
@ -64,6 +62,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.menu.BaseMenu;
import com.mapswithme.maps.widget.menu.MainMenu;
import com.mapswithme.maps.widget.placepage.BasePlacePageAnimationController;
import com.mapswithme.maps.widget.placepage.PlacePageView;
@ -125,6 +124,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
private NavigationController mNavigationController;
private MainMenu mMainMenu;
private PanelAnimator mPanelAnimator;
private OnmapDownloader mOnmapDownloader;
private MytargetHelper mMytargetHelper;
@ -346,7 +346,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
}
mNavigationController = new NavigationController(this);
initMenu();
initMainMenu();
initOnmapDownloader();
initPositionChooser();
}
@ -374,7 +374,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
if (Framework.nativeIsDownloadedMapAtScreenCenter())
startActivity(new Intent(MwmActivity.this, FeatureCategoryActivity.class));
else
UiUtils.showAlertDialog(getActivity(), R.string.message_invalid_feature_position);
UiUtils.showAlertDialog(MwmActivity.this, R.string.message_invalid_feature_position);
}
});
UiUtils.hide(mPositionChooser);
@ -508,16 +508,10 @@ public class MwmActivity extends BaseMwmFragmentActivity
mMainMenu.toggle(true);
}
private void initMenu()
private void initMainMenu()
{
mMainMenu = new MainMenu((ViewGroup) findViewById(R.id.menu_frame), new MainMenu.Container()
mMainMenu = new MainMenu(findViewById(R.id.menu_frame), new BaseMenu.ItemClickListener<MainMenu.Item>()
{
@Override
public Activity getActivity()
{
return MwmActivity.this;
}
@Override
public void onItemClick(MainMenu.Item item)
{
@ -613,7 +607,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
@Override
public void run()
{
startActivity(new Intent(getActivity(), SettingsActivity.class));
startActivity(new Intent(MwmActivity.this, SettingsActivity.class));
}
});
break;
@ -993,21 +987,28 @@ public class MwmActivity extends BaseMwmFragmentActivity
}
}
private BaseMenu getCurrentMenu()
{
return (RoutingController.get().isNavigating() ? mNavigationController.getNavMenu() : mMainMenu);
}
private void setFullscreen(boolean isFullscreen)
{
mIsFullscreen = isFullscreen;
final BaseMenu menu = getCurrentMenu();
if (isFullscreen)
{
if (mMainMenu.isAnimating())
if (menu.isAnimating())
return;
mIsFullscreenAnimating = true;
Animations.disappearSliding(mMainMenu.getFrame(), Animations.BOTTOM, new Runnable()
Animations.disappearSliding(menu.getFrame(), Animations.BOTTOM, new Runnable()
{
@Override
public void run()
{
final int menuHeight = mMainMenu.getFrame().getHeight();
final int menuHeight = menu.getFrame().getHeight();
adjustCompass(0, menuHeight);
adjustRuler(0, menuHeight);
@ -1022,7 +1023,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
}
else
{
Animations.appearSliding(mMainMenu.getFrame(), Animations.BOTTOM, new Runnable()
Animations.appearSliding(menu.getFrame(), Animations.BOTTOM, new Runnable()
{
@Override
public void run()
@ -1053,7 +1054,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
if (mMainMenu.close(true))
mFadeView.fadeOut();
}
}, MainMenu.ANIMATION_DURATION * 2);
}, BaseMenu.ANIMATION_DURATION * 2);
}
else
{
@ -1215,6 +1216,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
{
if (RoutingController.get().isNavigating())
{
mNavigationController.show(true);
mMainMenu.setState(MainMenu.State.NAVIGATION, false);
return;
}

View file

@ -12,6 +12,7 @@ import com.mapswithme.maps.Framework;
import com.mapswithme.maps.R;
import com.mapswithme.maps.bookmarks.data.DistanceAndAzimut;
import com.mapswithme.maps.location.LocationHelper;
import com.mapswithme.maps.widget.menu.NavMenu;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
@ -19,7 +20,7 @@ public class NavigationController
{
private final View mFrame;
private final View mTopFrame;
private final View mBottomFrame;
private final NavMenu mNavMenu;
private final ImageView mNextTurnImage;
private final TextView mNextTurnDistance;
@ -44,7 +45,7 @@ public class NavigationController
{
mFrame = activity.findViewById(R.id.navigation_frame);
mTopFrame = mFrame.findViewById(R.id.nav_top_frame);
mBottomFrame = mFrame.findViewById(R.id.nav_bottom_frame);
mNavMenu = createNavMenu();
// Top frame
View turnFrame = mTopFrame.findViewById(R.id.nav_next_turn_frame);
@ -80,6 +81,16 @@ public class NavigationController
// });
}
private NavMenu createNavMenu() {
return new NavMenu(mFrame.findViewById(R.id.nav_bottom_frame), new NavMenu.ItemClickListener<NavMenu.Item>() {
@Override
public void onItemClick(NavMenu.Item item)
{
}
});
}
private void updateVehicle(RoutingInfo info)
{
mNextTurnDistance.setText(Utils.formatUnitsText(mFrame.getContext(),
@ -156,4 +167,9 @@ public class NavigationController
{
UiUtils.showIf(show, mFrame);
}
public NavMenu getNavMenu()
{
return mNavMenu;
}
}

View file

@ -0,0 +1,239 @@
package com.mapswithme.maps.widget.menu;
import android.animation.Animator;
import android.support.annotation.DimenRes;
import android.support.annotation.IdRes;
import android.support.annotation.Nullable;
import android.view.View;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
import com.mapswithme.util.ThemeUtils;
import com.mapswithme.util.UiUtils;
public abstract class BaseMenu
{
public static final int ANIMATION_DURATION = MwmApplication.get().getResources().getInteger(R.integer.anim_menu);
final View mFrame;
final View mLineFrame;
final View mContentFrame;
private final ItemClickListener mItemClickListener;
int mContentHeight;
boolean mLayoutCorrected;
boolean mAnimating;
public interface Item
{
@IdRes int getViewId();
}
public interface ItemClickListener<T extends Item>
{
void onItemClick(T item);
}
private class AnimationListener extends UiUtils.SimpleAnimatorListener
{
@Override
public void onAnimationStart(android.animation.Animator animation)
{
mAnimating = true;
}
@Override
public void onAnimationEnd(android.animation.Animator animation)
{
mAnimating = false;
}
}
View mapItem(final Item item, View frame)
{
View res = frame.findViewById(item.getViewId());
if (res != null)
{
res.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
//noinspection unchecked
mItemClickListener.onItemClick(item);
}
});
}
return res;
}
private void adjustTransparency()
{
mFrame.setBackgroundColor(ThemeUtils.getColor(mFrame.getContext(), isOpen() ? R.attr.menuBackgroundOpen
: R.attr.menuBackground));
}
void afterLayoutCorrected(Runnable procAfterCorrection)
{
procAfterCorrection.run();
}
private void correctLayout(final Runnable procAfterCorrection)
{
if (mLayoutCorrected)
return;
UiUtils.measureView(mContentFrame, new UiUtils.OnViewMeasuredListener()
{
@Override
public void onViewMeasured(int width, int height)
{
mContentHeight = height;
mLayoutCorrected = true;
UiUtils.hide(mContentFrame);
afterLayoutCorrected(procAfterCorrection);
}
});
}
public void onResume(Runnable procAfterCorrection)
{
correctLayout(procAfterCorrection);
updateMarker();
}
BaseMenu(View frame, ItemClickListener<? extends Item> itemClickListener)
{
mFrame = frame;
mItemClickListener = itemClickListener;
mLineFrame = mFrame.findViewById(R.id.line_frame);
mContentFrame = mFrame.findViewById(R.id.content_frame);
adjustTransparency();
}
public boolean isOpen()
{
return UiUtils.isVisible(mContentFrame);
}
public boolean isAnimating()
{
return mAnimating;
}
public boolean open(boolean animate)
{
if ((animate && mAnimating) || isOpen())
return false;
UiUtils.show(mContentFrame);
adjustCollapsedItems();
adjustTransparency();
updateMarker();
setToggleState(true, animate);
if (!animate)
return true;
mFrame.setTranslationY(mContentHeight);
mFrame.animate()
.setDuration(ANIMATION_DURATION)
.translationY(0.0f)
.setListener(new AnimationListener())
.start();
return true;
}
public boolean close(boolean animate)
{
return close(animate, null);
}
public boolean close(boolean animate, @Nullable final Runnable onCloseListener)
{
if (mAnimating || !isOpen())
{
if (onCloseListener != null)
onCloseListener.run();
return false;
}
adjustCollapsedItems();
if (!animate)
{
UiUtils.hide(mContentFrame);
adjustTransparency();
updateMarker();
setToggleState(false, false);
if (onCloseListener != null)
onCloseListener.run();
return true;
}
setToggleState(false, true);
mFrame.animate()
.setDuration(ANIMATION_DURATION)
.translationY(mContentHeight)
.setListener(new AnimationListener()
{
@Override
public void onAnimationEnd(Animator animation)
{
super.onAnimationEnd(animation);
mFrame.setTranslationY(0.0f);
UiUtils.hide(mContentFrame);
adjustTransparency();
updateMarker();
if (onCloseListener != null)
onCloseListener.run();
}
}).start();
return true;
}
public void toggle(boolean animate)
{
if (mAnimating)
return;
boolean show = !isOpen();
if (show)
open(animate);
else
close(animate);
}
public void show(boolean show)
{
close(false);
UiUtils.showIf(show, mFrame);
}
public View getFrame()
{
return mFrame;
}
protected void adjustCollapsedItems() {}
protected void updateMarker() {}
protected void setToggleState(boolean open, boolean animate) {}
protected abstract @DimenRes int getHeightResId();
}

View file

@ -1,12 +1,8 @@
package com.mapswithme.maps.widget.menu;
import android.animation.Animator;
import android.app.Activity;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.mapswithme.maps.MwmActivity;
@ -16,7 +12,6 @@ import com.mapswithme.maps.downloader.MapManager;
import com.mapswithme.maps.downloader.UpdateInfo;
import com.mapswithme.maps.routing.RoutingController;
import com.mapswithme.util.Graphics;
import com.mapswithme.util.ThemeUtils;
import com.mapswithme.util.UiUtils;
import java.util.ArrayList;
@ -24,7 +19,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MainMenu
public class MainMenu extends BaseMenu
{
public enum State
{
@ -45,17 +40,13 @@ public class MainMenu
}
}
public static final int ANIMATION_DURATION = MwmApplication.get().getResources().getInteger(R.integer.anim_menu);
private static final String TAG_COLLAPSE = MwmApplication.get().getString(R.string.tag_menu_collapse);
private final int mButtonsWidth = UiUtils.dimen(R.dimen.menu_line_button_width);
private final int mPanelWidth = UiUtils.dimen(R.dimen.panel_width);
private final Container mContainer;
private final ViewGroup mFrame;
private final View mButtonsFrame;
private final View mRoutePlanFrame;
private final View mContentFrame;
private final View mAnimationSpacer;
private final View mAnimationSymmetricalGap;
private final View mNewsMarker;
@ -69,14 +60,9 @@ public class MainMenu
private final MenuToggle mToggle;
private Button mRouteStartButton;
private int mContentHeight;
// Maps Item into button view placed on mContentFrame
private final Map<Item, View> mItemViews = new HashMap<>();
private boolean mLayoutCorrected;
private boolean mAnimating;
private final MwmActivity.LeftAnimationTrackListener mAnimationTrackListener = new MwmActivity.LeftAnimationTrackListener()
{
private float mSymmetricalGapScale;
@ -127,7 +113,7 @@ public class MainMenu
}
};
public enum Item
public enum Item implements BaseMenu.Item
{
TOGGLE(R.id.toggle),
ADD_PLACE(R.id.add_place),
@ -145,50 +131,25 @@ public class MainMenu
{
mViewId = viewId;
}
}
public interface Container
{
Activity getActivity();
void onItemClick(Item item);
}
private class AnimationListener extends UiUtils.SimpleAnimatorListener
{
@Override
public void onAnimationStart(android.animation.Animator animation)
{
mAnimating = true;
}
@Override
public void onAnimationEnd(android.animation.Animator animation)
public int getViewId()
{
mAnimating = false;
return mViewId;
}
}
private View mapItem(final Item item, View frame)
@Override
View mapItem(BaseMenu.Item item, View frame)
{
View res = frame.findViewById(item.mViewId);
if (res != null)
{
if (TAG_COLLAPSE.equals(res.getTag()))
mCollapseViews.add(res);
View res = super.mapItem(item, frame);
if (res != null && TAG_COLLAPSE.equals(res.getTag()))
mCollapseViews.add(res);
res.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
mContainer.onItemClick(item);
}
});
}
return res;
}
private void mapItem(Item item)
private void mapItem(MainMenu.Item item)
{
mapItem(item, mButtonsFrame);
View view = mapItem(item, mContentFrame);
@ -198,7 +159,8 @@ public class MainMenu
Graphics.tint((TextView)view);
}
private void adjustCollapsedItems()
@Override
protected void adjustCollapsedItems()
{
for (View v : mCollapseViews)
{
@ -209,39 +171,20 @@ public class MainMenu
if (mAnimationSymmetricalGap == null)
return;
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mAnimationSymmetricalGap.getLayoutParams();
ViewGroup.LayoutParams lp = mAnimationSymmetricalGap.getLayoutParams();
lp.width = (mCollapsed ? 0 : mButtonsWidth);
mAnimationSymmetricalGap.setLayoutParams(lp);
}
private void adjustTransparency()
@Override
void afterLayoutCorrected(Runnable procAfterCorrection)
{
mFrame.setBackgroundColor(ThemeUtils.getColor(mFrame.getContext(), isOpen() ? R.attr.menuBackgroundOpen
: R.attr.menuBackgroundClosed));
UiUtils.showIf(!RoutingController.get().isNavigating(), mFrame);
super.afterLayoutCorrected(procAfterCorrection);
}
private void correctLayout(final Runnable procAfterCorrection)
{
if (mLayoutCorrected)
return;
UiUtils.measureView(mContentFrame, new UiUtils.OnViewMeasuredListener()
{
@Override
public void onViewMeasured(int width, int height)
{
mContentHeight = height;
mLayoutCorrected = true;
UiUtils.hide(mContentFrame);
UiUtils.showIf(!RoutingController.get().isNavigating(), mFrame);
procAfterCorrection.run();
}
});
}
private void updateMarker()
@Override
protected void updateMarker()
{
UpdateInfo info = MapManager.nativeGetUpdateInfo(null);
int count = (info == null ? 0 : info.filesCount);
@ -257,10 +200,10 @@ public class MainMenu
mNewsCounter.setText(String.valueOf(count));
}
public void onResume(Runnable procAfterCorrection)
@Override
protected void setToggleState(boolean open, boolean animate)
{
correctLayout(procAfterCorrection);
updateMarker();
mToggle.setOpen(open, animate);
}
private void init()
@ -275,26 +218,22 @@ public class MainMenu
mapItem(Item.SHOWCASE);
adjustCollapsedItems();
adjustTransparency();
setState(State.MENU, false);
}
public MainMenu(ViewGroup frame, Container container)
public MainMenu(View frame, ItemClickListener<Item> itemClickListener)
{
mContainer = container;
mFrame = frame;
super(frame, itemClickListener);
View lineFrame = mFrame.findViewById(R.id.line_frame);
mButtonsFrame = lineFrame.findViewById(R.id.buttons_frame);
mRoutePlanFrame = lineFrame.findViewById(R.id.routing_plan_frame);
mContentFrame = mFrame.findViewById(R.id.content_frame);
mButtonsFrame = mLineFrame.findViewById(R.id.buttons_frame);
mRoutePlanFrame = mLineFrame.findViewById(R.id.routing_plan_frame);
mAnimationSpacer = mFrame.findViewById(R.id.animation_spacer);
mAnimationSymmetricalGap = mButtonsFrame.findViewById(R.id.symmetrical_gap);
mMyPositionButton = new MyPositionButton(lineFrame.findViewById(R.id.my_position));
mToggle = new MenuToggle(lineFrame);
mapItem(Item.TOGGLE, lineFrame);
mMyPositionButton = new MyPositionButton(mLineFrame.findViewById(R.id.my_position));
mToggle = new MenuToggle(mLineFrame, getHeightResId());
mapItem(Item.TOGGLE, mLineFrame);
mNewsMarker = mButtonsFrame.findViewById(R.id.marker);
mNewsCounter = (TextView) mContentFrame.findViewById(R.id.counter);
@ -305,6 +244,12 @@ public class MainMenu
init();
}
@Override
protected int getHeightResId()
{
return R.dimen.menu_line_height;
}
public void setState(State state, boolean animateToggle)
{
if (state != State.NAVIGATION)
@ -333,117 +278,13 @@ public class MainMenu
if (mLayoutCorrected)
{
UiUtils.showIf(state != State.NAVIGATION, mFrame);
show(state != State.NAVIGATION);
mContentFrame.measure(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
mContentHeight = mContentFrame.getMeasuredHeight();
}
}
public boolean isOpen()
{
return UiUtils.isVisible(mContentFrame);
}
public boolean open(boolean animate)
{
if ((animate && mAnimating) || isOpen())
return false;
UiUtils.show(mContentFrame);
adjustCollapsedItems();
adjustTransparency();
updateMarker();
mToggle.setOpen(true, animate);
if (!animate)
return true;
mFrame.setTranslationY(mContentHeight);
mFrame.animate()
.setDuration(ANIMATION_DURATION)
.translationY(0.0f)
.setListener(new AnimationListener())
.start();
return true;
}
public boolean close(boolean animate)
{
return close(animate, null);
}
public boolean close(boolean animate, @Nullable final Runnable onCloseListener)
{
if (mAnimating || !isOpen())
{
if (onCloseListener != null)
onCloseListener.run();
return false;
}
adjustCollapsedItems();
if (!animate)
{
UiUtils.hide(mContentFrame);
adjustTransparency();
updateMarker();
mToggle.setOpen(false, false);
if (onCloseListener != null)
onCloseListener.run();
return true;
}
mToggle.setOpen(false, true);
mFrame.animate()
.setDuration(ANIMATION_DURATION)
.translationY(mContentHeight)
.setListener(new AnimationListener()
{
@Override
public void onAnimationEnd(Animator animation)
{
super.onAnimationEnd(animation);
mFrame.setTranslationY(0.0f);
UiUtils.hide(mContentFrame);
adjustTransparency();
updateMarker();
if (onCloseListener != null)
onCloseListener.run();
}
}).start();
return true;
}
public void toggle(boolean animate)
{
if (mAnimating)
return;
boolean show = !isOpen();
if (show)
open(animate);
else
close(animate);
}
public void show(boolean show)
{
close(false);
UiUtils.showIf(show, mFrame);
}
public void setEnabled(Item item, boolean enable)
{
View button = mButtonsFrame.findViewById(item.mViewId);
@ -463,10 +304,6 @@ public class MainMenu
UiUtils.showIf(show, mItemViews.get(item));
}
public View getFrame()
{
return mFrame;
}
public MyPositionButton getMyPositionButton()
{
@ -487,9 +324,4 @@ public class MainMenu
{
return mRouteStartButton;
}
public boolean isAnimating()
{
return mAnimating;
}
}

View file

@ -3,6 +3,7 @@ package com.mapswithme.maps.widget.menu;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
import android.support.annotation.DimenRes;
import android.view.View;
import android.widget.ImageView;
@ -11,7 +12,7 @@ import com.mapswithme.maps.widget.RotateByAlphaDrawable;
import com.mapswithme.maps.widget.TrackedTransitionDrawable;
import com.mapswithme.util.UiUtils;
public class MenuToggle
class MenuToggle
{
private final ImageView mButton;
private final boolean mAlwaysShow;
@ -19,12 +20,12 @@ public class MenuToggle
private final TransitionDrawable mOpenImage;
private final TransitionDrawable mCollapseImage;
public MenuToggle(View frame)
MenuToggle(View frame, @DimenRes int heightRes)
{
mButton = (ImageView) frame.findViewById(R.id.toggle);
mAlwaysShow = (frame.findViewById(R.id.disable_toggle) == null);
int sz = UiUtils.dimen(R.dimen.menu_line_height);
int sz = UiUtils.dimen(heightRes);
Rect bounds = new Rect(0, 0, sz, sz);
mOpenImage = new TrackedTransitionDrawable(new Drawable[] { new RotateByAlphaDrawable(frame.getContext(), R.drawable.ic_menu_open, R.attr.iconTint, false)
@ -48,25 +49,25 @@ public class MenuToggle
mButton.setImageDrawable(image);
if (forward)
image.startTransition(animate ? MainMenu.ANIMATION_DURATION : 0);
image.startTransition(animate ? BaseMenu.ANIMATION_DURATION : 0);
else
image.reverseTransition(animate ? MainMenu.ANIMATION_DURATION : 0);
image.reverseTransition(animate ? BaseMenu.ANIMATION_DURATION : 0);
if (!animate)
image.getDrawable(forward ? 1 : 0).setAlpha(0xFF);
}
public void show(boolean show)
void show(boolean show)
{
UiUtils.showIf(mAlwaysShow || show, mButton);
}
public void setOpen(boolean open, boolean animate)
void setOpen(boolean open, boolean animate)
{
transitImage(mOpenImage, open, animate);
}
public void setCollapsed(boolean collapse, boolean animate)
void setCollapsed(boolean collapse, boolean animate)
{
transitImage(mCollapseImage, collapse, animate);
}

View file

@ -0,0 +1,84 @@
package com.mapswithme.maps.widget.menu;
import android.animation.ValueAnimator;
import android.view.View;
import android.widget.ImageView;
import com.mapswithme.maps.R;
import com.mapswithme.maps.widget.RotateDrawable;
public class NavMenu extends BaseMenu
{
private final ImageView mToggle;
private final RotateDrawable mToggleImage = new RotateDrawable(R.drawable.ic_menu_close);
public enum Item implements BaseMenu.Item
{
TOGGLE(R.id.toggle),
TTS_VOLUME(R.id.toggle),
STOP(R.id.toggle),
//OVERVIEW(R.id.toggle), TODO
SETTINGS(R.id.settings);
private final int mViewId;
Item(int viewId)
{
mViewId = viewId;
}
@Override
public int getViewId()
{
return mViewId;
}
}
public NavMenu(View frame, ItemClickListener<Item> listener)
{
super(frame, listener);
mToggle = (ImageView) mLineFrame.findViewById(R.id.toggle);
mToggle.setImageDrawable(mToggleImage);
mToggle.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
toggle(true);
}
});
setToggleState(false, false);
}
@Override
protected void setToggleState(boolean open, boolean animate)
{
if (!animate)
{
mToggleImage.setAngle(open ? -90.0f : 90.0f);
return;
}
ValueAnimator animator = ValueAnimator.ofFloat(open ? 1.0f : 0, open ? 0 : 1.0f);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
{
@Override
public void onAnimationUpdate(ValueAnimator animation)
{
float fraction = (float)animation.getAnimatedValue();
mToggleImage.setAngle((1.0f - fraction) * 180.0f);
}
});
animator.setDuration(ANIMATION_DURATION);
animator.start();
}
@Override
protected int getHeightResId()
{
return R.dimen.nav_menu_height;
}
}