Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksandr Zatsepin <alexzatsepin@users.noreply.github.com>2017-06-19 14:15:38 +0300
committerGitHub <noreply@github.com>2017-06-19 14:15:38 +0300
commit285cefb96a6e087b9c244bcfd527dd3a7e9bd5ac (patch)
tree5b1a2b6484ddcf44cff179a0dba196450f7561ee
parent2c7d7354d99080aa790fe84db42975bddf3181b6 (diff)
parent315444c543fd4f8d39d0f433c15651b73360fb68 (diff)
Merge pull request #6246 from goblinr/MAPSME-4690-p2p-bookmark-buttonbeta-873beta-872
[android] Added bookmark button on map
-rw-r--r--android/res/layout-land/layout_nav_search.xml19
-rw-r--r--android/res/layout/layout_nav_search.xml22
-rw-r--r--android/src/com/mapswithme/maps/MwmActivity.java46
-rw-r--r--android/src/com/mapswithme/maps/NavigationButtonsAnimationController.java23
-rw-r--r--android/src/com/mapswithme/maps/routing/NavigationController.java59
-rw-r--r--android/src/com/mapswithme/maps/routing/RoutingController.java40
-rw-r--r--android/src/com/mapswithme/maps/routing/RoutingPlanController.java4
-rw-r--r--android/src/com/mapswithme/maps/routing/SearchWheel.java6
-rw-r--r--android/src/com/mapswithme/maps/search/SearchAdapter.java2
-rw-r--r--android/src/com/mapswithme/maps/search/SearchFragment.java19
10 files changed, 187 insertions, 53 deletions
diff --git a/android/res/layout-land/layout_nav_search.xml b/android/res/layout-land/layout_nav_search.xml
index 9b0283c55b..52ddd12577 100644
--- a/android/res/layout-land/layout_nav_search.xml
+++ b/android/res/layout-land/layout_nav_search.xml
@@ -60,8 +60,8 @@
<ImageButton
android:id="@+id/btn_search"
style="@style/MwmWidget.SearchNavigationButton"
- android:layout_width="64dp"
- android:layout_height="64dp"
+ android:layout_width="@dimen/margin_quadruple"
+ android:layout_height="@dimen/margin_quadruple"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
@@ -69,4 +69,19 @@
android:background="?nav_background"
android:src="@drawable/ic_menu_search"
android:tint="@null"/>
+
+ <ImageButton
+ android:id="@+id/btn_bookmarks"
+ style="@style/MwmWidget.SearchNavigationButton"
+ android:layout_width="@dimen/margin_quadruple"
+ android:layout_height="@dimen/margin_quadruple"
+ android:layout_marginStart="@dimen/margin_eighth"
+ android:layout_marginLeft="@dimen/margin_eighth"
+ android:layout_above="@id/btn_search"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true"
+ android:background="?nav_background"
+ android:src="@drawable/ic_menu_bookmarks"
+ android:tint="@null"/>
+
</RelativeLayout>
diff --git a/android/res/layout/layout_nav_search.xml b/android/res/layout/layout_nav_search.xml
index dafc48f3f4..68c34c5800 100644
--- a/android/res/layout/layout_nav_search.xml
+++ b/android/res/layout/layout_nav_search.xml
@@ -21,6 +21,20 @@
android:layout_height="match_parent"
android:visibility="gone"/>
+ <ImageButton
+ android:id="@+id/btn_bookmarks"
+ style="@style/MwmWidget.SearchNavigationButton"
+ android:layout_width="@dimen/margin_quadruple"
+ android:layout_height="@dimen/margin_quadruple"
+ android:layout_marginTop="@dimen/nav_zoom_top"
+ android:layout_marginStart="@dimen/margin_eighth"
+ android:layout_marginLeft="@dimen/margin_eighth"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true"
+ android:background="?nav_background"
+ android:src="@drawable/ic_menu_bookmarks"
+ android:tint="@null"/>
+
<RelativeLayout
android:id="@+id/search_frame"
android:layout_width="200dp"
@@ -28,7 +42,7 @@
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="-68dp"
- android:layout_below="@id/anchor_center"
+ android:layout_below="@id/btn_bookmarks"
android:layout_marginLeft="-70dp"
android:layout_marginStart="-70dp"
android:background="?searchLayoutBackground"
@@ -87,11 +101,11 @@
<ImageButton
android:id="@+id/btn_search"
style="@style/MwmWidget.SearchNavigationButton"
- android:layout_width="64dp"
- android:layout_height="64dp"
+ android:layout_width="@dimen/margin_quadruple"
+ android:layout_height="@dimen/margin_quadruple"
android:layout_marginStart="@dimen/margin_eighth"
android:layout_marginLeft="@dimen/margin_eighth"
- android:layout_below="@id/anchor_center"
+ android:layout_below="@id/btn_bookmarks"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="?nav_background"
diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java
index f3e7e731ce..5675ce516b 100644
--- a/android/src/com/mapswithme/maps/MwmActivity.java
+++ b/android/src/com/mapswithme/maps/MwmActivity.java
@@ -118,7 +118,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
RoutingPlanController.OnToggleListener,
RoutingPlanController.SearchPoiTransitionListener,
FloatingSearchToolbarController.VisibilityListener,
- NativeSearchListener
+ NativeSearchListener, NavigationButtonsAnimationController.OnTranslationChangedListener
{
public static final String EXTRA_TASK = "map_task";
private static final String EXTRA_CONSUMED = "mwm.extra.intent.processed";
@@ -674,7 +674,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
mTraffic = new TrafficButton(this, traffic);
mTrafficButtonController = new TrafficButtonController(mTraffic, this);
mNavAnimationController = new NavigationButtonsAnimationController(
- zoomIn, zoomOut, myPosition, getWindow().getDecorView().getRootView());
+ zoomIn, zoomOut, myPosition, getWindow().getDecorView().getRootView(), this);
}
public boolean closePlacePage()
@@ -1564,6 +1564,12 @@ public class MwmActivity extends BaseMwmFragmentActivity
@Override
public void run()
{
+ if (mNavigationController != null)
+ {
+ mNavigationController.showSearchButtons(RoutingController.get().isPlanning()
+ || RoutingController.get().isBuilt());
+ }
+
if (RoutingController.get().isNavigating())
{
if (mNavigationController != null)
@@ -1605,7 +1611,11 @@ public class MwmActivity extends BaseMwmFragmentActivity
if (controller.isPlanning() || controller.isBuilding() || controller.isErrorEncountered())
{
if (showAddStartOrFinishFrame(controller, true))
+ {
+ if (completion != null)
+ completion.run();
return;
+ }
showLineFrame(false, new Runnable()
{
@@ -1736,7 +1746,10 @@ public class MwmActivity extends BaseMwmFragmentActivity
{
replaceFragment(RoutingPlanFragment.class, null, completionListener);
showAddStartOrFinishFrame(RoutingController.get(), false);
- adjustTraffic(UiUtils.dimen(R.dimen.panel_width), UiUtils.getStatusBarHeight(getApplicationContext()));
+ int width = UiUtils.dimen(R.dimen.panel_width);
+ adjustTraffic(width, UiUtils.getStatusBarHeight(getApplicationContext()));
+ if (mNavigationController != null)
+ mNavigationController.adjustSearchButtons(width);
}
else
{
@@ -1755,9 +1768,15 @@ public class MwmActivity extends BaseMwmFragmentActivity
else
{
if (mIsFragmentContainer)
+ {
adjustTraffic(0, UiUtils.getStatusBarHeight(getApplicationContext()));
+ if (mNavigationController != null)
+ mNavigationController.adjustSearchButtons(0);
+ }
else
+ {
mRoutingPlanInplaceController.show(false);
+ }
closeAllFloatingPanels();
@@ -1995,6 +2014,27 @@ public class MwmActivity extends BaseMwmFragmentActivity
showLocationErrorDialog(intent);
}
+ @Override
+ public void onTranslationChanged(float translation)
+ {
+ if (mNavigationController != null)
+ mNavigationController.updateSearchButtonsTranslation(translation);
+ }
+
+ @Override
+ public void onFadeInZoomButtons()
+ {
+ if (mNavigationController != null)
+ mNavigationController.fadeInSearchButtons();
+ }
+
+ @Override
+ public void onFadeOutZoomButtons()
+ {
+ if (mNavigationController != null)
+ mNavigationController.fadeOutSearchButtons();
+ }
+
private void showLocationErrorDialog(@NonNull final Intent intent)
{
if (mLocationErrorDialog != null && mLocationErrorDialog.isShowing())
diff --git a/android/src/com/mapswithme/maps/NavigationButtonsAnimationController.java b/android/src/com/mapswithme/maps/NavigationButtonsAnimationController.java
index bd5e5c4477..6a9c044547 100644
--- a/android/src/com/mapswithme/maps/NavigationButtonsAnimationController.java
+++ b/android/src/com/mapswithme/maps/NavigationButtonsAnimationController.java
@@ -5,6 +5,7 @@ import android.animation.ValueAnimator;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import android.view.View;
import com.mapswithme.maps.location.LocationHelper;
@@ -26,6 +27,9 @@ class NavigationButtonsAnimationController
@NonNull
private final View mMyPosition;
+ @Nullable
+ private final OnTranslationChangedListener mTranslationListener;
+
private final float mMargin;
private float mContentHeight;
private float mMyPositionBottom;
@@ -41,7 +45,8 @@ class NavigationButtonsAnimationController
private float mCurrentOffset;
NavigationButtonsAnimationController(@NonNull View zoomIn, @NonNull View zoomOut,
- @NonNull View myPosition, @NonNull final View contentView)
+ @NonNull View myPosition, @NonNull final View contentView,
+ @Nullable OnTranslationChangedListener translationListener)
{
mZoomIn = zoomIn;
mZoomOut = zoomOut;
@@ -62,6 +67,7 @@ class NavigationButtonsAnimationController
contentView.removeOnLayoutChangeListener(this);
}
});
+ mTranslationListener = translationListener;
}
private void checkZoomButtonsVisibility()
@@ -120,6 +126,8 @@ class NavigationButtonsAnimationController
mZoomOut.setVisibility(View.INVISIBLE);
}
});
+ if (mTranslationListener != null)
+ mTranslationListener.onFadeOutZoomButtons();
}
private void fadeInZoom()
@@ -136,6 +144,8 @@ class NavigationButtonsAnimationController
}
});
Animations.fadeInView(mZoomOut, null);
+ if (mTranslationListener != null)
+ mTranslationListener.onFadeInZoomButtons();
}
private void fadeOutMyPosition()
@@ -210,6 +220,8 @@ class NavigationButtonsAnimationController
{
fadeInMyPosition();
}
+ if (mTranslationListener != null)
+ mTranslationListener.onTranslationChanged(translation);
}
private boolean isViewInsideLimits(@NonNull View view)
@@ -295,4 +307,13 @@ class NavigationButtonsAnimationController
{
mZoomVisible = state.getBoolean(STATE_VISIBLE, false);
}
+
+ interface OnTranslationChangedListener
+ {
+ void onTranslationChanged(float translation);
+
+ void onFadeInZoomButtons();
+
+ void onFadeOutZoomButtons();
+ }
}
diff --git a/android/src/com/mapswithme/maps/routing/NavigationController.java b/android/src/com/mapswithme/maps/routing/NavigationController.java
index 4e43bf7b98..56c37902da 100644
--- a/android/src/com/mapswithme/maps/routing/NavigationController.java
+++ b/android/src/com/mapswithme/maps/routing/NavigationController.java
@@ -1,6 +1,7 @@
package com.mapswithme.maps.routing;
import android.app.Activity;
+import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.os.Build;
@@ -10,12 +11,14 @@ import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Pair;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.MwmActivity;
import com.mapswithme.maps.R;
+import com.mapswithme.maps.bookmarks.BookmarkCategoriesActivity;
import com.mapswithme.maps.bookmarks.data.DistanceAndAzimut;
import com.mapswithme.maps.location.LocationHelper;
import com.mapswithme.maps.settings.SettingsActivity;
@@ -23,6 +26,8 @@ import com.mapswithme.maps.sound.TtsPlayer;
import com.mapswithme.maps.traffic.TrafficManager;
import com.mapswithme.maps.widget.FlatProgressView;
import com.mapswithme.maps.widget.menu.NavMenu;
+import com.mapswithme.util.Animations;
+import com.mapswithme.util.Graphics;
import com.mapswithme.util.StringUtils;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
@@ -35,7 +40,7 @@ import java.util.Calendar;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
-public class NavigationController implements TrafficManager.TrafficCallback
+public class NavigationController implements TrafficManager.TrafficCallback, View.OnClickListener
{
private static final String STATE_SHOW_TIME_LEFT = "ShowTimeLeft";
@@ -121,6 +126,11 @@ public class NavigationController implements TrafficManager.TrafficCallback
mSearchButtonFrame = activity.findViewById(R.id.search_button_frame);
mSearchWheel = new SearchWheel(mSearchButtonFrame);
+
+ ImageView bookmarkButton = (ImageView) mSearchButtonFrame.findViewById(R.id.btn_bookmarks);
+ bookmarkButton.setImageDrawable(Graphics.tint(bookmarkButton.getContext(),
+ R.drawable.ic_menu_bookmarks));
+ bookmarkButton.setOnClickListener(this);
}
public void onResume()
@@ -297,6 +307,41 @@ public class NavigationController implements TrafficManager.TrafficCallback
update(Framework.nativeGetRouteFollowingInfo());
}
+ public void showSearchButtons(boolean show)
+ {
+ UiUtils.showIf(show, mSearchButtonFrame);
+ }
+
+ public void adjustSearchButtons(int width)
+ {
+ ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mSearchButtonFrame.getLayoutParams();
+ params.setMargins(width, params.topMargin, params.rightMargin, params.bottomMargin);
+ mSearchButtonFrame.requestLayout();
+ }
+
+ public void updateSearchButtonsTranslation(float translation)
+ {
+ mSearchButtonFrame.setTranslationY(translation);
+ }
+
+ public void fadeInSearchButtons()
+ {
+ UiUtils.show(mSearchButtonFrame);
+ Animations.fadeInView(mSearchButtonFrame, null);
+ }
+
+ public void fadeOutSearchButtons()
+ {
+ Animations.fadeOutView(mSearchButtonFrame, new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ mSearchButtonFrame.setVisibility(View.INVISIBLE);
+ }
+ });
+ }
+
public void show(boolean show)
{
UiUtils.showIf(show, mFrame);
@@ -368,4 +413,16 @@ public class NavigationController implements TrafficManager.TrafficCallback
{
// no op
}
+
+ @Override
+ public void onClick(View v)
+ {
+ switch (v.getId())
+ {
+ case R.id.btn_bookmarks:
+ Context context = mFrame.getContext();
+ context.startActivity(new Intent(context, BookmarkCategoriesActivity.class));
+ break;
+ }
+ }
}
diff --git a/android/src/com/mapswithme/maps/routing/RoutingController.java b/android/src/com/mapswithme/maps/routing/RoutingController.java
index 7573a2d119..18c640dc9d 100644
--- a/android/src/com/mapswithme/maps/routing/RoutingController.java
+++ b/android/src/com/mapswithme/maps/routing/RoutingController.java
@@ -18,7 +18,6 @@ import android.widget.TextView;
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
-import com.mapswithme.maps.api.RoutePoint;
import com.mapswithme.maps.bookmarks.data.MapObject;
import com.mapswithme.maps.downloader.MapManager;
import com.mapswithme.maps.location.LocationHelper;
@@ -43,7 +42,6 @@ import java.util.concurrent.TimeUnit;
public class RoutingController
{
private static final String TAG = RoutingController.class.getSimpleName();
- private static final int NO_SLOT = 0;
private enum State
{
@@ -89,7 +87,7 @@ public class RoutingController
private BuildState mBuildState = BuildState.NONE;
private State mState = State.NONE;
- private int mWaitingPoiPickSlot = NO_SLOT;
+ private boolean mWaitingPoiPick;
@Nullable
private MapObject mStartPoint;
@@ -523,7 +521,7 @@ public class RoutingController
mStartPoint = null;
mEndPoint = null;
setPointsInternal();
- mWaitingPoiPickSlot = NO_SLOT;
+ mWaitingPoiPick = false;
mUberRequestHandled = false;
setBuildState(BuildState.NONE);
@@ -611,7 +609,7 @@ public class RoutingController
public boolean isWaitingPoiPick()
{
- return (mWaitingPoiPickSlot != NO_SLOT);
+ return mWaitingPoiPick;
}
public boolean isUberRequestHandled()
@@ -833,12 +831,11 @@ public class RoutingController
build();
}
- void searchPoi(int slotId)
+ void searchPoi()
{
- mLogger.d(TAG, "searchPoi: " + slotId);
Statistics.INSTANCE.trackEvent(Statistics.EventName.ROUTING_SEARCH_POINT);
AlohaHelper.logClick(AlohaHelper.ROUTING_SEARCH_POINT);
- mWaitingPoiPickSlot = slotId;
+ mWaitingPoiPick = true;
if (mContainer != null)
{
mContainer.showSearch();
@@ -846,31 +843,24 @@ public class RoutingController
}
}
- private void onPoiSelectedInternal(@Nullable MapObject point, int slot)
+ public void onPoiSelected(@Nullable MapObject point)
{
- if (point != null)
+ mWaitingPoiPick = false;
+
+ if (point != null && point.getMapObjectType() == MapObject.MY_POSITION)
{
- if (slot == 1)
+ if (mStartPoint == null)
setStartPoint(point);
- else
+ else if (mEndPoint == null)
setEndPoint(point);
}
- if (mContainer == null)
- return;
-
- mContainer.updateMenu();
- showRoutePlan();
- }
-
- public void onPoiSelected(@Nullable MapObject point)
- {
- int slot = mWaitingPoiPickSlot;
- mWaitingPoiPickSlot = NO_SLOT;
-
- onPoiSelectedInternal(point, slot);
if (mContainer != null)
+ {
mContainer.updatePoints();
+ mContainer.updateMenu();
+ showRoutePlan();
+ }
}
public static CharSequence formatRoutingTime(Context context, int seconds, @DimenRes int unitsSize)
diff --git a/android/src/com/mapswithme/maps/routing/RoutingPlanController.java b/android/src/com/mapswithme/maps/routing/RoutingPlanController.java
index 6f745e5b2c..778146d098 100644
--- a/android/src/com/mapswithme/maps/routing/RoutingPlanController.java
+++ b/android/src/com/mapswithme/maps/routing/RoutingPlanController.java
@@ -182,13 +182,13 @@ public class RoutingPlanController extends ToolbarController implements SlotFram
@Override
public void run()
{
- RoutingController.get().searchPoi(order);
+ RoutingController.get().searchPoi();
}
});
}
else
{
- RoutingController.get().searchPoi(order);
+ RoutingController.get().searchPoi();
}
}
diff --git a/android/src/com/mapswithme/maps/routing/SearchWheel.java b/android/src/com/mapswithme/maps/routing/SearchWheel.java
index d326dd1eea..5e99b6f207 100644
--- a/android/src/com/mapswithme/maps/routing/SearchWheel.java
+++ b/android/src/com/mapswithme/maps/routing/SearchWheel.java
@@ -218,6 +218,12 @@ class SearchWheel implements View.OnClickListener
switch (v.getId())
{
case R.id.btn_search:
+ if (RoutingController.get().isPlanning())
+ {
+ RoutingController.get().searchPoi();
+ return;
+ }
+
if (mCurrentOption != null || !TextUtils.isEmpty(SearchEngine.getQuery()))
{
SearchEngine.cancelSearch();
diff --git a/android/src/com/mapswithme/maps/search/SearchAdapter.java b/android/src/com/mapswithme/maps/search/SearchAdapter.java
index 5e0069bbc8..f63c03fa0a 100644
--- a/android/src/com/mapswithme/maps/search/SearchAdapter.java
+++ b/android/src/com/mapswithme/maps/search/SearchAdapter.java
@@ -220,7 +220,7 @@ class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.BaseViewHolder>
@Override
void processClick(SearchResult result, int order)
{
- mSearchFragment.showSingleResultOnMap(result, order);
+ mSearchFragment.showSingleResultOnMap(order);
}
}
diff --git a/android/src/com/mapswithme/maps/search/SearchFragment.java b/android/src/com/mapswithme/maps/search/SearchFragment.java
index 07a030ded2..dbce3e8e32 100644
--- a/android/src/com/mapswithme/maps/search/SearchFragment.java
+++ b/android/src/com/mapswithme/maps/search/SearchFragment.java
@@ -25,8 +25,6 @@ import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseMwmFragment;
import com.mapswithme.maps.base.OnBackPressListener;
-import com.mapswithme.maps.ads.Banner;
-import com.mapswithme.maps.bookmarks.data.MapObject;
import com.mapswithme.maps.downloader.CountrySuggestFragment;
import com.mapswithme.maps.downloader.MapManager;
import com.mapswithme.maps.location.LocationHelper;
@@ -462,15 +460,10 @@ public class SearchFragment extends BaseMwmFragment
return false;
}
- private void processSelected(SearchResult result)
+ private void processSelected()
{
if (mFromRoutePlan)
- {
- //noinspection ConstantConditions
- final MapObject point = new MapObject("", 0L, 0, MapObject.SEARCH, result.name, "",
- result.description.featureType, "", result.lat, result.lon, "", null, false, "", null, null);
- RoutingController.get().onPoiSelected(point);
- }
+ RoutingController.get().onPoiSelected(null);
mToolbarController.deactivate();
@@ -478,16 +471,14 @@ public class SearchFragment extends BaseMwmFragment
Utils.navigateToParent(getActivity());
}
- void showSingleResultOnMap(SearchResult result, int resultIndex)
+ void showSingleResultOnMap(int resultIndex)
{
final String query = getQuery();
SearchRecents.add(query);
SearchEngine.cancelApiCall();
- if (!mFromRoutePlan)
- SearchEngine.showResult(resultIndex);
-
- processSelected(result);
+ SearchEngine.showResult(resultIndex);
+ processSelected();
Statistics.INSTANCE.trackEvent(Statistics.EventName.SEARCH_ITEM_CLICKED);
}