Fixed search card on dashboard

This commit is contained in:
Alexey Kulish 2016-10-18 11:16:03 +03:00
parent a75287f3a7
commit 30c9c5dc72
4 changed files with 33 additions and 142 deletions

View file

@ -1,75 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:id="@+id/search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_card"
android:layout_marginTop="@dimen/dash_margin"
android:layout_marginBottom="@dimen/dash_margin"
android:layout_marginLeft="@dimen/dash_margin_h"
android:layout_marginRight="@dimen/dash_margin_h"
android:orientation="vertical" >
<LinearLayout android:id="@+id/search"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dash_margin"
android:layout_marginLeft="@dimen/dash_margin_h"
android:layout_marginRight="@dimen/dash_margin_h"
android:layout_marginTop="@dimen/dash_margin"
android:background="?attr/bg_card"
android:orientation="vertical">
<LinearLayout
android:id="@+id/search_card"
android:layout_width="fill_parent"
android:layout_height="@dimen/list_header_height" >
android:layout_height="56dp"
android:background="?attr/selectableItemBackground">
<TextView
android:id="@+id/search_for"
style="@style/DashboardSubHeader"
android:layout_width="wrap_content"
android:text="@string/search_for" />
<net.osmand.plus.widgets.ButtonEx
android:id="@+id/recents"
android:layout_width="wrap_content"
style="@style/DashboardGeneralButton"
android:text="@string/shared_string_history"
osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/dashSearchBtnHeight"
android:orientation="horizontal" >
<net.osmand.plus.widgets.ButtonEx
android:id="@+id/poi"
style="@style/DashboardSearchButton"
android:text="@string/poi"
osmand:textAllCapsCompat="false"
osmand:typeface="@string/font_roboto_medium" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/dashboard_divider" />
android:text="@string/search_hint"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_list_text_size"/>
<net.osmand.plus.widgets.ButtonEx
android:id="@+id/address"
style="@style/DashboardSearchButton"
android:text="@string/address"
osmand:textAllCapsCompat="false"
osmand:typeface="@string/font_roboto_medium" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/dashboard_divider" />
<net.osmand.plus.widgets.ButtonEx
android:id="@+id/coord"
style="@style/DashboardSearchButton"
android:text="@string/coordinates"
osmand:textAllCapsCompat="false"
osmand:typeface="@string/font_roboto_medium" />
</LinearLayout>
</LinearLayout>

View file

@ -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
-->
<string name="search_hint">Type city, address, poi name</string>
<string name="translit_name_if_miss">Transliterate if %1$s name is missing</string>
<string name="translit_names">Transliterate names</string>
<string name="edit_filter">Edit filter</string>

View file

@ -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() {
}
}

View file

@ -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,