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

View file

@ -3,6 +3,8 @@ package net.osmand.plus.search;
import android.app.ProgressDialog;
import android.os.AsyncTask;
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.content.ContextCompat;
import android.support.v7.widget.Toolbar;
@ -88,25 +90,6 @@ public class QuickSearchDialogFragment extends DialogFragment {
// Setup search
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();
BinaryMapIndexReader[] binaryMapIndexReaderArray = new BinaryMapIndexReader[regionAddressRepositories.size()];
int i = 0;
@ -381,10 +364,7 @@ public class QuickSearchDialogFragment extends DialogFragment {
bundle.putString(QUICK_SEARCH_QUERY_KEY, searchQuery);
QuickSearchDialogFragment fragment = new QuickSearchDialogFragment();
fragment.setArguments(bundle);
mapActivity.getSupportFragmentManager().beginTransaction()
//.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();
fragment.show(mapActivity.getSupportFragmentManager(), TAG);
}
private MapActivity getMapActivity() {

View file

@ -12,6 +12,7 @@ import android.widget.TextView;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.util.Algorithms;
import java.util.List;
@ -81,8 +82,15 @@ public class SearchListAdapter extends ArrayAdapter<SearchListItem> {
TextView distance = (TextView) view.findViewById(R.id.distance);
imageView.setImageDrawable(listItem.getIcon());
title.setText(listItem.getName());
subtitle.setText(listItem.getTypeName());
String name = listItem.getName();
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();
if (dist == 0) {
distance.setText("");

View file

@ -11,6 +11,8 @@ import net.osmand.osm.PoiFilter;
import net.osmand.osm.PoiType;
import net.osmand.plus.OsmAndFormatter;
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.util.Algorithms;
@ -59,17 +61,17 @@ public class SearchListItem {
return streetCity.getName() + " - " + Algorithms.capitalizeFirstLetterAndLowercase(streetCity.getType().name());
}
case HOUSE:
return "House";
return "";
case STREET_INTERSECTION:
return "Street intersection";
return "";
case POI_TYPE:
AbstractPoiType abstractPoiType = (AbstractPoiType) searchResult.object;
String res;
if (abstractPoiType instanceof PoiCategory) {
res = "POI category";
res = "";
} else if (abstractPoiType instanceof PoiFilter) {
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) {
PoiType poiType = (PoiType) abstractPoiType;
@ -78,15 +80,23 @@ public class SearchListItem {
res = poiType.getCategory() != null ? poiType.getCategory().getTranslation() : null;
}
if (res == null) {
res = "POI type";
res = "";
}
} else {
res = "POI type";
res = "";
}
return res;
case POI:
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:
break;
case FAVORITE:
@ -118,15 +128,32 @@ public class SearchListItem {
case STREET_INTERSECTION:
break;
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:
Amenity amenity = (Amenity) searchResult.object;
Drawable drawable = null;
String id = null;
PoiType st = amenity.getType().getPoiTypeByKeyName(amenity.getSubType());
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:
break;
case FAVORITE: