Added search for categories. Fixed search duplicates

This commit is contained in:
Alexey Kulish 2016-10-19 22:13:24 +03:00
parent f4927f44e1
commit bee67b7054
8 changed files with 114 additions and 4 deletions

View file

@ -108,7 +108,6 @@ public class SearchUICore {
searchResults.add(addedResult);
}
j++;
i = searchResults.size();
continue;
}
SearchResult existingResult = searchResults.get(i);
@ -119,7 +118,6 @@ public class SearchUICore {
int compare = cmp.compare(existingResult, addedResult);
if(compare == 0) {
// existingResult == addedResult
this.searchResults.add(addedResults.get(j));
j++;
} else if(compare > 0) {
// existingResult > addedResult

View file

@ -488,6 +488,7 @@ public class SearchCoreFactory {
private Map<String, PoiType> translatedNames = new LinkedHashMap<>();
private List<PoiFilter> topVisibleFilters;
private List<PoiCategory> categories;
private List<CustomSearchPoiFilter> customPoiFilters = new ArrayList<>();
private TIntArrayList customPoiFiltersPriorites = new TIntArrayList();
private MapPoiTypes types;
@ -511,6 +512,7 @@ public class SearchCoreFactory {
if(translatedNames.isEmpty()) {
translatedNames = types.getAllTranslatedNames(false);
topVisibleFilters = types.getTopVisibleFilters();
categories = types.getCategories(false);
}
// results.clear();
TreeMap<String, AbstractPoiType> results = new TreeMap<String, AbstractPoiType>() ;
@ -521,6 +523,11 @@ public class SearchCoreFactory {
}
}
if (phrase.isUnknownSearchWordPresent()) {
for (PoiCategory c : categories) {
if (!phrase.isUnknownSearchWordPresent() || nm.matches(c.getTranslation())) {
results.put(c.getTranslation(), c);
}
}
Iterator<Entry<String, PoiType>> it = translatedNames.entrySet().iterator();
while (it.hasNext()) {
Entry<String, PoiType> e = it.next();

View file

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="22dp"
android:padding="24dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_christmas_illustration"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:textSize="@dimen/default_desc_text_size"
android:textColor="@color/color_white"
android:text="@string/christmas_desc"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="22dp"
android:textSize="@dimen/default_desc_text_size"
android:textColor="@color/color_white"
android:text="@string/christmas_desc_q"/>
</LinearLayout>

View file

@ -0,0 +1,20 @@
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="24dp"
android:paddingRight="16dp"
android:paddingTop="18dp">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/christmas_poi"
android:textColor="@color/color_white"
android:textSize="@dimen/dialog_header_text_size"
osmand:typeface="@string/font_roboto_medium"/>
</LinearLayout>

View file

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="xmas_blue">#3f51b5</color>
<color name="disabled_btn_text_color">#a0a0a0</color>
<color name="discount_bar_bg">#357ef2</color>

View file

@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='utf-8'?>
<resources>
<!--
Disclaimer:
@ -9,6 +9,9 @@
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="christmas_poi">Christmas POI</string>
<string name="christmas_desc">Anticipating Christmas and New Year holidays, you can choose to display the POI associated with Christmas: the Christmas tree, markets.</string>
<string name="christmas_desc_q">Show Christmas POI?</string>
<string name="rendering_value_light_brown_name">Light brown</string>
<string name="rendering_value_dark_brown_name">Dark brown</string>
<string name="rendering_attr_contourColorScheme_name">Color scheme of contours</string>
@ -19,7 +22,7 @@
<string name="edit_filter">Edit filter</string>
<string name="subcategories">Subcategories</string>
<string name="selected_categories">Selected categories</string>
<string name="create_custom_poi">Create custom POI</string>
<string name="create_custom_poi">Create custom filter</string>
<string name="custom_search">Custom search</string>
<string name="shared_string_filters">Filters</string>
<string name="apply_filters">Apply filters</string>

View file

@ -411,4 +411,8 @@
<item name="android:textSize">@dimen/default_desc_text_size</item>
</style>
<style name="XmasDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:background">@color/xmas_blue</item>
</style>
</resources>

View file

@ -12,6 +12,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.media.AudioManager;
import android.net.Uri;
import android.os.AsyncTask;
@ -25,19 +26,24 @@ import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.SwitchCompat;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewStub;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.Location;
import net.osmand.PlatformUtil;
import net.osmand.StateChangedListener;
@ -635,6 +641,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
getSupportFragmentManager().beginTransaction()
.add(R.id.fragmentContainer, new FirstUsageWelcomeFragment(),
FirstUsageWelcomeFragment.TAG).commitAllowingStateLoss();
} else {
//showXMasDialog();
}
FirstUsageWelcomeFragment.SHOW = false;
}
@ -1501,6 +1509,44 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
mapInfoLayer.removeTopToolbarController(controller);
}
private void showXMasDialog() {
final AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.XmasDialogTheme);
View titleView = getLayoutInflater().inflate(R.layout.xmas_dialog_title, null);
builder.setCustomTitle(titleView);
builder.setCancelable(true);
builder.setNegativeButton(getString(R.string.shared_string_cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.setPositiveButton(getString(R.string.shared_string_show), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//showQuickSearch();
}
});
builder.setView(getLayoutInflater().inflate(R.layout.xmas_dialog, null));
AlertDialog dialog = builder.create();
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
// Customize POSITIVE, NEGATIVE and NEUTRAL buttons.
Button positiveButton = ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_POSITIVE);
positiveButton.setTextColor(getResources().getColor(R.color.color_white));
positiveButton.invalidate();
Button negativeButton = ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_NEGATIVE);
negativeButton.setTextColor(getResources().getColor(R.color.color_white));
negativeButton.invalidate();
}
});
dialog.show();
}
public enum ShowQuickSearchMode {
NEW,
NEW_IF_EXPIRED,