[android] refactor: Navigation panels.

refator: FadeView simplified.
TODO: Refactor bottom navigation panel.
This commit is contained in:
Alexander Marchuk 2016-07-20 01:45:36 +03:00
parent 04a96a39ac
commit 30590db3ac
38 changed files with 435 additions and 323 deletions

View file

@ -0,0 +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"/>
<corners android:radius="4dp"/>
</shape>

View file

@ -0,0 +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"/>
<corners android:radius="4dp"/>
</shape>

View file

@ -0,0 +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/base_accent"/>
<corners android:radius="4dp"/>
</shape>

View file

@ -0,0 +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/base_accent_night"/>
<corners android:radius="4dp"/>
</shape>

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="@dimen/margin_base_plus"/>
<solid android:color="@color/text_dark_subtitle"/>
</shape>

View file

@ -33,9 +33,9 @@
tools:visibility="visible"/>
<include
layout="@layout/layout_routing_full"
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

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

View file

@ -1,82 +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">
<LinearLayout
android:id="@+id/time_distance"
android:layout_width="match_parent"
android:layout_height="@dimen/height_item_oneline"
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_centerVertical="true"
android:layout_marginRight="@dimen/margin_base"
android:layout_weight="0"
android:background="?attr/selectableItemBackgroundBorderless"
android:scaleType="center"
android:tint="?iconTint"
android:src="@drawable/ic_cancel"/>
<TextView
android:id="@+id/tv__total_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/margin_base"
android:layout_weight="1"
android:gravity="center"
android:textAppearance="@style/MwmTextAppearance.RoutingNumber"
tools:text="1.4 km"/>
<TextView
android:id="@+id/tv__total_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/margin_base"
android:layout_weight="1"
android:gravity="center"
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_weight="1"
android:gravity="center"
android:textAppearance="@style/MwmTextAppearance.RoutingNumber"
tools:text="1:00"/>
</LinearLayout>
<com.mapswithme.maps.widget.FlatProgressView
android:id="@+id/fp__route_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/time_distance"
app:headRadius="2dp"
app:progressColor="@color/routing_progress"
app:headColor="@color/routing_progress"
app:progressThickness="2dp"
app:secondaryProgressColor="@color/divider"
app:secondaryProgressThickness="2dp"/>
<include
android:id="@+id/turns"
layout="@layout/layout_turn_and_street"
android:layout_width="@dimen/panel_width"
android:layout_height="wrap_content"
android:layout_below="@id/fp__route_progress"
android:layout_centerHorizontal="true"/>
</RelativeLayout>

View file

@ -31,7 +31,7 @@
tools:visibility="visible"/>
<include
layout="@layout/layout_routing_full"
layout="@layout/layout_nav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/toolbar"

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/navigation_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/layout_nav_top"/>
<include layout="@layout/layout_nav_bottom"/>
</FrameLayout>

View file

@ -0,0 +1,10 @@
<?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>

View file

@ -0,0 +1,92 @@
<?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:id="@+id/nav_top_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:background="#20FF0000">
<FrameLayout
android:id="@+id/street_frame"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_street_height"
android:elevation="@dimen/nav_elevation"
android:background="?navPanel">
<TextView
android:id="@+id/street"
style="@style/MwmWidget.TextView.NavStreet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/nav_street_left"
android:maxLines="2"
android:layout_gravity="center_vertical"
android:gravity="center"
tools:text="Sample street name.\nLong looooooooong!!!!"/>
</FrameLayout>
<include
layout="@layout/shadow_top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/street_frame"/>
<LinearLayout
android:id="@+id/nav_next_turn_frame"
android:layout_width="@dimen/nav_next_turn_frame"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin_half"
android:orientation="vertical"
android:background="?navNextTurnFrame"
android:elevation="@dimen/nav_elevation">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/nav_next_turn_top"
android:layout_marginBottom="@dimen/nav_next_turn_space"
android:layout_gravity="center_horizontal">
<com.mapswithme.maps.widget.ArrowView
android:id="@+id/turn"
android:layout_width="@dimen/nav_next_turn_sign"
android:layout_height="@dimen/nav_next_turn_sign"
tools:background="#400000FF"/>
<TextView
android:id="@+id/circle_exit"
style="@style/MwmWidget.TextView.NavNextTurn.Exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
tools:text="9"/>
</FrameLayout>
<TextView
android:id="@+id/distance"
style="@style/MwmWidget.TextView.NavNextTurn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/nav_next_turn_bottom"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
tools:text="9999 ft"/>
</LinearLayout>
<FrameLayout
android:id="@+id/nav_next_next_turn_frame"
android:layout_width="wrap_content"
android:layout_height="@dimen/nav_next_next_turn_frame"
android:layout_marginBottom="@dimen/margin_base"
android:layout_below="@id/nav_next_turn_frame"
android:layout_alignLeft="@id/nav_next_turn_frame"
android:layout_alignRight="@id/nav_next_turn_frame"
android:background="?navNextNextTurnFrame"
android:elevation="@dimen/nav_elevation"
android:visibility="gone"
tools:visibility="visible">
<ImageView
android:id="@id/turn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
tools:src="@drawable/ic_close"/>
</FrameLayout>
</RelativeLayout>

View file

@ -1,47 +0,0 @@
<?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:id="@+id/navigation_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
layout="@layout/layout_turn_instructions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/margin_half"
android:layout_marginBottom="@dimen/margin_half"/>
<LinearLayout
android:id="@+id/next_turn_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@drawable/bg_next_turn"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingBottom="@dimen/margin_quarter"
android:paddingLeft="@dimen/margin_base"
android:paddingRight="@dimen/margin_base"
android:paddingTop="@dimen/margin_quarter"
android:visibility="gone"
tools:visibility="visible">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="@dimen/margin_quarter"
android:text="@string/next_turn_then"
android:textColor="@android:color/white"
android:textSize="@dimen/text_size_toolbar"/>
<ImageView
android:id="@+id/iv__next_turn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="@string/next_turn_then"
tools:src="@drawable/ic_then_round"/>
</LinearLayout>
</LinearLayout>

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/turns"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="@dimen/panel_width"

View file

@ -66,7 +66,6 @@
app:secondaryProgressThickness="2dp"/>
<include
android:id="@+id/turns"
layout="@layout/layout_turn_and_street"
android:layout_width="@dimen/panel_width"
android:layout_height="wrap_content"

View file

@ -1,26 +1,26 @@
<?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="match_parent"
android:orientation="vertical"
android:gravity="right"
android:paddingLeft="@dimen/margin_navigation_buttons"
android:paddingRight="0dp"
android:paddingBottom="@dimen/margin_navigation_buttons">
<android.support.v4.widget.Space
android:id="@+id/space_bottom"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>
<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"
android:layout_marginBottom="@dimen/nav_menu_height">
<ImageButton
android:id="@+id/nav_zoom_out"
style="@style/MwmWidget.MapButton"
android:layout_marginBottom="@dimen/nav_zoom_bottom"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
tools:src="@drawable/zoom_out"/>
<ImageButton android:id="@+id/map_button_plus"
style="@style/MwmWidget.MapButton"
android:layout_marginRight="@dimen/margin_quarter"
tools:src="@drawable/zoom_in"/>
<ImageButton android:id="@+id/map_button_minus"
style="@style/MwmWidget.MapButton"
android:layout_marginRight="@dimen/margin_quarter"
tools:src="@drawable/zoom_out"/>
</LinearLayout>
<ImageButton
android:id="@+id/nav_zoom_in"
style="@style/MwmWidget.MapButton"
android:layout_marginBottom="@dimen/nav_frame_padding"
android:layout_above="@id/nav_zoom_out"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
tools:src="@drawable/zoom_in"/>
</RelativeLayout>

View file

@ -1,10 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="zoom_plus_top_margin">-10dp</dimen>
<dimen name="drawer_top_padding">12dp</dimen>
<dimen name="tabs_height">48dp</dimen>
<dimen name="menu_line_button_inset_edge">-12dp</dimen>
<dimen name="menu_line_button_width_edge">72dp</dimen>
<dimen name="menu_line_button_width">88dp</dimen>
<!-- Nav menu -->
<dimen name="nav_menu_height">40dp</dimen>
<dimen name="nav_zoom_bottom">80dp</dimen>
</resources>

View file

@ -1,8 +1,6 @@
<resources>
<dimen name="dialog_max_height">560dp</dimen>
<dimen name="routing_pp_height">63dp</dimen>
<!-- direction fragment -->
<dimen name="margin_direction_small">12dp</dimen>
<dimen name="margin_direction_big">80dp</dimen>

View file

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

View file

@ -1,3 +1,15 @@
<resources>
<dimen name="dialog_max_height">600dp</dimen>
<dimen name="nav_street_height">56dp</dimen>
<dimen name="nav_street_left">152dp</dimen>
<dimen name="nav_next_turn_frame">132dp</dimen>
<dimen name="nav_next_turn_top">12dp</dimen>
<dimen name="nav_next_turn_bottom">9dp</dimen>
<dimen name="nav_next_turn_space">9dp</dimen>
<dimen name="nav_next_turn_sign">96dp</dimen>
<dimen name="nav_next_next_turn_frame">48dp</dimen>
<dimen name="nav_frame_padding">@dimen/margin_base</dimen>
<dimen name="nav_zoom_bottom">250dp</dimen>
</resources>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="text_size_nav_street">26sp</dimen>
<dimen name="text_size_nav_next_turn">32sp</dimen>
<dimen name="text_size_nav_circle_exit">16sp</dimen>
<dimen name="text_size_nav_number">36sp</dimen>
<dimen name="text_size_nav_dimension">30sp</dimen>
</resources>

View file

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="margin_navigation_buttons">@dimen/margin_half</dimen>
</resources>

View file

@ -37,6 +37,8 @@
<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>

View file

@ -25,8 +25,6 @@
<dimen name="neg_margin_base">-16dp</dimen>
<dimen name="neg_margin_double">-32dp</dimen>
<dimen name="margin_navigation_buttons">@dimen/margin_quarter</dimen>
<!-- base sizes -->
<dimen name="height_block_base">48dp</dimen>
<dimen name="height_item_oneline">56dp</dimen>
@ -57,9 +55,6 @@
<dimen name="margin_direction_around_center">40dp</dimen>
<dimen name="direction_frame_min_height">36dp</dimen>
<dimen name="zoom_buttons_top_required_space">266dp</dimen>
<dimen name="zoom_buttons_bottom_max_space">228dp</dimen>
<!-- map widgets -->
<dimen name="margin_compass_left">32dp</dimen>
<dimen name="margin_compass_bottom">80dp</dimen>
@ -87,6 +82,22 @@
<dimen name="menu_line_button_inset_edge">-16dp</dimen>
<dimen name="menu_list_item_height">48dp</dimen>
<!-- Nav menu -->
<dimen name="nav_elevation">6dp</dimen>
<dimen name="nav_street_height">44dp</dimen>
<dimen name="nav_street_left">104dp</dimen>
<dimen name="nav_next_turn_frame">88dp</dimen>
<dimen name="nav_next_turn_top">8dp</dimen>
<dimen name="nav_next_turn_bottom">6dp</dimen>
<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_frame_padding">@dimen/margin_half</dimen>
<dimen name="nav_button">28dp</dimen>
<dimen name="nav_zoom_bottom">160dp</dimen>
<dimen name="panel_elevation">12dp</dimen>
<dimen name="appbar_elevation">4dp</dimen>
<dimen name="placepage_elevation">4dp</dimen>

View file

@ -37,4 +37,9 @@
<dimen name="text_size_routing_plan_detail_arrival">14sp</dimen>
<dimen name="text_size_time_picker">56sp</dimen>
<dimen name="text_size_nav_street">17sp</dimen>
<dimen name="text_size_nav_next_turn">24sp</dimen>
<dimen name="text_size_nav_circle_exit">12sp</dimen>
<dimen name="text_size_nav_number">24sp</dimen>
<dimen name="text_size_nav_dimension">20sp</dimen>
</resources>

View file

@ -117,6 +117,23 @@
<item name="android:textColor">?secondary</item>
</style>
<style name="MwmTextAppearance.NavStreet">
<item name="android:textSize">@dimen/text_size_nav_street</item>
<item name="android:fontFamily" tools:ignore="NewApi">@string/robotoMedium</item>
<item name="android:textColor">?android:textColorPrimary</item>
</style>
<style name="MwmTextAppearance.NavNextTurn">
<item name="android:textSize">@dimen/text_size_nav_next_turn</item>
<item name="android:fontFamily" tools:ignore="NewApi">@string/robotoMedium</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">?android:textColorPrimaryInverse</item>
</style>
<style name="MwmTextAppearance.NavNextTurn.Exit">
<item name="android:textSize">@dimen/text_size_nav_circle_exit</item>
</style>
<style name="MwmTextAppearance.PlacePage"
parent="MwmTextAppearance.Body1"/>

View file

@ -149,6 +149,18 @@
<item name="android:layout_centerVertical">true</item>
</style>
<style name="MwmWidget.TextView.NavStreet">
<item name="android:textAppearance">@style/MwmTextAppearance.NavStreet</item>
</style>
<style name="MwmWidget.TextView.NavNextTurn">
<item name="android:textAppearance">@style/MwmTextAppearance.NavNextTurn</item>
</style>
<style name="MwmWidget.TextView.NavNextTurn.Exit">
<item name="android:textAppearance">@style/MwmTextAppearance.NavNextTurn.Exit</item>
</style>
<style name="MwmWidget.FrameLayout.Elevation">
<item name="android:foreground">@drawable/shadow_top</item>
</style>

View file

@ -28,6 +28,9 @@
<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"/>
<attr name="buttonBackground" format="reference"/>
<attr name="buttonTextColor" format="color"/>
@ -45,11 +48,20 @@
<attr name="myPositionButtonAnimation" format="reference"/>
<attr name="wheelPendingAnimation" format="reference"/>
<attr name="navButtonsTheme" format="reference"/>
<attr name="downloaderTheme" format="reference"/>
<attr name="fabAdd" format="reference"/>
</declare-styleable>
<declare-styleable name="ThemeAttrs.NavButtons">
<attr name="nav_zoom_in" format="reference"/>
<attr name="nav_zoom_out" format="reference"/>
<attr name="nav_search_closed" format="reference"/>
<attr name="nav_search_open" format="reference"/>
<attr name="nav_bookmark" format="reference"/>
</declare-styleable>
<declare-styleable name="ThemeAttrs.Downloader">
<attr name="status_done" format="reference"/>
<attr name="status_downloadable" format="reference"/>

View file

@ -44,6 +44,9 @@
<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>
<item name="buttonBackground">@drawable/button</item>
<item name="buttonTextColor">@color/button_text</item>
@ -61,6 +64,7 @@
<item name="myPositionButtonAnimation">@drawable/anim_myposition_pending</item>
<item name="wheelPendingAnimation">@drawable/anim_spinner_pending</item>
<item name="navButtonsTheme">@style/MwmTheme.NavButtons</item>
<item name="downloaderTheme">@style/MwmTheme.Downloader</item>
<item name="fabAdd">@drawable/ic_fab_add</item>
@ -110,6 +114,9 @@
<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>
<item name="buttonBackground">@drawable/button_night</item>
<item name="buttonTextColor">@color/button_text_night</item>
@ -127,6 +134,7 @@
<item name="myPositionButtonAnimation">@drawable/anim_myposition_pending_night</item>
<item name="wheelPendingAnimation">@drawable/anim_spinner_pending_night</item>
<item name="navButtonsTheme">@style/MwmTheme.NavButtons.Night</item>
<item name="downloaderTheme">@style/MwmTheme.Downloader.Night</item>
<item name="fabAdd">@drawable/ic_fab_add_night</item>

View file

@ -132,4 +132,20 @@
<item name="status_folder">@drawable/ic_downloader_folder_night</item>
<item name="status_folder_done">@drawable/ic_downloader_folder_done_night</item>
</style>
<style name="MwmTheme.NavButtons">
<item name="nav_zoom_in">@drawable/zoom_in</item>
<item name="nav_zoom_out">@drawable/zoom_out</item>
<item name="nav_search_closed">@drawable/zoom_in</item>
<item name="nav_search_open">@drawable/zoom_out</item>
<item name="nav_bookmark">@drawable/zoom_in</item>
</style>
<style name="MwmTheme.NavButtons.Night">
<item name="nav_zoom_in">@drawable/ic_zoom_in_night</item>
<item name="nav_zoom_out">@drawable/zoom_out_night</item>
<item name="nav_search_closed">@drawable/zoom_in_night</item>
<item name="nav_search_open">@drawable/zoom_out_night</item>
<item name="nav_bookmark">@drawable/zoom_in_night</item>
</style>
</resources>

View file

@ -7,6 +7,8 @@ import android.content.Intent;
import android.location.Location;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.AttrRes;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
@ -21,10 +23,6 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import java.io.Serializable;
import java.util.Stack;
import com.mapswithme.maps.Framework.MapObjectListener;
import com.mapswithme.maps.activity.CustomNavigateUpListener;
@ -86,6 +84,9 @@ import com.mapswithme.util.statistics.Statistics;
import ru.mail.android.mytarget.nativeads.NativeAppwallAd;
import ru.mail.android.mytarget.nativeads.banners.NativeAppwallBanner;
import java.io.Serializable;
import java.util.Stack;
public class MwmActivity extends BaseMwmFragmentActivity
implements MapObjectListener,
View.OnTouchListener,
@ -130,8 +131,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
private FadeView mFadeView;
private ImageButton mBtnZoomIn;
private ImageButton mBtnZoomOut;
private View mNavZoomIn;
private View mNavZoomOut;
private View mPositionChooser;
@ -421,17 +422,20 @@ public class MwmActivity extends BaseMwmFragmentActivity
mMapFrame.setOnTouchListener(this);
}
private View initNavigationButton(View frame, @IdRes int id, @AttrRes int iconAttr)
{
ImageButton res = (ImageButton) frame.findViewById(id);
res.setImageResource(ThemeUtils.getResource(this, R.attr.navButtonsTheme, iconAttr));
res.setOnClickListener(this);
return res;
}
private void initNavigationButtons()
{
View frame = findViewById(R.id.navigation_buttons);
mBtnZoomIn = (ImageButton) frame.findViewById(R.id.map_button_plus);
mBtnZoomIn.setImageResource(ThemeUtils.isNightTheme() ? R.drawable.zoom_in_night
: R.drawable.zoom_in);
mBtnZoomIn.setOnClickListener(this);
mBtnZoomOut = (ImageButton) frame.findViewById(R.id.map_button_minus);
mBtnZoomOut.setOnClickListener(this);
mBtnZoomOut.setImageResource(ThemeUtils.isNightTheme() ? R.drawable.zoom_out_night
: R.drawable.zoom_out);
mNavZoomIn = initNavigationButton(frame, R.id.nav_zoom_in, R.attr.nav_zoom_in);
mNavZoomOut = initNavigationButton(frame, R.id.nav_zoom_out, R.attr.nav_zoom_out);
}
private boolean closePlacePage()
@ -452,7 +456,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
if (removeCurrentFragment(true))
{
InputUtils.hideKeyboard(mFadeView);
mFadeView.fadeOut(false);
mFadeView.fadeOut();
return true;
}
@ -464,7 +468,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
Statistics.INSTANCE.trackEvent(statEvent);
AlohaHelper.logClick(alohaStatEvent);
mFadeView.fadeOut(false);
mFadeView.fadeOut();
mMainMenu.close(true, procAfterClose);
}
@ -497,7 +501,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
private void toggleMenu()
{
if (mMainMenu.isOpen())
mFadeView.fadeOut(false);
mFadeView.fadeOut();
else
mFadeView.fadeIn();
@ -794,28 +798,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
private void adjustZoomButtons()
{
final boolean show = showZoomButtons();
UiUtils.showIf(show, mBtnZoomIn, mBtnZoomOut);
if (!show)
return;
mMapFrame.post(new Runnable()
{
@Override
public void run()
{
int height = mMapFrame.getMeasuredHeight();
int top = UiUtils.dimen(R.dimen.zoom_buttons_top_required_space);
int bottom = UiUtils.dimen(R.dimen.zoom_buttons_bottom_max_space);
int space = (top + bottom < height ? bottom : height - top);
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mBtnZoomOut.getLayoutParams();
lp.bottomMargin = space;
mBtnZoomOut.setLayoutParams(lp);
}
});
UiUtils.showIf(showZoomButtons(), mNavZoomIn, mNavZoomOut);
}
private static boolean showZoomButtons()
@ -892,7 +875,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
{
if (mMainMenu.close(true))
{
mFadeView.fadeOut(false);
mFadeView.fadeOut();
return;
}
@ -990,7 +973,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
mPlacePage.setState(State.PREVIEW);
if (UiUtils.isVisible(mFadeView))
mFadeView.fadeOut(false);
mFadeView.fadeOut();
}
@Override
@ -1033,8 +1016,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
});
if (showZoomButtons())
{
Animations.disappearSliding(mBtnZoomOut, Animations.RIGHT, null);
Animations.disappearSliding(mBtnZoomIn, Animations.RIGHT, null);
Animations.disappearSliding(mNavZoomOut, Animations.RIGHT, null);
Animations.disappearSliding(mNavZoomIn, Animations.RIGHT, null);
}
}
else
@ -1050,8 +1033,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
});
if (showZoomButtons())
{
Animations.appearSliding(mBtnZoomOut, Animations.RIGHT, null);
Animations.appearSliding(mBtnZoomIn, Animations.RIGHT, null);
Animations.appearSliding(mNavZoomOut, Animations.RIGHT, null);
Animations.appearSliding(mNavZoomIn, Animations.RIGHT, null);
}
}
}
@ -1068,7 +1051,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
public void run()
{
if (mMainMenu.close(true))
mFadeView.fadeOut(false);
mFadeView.fadeOut();
}
}, MainMenu.ANIMATION_DURATION * 2);
}
@ -1095,12 +1078,12 @@ public class MwmActivity extends BaseMwmFragmentActivity
{
switch (v.getId())
{
case R.id.map_button_plus:
case R.id.nav_zoom_in:
Statistics.INSTANCE.trackEvent(Statistics.EventName.ZOOM_IN);
AlohaHelper.logClick(AlohaHelper.ZOOM_IN);
MapFragment.nativeScalePlus();
break;
case R.id.map_button_minus:
case R.id.nav_zoom_out:
Statistics.INSTANCE.trackEvent(Statistics.EventName.ZOOM_OUT);
AlohaHelper.logClick(AlohaHelper.ZOOM_OUT);
MapFragment.nativeScaleMinus();

View file

@ -2,85 +2,97 @@ package com.mapswithme.maps.routing;
import android.app.Activity;
import android.location.Location;
import android.os.Build;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
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.FlatProgressView;
import com.mapswithme.util.Animations;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
import com.mapswithme.util.statistics.AlohaHelper;
import com.mapswithme.util.statistics.Statistics;
public class NavigationController
{
private final View mFrame;
private final View mTopFrame;
private final View mBottomFrame;
private final TextView mDistanceTotal;
private final TextView mTimeTotal;
private final ImageView mTurnDirection;
private final TextView mExitNumber;
private final View mNextTurnFrame;
private final ImageView mNextTurnImage;
private final TextView mNextTurnDistance;
private final TextView mCircleExit;
private final View mNextNextTurnFrame;
private final ImageView mNextNextTurnImage;
private final TextView mDistanceTurn;
private final FlatProgressView mRouteProgress;
private final TextView mNextStreet;
private final TextView mTimeArrival;
// private final TextView mDistanceTotal;
// private final TextView mTimeTotal;
// private final ImageView mTurnDirection;
//
// private final FlatProgressView mRouteProgress;
// private final TextView mTimeArrival;
private double mNorth;
public NavigationController(Activity activity)
{
mFrame = activity.findViewById(R.id.navigation_frame);
mTopFrame = mFrame.findViewById(R.id.nav_top_frame);
mBottomFrame = mFrame.findViewById(R.id.nav_bottom_frame);
mDistanceTotal = (TextView) mFrame.findViewById(R.id.tv__total_distance);
mTimeTotal = (TextView) mFrame.findViewById(R.id.tv__total_time);
mTimeArrival = (TextView) mFrame.findViewById(R.id.tv__arrival_time);
mTurnDirection = (ImageView) mFrame.findViewById(R.id.iv__turn);
mExitNumber = (TextView) mFrame.findViewById(R.id.tv__exit_num);
// Top frame
View turnFrame = mTopFrame.findViewById(R.id.nav_next_turn_frame);
mNextTurnImage = (ImageView) turnFrame.findViewById(R.id.turn);
mNextTurnDistance = (TextView) turnFrame.findViewById(R.id.distance);
mCircleExit = (TextView) turnFrame.findViewById(R.id.circle_exit);
mDistanceTurn = (TextView) mFrame.findViewById(R.id.tv__turn_distance);
mRouteProgress = (FlatProgressView) mFrame.findViewById(R.id.fp__route_progress);
mNextStreet = (TextView) mFrame.findViewById(R.id.tv__next_street);
mNextNextTurnFrame = mTopFrame.findViewById(R.id.nav_next_next_turn_frame);
mNextNextTurnImage = (ImageView) mNextNextTurnFrame.findViewById(R.id.turn);
mFrame.findViewById(R.id.btn__close).setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
AlohaHelper.logClick(AlohaHelper.ROUTING_CLOSE);
Statistics.INSTANCE.trackEvent(Statistics.EventName.ROUTING_CLOSE);
RoutingController.get().cancel();
}
});
mNextStreet = (TextView) mTopFrame.findViewById(R.id.street);
View shadow = mTopFrame.findViewById(R.id.shadow_top);
UiUtils.showIf(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP, shadow);
mNextTurnFrame = mFrame.findViewById(R.id.next_turn_frame);
mNextTurnImage = (ImageView) mNextTurnFrame.findViewById(R.id.iv__next_turn);
// TODO (trashkalmar): Bottom frame
// mDistanceTotal = (TextView) mFrame.findViewById(R.id.tv__total_distance);
// mTimeTotal = (TextView) mFrame.findViewById(R.id.tv__total_time);
// mTimeArrival = (TextView) mFrame.findViewById(R.id.tv__arrival_time);
// mTurnDirection = (ImageView) mFrame.findViewById(R.id.iv__turn);
//
// mRouteProgress = (FlatProgressView) mFrame.findViewById(R.id.fp__route_progress);
//
// mFrame.findViewById(R.id.btn__close).setOnClickListener(new View.OnClickListener()
// {
// @Override
// public void onClick(View v)
// {
// AlohaHelper.logClick(AlohaHelper.ROUTING_CLOSE);
// Statistics.INSTANCE.trackEvent(Statistics.EventName.ROUTING_CLOSE);
// RoutingController.get().cancel();
// }
// });
}
private void updateVehicle(RoutingInfo info)
{
mDistanceTurn.setText(Utils.formatUnitsText(R.dimen.text_size_display_1, R.dimen.text_size_toolbar,
info.distToTurn, info.turnUnits));
info.vehicleTurnDirection.setTurnDrawable(mTurnDirection);
mNextTurnDistance.setText(Utils.formatUnitsText(mFrame.getContext(),
R.dimen.text_size_nav_number,
R.dimen.text_size_nav_dimension,
info.distToTurn,
info.turnUnits));
info.vehicleTurnDirection.setTurnDrawable(mNextTurnImage);
if (RoutingInfo.VehicleTurnDirection.isRoundAbout(info.vehicleTurnDirection))
UiUtils.setTextAndShow(mExitNumber, String.valueOf(info.exitNum));
UiUtils.setTextAndShow(mCircleExit, String.valueOf(info.exitNum));
else
UiUtils.hide(mExitNumber);
UiUtils.hide(mCircleExit);
UiUtils.showIf(info.vehicleNextTurnDirection.containsNextTurn(), mNextNextTurnFrame);
if (info.vehicleNextTurnDirection.containsNextTurn())
{
Animations.appearSliding(mNextTurnFrame, Animations.TOP, null);
info.vehicleNextTurnDirection.setNextTurnDrawable(mNextTurnImage);
}
else
Animations.disappearSliding(mNextTurnFrame, Animations.BOTTOM, null);
info.vehicleNextTurnDirection.setNextTurnDrawable(mNextNextTurnImage);
}
private void updatePedestrian(RoutingInfo info)
@ -91,10 +103,13 @@ public class NavigationController
location.getLatitude(), location.getLongitude(),
mNorth);
String[] splitDistance = da.getDistance().split(" ");
mDistanceTurn.setText(Utils.formatUnitsText(R.dimen.text_size_display_1, R.dimen.text_size_toolbar,
splitDistance[0], splitDistance[1]));
mNextTurnDistance.setText(Utils.formatUnitsText(mFrame.getContext(),
R.dimen.text_size_nav_number,
R.dimen.text_size_nav_dimension,
splitDistance[0],
splitDistance[1]));
if (info.pedestrianTurnDirection != null)
RoutingInfo.PedestrianTurnDirection.setTurnDrawable(mTurnDirection, da);
RoutingInfo.PedestrianTurnDirection.setTurnDrawable(mNextTurnImage, da);
}
public void updateNorth(double north)
@ -116,18 +131,23 @@ public class NavigationController
else
updateVehicle(info);
mTimeTotal.setText(RoutingController.formatRoutingTime(info.totalTimeInSeconds, R.dimen.text_size_routing_dimension));
mDistanceTotal.setText(Utils.formatUnitsText(R.dimen.text_size_routing_number, R.dimen.text_size_routing_dimension,
info.distToTarget, info.targetUnits));
mTimeArrival.setText(RoutingController.formatArrivalTime(info.totalTimeInSeconds));
UiUtils.setTextAndHideIfEmpty(mNextStreet, info.nextStreet);
mRouteProgress.setProgress((int) info.completionPercent);
/*
mTimeTotal.setText(RoutingController.formatRoutingTime(mFrame.getContext(),
info.totalTimeInSeconds,
R.dimen.text_size_routing_dimension));
mDistanceTotal.setText(Utils.formatUnitsText(mFrame.getContext(),
R.dimen.text_size_routing_number,
R.dimen.text_size_routing_dimension,
info.distToTarget,
info.targetUnits));
mTimeArrival.setText(RoutingController.formatArrivalTime(info.totalTimeInSeconds));
mRouteProgress.setProgress((int) info.completionPercent);*/
}
public void show(boolean show)
{
UiUtils.showIf(show, mFrame);
if (!show)
UiUtils.hide(mNextTurnFrame);
}
}

View file

@ -1,6 +1,7 @@
package com.mapswithme.maps.routing;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.support.annotation.DimenRes;
import android.support.annotation.IntRange;
@ -13,9 +14,6 @@ import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.Calendar;
import java.util.concurrent.TimeUnit;
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
@ -33,6 +31,9 @@ import com.mapswithme.util.log.Logger;
import com.mapswithme.util.statistics.AlohaHelper;
import com.mapswithme.util.statistics.Statistics;
import java.util.Calendar;
import java.util.concurrent.TimeUnit;
@android.support.annotation.UiThread
public class RoutingController
{
@ -705,16 +706,16 @@ public class RoutingController
mContainer.updatePoints();
}
public static CharSequence formatRoutingTime(int seconds, @DimenRes int unitsSize)
static CharSequence formatRoutingTime(Context context, int seconds, @DimenRes int unitsSize)
{
long minutes = TimeUnit.SECONDS.toMinutes(seconds) % 60;
long hours = TimeUnit.SECONDS.toHours(seconds);
return hours == 0 ? Utils.formatUnitsText(R.dimen.text_size_routing_number, unitsSize,
return hours == 0 ? Utils.formatUnitsText(context, R.dimen.text_size_routing_number, unitsSize,
String.valueOf(minutes), "min")
: TextUtils.concat(Utils.formatUnitsText(R.dimen.text_size_routing_number, unitsSize,
: TextUtils.concat(Utils.formatUnitsText(context, R.dimen.text_size_routing_number, unitsSize,
String.valueOf(hours), "h "),
Utils.formatUnitsText(R.dimen.text_size_routing_number, unitsSize,
Utils.formatUnitsText(context, R.dimen.text_size_routing_number, unitsSize,
String.valueOf(minutes), "min"));
}

View file

@ -89,7 +89,7 @@ public class RoutingInfo
}
}
public enum PedestrianTurnDirection
enum PedestrianTurnDirection
{
NONE,
UPSTAIRS,

View file

@ -193,7 +193,7 @@ public class RoutingPlanController extends ToolbarController
return;
RoutingInfo rinfo = RoutingController.get().getCachedRoutingInfo();
mNumbersTime.setText(RoutingController.formatRoutingTime(rinfo.totalTimeInSeconds, R.dimen.text_size_routing_number));
mNumbersTime.setText(RoutingController.formatRoutingTime(mFrame.getContext(), rinfo.totalTimeInSeconds, R.dimen.text_size_routing_number));
mNumbersDistance.setText(rinfo.distToTarget + " " + rinfo.targetUnits);
if (mNumbersArrival != null)

View file

@ -1,7 +1,6 @@
package com.mapswithme.maps.widget;
import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
@ -18,12 +17,23 @@ public class FadeView extends FrameLayout
private static final String PROPERTY_ALPHA = "alpha";
private static final int DURATION = MwmApplication.get().getResources().getInteger(R.integer.anim_fade_main);
private final Animator.AnimatorListener mFadeInListener = new UiUtils.SimpleAnimatorListener()
{
@Override
public void onAnimationEnd(Animator animation)
{
UiUtils.show(FadeView.this);
animation.removeListener(this);
}
};
private final Animator.AnimatorListener mFadeOutListener = new UiUtils.SimpleAnimatorListener()
{
@Override
public void onAnimationEnd(Animator animation)
{
UiUtils.hide(FadeView.this);
animation.removeListener(this);
}
};
@ -57,38 +67,31 @@ public class FadeView extends FrameLayout
public void fadeIn()
{
setAlpha(0.0f);
UiUtils.show(this);
ObjectAnimator animation = ObjectAnimator.ofFloat(this, PROPERTY_ALPHA, 0f, FADE_ALPHA_VALUE);
animation.setDuration(DURATION);
animation.start();
animate().alpha(FADE_ALPHA_VALUE)
.setDuration(DURATION)
.setListener(mFadeInListener)
.start();
}
public void fadeOut(boolean notify)
public void fadeOut()
{
if (mListener != null && notify)
{
if (!mListener.onTouch())
return;
}
ObjectAnimator animation = ObjectAnimator.ofFloat(this, PROPERTY_ALPHA, FADE_ALPHA_VALUE, 0f);
animation.addListener(mFadeOutListener);
animation.setDuration(DURATION);
animation.start();
}
public void fadeInInstantly()
{
UiUtils.show(this);
setAlpha(FADE_ALPHA_VALUE);
animate().alpha(0.0f)
.setDuration(DURATION)
.setListener(mFadeOutListener)
.start();
}
@Override
public boolean onTouchEvent(@NonNull MotionEvent event)
{
if (event.getAction() == MotionEvent.ACTION_DOWN)
fadeOut(true);
if (event.getAction() != MotionEvent.ACTION_DOWN)
return true;
if (mListener == null || mListener.onTouch())
fadeOut();
return true;
}

View file

@ -272,7 +272,12 @@ public final class UiUtils
public static int dimen(@DimenRes int id)
{
return MwmApplication.get().getResources().getDimensionPixelSize(id);
return dimen(MwmApplication.get(), id);
}
public static int dimen(Context context, @DimenRes int id)
{
return context.getResources().getDimensionPixelSize(id);
}
public static int toPx(int dp)

View file

@ -26,6 +26,12 @@ import android.util.Log;
import android.view.Window;
import android.widget.Toast;
import com.mapswithme.maps.BuildConfig;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
import com.mapswithme.maps.activity.CustomNavigateUpListener;
import com.mapswithme.util.statistics.AlohaHelper;
import java.io.Closeable;
import java.io.File;
import java.io.FileWriter;
@ -35,12 +41,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import com.mapswithme.maps.BuildConfig;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
import com.mapswithme.maps.activity.CustomNavigateUpListener;
import com.mapswithme.util.statistics.AlohaHelper;
public class Utils
{
private static final String TAG = "Utils";
@ -340,11 +340,11 @@ public class Utils
NavUtils.navigateUpTo(activity, intent);
}
public static SpannableStringBuilder formatUnitsText(@DimenRes int size, @DimenRes int units, String dimension, String unitText)
public static SpannableStringBuilder formatUnitsText(Context context, @DimenRes int size, @DimenRes int units, String dimension, String unitText)
{
final SpannableStringBuilder res = new SpannableStringBuilder(dimension).append(" ").append(unitText);
res.setSpan(new AbsoluteSizeSpan(UiUtils.dimen(size), false), 0, dimension.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
res.setSpan(new AbsoluteSizeSpan(UiUtils.dimen(units), false), dimension.length(), res.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
res.setSpan(new AbsoluteSizeSpan(UiUtils.dimen(context, size), false), 0, dimension.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
res.setSpan(new AbsoluteSizeSpan(UiUtils.dimen(context, units), false), dimension.length(), res.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
return res;
}