Formatting

This commit is contained in:
Roman Inflianskas 2016-07-05 17:14:21 +03:00
parent df32aa5b57
commit 30c71820aa

View file

@ -144,9 +144,9 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(searchFilter, InputMethodManager.SHOW_IMPLICIT); imm.showSoftInput(searchFilter, InputMethodManager.SHOW_IMPLICIT);
} else { } else {
if(filter != null) { if (filter != null) {
searchFilter.setText(filter.getSavedFilterByName() == null ? "" : searchFilter.setText(filter.getSavedFilterByName() == null ? "" :
filter.getSavedFilterByName()); filter.getSavedFilterByName());
} }
searchFilterLayout.setVisibility(View.GONE); searchFilterLayout.setVisibility(View.GONE);
} }
@ -187,7 +187,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
@Override @Override
protected void onDestroy() { protected void onDestroy() {
// Issue 2657 // Issue 2657
super.onDestroy(); super.onDestroy();
if (!(currentSearchTask == null || currentSearchTask.getStatus() == Status.FINISHED)) { if (!(currentSearchTask == null || currentSearchTask.getStatus() == Status.FINISHED)) {
currentSearchTask.cancel(true); currentSearchTask.cancel(true);
@ -209,7 +209,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
.show(); .show();
return true; return true;
} }
if ((isNameSearch() && !Algorithms.objectEquals(filter.getFilterByName(), query)) ) { if ((isNameSearch() && !Algorithms.objectEquals(filter.getFilterByName(), query))) {
filter.clearPreviousZoom(); filter.clearPreviousZoom();
filter.setFilterByName(query); filter.setFilterByName(query);
runNewSearchQuery(location, NEW_SEARCH_INIT); runNewSearchQuery(location, NEW_SEARCH_INIT);
@ -263,10 +263,10 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
} }
}); });
searchFilter.setHint(R.string.filter_poi_hint); searchFilter.setHint(R.string.filter_poi_hint);
((ImageView)findViewById(R.id.search_icon)).setImageDrawable( ((ImageView) findViewById(R.id.search_icon)).setImageDrawable(
getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_filter_dark)); getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_filter_dark));
((ImageView) findViewById(R.id.options)). ((ImageView) findViewById(R.id.options)).
setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_overflow_menu_white)); setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_overflow_menu_white));
findViewById(R.id.options).setOnClickListener(new View.OnClickListener() { findViewById(R.id.options).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -288,7 +288,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
String filterId = bundle.getString(AMENITY_FILTER); String filterId = bundle.getString(AMENITY_FILTER);
this.filter = app.getPoiFilters().getFilterById(filterId); this.filter = app.getPoiFilters().getFilterById(filterId);
if (filter != null) { if (filter != null) {
if(filter.isEmpty() && !isNameSearch()) { if (filter.isEmpty() && !isNameSearch()) {
showEditActivity(filter); showEditActivity(filter);
} else { } else {
filter.clearPreviousZoom(); filter.clearPreviousZoom();
@ -296,7 +296,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
runNewSearchQuery(location, NEW_SEARCH_INIT); runNewSearchQuery(location, NEW_SEARCH_INIT);
} }
} else { } else {
amenityAdapter.setNewModel(Collections.<Amenity> emptyList()); amenityAdapter.setNewModel(Collections.<Amenity>emptyList());
finish(); finish();
} }
} }
@ -334,9 +334,9 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
String queue = s.toString().trim(); String queue = s.toString().trim();
// if (!isNameSearch() ) { // if (!isNameSearch() ) {
amenityAdapter.getFilter().filter(queue); amenityAdapter.getFilter().filter(queue);
String cfilter = filter == null || filter.getFilterByName() == null ? "" : String cfilter = filter == null || filter.getFilterByName() == null ? "" :
filter.getFilterByName().toLowerCase(); filter.getFilterByName().toLowerCase();
if(!isNameSearch() && !queue.toString().toLowerCase().startsWith(cfilter)) { if (!isNameSearch() && !queue.toString().toLowerCase().startsWith(cfilter)) {
filter.setFilterByName(queue.toString()); filter.setFilterByName(queue.toString());
runNewSearchQuery(location, SEARCH_AGAIN); runNewSearchQuery(location, SEARCH_AGAIN);
} }
@ -364,14 +364,14 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
addFilter(optionsMenu, getString(R.string.shared_string_is_open)); addFilter(optionsMenu, getString(R.string.shared_string_is_open));
addFilter(optionsMenu, getString(R.string.shared_string_is_open_24_7)); addFilter(optionsMenu, getString(R.string.shared_string_is_open_24_7));
Map<String, PoiType> poiAdditionals = f.getPoiAdditionals(); Map<String, PoiType> poiAdditionals = f.getPoiAdditionals();
if(poiAdditionals != null) { if (poiAdditionals != null) {
TreeMap<String, PoiType> adds = new TreeMap<String, PoiType>(); TreeMap<String, PoiType> adds = new TreeMap<String, PoiType>();
for(PoiType vtype : poiAdditionals.values()) { for (PoiType vtype : poiAdditionals.values()) {
if(vtype.isTopVisible()) { if (vtype.isTopVisible()) {
adds.put(vtype.getTranslation().replace(' ', ':').toLowerCase(), vtype); adds.put(vtype.getTranslation().replace(' ', ':').toLowerCase(), vtype);
} }
} }
for(String vtype : adds.keySet()) { for (String vtype : adds.keySet()) {
addFilter(optionsMenu, vtype); addFilter(optionsMenu, vtype);
} }
} }
@ -386,7 +386,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
if(searchFilterLayout.getVisibility() == View.GONE) { if (searchFilterLayout.getVisibility() == View.GONE) {
searchFilterLayout.setVisibility(View.VISIBLE); searchFilterLayout.setVisibility(View.VISIBLE);
} }
searchFilter.setText((searchFilter.getText().toString() + " " + value.replace(' ', '_').toLowerCase()).trim()); searchFilter.setText((searchFilter.getText().toString() + " " + value.replace(' ', '_').toLowerCase()).trim());
@ -399,11 +399,11 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
Intent newIntent = new Intent(this, EditPOIFilterActivity.class); Intent newIntent = new Intent(this, EditPOIFilterActivity.class);
// folder selected // folder selected
newIntent.putExtra(EditPOIFilterActivity.AMENITY_FILTER, poi.getFilterId()); newIntent.putExtra(EditPOIFilterActivity.AMENITY_FILTER, poi.getFilterId());
if(location != null) { if (location != null) {
newIntent.putExtra(SearchActivity.SEARCH_LAT, location.getLatitude()); newIntent.putExtra(SearchActivity.SEARCH_LAT, location.getLatitude());
newIntent.putExtra(SearchActivity.SEARCH_LON, location.getLongitude()); newIntent.putExtra(SearchActivity.SEARCH_LON, location.getLongitude());
} }
if(searchNearBy) { if (searchNearBy) {
newIntent.putExtra(SearchActivity.SEARCH_NEARBY, true); newIntent.putExtra(SearchActivity.SEARCH_NEARBY, true);
} }
startActivityForResult(newIntent, RESULT_REQUEST_CODE); startActivityForResult(newIntent, RESULT_REQUEST_CODE);
@ -445,10 +445,10 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
name = "'" + filter.getFilterByName() + "'"; name = "'" + filter.getFilterByName() + "'";
} }
if(name.length() >= maxLength) { if (name.length() >= maxLength) {
name = name.substring(0, maxLength) + getString(R.string.shared_string_ellipsis); name = name.substring(0, maxLength) + getString(R.string.shared_string_ellipsis);
} }
if(filter instanceof NominatimPoiFilter && !((NominatimPoiFilter) filter).isPlacesQuery()) { if (filter instanceof NominatimPoiFilter && !((NominatimPoiFilter) filter).isPlacesQuery()) {
// nothing to add // nothing to add
} else { } else {
name += " " + filter.getSearchArea(next); name += " " + filter.getSearchArea(next);
@ -460,7 +460,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
boolean taskAlreadyFinished = currentSearchTask == null || currentSearchTask.getStatus() != Status.RUNNING; boolean taskAlreadyFinished = currentSearchTask == null || currentSearchTask.getStatus() != Status.RUNNING;
boolean enabled = taskAlreadyFinished && location != null && boolean enabled = taskAlreadyFinished && location != null &&
filter != null && filter.isSearchFurtherAvailable(); filter != null && filter.isSearchFurtherAvailable();
if(isNameSearch() && !Algorithms.objectEquals(searchFilter.getText().toString(), filter.getFilterByName())) { if (isNameSearch() && !Algorithms.objectEquals(searchFilter.getText().toString(), filter.getFilterByName())) {
title = R.string.search_button; title = R.string.search_button;
// Issue #2667 (2) // Issue #2667 (2)
if (currentSearchTask == null) { if (currentSearchTask == null) {
@ -618,7 +618,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
} }
net.osmand.Location getSearchedLocation() { net.osmand.Location getSearchedLocation() {
return searchLocation ; return searchLocation;
} }
@Override @Override
@ -655,7 +655,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
} }
amenityAdapter.setNewModel(result); amenityAdapter.setNewModel(result);
if(showOnMapItem != null) { if (showOnMapItem != null) {
showOnMapItem.setEnabled(amenityAdapter.getCount() > 0); showOnMapItem.setEnabled(amenityAdapter.getCount() > 0);
} }
} else { } else {
@ -954,7 +954,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.edit_filter_save_as_menu_item); builder.setTitle(R.string.edit_filter_save_as_menu_item);
final EditText editText = new EditText(this); final EditText editText = new EditText(this);
if(filter.isStandardFilter()) { if (filter.isStandardFilter()) {
editText.setText((filter.getName() + " " + searchFilter.getText()).trim()); editText.setText((filter.getName() + " " + searchFilter.getText()).trim());
} else { } else {
editText.setText(filter.getName()); editText.setText(filter.getName());
@ -970,7 +970,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
PoiUIFilter nFilter = new PoiUIFilter(editText.getText().toString(), PoiUIFilter nFilter = new PoiUIFilter(editText.getText().toString(),
null, null,
filter.getAcceptedTypes(), (OsmandApplication) getApplication()); filter.getAcceptedTypes(), (OsmandApplication) getApplication());
if(searchFilter.getText().toString().length() > 0) { if (searchFilter.getText().toString().length() > 0) {
nFilter.setSavedFilterByName(searchFilter.getText().toString()); nFilter.setSavedFilterByName(searchFilter.getText().toString());
} }
if (app.getPoiFilters().createPoiFilter(nFilter)) { if (app.getPoiFilters().createPoiFilter(nFilter)) {