[Quick search] UI fixes

This commit is contained in:
Alexey Kulish 2016-07-14 00:02:56 +03:00
parent eb4a2a176c
commit 7c3c4c13f9
4 changed files with 53 additions and 37 deletions

View file

@ -15,7 +15,7 @@
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
android:layout_gravity="top" android:layout_gravity="center_vertical"
android:scaleType="centerInside" android:scaleType="centerInside"
android:visibility="visible"/> android:visibility="visible"/>
@ -23,6 +23,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginLeft="8dp"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout

View file

@ -3,6 +3,8 @@ package net.osmand.plus.search;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityManagerCompat;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
@ -88,25 +90,6 @@ public class QuickSearchDialogFragment extends DialogFragment {
// Setup search // Setup search
String locale = app.getSettings().MAP_PREFERRED_LOCALE.get(); String locale = app.getSettings().MAP_PREFERRED_LOCALE.get();
/*
List<BinaryMapIndexReader> files = new ArrayList<>();
File file = new File(Environment.getExternalStorageDirectory() + "/osmand");
if (file.exists() && file.listFiles() != null) {
for (File obf : file.listFiles()) {
if (!obf.isDirectory() && obf.getName().endsWith(".obf")) {
try {
BinaryMapIndexReader bmir = new BinaryMapIndexReader(new RandomAccessFile(obf, "r"), obf);
files.add(bmir);
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
}
searchUICore = new SearchUICore(app.getPoiTypes(), locale, files.toArray(new BinaryMapIndexReader[files.size()]));
*/
Collection<RegionAddressRepository> regionAddressRepositories = app.getResourceManager().getAddressRepositories(); Collection<RegionAddressRepository> regionAddressRepositories = app.getResourceManager().getAddressRepositories();
BinaryMapIndexReader[] binaryMapIndexReaderArray = new BinaryMapIndexReader[regionAddressRepositories.size()]; BinaryMapIndexReader[] binaryMapIndexReaderArray = new BinaryMapIndexReader[regionAddressRepositories.size()];
int i = 0; int i = 0;
@ -381,10 +364,7 @@ public class QuickSearchDialogFragment extends DialogFragment {
bundle.putString(QUICK_SEARCH_QUERY_KEY, searchQuery); bundle.putString(QUICK_SEARCH_QUERY_KEY, searchQuery);
QuickSearchDialogFragment fragment = new QuickSearchDialogFragment(); QuickSearchDialogFragment fragment = new QuickSearchDialogFragment();
fragment.setArguments(bundle); fragment.setArguments(bundle);
mapActivity.getSupportFragmentManager().beginTransaction() fragment.show(mapActivity.getSupportFragmentManager(), TAG);
//.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_in_left, R.anim.slide_out_left)
.add(R.id.fragmentContainer, fragment, TAG)
.addToBackStack(TAG).commitAllowingStateLoss();
} }
private MapActivity getMapActivity() { private MapActivity getMapActivity() {

View file

@ -12,6 +12,7 @@ import android.widget.TextView;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.util.Algorithms;
import java.util.List; import java.util.List;
@ -81,8 +82,15 @@ public class SearchListAdapter extends ArrayAdapter<SearchListItem> {
TextView distance = (TextView) view.findViewById(R.id.distance); TextView distance = (TextView) view.findViewById(R.id.distance);
imageView.setImageDrawable(listItem.getIcon()); imageView.setImageDrawable(listItem.getIcon());
title.setText(listItem.getName()); String name = listItem.getName();
subtitle.setText(listItem.getTypeName()); title.setText(name);
String desc = listItem.getTypeName();
if (!Algorithms.isEmpty(desc) && !desc.equals(name)) {
subtitle.setText(desc);
subtitle.setVisibility(View.VISIBLE);
} else {
subtitle.setVisibility(View.GONE);
}
float dist = (float) listItem.getDistance(); float dist = (float) listItem.getDistance();
if (dist == 0) { if (dist == 0) {
distance.setText(""); distance.setText("");

View file

@ -11,6 +11,8 @@ import net.osmand.osm.PoiFilter;
import net.osmand.osm.PoiType; import net.osmand.osm.PoiType;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.render.RenderingIcons;
import net.osmand.search.core.SearchResult; import net.osmand.search.core.SearchResult;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -59,17 +61,17 @@ public class SearchListItem {
return streetCity.getName() + " - " + Algorithms.capitalizeFirstLetterAndLowercase(streetCity.getType().name()); return streetCity.getName() + " - " + Algorithms.capitalizeFirstLetterAndLowercase(streetCity.getType().name());
} }
case HOUSE: case HOUSE:
return "House"; return "";
case STREET_INTERSECTION: case STREET_INTERSECTION:
return "Street intersection"; return "";
case POI_TYPE: case POI_TYPE:
AbstractPoiType abstractPoiType = (AbstractPoiType) searchResult.object; AbstractPoiType abstractPoiType = (AbstractPoiType) searchResult.object;
String res; String res;
if (abstractPoiType instanceof PoiCategory) { if (abstractPoiType instanceof PoiCategory) {
res = "POI category"; res = "";
} else if (abstractPoiType instanceof PoiFilter) { } else if (abstractPoiType instanceof PoiFilter) {
PoiFilter poiFilter = (PoiFilter) abstractPoiType; PoiFilter poiFilter = (PoiFilter) abstractPoiType;
res = poiFilter.getPoiCategory() != null ? poiFilter.getPoiCategory().getTranslation() : "POI filter"; res = poiFilter.getPoiCategory() != null ? poiFilter.getPoiCategory().getTranslation() : "";
} else if (abstractPoiType instanceof PoiType) { } else if (abstractPoiType instanceof PoiType) {
PoiType poiType = (PoiType) abstractPoiType; PoiType poiType = (PoiType) abstractPoiType;
@ -78,15 +80,23 @@ public class SearchListItem {
res = poiType.getCategory() != null ? poiType.getCategory().getTranslation() : null; res = poiType.getCategory() != null ? poiType.getCategory().getTranslation() : null;
} }
if (res == null) { if (res == null) {
res = "POI type"; res = "";
} }
} else { } else {
res = "POI type"; res = "";
} }
return res; return res;
case POI: case POI:
Amenity amenity = (Amenity) searchResult.object; Amenity amenity = (Amenity) searchResult.object;
return amenity.getType().toString(); PoiCategory pc = amenity.getType();
PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType());
String typeStr = amenity.getSubType();
if (pt != null) {
typeStr = pt.getTranslation();
} else if (typeStr != null) {
typeStr = Algorithms.capitalizeFirstLetterAndLowercase(typeStr.replace('_', ' '));
}
return typeStr;
case LOCATION: case LOCATION:
break; break;
case FAVORITE: case FAVORITE:
@ -118,15 +128,32 @@ public class SearchListItem {
case STREET_INTERSECTION: case STREET_INTERSECTION:
break; break;
case POI_TYPE: case POI_TYPE:
break; AbstractPoiType abstractPoiType = (AbstractPoiType) searchResult.object;
if (RenderingIcons.containsBigIcon(abstractPoiType.getIconKeyName())) {
int iconId = RenderingIcons.getBigIconResourceId(abstractPoiType.getIconKeyName());
return app.getIconsCache().getIcon(iconId,
app.getSettings().isLightContent() ? R.color.osmand_orange : R.color.osmand_orange_dark);
} else {
return null;
}
case POI: case POI:
Amenity amenity = (Amenity) searchResult.object; Amenity amenity = (Amenity) searchResult.object;
Drawable drawable = null; String id = null;
PoiType st = amenity.getType().getPoiTypeByKeyName(amenity.getSubType()); PoiType st = amenity.getType().getPoiTypeByKeyName(amenity.getSubType());
if (st != null) { if (st != null) {
//drawable = app.getIconsCache().getMapIcon(st.getOsmTag() + "_" + st.getOsmValue()); if (RenderingIcons.containsBigIcon(st.getIconKeyName())) {
id = st.getIconKeyName();
} else if (RenderingIcons.containsBigIcon(st.getOsmTag() + "_" + st.getOsmValue())) {
id = st.getOsmTag() + "_" + st.getOsmValue();
}
}
if (id != null) {
int iconId = RenderingIcons.getBigIconResourceId(id);
return app.getIconsCache().getIcon(iconId,
app.getSettings().isLightContent() ? R.color.osmand_orange : R.color.osmand_orange_dark);
} else {
return null;
} }
return drawable;
case LOCATION: case LOCATION:
break; break;
case FAVORITE: case FAVORITE: