diff --git a/OsmAnd/res/layout/search_activity_single.xml b/OsmAnd/res/layout/search_activity_single.xml
index 803fc72bbe..2f1d82167e 100644
--- a/OsmAnd/res/layout/search_activity_single.xml
+++ b/OsmAnd/res/layout/search_activity_single.xml
@@ -12,14 +12,9 @@
android:layout_height="0dp"
android:layout_weight="1"/>
-
-
\ No newline at end of file
diff --git a/OsmAnd/res/layout/search_main.xml b/OsmAnd/res/layout/search_main.xml
index 5c26c32a7b..227fb6d224 100644
--- a/OsmAnd/res/layout/search_main.xml
+++ b/OsmAnd/res/layout/search_main.xml
@@ -1,63 +1,28 @@
-
+
-
+ android:layout_height="wrap_content" />
-
+
-
+
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/OsmAnd/src/com/example/android/common/view/SlidingTabLayout.java b/OsmAnd/src/com/example/android/common/view/SlidingTabLayout.java
new file mode 100644
index 0000000000..4463c8a4d4
--- /dev/null
+++ b/OsmAnd/src/com/example/android/common/view/SlidingTabLayout.java
@@ -0,0 +1,314 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.common.view;
+
+import android.content.Context;
+import android.graphics.Typeface;
+import android.os.Build;
+import android.support.v4.view.PagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.util.AttributeSet;
+import android.util.TypedValue;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.HorizontalScrollView;
+import android.widget.TextView;
+
+/**
+ * To be used with ViewPager to provide a tab indicator component which give constant feedback as to
+ * the user's scroll progress.
+ *
+ * To use the component, simply add it to your view hierarchy. Then in your
+ * {@link android.app.Activity} or {@link android.support.v4.app.Fragment} call
+ * {@link #setViewPager(ViewPager)} providing it the ViewPager this layout is being used for.
+ *
+ * The colors can be customized in two ways. The first and simplest is to provide an array of colors
+ * via {@link #setSelectedIndicatorColors(int...)} and {@link #setDividerColors(int...)}. The
+ * alternative is via the {@link TabColorizer} interface which provides you complete control over
+ * which color is used for any individual position.
+ *
+ * The views used as tabs can be customized by calling {@link #setCustomTabView(int, int)},
+ * providing the layout ID of your custom layout.
+ */
+public class SlidingTabLayout extends HorizontalScrollView {
+
+ /**
+ * Allows complete control over the colors drawn in the tab layout. Set with
+ * {@link #setCustomTabColorizer(TabColorizer)}.
+ */
+ public interface TabColorizer {
+
+ /**
+ * @return return the color of the indicator used when {@code position} is selected.
+ */
+ int getIndicatorColor(int position);
+
+ /**
+ * @return return the color of the divider drawn to the right of {@code position}.
+ */
+ int getDividerColor(int position);
+
+ }
+
+ private static final int TITLE_OFFSET_DIPS = 24;
+ private static final int TAB_VIEW_PADDING_DIPS = 16;
+ private static final int TAB_VIEW_TEXT_SIZE_SP = 12;
+
+ private int mTitleOffset;
+
+ private int mTabViewLayoutId;
+ private int mTabViewTextViewId;
+
+ private ViewPager mViewPager;
+ private ViewPager.OnPageChangeListener mViewPagerPageChangeListener;
+
+ private final SlidingTabStrip mTabStrip;
+
+ public SlidingTabLayout(Context context) {
+ this(context, null);
+ }
+
+ public SlidingTabLayout(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public SlidingTabLayout(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+
+ // Disable the Scroll Bar
+ setHorizontalScrollBarEnabled(false);
+ // Make sure that the Tab Strips fills this View
+ setFillViewport(true);
+
+ mTitleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density);
+
+ mTabStrip = new SlidingTabStrip(context);
+ addView(mTabStrip, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
+ }
+
+ /**
+ * Set the custom {@link TabColorizer} to be used.
+ *
+ * If you only require simple custmisation then you can use
+ * {@link #setSelectedIndicatorColors(int...)} and {@link #setDividerColors(int...)} to achieve
+ * similar effects.
+ */
+ public void setCustomTabColorizer(TabColorizer tabColorizer) {
+ mTabStrip.setCustomTabColorizer(tabColorizer);
+ }
+
+ /**
+ * Sets the colors to be used for indicating the selected tab. These colors are treated as a
+ * circular array. Providing one color will mean that all tabs are indicated with the same color.
+ */
+ public void setSelectedIndicatorColors(int... colors) {
+ mTabStrip.setSelectedIndicatorColors(colors);
+ }
+
+ /**
+ * Sets the colors to be used for tab dividers. These colors are treated as a circular array.
+ * Providing one color will mean that all tabs are indicated with the same color.
+ */
+ public void setDividerColors(int... colors) {
+ mTabStrip.setDividerColors(colors);
+ }
+
+ /**
+ * Set the {@link ViewPager.OnPageChangeListener}. When using {@link SlidingTabLayout} you are
+ * required to set any {@link ViewPager.OnPageChangeListener} through this method. This is so
+ * that the layout can update it's scroll position correctly.
+ *
+ * @see ViewPager#setOnPageChangeListener(ViewPager.OnPageChangeListener)
+ */
+ public void setOnPageChangeListener(ViewPager.OnPageChangeListener listener) {
+ mViewPagerPageChangeListener = listener;
+ }
+
+ /**
+ * Set the custom layout to be inflated for the tab views.
+ *
+ * @param layoutResId Layout id to be inflated
+ * @param textViewId id of the {@link TextView} in the inflated view
+ */
+ public void setCustomTabView(int layoutResId, int textViewId) {
+ mTabViewLayoutId = layoutResId;
+ mTabViewTextViewId = textViewId;
+ }
+
+ /**
+ * Sets the associated view pager. Note that the assumption here is that the pager content
+ * (number of tabs and tab titles) does not change after this call has been made.
+ */
+ public void setViewPager(ViewPager viewPager) {
+ mTabStrip.removeAllViews();
+
+ mViewPager = viewPager;
+ if (viewPager != null) {
+ viewPager.setOnPageChangeListener(new InternalViewPagerListener());
+ populateTabStrip();
+ }
+ }
+
+ /**
+ * Create a default view to be used for tabs. This is called if a custom tab view is not set via
+ * {@link #setCustomTabView(int, int)}.
+ */
+ protected TextView createDefaultTabView(Context context) {
+ TextView textView = new TextView(context);
+ textView.setGravity(Gravity.CENTER);
+ textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
+ textView.setTypeface(Typeface.DEFAULT_BOLD);
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
+ // If we're running on Honeycomb or newer, then we can use the Theme's
+ // selectableItemBackground to ensure that the View has a pressed state
+ TypedValue outValue = new TypedValue();
+ getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
+ outValue, true);
+ textView.setBackgroundResource(outValue.resourceId);
+ }
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
+ textView.setAllCaps(true);
+ }
+
+ int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
+ textView.setPadding(padding, padding, padding, padding);
+
+ return textView;
+ }
+
+ private void populateTabStrip() {
+ final PagerAdapter adapter = mViewPager.getAdapter();
+ final View.OnClickListener tabClickListener = new TabClickListener();
+
+ for (int i = 0; i < adapter.getCount(); i++) {
+ View tabView = null;
+ TextView tabTitleView = null;
+
+ if (mTabViewLayoutId != 0) {
+ // If there is a custom tab view layout id set, try and inflate it
+ tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip,
+ false);
+ tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
+ }
+
+ if (tabView == null) {
+ tabView = createDefaultTabView(getContext());
+ }
+
+ if (tabTitleView == null && TextView.class.isInstance(tabView)) {
+ tabTitleView = (TextView) tabView;
+ }
+
+ tabTitleView.setText(adapter.getPageTitle(i));
+ tabView.setOnClickListener(tabClickListener);
+
+ mTabStrip.addView(tabView);
+ }
+ }
+
+ @Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+
+ if (mViewPager != null) {
+ scrollToTab(mViewPager.getCurrentItem(), 0);
+ }
+ }
+
+ private void scrollToTab(int tabIndex, int positionOffset) {
+ final int tabStripChildCount = mTabStrip.getChildCount();
+ if (tabStripChildCount == 0 || tabIndex < 0 || tabIndex >= tabStripChildCount) {
+ return;
+ }
+
+ View selectedChild = mTabStrip.getChildAt(tabIndex);
+ if (selectedChild != null) {
+ int targetScrollX = selectedChild.getLeft() + positionOffset;
+
+ if (tabIndex > 0 || positionOffset > 0) {
+ // If we're not at the first child and are mid-scroll, make sure we obey the offset
+ targetScrollX -= mTitleOffset;
+ }
+
+ scrollTo(targetScrollX, 0);
+ }
+ }
+
+ private class InternalViewPagerListener implements ViewPager.OnPageChangeListener {
+ private int mScrollState;
+
+ @Override
+ public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
+ int tabStripChildCount = mTabStrip.getChildCount();
+ if ((tabStripChildCount == 0) || (position < 0) || (position >= tabStripChildCount)) {
+ return;
+ }
+
+ mTabStrip.onViewPagerPageChanged(position, positionOffset);
+
+ View selectedTitle = mTabStrip.getChildAt(position);
+ int extraOffset = (selectedTitle != null)
+ ? (int) (positionOffset * selectedTitle.getWidth())
+ : 0;
+ scrollToTab(position, extraOffset);
+
+ if (mViewPagerPageChangeListener != null) {
+ mViewPagerPageChangeListener.onPageScrolled(position, positionOffset,
+ positionOffsetPixels);
+ }
+ }
+
+ @Override
+ public void onPageScrollStateChanged(int state) {
+ mScrollState = state;
+
+ if (mViewPagerPageChangeListener != null) {
+ mViewPagerPageChangeListener.onPageScrollStateChanged(state);
+ }
+ }
+
+ @Override
+ public void onPageSelected(int position) {
+ if (mScrollState == ViewPager.SCROLL_STATE_IDLE) {
+ mTabStrip.onViewPagerPageChanged(position, 0f);
+ scrollToTab(position, 0);
+ }
+
+ if (mViewPagerPageChangeListener != null) {
+ mViewPagerPageChangeListener.onPageSelected(position);
+ }
+ }
+
+ }
+
+ private class TabClickListener implements View.OnClickListener {
+ @Override
+ public void onClick(View v) {
+ for (int i = 0; i < mTabStrip.getChildCount(); i++) {
+ if (v == mTabStrip.getChildAt(i)) {
+ mViewPager.setCurrentItem(i);
+ return;
+ }
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/OsmAnd/src/com/example/android/common/view/SlidingTabStrip.java b/OsmAnd/src/com/example/android/common/view/SlidingTabStrip.java
new file mode 100644
index 0000000000..1d6ba341a6
--- /dev/null
+++ b/OsmAnd/src/com/example/android/common/view/SlidingTabStrip.java
@@ -0,0 +1,208 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.common.view;
+
+import android.R;
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.util.AttributeSet;
+import android.util.TypedValue;
+import android.view.View;
+import android.widget.LinearLayout;
+
+class SlidingTabStrip extends LinearLayout {
+
+ private static final int DEFAULT_BOTTOM_BORDER_THICKNESS_DIPS = 2;
+ private static final byte DEFAULT_BOTTOM_BORDER_COLOR_ALPHA = 0x26;
+ private static final int SELECTED_INDICATOR_THICKNESS_DIPS = 8;
+ private static final int DEFAULT_SELECTED_INDICATOR_COLOR = 0xFF33B5E5;
+
+ private static final int DEFAULT_DIVIDER_THICKNESS_DIPS = 1;
+ private static final byte DEFAULT_DIVIDER_COLOR_ALPHA = 0x20;
+ private static final float DEFAULT_DIVIDER_HEIGHT = 0.5f;
+
+ private final int mBottomBorderThickness;
+ private final Paint mBottomBorderPaint;
+
+ private final int mSelectedIndicatorThickness;
+ private final Paint mSelectedIndicatorPaint;
+
+ private final int mDefaultBottomBorderColor;
+
+ private final Paint mDividerPaint;
+ private final float mDividerHeight;
+
+ private int mSelectedPosition;
+ private float mSelectionOffset;
+
+ private SlidingTabLayout.TabColorizer mCustomTabColorizer;
+ private final SimpleTabColorizer mDefaultTabColorizer;
+
+ SlidingTabStrip(Context context) {
+ this(context, null);
+ }
+
+ SlidingTabStrip(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setWillNotDraw(false);
+
+ final float density = getResources().getDisplayMetrics().density;
+
+ TypedValue outValue = new TypedValue();
+ context.getTheme().resolveAttribute(R.attr.colorForeground, outValue, true);
+ final int themeForegroundColor = outValue.data;
+
+ mDefaultBottomBorderColor = setColorAlpha(themeForegroundColor,
+ DEFAULT_BOTTOM_BORDER_COLOR_ALPHA);
+
+ mDefaultTabColorizer = new SimpleTabColorizer();
+ mDefaultTabColorizer.setIndicatorColors(DEFAULT_SELECTED_INDICATOR_COLOR);
+ mDefaultTabColorizer.setDividerColors(setColorAlpha(themeForegroundColor,
+ DEFAULT_DIVIDER_COLOR_ALPHA));
+
+ mBottomBorderThickness = (int) (DEFAULT_BOTTOM_BORDER_THICKNESS_DIPS * density);
+ mBottomBorderPaint = new Paint();
+ mBottomBorderPaint.setColor(mDefaultBottomBorderColor);
+
+ mSelectedIndicatorThickness = (int) (SELECTED_INDICATOR_THICKNESS_DIPS * density);
+ mSelectedIndicatorPaint = new Paint();
+
+ mDividerHeight = DEFAULT_DIVIDER_HEIGHT;
+ mDividerPaint = new Paint();
+ mDividerPaint.setStrokeWidth((int) (DEFAULT_DIVIDER_THICKNESS_DIPS * density));
+ }
+
+ void setCustomTabColorizer(SlidingTabLayout.TabColorizer customTabColorizer) {
+ mCustomTabColorizer = customTabColorizer;
+ invalidate();
+ }
+
+ void setSelectedIndicatorColors(int... colors) {
+ // Make sure that the custom colorizer is removed
+ mCustomTabColorizer = null;
+ mDefaultTabColorizer.setIndicatorColors(colors);
+ invalidate();
+ }
+
+ void setDividerColors(int... colors) {
+ // Make sure that the custom colorizer is removed
+ mCustomTabColorizer = null;
+ mDefaultTabColorizer.setDividerColors(colors);
+ invalidate();
+ }
+
+ void onViewPagerPageChanged(int position, float positionOffset) {
+ mSelectedPosition = position;
+ mSelectionOffset = positionOffset;
+ invalidate();
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ final int height = getHeight();
+ final int childCount = getChildCount();
+ final int dividerHeightPx = (int) (Math.min(Math.max(0f, mDividerHeight), 1f) * height);
+ final SlidingTabLayout.TabColorizer tabColorizer = mCustomTabColorizer != null
+ ? mCustomTabColorizer
+ : mDefaultTabColorizer;
+
+ // Thick colored underline below the current selection
+ if (childCount > 0) {
+ View selectedTitle = getChildAt(mSelectedPosition);
+ int left = selectedTitle.getLeft();
+ int right = selectedTitle.getRight();
+ int color = tabColorizer.getIndicatorColor(mSelectedPosition);
+
+ if (mSelectionOffset > 0f && mSelectedPosition < (getChildCount() - 1)) {
+ int nextColor = tabColorizer.getIndicatorColor(mSelectedPosition + 1);
+ if (color != nextColor) {
+ color = blendColors(nextColor, color, mSelectionOffset);
+ }
+
+ // Draw the selection partway between the tabs
+ View nextTitle = getChildAt(mSelectedPosition + 1);
+ left = (int) (mSelectionOffset * nextTitle.getLeft() +
+ (1.0f - mSelectionOffset) * left);
+ right = (int) (mSelectionOffset * nextTitle.getRight() +
+ (1.0f - mSelectionOffset) * right);
+ }
+
+ mSelectedIndicatorPaint.setColor(color);
+
+ canvas.drawRect(left, height - mSelectedIndicatorThickness, right,
+ height, mSelectedIndicatorPaint);
+ }
+
+ // Thin underline along the entire bottom edge
+ canvas.drawRect(0, height - mBottomBorderThickness, getWidth(), height, mBottomBorderPaint);
+
+ // Vertical separators between the titles
+ int separatorTop = (height - dividerHeightPx) / 2;
+ for (int i = 0; i < childCount - 1; i++) {
+ View child = getChildAt(i);
+ mDividerPaint.setColor(tabColorizer.getDividerColor(i));
+ canvas.drawLine(child.getRight(), separatorTop, child.getRight(),
+ separatorTop + dividerHeightPx, mDividerPaint);
+ }
+ }
+
+ /**
+ * Set the alpha value of the {@code color} to be the given {@code alpha} value.
+ */
+ private static int setColorAlpha(int color, byte alpha) {
+ return Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color));
+ }
+
+ /**
+ * Blend {@code color1} and {@code color2} using the given ratio.
+ *
+ * @param ratio of which to blend. 1.0 will return {@code color1}, 0.5 will give an even blend,
+ * 0.0 will return {@code color2}.
+ */
+ private static int blendColors(int color1, int color2, float ratio) {
+ final float inverseRation = 1f - ratio;
+ float r = (Color.red(color1) * ratio) + (Color.red(color2) * inverseRation);
+ float g = (Color.green(color1) * ratio) + (Color.green(color2) * inverseRation);
+ float b = (Color.blue(color1) * ratio) + (Color.blue(color2) * inverseRation);
+ return Color.rgb((int) r, (int) g, (int) b);
+ }
+
+ private static class SimpleTabColorizer implements SlidingTabLayout.TabColorizer {
+ private int[] mIndicatorColors;
+ private int[] mDividerColors;
+
+ @Override
+ public final int getIndicatorColor(int position) {
+ return mIndicatorColors[position % mIndicatorColors.length];
+ }
+
+ @Override
+ public final int getDividerColor(int position) {
+ return mDividerColors[position % mDividerColors.length];
+ }
+
+ void setIndicatorColors(int... colors) {
+ mIndicatorColors = colors;
+ }
+
+ void setDividerColors(int... colors) {
+ mDividerColors = colors;
+ }
+ }
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/activities/FavouritesListFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavouritesListFragment.java
index a3bdbff704..c1428f5adf 100644
--- a/OsmAnd/src/net/osmand/plus/activities/FavouritesListFragment.java
+++ b/OsmAnd/src/net/osmand/plus/activities/FavouritesListFragment.java
@@ -8,6 +8,7 @@ import java.util.Comparator;
import java.util.List;
import android.support.v4.app.ListFragment;
+import android.support.v7.widget.Toolbar;
import android.view.*;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
@@ -16,7 +17,6 @@ import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
-import net.osmand.plus.activities.search.BottomMenuItem;
import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
import net.osmand.plus.base.FavoriteImageDrawable;
@@ -102,9 +102,9 @@ public class FavouritesListFragment extends ListFragment implements SearchActivi
@Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- if (getActivity() instanceof SearchActivity) {
- ((SearchActivity)getActivity()).setupBottomMenu(new ArrayList());
+ public void onCreateOptionsMenu(Menu onCreate, MenuInflater inflater) {
+ if(getActivity() instanceof SearchActivity) {
+ ((SearchActivity) getActivity()).getClearToolbar(false);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/activities/NavigatePointFragment.java b/OsmAnd/src/net/osmand/plus/activities/NavigatePointFragment.java
index dae3753885..5270efa01c 100644
--- a/OsmAnd/src/net/osmand/plus/activities/NavigatePointFragment.java
+++ b/OsmAnd/src/net/osmand/plus/activities/NavigatePointFragment.java
@@ -2,23 +2,14 @@ package net.osmand.plus.activities;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Locale;
import java.util.StringTokenizer;
-import android.support.v4.app.Fragment;
-import android.support.v4.view.MenuItemCompat;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.MenuItem.OnMenuItemClickListener;
import net.osmand.PlatformUtil;
import net.osmand.data.LatLon;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
-import net.osmand.plus.activities.search.BottomMenuItem;
import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
import net.osmand.plus.dialogs.DirectionsDialogs;
@@ -28,9 +19,15 @@ import android.app.Dialog;
import android.content.Intent;
import android.location.Location;
import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.MenuItem.OnMenuItemClickListener;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
@@ -111,63 +108,65 @@ public class NavigatePointFragment extends Fragment implements SearchActivityChi
@Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ public void onCreateOptionsMenu(Menu onCreate, MenuInflater inflater) {
OsmandApplication app = (OsmandApplication) getActivity().getApplication();
boolean light = app.getSettings().isLightActionBar();
-
- List menuItems = new ArrayList();
- BottomMenuItem menuItem = new BottomMenuItem().
- setIcon(light ? R.drawable.ic_action_gdirections_light : R.drawable.ic_action_gdirections_dark).
- setMsg(R.string.context_menu_item_directions_to).
- setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- select(NAVIGATE_TO);
- }
- });
- menuItems.add(menuItem);
-
- TargetPointsHelper targets = app.getTargetPointsHelper();
- menuItem = new BottomMenuItem();
- if (targets.getPointToNavigate() != null) {
- menuItem.setIcon(light ? R.drawable.ic_action_flage_light : R.drawable.ic_action_flage_dark).
- setMsg(R.string.context_menu_item_intermediate_point);
- } else {
- menuItem.setIcon(light ? R.drawable.ic_action_flag_light : R.drawable.ic_action_flag_dark).
- setMsg(R.string.context_menu_item_destination_point);
+ Menu menu = onCreate;
+ if(getActivity() instanceof SearchActivity) {
+ menu = ((SearchActivity) getActivity()).getClearToolbar(true).getMenu();
}
- menuItem.setOnClickListener(new View.OnClickListener() {
+ MenuItem menuItem = menu.add(0, NAVIGATE_TO, 0, R.string.context_menu_item_directions_to).setShowAsActionFlags(
+ MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
+ menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gdirections_light : R.drawable.ic_action_gdirections_dark);
+ menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
+
@Override
- public void onClick(View v) {
- select(ADD_WAYPOINT);
+ public boolean onMenuItemClick(MenuItem item) {
+ select(NAVIGATE_TO);
+ return true;
}
});
- menuItems.add(menuItem);
+ TargetPointsHelper targets = app.getTargetPointsHelper();
+ if (targets.getPointToNavigate() != null) {
+ menuItem = menu.add(0, ADD_WAYPOINT, 0, R.string.context_menu_item_intermediate_point).setShowAsActionFlags(
+ MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
+ menuItem = menuItem.setIcon(light ? R.drawable.ic_action_flage_light
+ : R.drawable.ic_action_flage_dark);
+ } else {
+ menuItem = menu.add(0, ADD_WAYPOINT, 0, R.string.context_menu_item_destination_point).setShowAsActionFlags(
+ MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
+ menuItem = menuItem.setIcon(light ? R.drawable.ic_action_flag_light
+ : R.drawable.ic_action_flag_dark);
+ }
+ menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ select(ADD_WAYPOINT);
+ return true;
+ }
+ });
+ //}
+ menuItem = menu.add(0, SHOW_ON_MAP, 0, R.string.search_shown_on_map).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
+ menuItem = menuItem.setIcon(light ? R.drawable.ic_action_marker_light : R.drawable.ic_action_marker_dark);
- menuItem = new BottomMenuItem().
- setIcon(light ? R.drawable.ic_action_marker_light : R.drawable.ic_action_marker_dark).
- setMsg(R.string.search_shown_on_map).
- setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- select(SHOW_ON_MAP);
- }
- });
- menuItems.add(menuItem);
+ menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ select(SHOW_ON_MAP);
+ return true;
+ }
+ });
+
+ menuItem = menu.add(0, ADD_TO_FAVORITE, 0, R.string.add_to_favourite).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
+ menuItem = menuItem.setIcon(light ? R.drawable.ic_action_fav_light : R.drawable.ic_action_fav_dark);
-
- menuItem = new BottomMenuItem().
- setIcon(light ? R.drawable.ic_action_fav_light : R.drawable.ic_action_fav_dark).
- setMsg(R.string.add_to_favourite).
- setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- select(ADD_TO_FAVORITE);
- }
- });
- menuItems.add(menuItem);
-
- ((SearchActivity)getActivity()).setupBottomMenu(menuItems);
+ menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ select(ADD_TO_FAVORITE);
+ return true;
+ }
+ });
}
@Override
diff --git a/OsmAnd/src/net/osmand/plus/activities/search/BottomMenuItem.java b/OsmAnd/src/net/osmand/plus/activities/search/BottomMenuItem.java
deleted file mode 100644
index b0055b0229..0000000000
--- a/OsmAnd/src/net/osmand/plus/activities/search/BottomMenuItem.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package net.osmand.plus.activities.search;
-
-import android.view.View;
-
-/**
- * Created by Denis
- * on 19.01.2015.
- */
-public class BottomMenuItem {
- private int icon;
- private View.OnClickListener onClickListener;
- private int msg;
-
- public BottomMenuItem setIcon(int iconId) {
- this.icon = iconId;
- return BottomMenuItem.this;
- }
-
- public BottomMenuItem setMsg(int message) {
- this.msg = message;
- return BottomMenuItem.this;
- }
-
- public BottomMenuItem setOnClickListener(View.OnClickListener onClickListener) {
- this.onClickListener = onClickListener;
- return BottomMenuItem.this;
- }
-
- public int getIcon() {
- return icon;
- }
-
- public int getMsg() {
- return msg;
- }
-
- public View.OnClickListener getOnClickListener(){
- return onClickListener;
- }
-}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java
index 45ab296d64..dc513fe1d9 100644
--- a/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java
@@ -1,5 +1,6 @@
package net.osmand.plus.activities.search;
+
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@@ -8,11 +9,6 @@ import java.util.Formatter;
import java.util.List;
import java.util.Locale;
-import android.content.pm.ActivityInfo;
-import android.os.Build;
-import android.support.v7.app.ActionBarActivity;
-import android.view.*;
-import android.widget.*;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.plus.OsmAndLocationProvider;
@@ -25,24 +21,26 @@ import net.osmand.plus.activities.FavouritesListFragment;
import net.osmand.plus.activities.NavigatePointFragment;
import net.osmand.util.Algorithms;
import android.app.ActionBar;
-import android.content.Context;
import android.content.Intent;
+import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
-import android.util.Log;
-import android.widget.TabHost.TabSpec;
+import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.support.v7.app.ActionBar.OnNavigationListener;
+import android.support.v7.app.ActionBarActivity;
+import android.support.v7.widget.Toolbar;
+import android.util.Log;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+
+import com.example.android.common.view.SlidingTabLayout;
public class SearchActivity extends ActionBarActivity implements OsmAndLocationListener {
- private static final String SEARCH_HISTORY = "Search_History";
- private static final String SEARCH_FAVORITES = "Search_Favorites";
- private static final String SEARCH_TRANSPORT = "Search_Transport";
- private static final String SEARCH_LOCATION = "Search_Location";
- private static final String SEARCH_ADDRESS = "Search_Address";
- private static final String SEARCH_POI = "Search_POI";
public static final int POI_TAB_INDEX = 0;
public static final int ADDRESS_TAB_INDEX = 1;
public static final int LOCATION_TAB_INDEX = 2;
@@ -70,24 +68,38 @@ public class SearchActivity extends ActionBarActivity implements OsmAndLocationL
private static boolean searchOnLine = false;
private ArrayAdapter spinnerAdapter;
private OsmandSettings settings;
- private TabsAdapter mTabsAdapter;
List> fragList = new ArrayList>();
private boolean showOnlyOneTab;
+ private List mTabs = new ArrayList();
+ private ViewPager mViewPager;
+ private SlidingTabLayout mSlidingTabLayout;
+
public interface SearchActivityChild {
public void locationUpdate(LatLon l);
}
+ private static class TabItem {
+ private final CharSequence mTitle;
+ private final int mIcon;
+ private final int mIndicatorColor;
+ private final int mDividerColor;
+ private final Class> fragment;
+
+ public TabItem(CharSequence mTitle, int mIcon, int mIndicatorColor, int mDividerColor, Class> fragment) {
+ this.mTitle = mTitle;
+ this.mIcon = mIcon;
+ this.mIndicatorColor = mIndicatorColor;
+ this.mDividerColor = mDividerColor;
+ this.fragment = fragment;
+ }
+
+ }
- private View getTabIndicator(TabHost tabHost, int imageId, int stringId){
- View r = getLayoutInflater().inflate(R.layout.search_main_tab_header, tabHost, false);
- ImageView tabImage = (ImageView)r.findViewById(R.id.TabImage);
- tabImage.setImageResource(imageId);
- tabImage.setBackgroundResource(R.drawable.tab_icon_background);
- tabImage.setContentDescription(getString(stringId));
- return r;
+ private TabItem getTabIndicator(int iconId, int resId, Class> fragment){
+ return new TabItem(getString(resId), iconId, Color.DKGRAY, Color.LTGRAY, fragment);
}
@Override
@@ -107,34 +119,36 @@ public class SearchActivity extends ActionBarActivity implements OsmAndLocationL
if (!showOnlyOneTab) {
- final TextView tabinfo = (TextView) findViewById(R.id.textViewADesc);
- TabWidget tabs = (TabWidget) findViewById(android.R.id.tabs);
- tabs.setBackgroundResource(R.drawable.tab_icon_background);
-
- TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);
- tabHost.setup();
- ViewPager mViewPager = (ViewPager)findViewById(R.id.pager);
- mTabsAdapter = new TabsAdapter(this, tabHost, tabinfo, mViewPager, settings);
- TabSpec poiTab = tabHost.newTabSpec(SEARCH_POI).setIndicator(
- getTabIndicator(tabHost, R.drawable.tab_search_poi_icon, R.string.poi));
- mTabsAdapter.addTab(poiTab, getFragment(POI_TAB_INDEX), null);
- TabSpec addressSpec = tabHost.newTabSpec(SEARCH_ADDRESS).setIndicator(
- getTabIndicator(tabHost, R.drawable.tab_search_address_icon, R.string.address));
- mTabsAdapter.addTab(addressSpec, getFragment(ADDRESS_TAB_INDEX), null);
+ mViewPager = (ViewPager)findViewById(R.id.pager);
+ mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
- TabSpec locationTab = tabHost.newTabSpec(SEARCH_LOCATION).setIndicator(
- getTabIndicator(tabHost, R.drawable.tab_search_location_icon, R.string.search_tabs_location));
- mTabsAdapter.addTab(locationTab, getFragment(LOCATION_TAB_INDEX), null);
- TabSpec favoriteTab = tabHost.newTabSpec(SEARCH_FAVORITES).setIndicator(
- getTabIndicator(tabHost, R.drawable.tab_search_favorites_icon, R.string.favorite));
- mTabsAdapter.addTab(favoriteTab, getFragment(FAVORITES_TAB_INDEX), null);
- TabSpec historyTab = tabHost.newTabSpec(SEARCH_HISTORY).setIndicator(
- getTabIndicator(tabHost, R.drawable.tab_search_history_icon, R.string.history));
- mTabsAdapter.addTab(historyTab, getFragment(HISTORY_TAB_INDEX), null);
-// TabSpec transportTab = tabHost.newTabSpec(SEARCH_TRANSPORT).setIndicator(
-// getTabIndicator(tabHost, R.drawable.tab_search_transport_icon, R.string.transport));
-// mTabsAdapter.addTab(transportTab, getFragment(TRANSPORT_TAB_INDEX), null);
- tabHost.setCurrentTab(Math.min(tab , HISTORY_TAB_INDEX));
+ mTabs.add(getTabIndicator(R.drawable.tab_search_poi_icon, R.string.poi, getFragment(POI_TAB_INDEX)));
+ mTabs.add(getTabIndicator(R.drawable.tab_search_address_icon, R.string.address, getFragment(ADDRESS_TAB_INDEX)));
+ mTabs.add(getTabIndicator(R.drawable.tab_search_location_icon, R.string.search_tabs_location, getFragment(LOCATION_TAB_INDEX)));
+ mTabs.add(getTabIndicator(R.drawable.tab_search_favorites_icon, R.string.favorite, getFragment(FAVORITES_TAB_INDEX)));
+ mTabs.add(getTabIndicator(R.drawable.tab_search_history_icon, R.string.history, getFragment(HISTORY_TAB_INDEX)));
+
+
+ mViewPager.setAdapter(new SearchFragmentPagerAdapter(getSupportFragmentManager()));
+ mSlidingTabLayout.setViewPager(mViewPager);
+
+ mViewPager.setCurrentItem(Math.min(tab , HISTORY_TAB_INDEX));
+ mSlidingTabLayout.setOnPageChangeListener(new OnPageChangeListener() {
+
+ @Override
+ public void onPageSelected(int arg0) {
+ settings.SEARCH_TAB.set(arg0);
+ }
+
+ @Override
+ public void onPageScrolled(int arg0, float arg1, int arg2) {
+ }
+
+ @Override
+ public void onPageScrollStateChanged(int arg0) {
+
+ }
+ });
} else {
setContentView(R.layout.search_activity_single);
Class> cl = getFragment(tab);
@@ -284,33 +298,16 @@ public class SearchActivity extends ActionBarActivity implements OsmAndLocationL
}
}
}
-
- public void setupBottomMenu(List menuItems) {
- LinearLayout bottomControls = (LinearLayout) findViewById(R.id.bottomControls);
- if (bottomControls == null) {
- return;
- }
- bottomControls.removeAllViews();
-
- if (menuItems.size() == 0) {
- findViewById(R.id.devider).setVisibility(View.GONE);
- } else {
- findViewById(R.id.devider).setVisibility(View.VISIBLE);
- }
-
- for (BottomMenuItem item : menuItems) {
- ImageButton imageButton = new ImageButton(this);
- imageButton.setImageResource(item.getIcon());
- TableRow.LayoutParams params = new TableRow.LayoutParams(0,
- ViewGroup.LayoutParams.WRAP_CONTENT, 1.0f);
- params.gravity = Gravity.CENTER_VERTICAL;
- imageButton.setLayoutParams(params);
- imageButton.setOnClickListener(item.getOnClickListener());
- imageButton.setBackgroundResource(R.drawable.bottom_menu_item);
- bottomControls.addView(imageButton);
- }
+
+ public Toolbar getClearToolbar(boolean visible) {
+ final Toolbar tb = (Toolbar) findViewById(R.id.bottomControls);
+ tb.setTitle(null);
+ tb.getMenu().clear();
+ tb.setVisibility(visible? View.VISIBLE : View.GONE);
+ return tb;
}
+
public void updateLocation(net.osmand.Location location){
if (location != null) {
updateSearchPoint(new LatLon(location.getLatitude(), location.getLongitude()),
@@ -410,128 +407,42 @@ public class SearchActivity extends ActionBarActivity implements OsmAndLocationL
}
- /**
- * This is a helper class that implements the management of tabs and all
- * details of connecting a ViewPager with associated TabHost. It relies on a
- * trick. Normally a tab host has a simple API for supplying a View or
- * Intent that each tab will show. This is not sufficient for switching
- * between pages. So instead we make the content part of the tab host
- * 0dp high (it is not shown) and the TabsAdapter supplies its own dummy
- * view to show as the tab content. It listens to changes in tabs, and takes
- * care of switch to the correct paged in the ViewPager whenever the selected
- * tab changes.
- */
- public static class TabsAdapter extends FragmentPagerAdapter
- implements TabHost.OnTabChangeListener, ViewPager.OnPageChangeListener {
- private final Context mContext;
- private final TabHost mTabHost;
- private final ViewPager mViewPager;
- private final ArrayList mTabs = new ArrayList();
- private TextView tabInfo;
- private OsmandSettings osmSettings;
+ class SearchFragmentPagerAdapter extends FragmentPagerAdapter
+ /*implements TabHost.OnTabChangeListener, ViewPager.OnPageChangeListener*/ {
- static final class TabInfo {
- private final String tag;
- private Class> clss;
- private Bundle args;
-
- TabInfo(String _tag, Class> _class, Bundle _args) {
- tag = _tag;
- clss = _class;
- args = _args;
- }
+ SearchFragmentPagerAdapter(FragmentManager fm) {
+ super(fm);
}
- static class DummyTabFactory implements TabHost.TabContentFactory {
- private final Context mContext;
-
- public DummyTabFactory(Context context) {
- mContext = context;
- }
-
- @Override
- public View createTabContent(String tag) {
- View v = new View(mContext);
- v.setMinimumWidth(0);
- v.setMinimumHeight(0);
- return v;
- }
+ /**
+ * Return the {@link android.support.v4.app.Fragment} to be displayed at {@code position}.
+ *
+ * Here we return the value returned from {@link SamplePagerItem#createFragment()}.
+ */
+ @Override
+ public Fragment getItem(int i) {
+ try {
+ return (Fragment) mTabs.get(i).fragment.newInstance();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
- public TabsAdapter(FragmentActivity activity, TabHost tabHost, TextView tabinfo, ViewPager pager, OsmandSettings settings) {
- super(activity.getSupportFragmentManager());
- mContext = activity;
- mTabHost = tabHost;
- tabInfo = tabinfo;
- mViewPager = pager;
- osmSettings = settings;
- mTabHost.setOnTabChangedListener(this);
- mViewPager.setAdapter(this);
- mViewPager.setOnPageChangeListener(this);
- }
-
- public void addTab(TabHost.TabSpec tabSpec, Class> clss, Bundle args) {
- tabSpec.setContent(new DummyTabFactory(mContext));
- String tag = tabSpec.getTag();
-
- TabInfo info = new TabInfo(tag, clss, args);
- mTabs.add(info);
- mTabHost.addTab(tabSpec);
- notifyDataSetChanged();
- }
-
-
@Override
public int getCount() {
return mTabs.size();
}
-
- @Override
- public Fragment getItem(int position) {
- TabInfo info = mTabs.get(position);
- return Fragment.instantiate(mContext, info.clss.getName(), info.args);
- }
+ // BEGIN_INCLUDE (pageradapter_getpagetitle)
+ /**
+ * Return the title of the item at {@code position}. This is important as what this method
+ * returns is what is displayed in the {@link SlidingTabLayout}.
+ *
+ * Here we return the value returned from {@link SamplePagerItem#getTitle()}.
+ */
@Override
- public void onTabChanged(String tabId) {
- int position = mTabHost.getCurrentTab();
- osmSettings.SEARCH_TAB.set(position);
- mViewPager.setCurrentItem(position);
- if (SEARCH_POI.equals(tabId)) {
- tabInfo.setText(R.string.poi_search_desc);
- } else if (SEARCH_ADDRESS.equals(tabId)) {
- tabInfo.setText(searchOnLine ? R.string.search_osm_nominatim : R.string.address_search_desc);
- } else if (SEARCH_LOCATION.equals(tabId)) {
- tabInfo.setText(R.string.navpoint_search_desc);
- } else if (SEARCH_TRANSPORT.equals(tabId)) {
- tabInfo.setText(R.string.transport_search_desc);
- } else if (SEARCH_FAVORITES.equals(tabId)) {
- tabInfo.setText(R.string.favourites_search_desc);
- } else if (SEARCH_HISTORY.equals(tabId)) {
- tabInfo.setText(R.string.history_search_desc);
- }
- }
-
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
- }
-
- @Override
- public void onPageSelected(int position) {
- // Unfortunately when TabHost changes the current tab, it kindly
- // also takes care of putting focus on it when not in touch mode.
- // The jerk.
- // This hack tries to prevent this from pulling focus out of our
- // ViewPager.
- TabWidget widget = mTabHost.getTabWidget();
- int oldFocusability = widget.getDescendantFocusability();
- widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
- mTabHost.setCurrentTab(position);
- widget.setDescendantFocusability(oldFocusability);
- }
-
- @Override
- public void onPageScrollStateChanged(int state) {
+ public CharSequence getPageTitle(int position) {
+ return mTabs.get(position).mTitle;
}
}
diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressFragment.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressFragment.java
index 3500fbe7a1..c07a3454c5 100644
--- a/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressFragment.java
+++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressFragment.java
@@ -6,6 +6,7 @@ import java.util.List;
import android.support.v4.app.Fragment;
import android.support.v4.view.MenuItemCompat;
+import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -80,11 +81,15 @@ public class SearchAddressFragment extends Fragment {
@Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ public void onCreateOptionsMenu(Menu onCreate, MenuInflater inflater) {
boolean light = ((OsmandApplication) getApplication()).getSettings().isLightActionBar();
+ Menu menu = onCreate;
+ if(getActivity() instanceof SearchActivity) {
+ menu = ((SearchActivity) getActivity()).getClearToolbar(true).getMenu();
+ }
if(getActivity() instanceof SearchAddressActivity) {
- MenuItem menuItem = menu.add(0, SELECT_POINT, 0, "");
- MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
+ MenuItem menuItem = menu.add(0, SELECT_POINT, 0, "").setShowAsActionFlags(
+ MenuItem.SHOW_AS_ACTION_ALWAYS );
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_ok_light : R.drawable.ic_action_ok_dark);
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
@@ -94,71 +99,63 @@ public class SearchAddressFragment extends Fragment {
}
});
} else {
- List menuItems = new ArrayList();
- BottomMenuItem menuItem = new BottomMenuItem().
- setIcon(light ? R.drawable.ic_action_gdirections_light : R.drawable.ic_action_gdirections_dark).
- setMsg(R.string.context_menu_item_directions_to).
- setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- select(NAVIGATE_TO);
- }
- });
- menuItems.add(menuItem);
-
- TargetPointsHelper targets = ((OsmandApplication) getApplication()).getTargetPointsHelper();
- menuItem = new BottomMenuItem();
- if (targets.getPointToNavigate() != null) {
- menuItem.setIcon(light ? R.drawable.ic_action_flage_light : R.drawable.ic_action_flage_dark).
- setMsg(R.string.context_menu_item_intermediate_point);
- } else {
- menuItem.setIcon(light ? R.drawable.ic_action_flag_light : R.drawable.ic_action_flag_dark).
- setMsg(R.string.context_menu_item_destination_point);
- }
- menuItem.setOnClickListener(new View.OnClickListener() {
+ MenuItem menuItem = menu.add(0, NAVIGATE_TO, 0, R.string.context_menu_item_directions_to).setShowAsActionFlags(
+ MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
+ menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gdirections_light : R.drawable.ic_action_gdirections_dark);
+ menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
- public void onClick(View v) {
- select(ADD_WAYPOINT);
+ public boolean onMenuItemClick(MenuItem item) {
+ select(NAVIGATE_TO);
+ return true;
}
});
- menuItems.add(menuItem);
-
- menuItem = new BottomMenuItem().
- setIcon(light ? R.drawable.ic_action_marker_light : R.drawable.ic_action_marker_dark).
- setMsg(R.string.search_shown_on_map).
- setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- select(SHOW_ON_MAP);
- }
- });
- menuItems.add(menuItem);
-
- menuItem = new BottomMenuItem().
- setIcon(light ? R.drawable.ic_action_fav_light : R.drawable.ic_action_fav_dark).
- setMsg(R.string.add_to_favourite).
- setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- select(ADD_TO_FAVORITE);
- }
- });
- menuItems.add(menuItem);
-
- menuItem = new BottomMenuItem().
- setIcon(light ? R.drawable.ic_action_gnext_light : R.drawable.ic_action_gnext_dark).
- setMsg(R.string.search_online_address).
- setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- ((SearchActivity) getActivity()).startSearchAddressOnline();
- }
- });
- menuItems.add(menuItem);
-
- if (getActivity() instanceof SearchActivity) {
- ((SearchActivity)getActivity()).setupBottomMenu(menuItems);
+ TargetPointsHelper targets = ((OsmandApplication) getApplication()).getTargetPointsHelper();
+ if (targets.getPointToNavigate() != null) {
+ menuItem = menu.add(0, ADD_WAYPOINT, 0, R.string.context_menu_item_intermediate_point).setShowAsActionFlags(
+ MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
+ menuItem = menuItem.setIcon(light ? R.drawable.ic_action_flage_light : R.drawable.ic_action_flage_dark);
+ } else {
+ menuItem = menu.add(0, ADD_WAYPOINT, 0, R.string.context_menu_item_destination_point).setShowAsActionFlags(
+ MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
+ menuItem = menuItem.setIcon(light ? R.drawable.ic_action_flag_light : R.drawable.ic_action_flag_dark);
}
+ menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ select(ADD_WAYPOINT);
+ return true;
+ }
+ });
+ menuItem = menu.add(0, SHOW_ON_MAP, 0, R.string.search_shown_on_map).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
+ menuItem = menuItem.setIcon(light ? R.drawable.ic_action_marker_light : R.drawable.ic_action_marker_dark);
+
+ menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ select(SHOW_ON_MAP);
+ return true;
+ }
+ });
+
+ menuItem = menu.add(0, ADD_TO_FAVORITE, 0, R.string.add_to_favourite).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
+ menuItem = menuItem.setIcon(light ? R.drawable.ic_action_fav_light : R.drawable.ic_action_fav_dark);
+
+ menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ select(ADD_TO_FAVORITE);
+ return true;
+ }
+ });
+ menuItem = menu.add(0, ONLINE_SEARCH, 0, R.string.search_online_address).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
+ menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gnext_light : R.drawable.ic_action_gnext_dark);
+ menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ ((SearchActivity) getActivity()).startSearchAddressOnline();
+ return true;
+ }
+ });
}
}
diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressOnlineFragment.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressOnlineFragment.java
index a77b6f8dda..618a904595 100644
--- a/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressOnlineFragment.java
+++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressOnlineFragment.java
@@ -10,6 +10,7 @@ import java.util.Locale;
import android.support.v4.app.Fragment;
import android.support.v4.view.MenuItemCompat;
+import android.support.v7.widget.Toolbar;
import android.view.*;
import android.view.MenuItem.OnMenuItemClickListener;
import net.osmand.PlatformUtil;
@@ -57,34 +58,34 @@ public class SearchAddressOnlineFragment extends Fragment implements SearchActiv
@Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ public void onCreateOptionsMenu(Menu onCreate, MenuInflater inflater) {
boolean light = ((OsmandApplication) getActivity().getApplication()).getSettings().isLightActionBar();
- List menuItems = new ArrayList();
- BottomMenuItem menuItem = new BottomMenuItem().
- setIcon(light ? R.drawable.ic_action_gremove_light : R.drawable.ic_action_gremove_dark).
- setMsg(R.string.search_offline_clear_search).
- setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- searchText.setText("");
- adapter.clear();
- }
- });
- menuItems.add(menuItem);
-
- menuItem = new BottomMenuItem().
- setIcon(light ? R.drawable.ic_action_gnext_light : R.drawable.ic_action_gnext_dark).
- setMsg(R.string.search_offline_address).
- setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- ((SearchActivity) getActivity()).startSearchAddressOffline();
- }
- });
- menuItems.add(menuItem);
+ Menu menu = onCreate;
+ if(getActivity() instanceof SearchActivity) {
+ menu = ((SearchActivity) getActivity()).getClearToolbar(true).getMenu();
+ }
+ MenuItem menuItem = menu.add(0, 1, 0, R.string.search_offline_clear_search).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT );
+ menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gremove_light : R.drawable.ic_action_gremove_dark);
+ menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ searchText.setText("");
+ adapter.clear();
+ return true;
+ }
+ });
if (getActivity() instanceof SearchActivity) {
- ((SearchActivity)getActivity()).setupBottomMenu(menuItems);
+ menuItem = menu.add(0, 0, 0, R.string.search_offline_address).setShowAsActionFlags(
+ MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
+ menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gnext_light : R.drawable.ic_action_gnext_dark);
+ menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ ((SearchActivity) getActivity()).startSearchAddressOffline();
+ return true;
+ }
+ });
}
}
diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java
index 542216e29b..737c492c7a 100644
--- a/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java
+++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java
@@ -20,6 +20,7 @@ import net.osmand.util.MapUtils;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
+import android.support.v7.widget.Toolbar;
import android.text.Spannable;
import android.text.style.ForegroundColorSpan;
import android.view.View.OnClickListener;
@@ -177,9 +178,9 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
}
@Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- if (getActivity() instanceof SearchActivity) {
- ((SearchActivity)getActivity()).setupBottomMenu(new ArrayList());
+ public void onCreateOptionsMenu(Menu onCreate, MenuInflater inflater) {
+ if(getActivity() instanceof SearchActivity) {
+ ((SearchActivity) getActivity()).getClearToolbar(false);
}
}
}
diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java
index 41946bab76..005688264a 100644
--- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java
+++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java
@@ -9,6 +9,7 @@ import java.util.List;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.ListFragment;
import android.support.v7.app.ActionBarActivity;
+import android.support.v7.widget.Toolbar;
import android.view.*;
import net.osmand.access.AccessibleToast;
import net.osmand.data.LatLon;
@@ -180,8 +181,10 @@ public class SearchPoiFilterFragment extends ListFragment implements SearchActiv
}
@Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- ((SearchActivity)getActivity()).setupBottomMenu(new ArrayList());
+ public void onCreateOptionsMenu(Menu onCreate, MenuInflater inflater) {
+ if(getActivity() instanceof SearchActivity) {
+ ((SearchActivity) getActivity()).getClearToolbar(false);
+ }
}
@Override
diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchTransportFragment.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchTransportFragment.java
index 6d66064d59..cfe02df729 100644
--- a/OsmAnd/src/net/osmand/plus/activities/search/SearchTransportFragment.java
+++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchTransportFragment.java
@@ -8,6 +8,7 @@ import java.util.ArrayList;
import java.util.List;
import android.support.v4.app.Fragment;
+import android.support.v7.widget.Toolbar;
import android.view.*;
import net.osmand.data.LatLon;
import net.osmand.data.TransportRoute;
@@ -625,9 +626,9 @@ public class SearchTransportFragment extends Fragment implements SearchActivityC
}
@Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- if (getActivity() instanceof SearchActivity) {
- ((SearchActivity)getActivity()).setupBottomMenu(new ArrayList());
+ public void onCreateOptionsMenu(Menu onCreate, MenuInflater inflater) {
+ if(getActivity() instanceof SearchActivity) {
+ ((SearchActivity) getActivity()).getClearToolbar(false);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashMapFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashMapFragment.java
index 533db22522..f88a4865ae 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/DashMapFragment.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/DashMapFragment.java
@@ -162,10 +162,8 @@ public class DashMapFragment extends DashBaseFragment implements IMapDownloaderC
WindowManager wm = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
- final Point pnt = new Point();
- display.getSize(pnt);
- int height = pnt.y; // (int) getActivity().getResources().getDimension(R.dimen.dashMapHeight);
- int width = pnt.x;// display.getWidth();
+ int height = display.getHeight(); // (int) getActivity().getResources().getDimension(R.dimen.dashMapHeight);
+ int width = display.getWidth();
WindowManager mgr = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics dm = new DisplayMetrics();