forked from organicmaps/organicmaps
[android] Added fullscreen mode.
This commit is contained in:
parent
223179a1ef
commit
3b2072dff2
12 changed files with 225 additions and 78 deletions
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<translate android:fromYDelta="-100%"
|
||||
android:toYDelta="0%"
|
||||
android:duration="@integer/anim_default"/>
|
||||
|
||||
<alpha android:fromAlpha="0.1"
|
||||
android:toAlpha="1"
|
||||
android:duration="@integer/anim_default"/>
|
||||
</set>
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<translate android:fromYDelta="0%"
|
||||
android:toYDelta="-100%"
|
||||
android:duration="@integer/anim_default"/>
|
||||
|
||||
<alpha android:fromAlpha="1"
|
||||
android:toAlpha="0.1"
|
||||
android:duration="@integer/anim_default"/>
|
||||
</set>
|
|
@ -45,6 +45,7 @@ public class MapFragment extends BaseMwmFragment
|
|||
private static final int INVALID_TOUCH_ID = -1;
|
||||
|
||||
private int mHeight;
|
||||
private int mWidth;
|
||||
private boolean mRequireResize;
|
||||
private boolean mEngineCreated;
|
||||
|
||||
|
@ -58,14 +59,15 @@ public class MapFragment extends BaseMwmFragment
|
|||
private void setupWidgets(int width, int height)
|
||||
{
|
||||
mHeight = height;
|
||||
mWidth = width;
|
||||
|
||||
nativeSetupWidget(WIDGET_RULER,
|
||||
width - UiUtils.dimen(R.dimen.margin_ruler_right),
|
||||
mWidth - UiUtils.dimen(R.dimen.margin_ruler_right),
|
||||
mHeight - UiUtils.dimen(R.dimen.margin_ruler_bottom),
|
||||
ANCHOR_RIGHT_BOTTOM);
|
||||
|
||||
nativeSetupWidget(WIDGET_COPYRIGHT,
|
||||
width / 2,
|
||||
mWidth / 2,
|
||||
UiUtils.dimen(R.dimen.margin_base),
|
||||
ANCHOR_TOP);
|
||||
|
||||
|
@ -77,19 +79,29 @@ public class MapFragment extends BaseMwmFragment
|
|||
ANCHOR_LEFT_TOP);
|
||||
}
|
||||
|
||||
setupCompass(0, false);
|
||||
setupCompass(0, 0, false);
|
||||
}
|
||||
|
||||
void setupCompass(int offset, boolean forceRedraw)
|
||||
void setupCompass(int offsetX, int offsetY, boolean forceRedraw)
|
||||
{
|
||||
nativeSetupWidget(WIDGET_COMPASS,
|
||||
UiUtils.dimen(R.dimen.margin_compass_left) + offset,
|
||||
mHeight - UiUtils.dimen(R.dimen.margin_compass_bottom),
|
||||
UiUtils.dimen(R.dimen.margin_compass_left) + offsetX,
|
||||
mHeight - UiUtils.dimen(R.dimen.margin_compass_bottom) + offsetY,
|
||||
ANCHOR_CENTER);
|
||||
if (forceRedraw)
|
||||
nativeApplyWidgets();
|
||||
}
|
||||
|
||||
void setupRuler(int offsetX, int offsetY, boolean forceRedraw)
|
||||
{
|
||||
nativeSetupWidget(WIDGET_RULER,
|
||||
mWidth - UiUtils.dimen(R.dimen.margin_ruler_right) + offsetX,
|
||||
mHeight - UiUtils.dimen(R.dimen.margin_ruler_bottom) + offsetY,
|
||||
ANCHOR_RIGHT_BOTTOM);
|
||||
if (forceRedraw)
|
||||
nativeApplyWidgets();
|
||||
}
|
||||
|
||||
private void onRenderingInitialized()
|
||||
{
|
||||
final Activity activity = getActivity();
|
||||
|
|
|
@ -121,6 +121,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
private ImageButton mBtnZoomOut;
|
||||
|
||||
private boolean mIsFragmentContainer;
|
||||
private boolean mIsFullscreen;
|
||||
|
||||
private LocationPredictor mLocationPredictor;
|
||||
private FloatingSearchToolbarController mSearchController;
|
||||
|
@ -833,14 +834,14 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
|
||||
switch (newMode)
|
||||
{
|
||||
case LocationState.UNKNOWN_POSITION:
|
||||
pauseLocation();
|
||||
break;
|
||||
case LocationState.PENDING_POSITION:
|
||||
resumeLocation();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case LocationState.UNKNOWN_POSITION:
|
||||
pauseLocation();
|
||||
break;
|
||||
case LocationState.PENDING_POSITION:
|
||||
resumeLocation();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1007,6 +1008,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
|
||||
private void activateMapObject(MapObject object)
|
||||
{
|
||||
setFullscreen(false);
|
||||
if (!mPlacePage.hasMapObject(object))
|
||||
{
|
||||
mPlacePage.setMapObject(object);
|
||||
|
@ -1022,6 +1024,48 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
{
|
||||
if (!mPlacePage.hasMapObject(null))
|
||||
mPlacePage.hide();
|
||||
else
|
||||
{
|
||||
if ((mPanelAnimator != null && mPanelAnimator.isVisible()) ||
|
||||
UiUtils.isVisible(mSearchController.getToolbar()))
|
||||
return;
|
||||
|
||||
setFullscreen(!mIsFullscreen);
|
||||
}
|
||||
}
|
||||
|
||||
private void setFullscreen(boolean isFullscreen)
|
||||
{
|
||||
mIsFullscreen = isFullscreen;
|
||||
if (isFullscreen)
|
||||
{
|
||||
Animations.disappearSliding(mMainMenu.getFrame(), Animations.BOTTOM, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final int menuHeight = mMainMenu.getFrame().getHeight();
|
||||
adjustCompass(0, menuHeight);
|
||||
adjustRuler(0, menuHeight);
|
||||
}
|
||||
});
|
||||
Animations.disappearSliding(mBtnZoomOut, Animations.RIGHT, null);
|
||||
Animations.disappearSliding(mBtnZoomIn, Animations.RIGHT, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
Animations.appearSliding(mMainMenu.getFrame(), Animations.BOTTOM, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
adjustCompass(0, 0);
|
||||
adjustRuler(0, 0);
|
||||
}
|
||||
});
|
||||
Animations.appearSliding(mBtnZoomOut, Animations.RIGHT, null);
|
||||
Animations.appearSliding(mBtnZoomIn, Animations.RIGHT, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1121,29 +1165,31 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
public boolean run(MwmActivity target)
|
||||
{
|
||||
if (mDoAutoDownload)
|
||||
{
|
||||
Framework.downloadCountry(mIndex);
|
||||
// set zoom level so that download process is visible
|
||||
Framework.nativeShowCountry(mIndex, true);
|
||||
}
|
||||
else
|
||||
Framework.nativeShowCountry(mIndex, false);
|
||||
|
||||
Framework.nativeShowCountry(mIndex, mDoAutoDownload);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void adjustCompass(int offset)
|
||||
public void adjustCompass(int offsetX, int offsetY)
|
||||
{
|
||||
if (mMapFragment == null || !mMapFragment.isAdded())
|
||||
return;
|
||||
|
||||
mMapFragment.setupCompass(mPanelAnimator.isVisible() ? offset : 0, true /* forceRedraw */);
|
||||
mMapFragment.setupCompass((mPanelAnimator != null && mPanelAnimator.isVisible()) ? offsetX : 0, offsetY, true);
|
||||
|
||||
if (mLastCompassData != null)
|
||||
MapFragment.nativeCompassUpdated(mLastCompassData.magneticNorth, mLastCompassData.trueNorth, true);
|
||||
}
|
||||
|
||||
public void adjustRuler(int offsetX, int offsetY)
|
||||
{
|
||||
if (mMapFragment == null || !mMapFragment.isAdded())
|
||||
return;
|
||||
|
||||
mMapFragment.setupRuler(offsetX, offsetY, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCategoryChanged(int bookmarkId, int newCategoryId)
|
||||
{
|
||||
|
|
|
@ -82,7 +82,7 @@ class PanelAnimator
|
|||
public void onAnimationEnd(Animator animation)
|
||||
{
|
||||
mAnimationTrackListener.onTrackFinished(true);
|
||||
mActivity.adjustCompass(WIDTH);
|
||||
mActivity.adjustCompass(WIDTH, 0);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -118,7 +118,7 @@ class PanelAnimator
|
|||
{
|
||||
UiUtils.hide(mPanel);
|
||||
mAnimationTrackListener.onTrackFinished(false);
|
||||
mActivity.adjustCompass(0);
|
||||
mActivity.adjustCompass(0, 0);
|
||||
|
||||
if (completionListener != null)
|
||||
completionListener.run();
|
||||
|
|
|
@ -5,7 +5,7 @@ import android.text.TextUtils;
|
|||
import com.mapswithme.maps.MwmActivity;
|
||||
import com.mapswithme.maps.api.ParsedMwmRequest;
|
||||
import com.mapswithme.maps.widget.SearchToolbarController;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.Animations;
|
||||
|
||||
public class FloatingSearchToolbarController extends SearchToolbarController
|
||||
{
|
||||
|
@ -42,12 +42,12 @@ public class FloatingSearchToolbarController extends SearchToolbarController
|
|||
|
||||
if (ParsedMwmRequest.hasRequest())
|
||||
{
|
||||
UiUtils.appearSlidingDown(mToolbar, null);
|
||||
Animations.appearSliding(mToolbar, Animations.TOP, null);
|
||||
setQuery(ParsedMwmRequest.getCurrentRequest().getTitle());
|
||||
}
|
||||
else if (!TextUtils.isEmpty(SearchEngine.getQuery()))
|
||||
{
|
||||
UiUtils.appearSlidingDown(mToolbar, null);
|
||||
Animations.appearSliding(mToolbar, Animations.TOP, null);
|
||||
setQuery(SearchEngine.getQuery());
|
||||
}
|
||||
else
|
||||
|
@ -73,7 +73,7 @@ public class FloatingSearchToolbarController extends SearchToolbarController
|
|||
if (!UiUtils.isVisible(mToolbar))
|
||||
return false;
|
||||
|
||||
UiUtils.disappearSlidingUp(mToolbar, null);
|
||||
Animations.disappearSliding(mToolbar, Animations.TOP, null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public class WebViewShadowController extends BaseShadowController<ObservableWebV
|
|||
return (mList.getScrollY() > 0);
|
||||
|
||||
case BOTTOM:
|
||||
return (mList.getScrollY() + mList.getHeight() < UiUtils.dp(mList.getContentHeight() - 1));
|
||||
return (mList.getScrollY() + mList.getHeight() < UiUtils.toPx(mList.getContentHeight() - 1));
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid shadow id: " + id);
|
||||
|
|
|
@ -103,8 +103,8 @@ class PlacePageBottomAnimationController extends BasePlacePageAnimationControlle
|
|||
{
|
||||
mGestureDetector = new GestureDetectorCompat(mPlacePage.getContext(), new GestureDetector.SimpleOnGestureListener()
|
||||
{
|
||||
private final int Y_MIN = UiUtils.dp(10);
|
||||
private final int Y_MAX = UiUtils.dp(50);
|
||||
private final int Y_MIN = UiUtils.toPx(10);
|
||||
private final int Y_MAX = UiUtils.toPx(50);
|
||||
private static final int X_TO_Y_SCROLL_RATIO = 2;
|
||||
|
||||
@Override
|
||||
|
|
|
@ -61,8 +61,8 @@ class PlacePageLeftAnimationController extends BasePlacePageAnimationController
|
|||
{
|
||||
mGestureDetector = new GestureDetectorCompat(mPlacePage.getContext(), new GestureDetector.SimpleOnGestureListener()
|
||||
{
|
||||
private final int X_MIN = UiUtils.dp(30);
|
||||
private final int X_MAX = UiUtils.dp(100);
|
||||
private final int X_MIN = UiUtils.toPx(30);
|
||||
private final int X_MAX = UiUtils.toPx(100);
|
||||
private static final int X_TO_Y_SCROLL_RATIO = 2;
|
||||
|
||||
@Override
|
||||
|
|
112
android/src/com/mapswithme/util/Animations.java
Normal file
112
android/src/com/mapswithme/util/Animations.java
Normal file
|
@ -0,0 +1,112 @@
|
|||
package com.mapswithme.util;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.support.annotation.IntDef;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.View;
|
||||
import android.view.ViewPropertyAnimator;
|
||||
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
public final class Animations
|
||||
{
|
||||
private Animations() {}
|
||||
|
||||
@IntDef({LEFT, RIGHT, TOP, BOTTOM})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface AnimationDirection {}
|
||||
public static final int LEFT = 0;
|
||||
public static final int RIGHT = 1;
|
||||
public static final int TOP = 2;
|
||||
public static final int BOTTOM = 3;
|
||||
|
||||
private static final int DURATION_DEFAULT = MwmApplication.get().getResources().getInteger(R.integer.anim_default);
|
||||
|
||||
public static void appearSliding(final View view, @AnimationDirection int appearFrom, @Nullable final Runnable completionListener)
|
||||
{
|
||||
if (UiUtils.isVisible(view))
|
||||
{
|
||||
if (completionListener != null)
|
||||
completionListener.run();
|
||||
return;
|
||||
}
|
||||
|
||||
final ViewPropertyAnimator animator = view.animate().setDuration(DURATION_DEFAULT).alpha(1).setListener(new UiUtils.SimpleAnimatorListener()
|
||||
{
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation)
|
||||
{
|
||||
if (completionListener != null)
|
||||
completionListener.run();
|
||||
}
|
||||
});
|
||||
|
||||
switch (appearFrom)
|
||||
{
|
||||
case LEFT:
|
||||
case RIGHT:
|
||||
animator.translationX(0);
|
||||
break;
|
||||
case TOP:
|
||||
case BOTTOM:
|
||||
animator.translationY(0);
|
||||
break;
|
||||
}
|
||||
|
||||
UiUtils.show(view);
|
||||
}
|
||||
|
||||
public static void disappearSliding(final View view, @AnimationDirection int disappearTo, @Nullable final Runnable completionListener)
|
||||
{
|
||||
if (!UiUtils.isVisible(view))
|
||||
{
|
||||
if (completionListener != null)
|
||||
completionListener.run();
|
||||
return;
|
||||
}
|
||||
|
||||
final ViewPropertyAnimator animator = view.animate().setDuration(DURATION_DEFAULT).alpha(0).setListener(new UiUtils.SimpleAnimatorListener()
|
||||
{
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation)
|
||||
{
|
||||
UiUtils.hide(view);
|
||||
if (completionListener != null)
|
||||
completionListener.run();
|
||||
}
|
||||
});
|
||||
|
||||
switch (disappearTo)
|
||||
{
|
||||
case RIGHT:
|
||||
animator.translationX(view.getWidth());
|
||||
break;
|
||||
case LEFT:
|
||||
animator.translationX(-view.getWidth());
|
||||
break;
|
||||
case BOTTOM:
|
||||
animator.translationY(view.getHeight());
|
||||
break;
|
||||
case TOP:
|
||||
animator.translationY(-view.getHeight());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void exchangeViews(final View viewToHide, final @AnimationDirection int disappearTo,
|
||||
final View viewToShow, final @AnimationDirection int appearFrom, @Nullable final Runnable completionListener)
|
||||
{
|
||||
disappearSliding(viewToHide, disappearTo, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
appearSliding(viewToShow, appearFrom, completionListener);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -10,7 +10,6 @@ import android.provider.Settings;
|
|||
import android.support.annotation.DimenRes;
|
||||
import android.support.annotation.IdRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.TextUtils;
|
||||
|
@ -19,7 +18,6 @@ import android.view.View;
|
|||
import android.view.ViewTreeObserver;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.Animation.AnimationListener;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
|
@ -29,7 +27,6 @@ public final class UiUtils
|
|||
{
|
||||
private static float sScreenDensity;
|
||||
|
||||
|
||||
public static class SimpleAnimationListener implements AnimationListener
|
||||
{
|
||||
@Override
|
||||
|
@ -385,12 +382,12 @@ public final class UiUtils
|
|||
return MwmApplication.get().getResources().getDimensionPixelSize(id);
|
||||
}
|
||||
|
||||
public static int dp(int v)
|
||||
public static int toPx(int dp)
|
||||
{
|
||||
if (sScreenDensity == 0)
|
||||
sScreenDensity = MwmApplication.get().getResources().getDisplayMetrics().density;
|
||||
|
||||
return (int) (v * sScreenDensity + 0.5);
|
||||
return (int) (dp * sScreenDensity + 0.5);
|
||||
}
|
||||
|
||||
// utility class
|
||||
|
|
|
@ -1559,26 +1559,26 @@ PoiMarkPoint * Framework::GetAddressMark(m2::PointD const & globalPoint) const
|
|||
|
||||
void Framework::ActivateUserMark(UserMark const * mark, bool needAnim)
|
||||
{
|
||||
if (m_activateUserMarkFn)
|
||||
{
|
||||
if (mark)
|
||||
{
|
||||
m_activateUserMarkFn(mark->Copy());
|
||||
m2::PointD pt = mark->GetPivot();
|
||||
df::SelectionShape::ESelectedObject object = df::SelectionShape::OBJECT_USER_MARK;
|
||||
UserMark::Type type = mark->GetMarkType();
|
||||
if (type == UserMark::Type::MY_POSITION)
|
||||
object = df::SelectionShape::OBJECT_MY_POSITION;
|
||||
else if (type == UserMark::Type::POI)
|
||||
object = df::SelectionShape::OBJECT_POI;
|
||||
if (!m_activateUserMarkFn)
|
||||
return;
|
||||
|
||||
CallDrapeFunction(bind(&df::DrapeEngine::SelectObject, _1, object, pt, needAnim));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_activateUserMarkFn(nullptr);
|
||||
CallDrapeFunction(bind(&df::DrapeEngine::DeselectObject, _1));
|
||||
}
|
||||
if (mark)
|
||||
{
|
||||
m_activateUserMarkFn(mark->Copy());
|
||||
m2::PointD pt = mark->GetPivot();
|
||||
df::SelectionShape::ESelectedObject object = df::SelectionShape::OBJECT_USER_MARK;
|
||||
UserMark::Type type = mark->GetMarkType();
|
||||
if (type == UserMark::Type::MY_POSITION)
|
||||
object = df::SelectionShape::OBJECT_MY_POSITION;
|
||||
else if (type == UserMark::Type::POI)
|
||||
object = df::SelectionShape::OBJECT_POI;
|
||||
|
||||
CallDrapeFunction(bind(&df::DrapeEngine::SelectObject, _1, object, pt, needAnim));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_activateUserMarkFn(nullptr);
|
||||
CallDrapeFunction(bind(&df::DrapeEngine::DeselectObject, _1));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue