[android] Added the traffic button in UI, core logic is not bound yet

This commit is contained in:
alexzatsepin 2016-11-29 16:37:56 +03:00
parent a4e3e54686
commit ad8aee6746
70 changed files with 132 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 649 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 644 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 703 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 756 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 699 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 874 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 723 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 735 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 765 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 762 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 888 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

After

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -21,6 +21,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.ImageButton;
import com.mapswithme.maps.Framework.MapObjectListener;
import com.mapswithme.maps.activity.CustomNavigateUpListener;
@ -67,6 +68,7 @@ import com.mapswithme.maps.settings.StoragePathManager;
import com.mapswithme.maps.settings.UnitLocale;
import com.mapswithme.maps.sound.TtsPlayer;
import com.mapswithme.maps.widget.FadeView;
import com.mapswithme.maps.widget.TrafficButton;
import com.mapswithme.maps.widget.menu.BaseMenu;
import com.mapswithme.maps.widget.menu.MainMenu;
import com.mapswithme.maps.widget.menu.MyPositionButton;
@ -139,6 +141,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
private View mNavZoomOut;
private MyPositionButton mNavMyPosition;
@Nullable
private TrafficButton mTraffic;
@Nullable
private NavigationButtonsAnimationController mNavAnimationController;
private View mPositionChooser;
@ -534,6 +538,9 @@ public class MwmActivity extends BaseMwmFragmentActivity
mNavZoomOut.setOnClickListener(this);
View myPosition = frame.findViewById(R.id.my_position);
mNavMyPosition = new MyPositionButton(myPosition);
ImageButton traffic = (ImageButton) frame.findViewById(R.id.traffic);
mTraffic = new TrafficButton(this, traffic);
mTraffic.setLoading(true);
mNavAnimationController = new NavigationButtonsAnimationController(mNavZoomIn, mNavZoomOut, myPosition,
frame.findViewById(R.id.anchor_center));
}

View file

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