New material-styled map bottom buttons.

This commit is contained in:
Dmitry Yunitsky 2015-05-25 09:35:30 +03:00 committed by Alex Zolotarev
parent 3eb8ab62f0
commit 8a4495a31c
16 changed files with 512 additions and 126 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item
android:drawable="@drawable/btn_green_menu"
android:duration="50"/>
<item
android:drawable="@drawable/btn_green_menu_2"
android:duration="50"/>
<item
android:drawable="@drawable/btn_green_menu_3"
android:duration="50"/>
<item
android:drawable="@drawable/btn_green_menu_4"
android:duration="50"/>
</animation-list>

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item
android:drawable="@drawable/btn_green_menu_4"
android:duration="50"/>
<item
android:drawable="@drawable/btn_green_menu_3"
android:duration="50"/>
<item
android:drawable="@drawable/btn_green_menu_2"
android:duration="50"/>
<item
android:drawable="@drawable/btn_green_menu"
android:duration="50"/>
</animation-list>

View file

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:enterFadeDuration="200"
android:exitFadeDuration="200"
tools:ignore="UnusedAttribute">
<item android:drawable="@drawable/btn_green_pressed"

View file

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:enterFadeDuration="200"
android:exitFadeDuration="200"
tools:ignore="UnusedAttribute">
<item android:drawable="@drawable/btn_white_normal"

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="UnusedAttribute">
<item android:drawable="@drawable/btn_white_second_pressed"
android:state_pressed="true"/>
<item android:drawable="@drawable/btn_white_second_normal"/>
</selector>

View file

@ -40,11 +40,11 @@
android:layout_height="match_parent"
android:layout_below="@id/fl__routing"/>
<ImageView
<com.mapswithme.maps.widget.FadeView
android:id="@+id/fade_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@android:color/black"
android:background="@android:color/black"
android:visibility="gone"/>
<include

View file

@ -34,11 +34,11 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<ImageView
<com.mapswithme.maps.widget.FadeView
android:id="@+id/fade_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@android:color/black"
android:background="@android:color/black"
android:visibility="gone"/>
<FrameLayout

View file

@ -34,11 +34,11 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<ImageView
<com.mapswithme.maps.widget.FadeView
android:id="@+id/fade_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@android:color/black"
android:background="@android:color/black"
android:visibility="gone"/>
<FrameLayout

View file

@ -33,11 +33,11 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<ImageView
<com.mapswithme.maps.widget.FadeView
android:id="@+id/fade_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@android:color/black"
android:background="@android:color/black"
android:visibility="gone"/>
<FrameLayout

View file

@ -46,7 +46,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<View
<com.mapswithme.maps.widget.FadeView
android:id="@+id/fade_view"
android:layout_width="match_parent"
android:layout_height="match_parent"

View file

@ -1,43 +1,156 @@
<?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/margin_small">
android:padding="@dimen/margin_small"
tools:ignore="UseCompoundDrawables">
<ImageButton
android:id="@+id/btn__bookmarks"
style="@style/MwmWidget.MapButton.Green"
android:layout_above="@+id/btn__download_maps"
<LinearLayout
android:id="@+id/ll__bookmarks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/ll__download_maps"
android:layout_alignParentRight="true"
android:src="@drawable/btn_green_bookmarks"/>
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageButton
android:id="@+id/btn__download_maps"
style="@style/MwmWidget.MapButton.Green"
android:layout_above="@+id/btn__settings"
<TextView
android:id="@+id/tv__bookmarks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/margin_small"
android:text="@string/bookmarks"
android:textAllCaps="true"
android:textAppearance="@style/MwmTextAppearance.Body1.Light"/>
<ImageView
android:id="@+id/btn__bookmarks"
style="@style/MwmWidget.MapButton.Green"
android:clickable="false"
android:contentDescription="@string/bookmarks"
android:duplicateParentState="true"
android:src="@drawable/btn_green_bookmarks"/>
</LinearLayout>
<LinearLayout
android:id="@+id/ll__download_maps"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/ll__settings"
android:layout_alignParentRight="true"
android:src="@drawable/btn_green_download"/>
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageButton
android:id="@+id/btn__settings"
style="@style/MwmWidget.MapButton.Green"
android:layout_above="@+id/btn__share"
<TextView
android:id="@+id/tv__download_maps"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/margin_small"
android:text="@string/download_maps"
android:textAllCaps="true"
android:textAppearance="@style/MwmTextAppearance.Body1.Light"/>
<ImageView
android:id="@+id/btn__download_maps"
style="@style/MwmWidget.MapButton.Green"
android:clickable="false"
android:contentDescription="@string/download_maps"
android:duplicateParentState="true"
android:src="@drawable/btn_green_download"/>
</LinearLayout>
<LinearLayout
android:id="@+id/ll__settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/ll__share"
android:layout_alignParentRight="true"
android:src="@drawable/btn_green_settings"/>
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageButton
android:id="@+id/btn__share"
style="@style/MwmWidget.MapButton.Green"
android:layout_above="@+id/btn__search"
<TextView
android:id="@+id/tv__settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/margin_small"
android:text="@string/settings"
android:textAllCaps="true"
android:textAppearance="@style/MwmTextAppearance.Body1.Light"/>
<ImageView
android:id="@+id/btn__settings"
style="@style/MwmWidget.MapButton.Green"
android:clickable="false"
android:contentDescription="@string/settings"
android:duplicateParentState="true"
android:src="@drawable/btn_green_settings"/>
</LinearLayout>
<LinearLayout
android:id="@+id/ll__share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/ll__search"
android:layout_alignParentRight="true"
android:src="@drawable/btn_green_share"/>
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/tv__share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/margin_small"
android:text="@string/share_my_location"
android:textAllCaps="true"
android:textAppearance="@style/MwmTextAppearance.Body1.Light"/>
<ImageView
android:id="@+id/btn__share"
style="@style/MwmWidget.MapButton.Green"
android:clickable="false"
android:contentDescription="@string/share_my_location"
android:src="@drawable/btn_green_share"/>
</LinearLayout>
<LinearLayout
android:id="@+id/ll__search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/tv__search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/margin_small"
android:text="@string/search"
android:textAllCaps="true"
android:textAppearance="@style/MwmTextAppearance.Body1.Light"/>
<ImageView
android:id="@+id/btn__search"
style="@style/MwmWidget.MapButton.Green"
android:clickable="false"
android:contentDescription="@string/search"
android:src="@drawable/btn_green_search"/>
</LinearLayout>
<ImageButton
android:id="@+id/btn__search"
android:id="@+id/btn__open_menu"
style="@style/MwmWidget.MapButton.Green"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:src="@drawable/btn_green_search"/>
android:contentDescription="@string/menu_search"
android:src="@drawable/anim_menu"/>
</RelativeLayout>

View file

@ -17,17 +17,12 @@
android:layout_alignParentRight="true"
android:src="@drawable/ic_btn_yota_ptb"/>
<View
android:id="@+id/anchor_center"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerVertical="true"/>
<ImageButton
android:id="@+id/map_button_plus"
style="@style/MwmWidget.MapButton.White"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_below="@id/anchor_center"
android:layout_marginBottom="250dp"
android:src="@drawable/btn_white_zoom_in"/>
<ImageButton

View file

@ -63,6 +63,10 @@
<item name="android:background">@drawable/bg_btn_white</item>
</style>
<style name="MwmWidget.MapButton.Zoom">
<item name="android:background">@drawable/bg_btn_zoom</item>
</style>
<style name="MwmWidget.MapButton.Green">
<item name="android:background">@drawable/bg_btn_green</item>
</style>
@ -179,6 +183,10 @@
<item name="android:fontFamily">@string/robotoRegular</item>
</style>
<style name="MwmTextAppearance.Body1.Light">
<item name="android:textColor">@color/text_light</item>
</style>
<style name="MwmTextAppearance.Body2">
<item name="android:textSize">@dimen/text_size_body_2</item>
<item name="android:textColor">@color/text_dark_subtitle</item>

View file

@ -8,6 +8,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Point;
import android.graphics.drawable.AnimationDrawable;
import android.location.Location;
import android.os.Build;
import android.os.Bundle;
@ -28,8 +29,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.OvershootInterpolator;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ProgressBar;
@ -64,6 +64,7 @@ import com.mapswithme.maps.settings.SettingsActivity;
import com.mapswithme.maps.settings.StoragePathManager;
import com.mapswithme.maps.settings.StoragePathManager.SetStoragePathListener;
import com.mapswithme.maps.settings.UnitLocale;
import com.mapswithme.maps.widget.FadeView;
import com.mapswithme.maps.widget.placepage.BasePlacePageAnimationController;
import com.mapswithme.maps.widget.placepage.PlacePageView;
import com.mapswithme.maps.widget.placepage.PlacePageView.State;
@ -77,7 +78,9 @@ import com.mapswithme.util.Yota;
import com.mapswithme.util.statistics.AlohaHelper;
import com.mapswithme.util.statistics.Statistics;
import com.nineoldandroids.animation.Animator;
import com.nineoldandroids.animation.AnimatorSet;
import com.nineoldandroids.animation.ObjectAnimator;
import com.nineoldandroids.animation.ValueAnimator;
import com.nineoldandroids.view.ViewHelper;
import java.io.Serializable;
@ -105,13 +108,13 @@ public class MWMActivity extends BaseMwmFragmentActivity
private static final String STATE_ROUTE_FOLLOWED = "RouteFollowed";
private static final String STATE_PP_OPENED = "PpOpened";
private static final String STATE_MAP_OBJECT = "MapObject";
private static final String STATE_MENU_OPENED = "MenuOpened";
private static final String STATE_BUTTONS_OPENED = "ButtonsOpened";
// Map tasks that we run AFTER rendering initialized
private final Stack<MapTask> mTasks = new Stack<>();
private BroadcastReceiver mExternalStorageReceiver;
private StoragePathManager mPathManager = new StoragePathManager();
private AlertDialog mStorageDisconnectedDialog;
private ImageButton mLocationButton;
private ImageButton mBtnLocation;
// map
private MapFragment mMapFragment;
// Place page
@ -135,11 +138,35 @@ public class MWMActivity extends BaseMwmFragmentActivity
// Initialized to invalid combination to force update on the first check
private boolean mStorageAvailable = false;
private boolean mStorageWritable = true;
// toolbars
private static final long VERT_TOOLBAR_ANIM_DURATION = 250;
private static final float FADE_VIEW_ALPHA = 0.5f;
private ViewGroup mBottomToolbar;
private View mFadeView;
// Buttons
private static final long BUTTONS_ANIM_DURATION = 100;
private static final long BUTTON_ANIM_DELAY = 50;
private ViewGroup mBottomButtons;
private ImageView mBtnBookmarks;
private ImageView mBtnSearch;
private ImageView mBtnDownloader;
private ImageView mBtnShare;
private ImageView mBtnSettings;
private ImageButton mBtnMenu;
private View mLlBookmarks;
private View mLlSearch;
private View mLlDownloader;
private View mLlShare;
private View mLlSettings;
private View mTvShare;
private View mTvBookmarks;
private View mTvDownloader;
private View mTvSettings;
private View mTvSearch;
private AnimationDrawable mAnimMenu;
private AnimationDrawable mAnimMenuReversed;
private FadeView mFadeView;
private ViewGroup mNavigationButtons;
private ImageButton mBtnZoomIn;
private ImageButton mBtnZoomOut;
private static final String IS_KML_MOVED = "KmlBeenMoved";
private static final String IS_KITKAT_MIGRATION_COMPLETED = "KitKatMigrationCompleted";
@ -151,7 +178,6 @@ public class MWMActivity extends BaseMwmFragmentActivity
private LocationPredictor mLocationPredictor;
private LikesManager mLikesManager;
public static Intent createShowMapIntent(Context context, Index index, boolean doAutoDownload)
{
return new Intent(context, DownloadResourcesActivity.class)
@ -227,7 +253,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
{
final double lat = Double.parseDouble(intent.getStringExtra(EXTRA_LAT));
final double lon = Double.parseDouble(intent.getStringExtra(EXTRA_LON));
mBottomToolbar.getHandler().postDelayed(new Runnable()
mBottomButtons.getHandler().postDelayed(new Runnable()
{
@Override
public void run()
@ -413,25 +439,6 @@ public class MWMActivity extends BaseMwmFragmentActivity
startActivity(new Intent(this, SearchActivity.class));
}
private void fadeMap(float fromAlpha, final float toAlpha)
{
Animation alphaAnimation = new AlphaAnimation(fromAlpha, toAlpha);
alphaAnimation.setFillBefore(true);
alphaAnimation.setFillAfter(true);
alphaAnimation.setDuration(VERT_TOOLBAR_ANIM_DURATION);
alphaAnimation.setAnimationListener(new UiUtils.SimpleAnimationListener()
{
@Override
public void onAnimationEnd(Animation animation)
{
if (toAlpha == 0)
mFadeView.setVisibility(View.GONE);
}
});
mFadeView.setVisibility(View.VISIBLE);
mFadeView.startAnimation(alphaAnimation);
}
private void shareMyLocation()
{
final Location loc = LocationHelper.INSTANCE.getLastLocation();
@ -481,7 +488,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
transaction.add(R.id.fragment_container, fragment, fragment.getClass().getName());
transaction.addToBackStack(null).commit();
fadeMap(0, FADE_VIEW_ALPHA);
mFadeView.fadeIn();
}
else
{
@ -560,11 +567,11 @@ public class MWMActivity extends BaseMwmFragmentActivity
private void initViews()
{
setupMap();
setupYota();
setupPlacePage();
setupRoutingBox();
setupToolbars();
initMap();
initYota();
initPlacePage();
initRoutingBox();
initNavigationButtons();
if (findViewById(R.id.fragment_container) != null)
{
mIsFragmentContainer = true;
@ -576,9 +583,23 @@ public class MWMActivity extends BaseMwmFragmentActivity
}
}
private void setupMap()
private void initMap()
{
mFadeView = findViewById(R.id.fade_view);
mFadeView = (FadeView) findViewById(R.id.fade_view);
mFadeView.setFadeListener(new FadeView.FadeListener()
{
@Override
public void onFadeOut()
{
toggleMenuButtons();
}
@Override
public void onFadeIn()
{
}
});
mMapFragment = (MapFragment) getSupportFragmentManager().findFragmentByTag(MapFragment.FRAGMENT_TAG);
if (mMapFragment == null)
{
@ -589,22 +610,47 @@ public class MWMActivity extends BaseMwmFragmentActivity
findViewById(R.id.map_fragment_container).setOnTouchListener(this);
}
private void setupToolbars()
@SuppressWarnings("deprecation")
private void initNavigationButtons()
{
mBottomToolbar = (ViewGroup) findViewById(R.id.map_bottom_buttons);
mBottomToolbar.findViewById(R.id.btn__search).setOnClickListener(this);
mBottomToolbar.findViewById(R.id.btn__bookmarks).setOnClickListener(this);
mBottomToolbar.findViewById(R.id.btn__download_maps).setOnClickListener(this);
mBottomToolbar.findViewById(R.id.btn__share).setOnClickListener(this);
mBottomToolbar.findViewById(R.id.btn__settings).setOnClickListener(this);
mBottomButtons = (ViewGroup) findViewById(R.id.map_bottom_buttons);
mBtnBookmarks = (ImageView) mBottomButtons.findViewById(R.id.btn__bookmarks);
mLlBookmarks = mBottomButtons.findViewById(R.id.ll__bookmarks);
mLlBookmarks.setOnClickListener(this);
mTvBookmarks = mBottomButtons.findViewById(R.id.tv__bookmarks);
mBtnSearch = (ImageView) mBottomButtons.findViewById(R.id.btn__search);
mLlSearch = mBottomButtons.findViewById(R.id.ll__search);
mLlSearch.setOnClickListener(this);
mTvSearch = mBottomButtons.findViewById(R.id.tv__search);
mLlDownloader = mBottomButtons.findViewById(R.id.ll__download_maps);
mLlDownloader.setOnClickListener(this);
mBtnDownloader = (ImageView) mBottomButtons.findViewById(R.id.btn__download_maps);
mTvDownloader = mBottomButtons.findViewById(R.id.tv__download_maps);
mBtnShare = (ImageView) mBottomButtons.findViewById(R.id.btn__share);
mLlShare = mBottomButtons.findViewById(R.id.ll__share);
mLlShare.setOnClickListener(this);
mTvShare = mBottomButtons.findViewById(R.id.tv__share);
mBtnSettings = (ImageView) mBottomButtons.findViewById(R.id.btn__settings);
mLlSettings = mBottomButtons.findViewById(R.id.ll__settings);
mLlSettings.setOnClickListener(this);
mTvSettings = mBottomButtons.findViewById(R.id.tv__settings);
findViewById(R.id.map_button_plus).setOnClickListener(this);
findViewById(R.id.map_button_minus).setOnClickListener(this);
mLocationButton = (ImageButton) findViewById(R.id.btn__myposition);
mLocationButton.setOnClickListener(this);
mBtnMenu = (ImageButton) mBottomButtons.findViewById(R.id.btn__open_menu);
mBtnMenu.setOnClickListener(this);
mAnimMenu = (AnimationDrawable) getResources().getDrawable(R.drawable.anim_menu);
mAnimMenuReversed = (AnimationDrawable) getResources().getDrawable(R.drawable.anim_menu_reversed);
hideBottomButtons();
mNavigationButtons = (ViewGroup) findViewById(R.id.navigation_buttons);
mBtnZoomIn = (ImageButton) mNavigationButtons.findViewById(R.id.map_button_plus);
mBtnZoomIn.setOnClickListener(this);
mBtnZoomOut = (ImageButton) mNavigationButtons.findViewById(R.id.map_button_minus);
mBtnZoomOut.setOnClickListener(this);
mBtnLocation = (ImageButton) mNavigationButtons.findViewById(R.id.btn__myposition);
mBtnLocation.setOnClickListener(this);
}
private void setupPlacePage()
private void initPlacePage()
{
mPlacePage = (PlacePageView) findViewById(R.id.info_box);
mPlacePage.setOnVisibilityChangedListener(this);
@ -615,7 +661,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
mPbRoutingProgress = (ProgressBar) mRlStartRouting.findViewById(R.id.pb__routing_progress);
}
private void setupRoutingBox()
private void initRoutingBox()
{
mRlRoutingBox = (RelativeLayout) findViewById(R.id.rl__routing_box);
mRlRoutingBox.setVisibility(View.GONE);
@ -632,7 +678,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
mRlTurnByTurnBox.findViewById(R.id.btn__close).setOnClickListener(this);
}
private void setupYota()
private void initYota()
{
final View yopmeButton = findViewById(R.id.yop_it);
if (Yota.isFirstYota())
@ -659,8 +705,8 @@ public class MWMActivity extends BaseMwmFragmentActivity
outState.putBoolean(STATE_PP_OPENED, true);
outState.putParcelable(STATE_MAP_OBJECT, mPlacePage.getMapObject());
}
// else if (mVerticalToolbar.getVisibility() == View.VISIBLE)
// outState.putBoolean(STATE_MENU_OPENED, true);
else if (mBottomButtons.getVisibility() == View.VISIBLE)
outState.putBoolean(STATE_BUTTONS_OPENED, true);
super.onSaveInstanceState(outState);
}
@ -673,18 +719,30 @@ public class MWMActivity extends BaseMwmFragmentActivity
mPlacePage.setMapObject((MapObject) savedInstanceState.getParcelable(STATE_MAP_OBJECT));
mPlacePage.setState(State.PREVIEW);
}
// else if (savedInstanceState.getBoolean(STATE_MENU_OPENED))
// setVerticalToolbarVisible(true);
if (savedInstanceState.getBoolean(STATE_BUTTONS_OPENED))
showBottomButtons();
else
hideBottomButtons();
super.onRestoreInstanceState(savedInstanceState);
}
private void showBottomButtons()
{
UiUtils.show(mLlBookmarks, mLlDownloader, mLlSettings, mLlShare, mLlSearch);
}
private void hideBottomButtons()
{
UiUtils.hide(mLlBookmarks, mLlDownloader, mLlSettings, mLlShare, mLlSearch);
}
@Override
protected void onNewIntent(Intent intent)
{
super.onNewIntent(intent);
fadeMap(0, 0);
if (intent != null)
{
if (intent.hasExtra(EXTRA_TASK))
@ -894,7 +952,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
private void refreshLocationState(int newMode)
{
LocationButtonImageSetter.setButtonViewFromState(newMode, mLocationButton);
LocationButtonImageSetter.setButtonViewFromState(newMode, mBtnLocation);
switch (newMode)
{
case LocationState.UNKNOWN_POSITION:
@ -1037,15 +1095,15 @@ public class MWMActivity extends BaseMwmFragmentActivity
hidePlacePage();
Framework.deactivatePopup();
}
// else if (mVerticalToolbar.getVisibility() == View.VISIBLE)
// setVerticalToolbarVisible(false);
else if (mBtnMenu.getVisibility() == View.GONE)
slideSlideButtonsOut();
else if (canFragmentInterceptBackPress())
// TODO
return;
else if (popFragment())
{
InputUtils.hideKeyboard(mBottomToolbar);
if (isMapFaded())
fadeMap(FADE_VIEW_ALPHA, 0.0f);
InputUtils.hideKeyboard(mBottomButtons);
mFadeView.fadeOut();
}
else
super.onBackPressed();
@ -1188,7 +1246,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
mIvStartRouting.setVisibility(View.VISIBLE);
mPbRoutingProgress.setVisibility(View.GONE);
if (popFragment() && isMapFaded())
fadeMap(FADE_VIEW_ALPHA, 0);
mFadeView.fadeOut();
}
}
@ -1224,15 +1282,59 @@ public class MWMActivity extends BaseMwmFragmentActivity
mPlacePage.setMapObject(null);
}
if (previewIntersectsBottomMenu())
mBottomToolbar.setVisibility(isVisible ? View.GONE : View.VISIBLE);
mBottomButtons.setVisibility(isVisible ? View.GONE : View.VISIBLE);
if (previewIntersectsZoomButtons())
showNavigationButtons(isVisible);
{
// TODO hide zoom buttons?
}
}
private void showNavigationButtons(boolean isVisible)
private void slideBottomButtonsIn()
{
// TODO toggle zoom buttons and location. with animation.
// mNavigationButtons.setVisibility(isVisible ? View.GONE : View.VISIBLE);
final AnimatorSet animatorSet = new AnimatorSet();
mLlSearch.setVisibility(View.VISIBLE);
animatorSet.play(generateMenuAnimator(mLlShare, mBtnShare, mTvShare, mBtnShare.getWidth()));
animatorSet.play(generateMenuAnimator(mLlSettings, mBtnSettings, mTvSettings, mBtnSettings.getWidth())).after(BUTTON_ANIM_DELAY);
animatorSet.play(generateMenuAnimator(mLlDownloader, mBtnDownloader, mTvDownloader, mBtnDownloader.getWidth())).after(BUTTON_ANIM_DELAY * 2);
animatorSet.play(generateMenuAnimator(mLlBookmarks, mBtnBookmarks, mTvBookmarks, mBtnBookmarks.getWidth())).after(BUTTON_ANIM_DELAY * 3);
animatorSet.addListener(new UiUtils.SimpleNineoldAnimationListener()
{
@Override
public void onAnimationEnd(Animator animation)
{
mBtnMenu.setVisibility(View.GONE);
}
});
animatorSet.start();
}
private void slideSlideButtonsOut()
{
mBtnMenu.setVisibility(View.VISIBLE);
mBtnMenu.bringToFront();
hideBottomButtons();
}
private Animator generateMenuAnimator(@NonNull final View layout, @NonNull final View button, @NonNull final View textView, final float width)
{
ValueAnimator animator = ObjectAnimator.ofFloat(button, "translationX", width, 0);
animator.addListener(new UiUtils.SimpleNineoldAnimationListener()
{
@Override
public void onAnimationStart(Animator animation)
{
layout.setVisibility(View.VISIBLE);
textView.setAlpha(0);
}
});
animator.setInterpolator(new OvershootInterpolator());
animator.setDuration(BUTTONS_ANIM_DURATION);
final AnimatorSet result = new AnimatorSet();
result.play(animator);
animator = ObjectAnimator.ofFloat(textView, "alpha", 0, 1);
result.play(animator).after(BUTTONS_ANIM_DURATION / 2);
return result;
}
private boolean previewIntersectsBottomMenu()
@ -1250,7 +1352,9 @@ public class MWMActivity extends BaseMwmFragmentActivity
{
AlohaHelper.logClick(AlohaHelper.PP_OPEN);
if (placePageIntersectsZoomButtons())
showNavigationButtons(isVisible);
{
// TODO hide zoom buttons?
}
}
private boolean placePageIntersectsZoomButtons()
@ -1263,15 +1367,18 @@ public class MWMActivity extends BaseMwmFragmentActivity
{
switch (v.getId())
{
case R.id.btn_share:
case R.id.btn__share:
case R.id.ll__share:
AlohaHelper.logClick(AlohaHelper.MENU_SHARE);
shareMyLocation();
break;
case R.id.btn_settings:
case R.id.btn__settings:
case R.id.ll__settings:
AlohaHelper.logClick(AlohaHelper.MENU_SETTINGS);
startActivity(new Intent(this, SettingsActivity.class));
break;
case R.id.btn_download_maps:
case R.id.btn__download_maps:
case R.id.ll__download_maps:
AlohaHelper.logClick(AlohaHelper.MENU_DOWNLOADER);
showDownloader(false);
break;
@ -1299,14 +1406,18 @@ public class MWMActivity extends BaseMwmFragmentActivity
AlohaHelper.logClick(AlohaHelper.ZOOM_OUT);
mMapFragment.nativeScale(2 / 3.0);
break;
case R.id.btn__more:
case R.id.btn__open_menu:
AlohaHelper.logClick(AlohaHelper.TOOLBAR_MENU);
mFadeView.fadeIn();
toggleMenuButtons();
break;
case R.id.btn__search:
case R.id.ll__search:
AlohaHelper.logClick(AlohaHelper.TOOLBAR_SEARCH);
showSearchIfUpdated();
break;
case R.id.btn__bookmarks:
case R.id.ll__bookmarks:
AlohaHelper.logClick(AlohaHelper.TOOLBAR_BOOKMARKS);
showBookmarks();
break;
@ -1331,6 +1442,22 @@ public class MWMActivity extends BaseMwmFragmentActivity
}
}
private void toggleMenuButtons()
{
if (mLlSearch.getVisibility() == View.GONE)
{
mBtnMenu.setImageDrawable(mAnimMenu);
mAnimMenu.start();
slideBottomButtonsIn();
}
else
{
mBtnMenu.setImageDrawable(mAnimMenuReversed);
mAnimMenuReversed.start();
slideSlideButtonsOut();
}
}
private void followRoute()
{
Framework.nativeFollowRoute();
@ -1417,20 +1544,14 @@ public class MWMActivity extends BaseMwmFragmentActivity
public boolean onTouch(View view, MotionEvent event)
{
boolean result = false;
// if vertical toolbar is visible - hide it and ignore touch
// if (mVerticalToolbar.getVisibility() == View.VISIBLE)
// {
// setVerticalToolbarVisible(false);
// result = true;
// }
if (mPlacePage.getState() == State.DETAILS || mPlacePage.getState() == State.BOOKMARK)
{
Framework.deactivatePopup();
hidePlacePage();
result = true;
}
result |= mMapFragment.onTouch(view, event);
return result;
return result || mMapFragment.onTouch(view, event);
}
@Override
@ -1479,7 +1600,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
mLayoutRoutingGo.setVisibility(View.VISIBLE);
Animator animator = ObjectAnimator.ofFloat(mRlRoutingBox, "alpha", 0, 1);
animator.setDuration(VERT_TOOLBAR_ANIM_DURATION);
animator.setDuration(BUTTONS_ANIM_DURATION);
animator.start();
mRlRoutingBox.setVisibility(View.VISIBLE);

View file

@ -0,0 +1,109 @@
package com.mapswithme.maps.widget;
import android.content.Context;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import com.mapswithme.util.UiUtils;
import com.nineoldandroids.animation.Animator;
import com.nineoldandroids.animation.ObjectAnimator;
public class FadeView extends FrameLayout
{
private static final float ALPHA_VALUE = 0.5f;
private static final String PROPERTY_ALPHA = "alpha";
private ObjectAnimator mFadeInAnimation;
private ObjectAnimator mFadeOutAnimation;
private Animator.AnimatorListener mFadeOutListener = new UiUtils.SimpleNineoldAnimationListener()
{
@Override
public void onAnimationEnd(Animator animation)
{
setVisibility(View.GONE);
if (mFadeListener != null)
mFadeListener.onFadeOut();
}
};
private Animator.AnimatorListener mFadeInListener = new UiUtils.SimpleNineoldAnimationListener()
{
@Override
public void onAnimationEnd(Animator animation)
{
if (mFadeListener != null)
mFadeListener.onFadeIn();
}
};
public interface FadeListener
{
void onFadeOut();
void onFadeIn();
}
private FadeListener mFadeListener;
public FadeView(Context context)
{
super(context);
}
public FadeView(Context context, AttributeSet attrs)
{
super(context, attrs);
}
public FadeView(Context context, AttributeSet attrs, int defStyleAttr)
{
super(context, attrs, defStyleAttr);
}
public FadeView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
{
super(context, attrs, defStyleAttr, defStyleRes);
}
public void setFadeListener(FadeListener listener)
{
mFadeListener = listener;
}
public void fadeIn()
{
setVisibility(View.VISIBLE);
mFadeInAnimation = ObjectAnimator.ofFloat(this, PROPERTY_ALPHA, 0f, ALPHA_VALUE);
mFadeInAnimation.addListener(mFadeInListener);
mFadeInAnimation.start();
}
public void fadeOut()
{
mFadeOutAnimation = ObjectAnimator.ofFloat(this, PROPERTY_ALPHA, ALPHA_VALUE, 0f);
mFadeOutAnimation.addListener(mFadeOutListener);
mFadeOutAnimation.start();
}
public boolean isFadingIn()
{
return mFadeInAnimation != null && mFadeInAnimation.isRunning();
}
public boolean isFadingOut()
{
return mFadeOutAnimation != null && mFadeOutAnimation.isRunning();
}
@Override
public boolean onTouchEvent(@NonNull MotionEvent event)
{
if (event.getAction() == MotionEvent.ACTION_DOWN)
fadeOut();
return true;
}
}