Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
bafdcde19d
5 changed files with 36 additions and 18 deletions
|
@ -1353,17 +1353,27 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
|
||||
public void showQuickSearch(double latitude, double longitude) {
|
||||
mapContextMenu.hide();
|
||||
QuickSearchDialogFragment.showInstance(this, "", new LatLon(latitude, longitude));
|
||||
QuickSearchDialogFragment fragment = getQuickSearchDialogFragment();
|
||||
if (fragment != null) {
|
||||
fragment.dismiss();
|
||||
refreshMap();
|
||||
}
|
||||
QuickSearchDialogFragment.showInstance(this, "", true, new LatLon(latitude, longitude));
|
||||
}
|
||||
|
||||
public void showQuickSearch() {
|
||||
QuickSearchDialogFragment fragment = getQuickSearchDialogFragment();
|
||||
public void showQuickSearch(boolean newSearch, boolean showCategories) {
|
||||
mapContextMenu.hide();
|
||||
QuickSearchDialogFragment fragment = getQuickSearchDialogFragment();
|
||||
if (fragment != null) {
|
||||
fragment.show();
|
||||
if (newSearch) {
|
||||
fragment.dismiss();
|
||||
QuickSearchDialogFragment.showInstance(this, "", showCategories, null);
|
||||
} else {
|
||||
fragment.show();
|
||||
}
|
||||
refreshMap();
|
||||
} else {
|
||||
QuickSearchDialogFragment.showInstance(this, "", null);
|
||||
QuickSearchDialogFragment.showInstance(this, "", showCategories, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -352,10 +352,10 @@ public class MapActivityLayers {
|
|||
PoiUIFilter pf = list.get(which);
|
||||
String filterId = pf.getFilterId();
|
||||
if (filterId.equals(PoiUIFilter.CUSTOM_FILTER_ID)) {
|
||||
Intent search = new Intent(activity, SearchActivity.class);
|
||||
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
activity.getMyApplication().getSettings().SEARCH_TAB.set(SearchActivity.POI_TAB_INDEX);
|
||||
activity.startActivity(search);
|
||||
if (activity.getDashboard().isVisible()) {
|
||||
activity.getDashboard().hideDashboard();
|
||||
}
|
||||
activity.showQuickSearch(true, true);
|
||||
} else {
|
||||
getApplication().getPoiFilters().clearSelectedPoiFilters();
|
||||
getApplication().getPoiFilters().addSelectedPoiFilter(pf);
|
||||
|
|
|
@ -83,6 +83,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
private static final String QUICK_SEARCH_LAT_KEY = "quick_search_lat_key";
|
||||
private static final String QUICK_SEARCH_LON_KEY = "quick_search_lon_key";
|
||||
private static final String QUICK_SEARCH_SEARCHING_KEY = "quick_search_searching_key";
|
||||
private static final String QUICK_SEARCH_SHOW_CATEGORIES_KEY = "quick_search_show_categories_key";
|
||||
private Toolbar toolbar;
|
||||
private LockableViewPager viewPager;
|
||||
private SearchFragmentPagerAdapter pagerAdapter;
|
||||
|
@ -139,6 +140,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
final MapActivity mapActivity = getMapActivity();
|
||||
final View view = inflater.inflate(R.layout.search_dialog_fragment, container, false);
|
||||
|
||||
Bundle arguments = getArguments();
|
||||
if (savedInstanceState != null) {
|
||||
searchQuery = savedInstanceState.getString(QUICK_SEARCH_QUERY_KEY);
|
||||
double lat = savedInstanceState.getDouble(QUICK_SEARCH_LAT_KEY, Double.NaN);
|
||||
|
@ -148,10 +150,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
}
|
||||
interruptedSearch = savedInstanceState.getBoolean(QUICK_SEARCH_SEARCHING_KEY, false);
|
||||
}
|
||||
if (searchQuery == null) {
|
||||
searchQuery = getArguments().getString(QUICK_SEARCH_QUERY_KEY);
|
||||
double lat = getArguments().getDouble(QUICK_SEARCH_LAT_KEY, Double.NaN);
|
||||
double lon = getArguments().getDouble(QUICK_SEARCH_LON_KEY, Double.NaN);
|
||||
if (searchQuery == null && arguments != null) {
|
||||
searchQuery = arguments.getString(QUICK_SEARCH_QUERY_KEY);
|
||||
double lat = arguments.getDouble(QUICK_SEARCH_LAT_KEY, Double.NaN);
|
||||
double lon = arguments.getDouble(QUICK_SEARCH_LON_KEY, Double.NaN);
|
||||
if (!Double.isNaN(lat) && !Double.isNaN(lon)) {
|
||||
centerLatLon = new LatLon(lat, lon);
|
||||
}
|
||||
|
@ -160,6 +162,11 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
if (searchQuery == null)
|
||||
searchQuery = "";
|
||||
|
||||
boolean showCategories = false;
|
||||
if (arguments != null) {
|
||||
showCategories = arguments.getBoolean(QUICK_SEARCH_SHOW_CATEGORIES_KEY, false);
|
||||
}
|
||||
|
||||
tabToolbarView = view.findViewById(R.id.tab_toolbar_layout);
|
||||
tabsView = view.findViewById(R.id.tabs_view);
|
||||
searchView = view.findViewById(R.id.search_view);
|
||||
|
@ -278,7 +285,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
viewPager = (LockableViewPager) view.findViewById(R.id.pager);
|
||||
pagerAdapter = new SearchFragmentPagerAdapter(getChildFragmentManager(), getResources());
|
||||
viewPager.setAdapter(pagerAdapter);
|
||||
if (centerLatLon != null) {
|
||||
if (centerLatLon != null || showCategories) {
|
||||
viewPager.setCurrentItem(1);
|
||||
}
|
||||
|
||||
|
@ -877,7 +884,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
}
|
||||
|
||||
public static boolean showInstance(final MapActivity mapActivity, final String searchQuery,
|
||||
final LatLon latLon) {
|
||||
boolean showCategories, final LatLon latLon) {
|
||||
try {
|
||||
|
||||
if (mapActivity.isActivityDestroyed()) {
|
||||
|
@ -886,6 +893,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(QUICK_SEARCH_QUERY_KEY, searchQuery);
|
||||
bundle.putBoolean(QUICK_SEARCH_SHOW_CATEGORIES_KEY, showCategories);
|
||||
if (latLon != null) {
|
||||
bundle.putDouble(QUICK_SEARCH_LAT_KEY, latLon.getLatitude());
|
||||
bundle.putDouble(QUICK_SEARCH_LON_KEY, latLon.getLongitude());
|
||||
|
|
|
@ -223,7 +223,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
search.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mapActivity.showQuickSearch();
|
||||
mapActivity.showQuickSearch(true, false);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -177,14 +177,14 @@ public class MapInfoWidgetsFactory {
|
|||
searchBackButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
map.showQuickSearch();
|
||||
map.showQuickSearch(false, false);
|
||||
}
|
||||
});
|
||||
searchTitle = (TextView) map.findViewById(R.id.search_title);
|
||||
searchTitle.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
map.showQuickSearch();
|
||||
map.showQuickSearch(false, false);
|
||||
}
|
||||
});
|
||||
searchCloseButton = (ImageButton) map.findViewById(R.id.search_close_button);
|
||||
|
|
Loading…
Reference in a new issue