From 30c9c5dc726c24217cc5c2dfbae257f8f4e766be Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Tue, 18 Oct 2016 11:16:03 +0300 Subject: [PATCH] Fixed search card on dashboard --- OsmAnd/res/layout/dash_search_fragment.xml | 77 ++++----------- OsmAnd/res/values/strings.xml | 1 + .../plus/dashboard/DashSearchFragment.java | 93 +++---------------- .../osmand/plus/dashboard/DashboardOnMap.java | 4 +- 4 files changed, 33 insertions(+), 142 deletions(-) diff --git a/OsmAnd/res/layout/dash_search_fragment.xml b/OsmAnd/res/layout/dash_search_fragment.xml index 50b0f648ba..6a5242c3cd 100644 --- a/OsmAnd/res/layout/dash_search_fragment.xml +++ b/OsmAnd/res/layout/dash_search_fragment.xml @@ -1,75 +1,30 @@ - + + android:layout_height="56dp" + android:background="?attr/selectableItemBackground"> - - - - - - - - - - - + android:text="@string/search_hint" + android:textColor="?android:attr/textColorSecondary" + android:textSize="@dimen/default_list_text_size"/> - - - - - \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 1fe5c00e83..74d6dac054 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,7 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Type city, address, poi name Transliterate if %1$s name is missing Transliterate names Edit filter diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashSearchFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashSearchFragment.java index b9f18c83c3..c084742dbc 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashSearchFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashSearchFragment.java @@ -1,29 +1,20 @@ package net.osmand.plus.dashboard; -import android.app.Activity; -import android.content.Intent; import android.graphics.Typeface; import android.os.Bundle; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.Button; import android.widget.TextView; -import net.osmand.data.LatLon; -import net.osmand.plus.IconsCache; -import net.osmand.plus.OsmAndAppCustomization; +import net.osmand.AndroidUtils; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.search.SearchActivity; +import net.osmand.plus.activities.MapActivity.ShowQuickSearchMode; import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.helpers.FontCache; -/** - * Created by Denis on - * 24.11.2014. - */ public class DashSearchFragment extends DashBaseFragment { public static final String TAG = "DASH_SEARCH_FRAGMENT"; public static final DashFragmentData.ShouldShowFunction SHOULD_SHOW_FUNCTION = @@ -37,79 +28,23 @@ public class DashSearchFragment extends DashBaseFragment { @Override public View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = getActivity().getLayoutInflater().inflate(R.layout.dash_search_fragment, container, false); - setupButtons(view); - Typeface typeface = FontCache.getRobotoMedium(getActivity()); - ((TextView) view.findViewById(R.id.search_for)).setTypeface(typeface); - ((Button) view.findViewById(R.id.recents)).setTypeface(typeface); + + TextView searchFor = (TextView) view.findViewById(R.id.search_for); + searchFor.setCompoundDrawablesWithIntrinsicBounds(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_search_dark), null, null, null); + searchFor.setCompoundDrawablePadding(AndroidUtils.dpToPx(getActivity(), 16f)); + + view.findViewById(R.id.search_card).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ((MapActivity) getActivity()).showQuickSearch(ShowQuickSearchMode.NEW, false); + closeDashboard(); + } + }); return view; } - - protected void searchActivity(final Activity activity, final OsmAndAppCustomization appCustomization, int tab) { - Intent newIntent = new Intent(activity, appCustomization.getSearchActivity()); - // causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); - LatLon loc = ((MapActivity)activity).getMapLocation(); - newIntent.putExtra(SearchActivity.SEARCH_LAT, loc.getLatitude()); - newIntent.putExtra(SearchActivity.SEARCH_LON, loc.getLongitude()); - if(((MapActivity)activity).getMapViewTrackingUtilities().isMapLinkedToLocation()) { - newIntent.putExtra(SearchActivity.SEARCH_NEARBY, true); - } - newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - getMyApplication().getSettings().SEARCH_TAB.set(tab); - activity.startActivity(newIntent); - } - - private void setupButtons(View view) { - final Activity activity = getActivity(); - final OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization(); - - IconsCache iconsCache = getMyApplication().getIconsCache(); - boolean light = getMyApplication().getSettings().isLightContent(); - Button btn = (Button) view.findViewById(R.id.poi); - btn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - closeDashboard(); - searchActivity(activity, appCustomization, SearchActivity.POI_TAB_INDEX); - } - }); - btn.setCompoundDrawablesWithIntrinsicBounds(null, iconsCache.getIcon(R.drawable.ic_action_info2, - light ? R.color.dash_search_icon_light : R.color.dashboard_subheader_text_dark), null, null); - - btn = (Button)view.findViewById(R.id.address); - btn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - closeDashboard(); - searchActivity(activity, appCustomization, SearchActivity.ADDRESS_TAB_INDEX); - } - }); - btn.setCompoundDrawablesWithIntrinsicBounds(null, iconsCache.getIcon(R.drawable.ic_action_home2, - light ? R.color.dash_search_icon_light : R.color.dashboard_subheader_text_dark), null, null); - - btn = (Button) view.findViewById(R.id.coord); - btn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - closeDashboard(); - searchActivity(activity, appCustomization, SearchActivity.LOCATION_TAB_INDEX); - } - }); - btn.setCompoundDrawablesWithIntrinsicBounds(null, iconsCache.getIcon(R.drawable.ic_action_marker2, - light ? R.color.dash_search_icon_light : R.color.dashboard_subheader_text_dark), null, null); - - (view.findViewById(R.id.recents)).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - closeDashboard(); - searchActivity(activity, appCustomization, SearchActivity.HISTORY_TAB_INDEX); - } - }); - } - @Override public void onOpenDash() { - } } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index d24c442b83..b11056ad24 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -113,12 +113,12 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis DashDashboardOrDrawerFragment.SHOULD_SHOW_FUNCTION, 5, null), new DashFragmentData(DashErrorFragment.TAG, DashErrorFragment.class, DashErrorFragment.SHOULD_SHOW_FUNCTION, 30, null), + new DashFragmentData(DashSearchFragment.TAG, DashSearchFragment.class, + DashSearchFragment.SHOULD_SHOW_FUNCTION, 35, null), new DashFragmentData(DashNavigationFragment.TAG, DashNavigationFragment.class, DashNavigationFragment.SHOULD_SHOW_FUNCTION, 40, null), new DashFragmentData(DashWaypointsFragment.TAG, DashWaypointsFragment.class, DashWaypointsFragment.SHOULD_SHOW_FUNCTION, 60, null), - new DashFragmentData(DashSearchFragment.TAG, DashSearchFragment.class, - DashSearchFragment.SHOULD_SHOW_FUNCTION, 70, null), DashRecentsFragment.FRAGMENT_DATA, DashFavoritesFragment.FRAGMENT_DATA, new DashFragmentData(DashPluginsFragment.TAG, DashPluginsFragment.class,