Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-08-02 16:06:09 +02:00
commit 596461177b
4 changed files with 65 additions and 25 deletions

View file

@ -24,6 +24,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp" android:layout_height="56dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:focusableInTouchMode="true"
android:orientation="horizontal"> android:orientation="horizontal">
<EditText <EditText

View file

@ -567,10 +567,13 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
app.getDownloadThread().setUiActivity(this); app.getDownloadThread().setUiActivity(this);
if (mapViewTrackingUtilities.getShowRouteFinishDialog()) { //if (mapViewTrackingUtilities.getShowRouteFinishDialog()) {
DestinationReachedMenu.show(this);
//mapViewTrackingUtilities.setShowRouteFinishDialog(false);
//}
DestinationReachedMenu.show(this);
DestinationReachedMenu.show(this);
DestinationReachedMenu.show(this); DestinationReachedMenu.show(this);
mapViewTrackingUtilities.setShowRouteFinishDialog(false);
}
routingHelper.addListener(this); routingHelper.addListener(this);
app.getMapMarkersHelper().addListener(this); app.getMapMarkersHelper().addListener(this);
@ -1351,6 +1354,11 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
} }
} }
public void showQuickSearch(double latitude, double longitude) {
mapContextMenu.hide();
QuickSearchDialogFragment.showInstance(this, "", new LatLon(latitude, longitude));
}
public void showQuickSearch() { public void showQuickSearch() {
QuickSearchDialogFragment fragment = getQuickSearchDialogFragment(); QuickSearchDialogFragment fragment = getQuickSearchDialogFragment();
mapContextMenu.hide(); mapContextMenu.hide();
@ -1358,7 +1366,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
fragment.show(); fragment.show();
refreshMap(); refreshMap();
} else { } else {
QuickSearchDialogFragment.showInstance(this, ""); QuickSearchDialogFragment.showInstance(this, "", null);
} }
} }

View file

@ -296,11 +296,7 @@ public class MapActivityActions implements DialogProvider {
} else if (standardId == R.string.context_menu_item_last_intermediate_point) { } else if (standardId == R.string.context_menu_item_last_intermediate_point) {
mapActivity.getContextMenu().addAsLastIntermediate(); mapActivity.getContextMenu().addAsLastIntermediate();
} else if (standardId == R.string.context_menu_item_search) { } else if (standardId == R.string.context_menu_item_search) {
Intent intent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getSearchActivity()); mapActivity.showQuickSearch(latitude, longitude);
intent.putExtra(SearchActivity.SEARCH_LAT, latitude);
intent.putExtra(SearchActivity.SEARCH_LON, longitude);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
mapActivity.startActivity(intent);
} else if (standardId == R.string.context_menu_item_directions_from) { } else if (standardId == R.string.context_menu_item_directions_from) {
mapActivity.getContextMenu().hide(); mapActivity.getContextMenu().hide();
if (settings.USE_MAP_MARKERS.get() if (settings.USE_MAP_MARKERS.get()

View file

@ -80,6 +80,8 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
public static final String TAG = "QuickSearchDialogFragment"; public static final String TAG = "QuickSearchDialogFragment";
private static final String QUICK_SEARCH_QUERY_KEY = "quick_search_query_key"; private static final String QUICK_SEARCH_QUERY_KEY = "quick_search_query_key";
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_SEARCHING_KEY = "quick_search_searching_key";
private Toolbar toolbar; private Toolbar toolbar;
private LockableViewPager viewPager; private LockableViewPager viewPager;
@ -105,8 +107,9 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
private OsmandApplication app; private OsmandApplication app;
private QuickSearchHelper searchHelper; private QuickSearchHelper searchHelper;
private SearchUICore searchUICore; private SearchUICore searchUICore;
private String searchQuery = ""; private String searchQuery;
private LatLon centerLatLon;
private net.osmand.Location location = null; private net.osmand.Location location = null;
private Float heading = null; private Float heading = null;
private boolean useMapCenter; private boolean useMapCenter;
@ -138,10 +141,20 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
if (savedInstanceState != null) { if (savedInstanceState != null) {
searchQuery = savedInstanceState.getString(QUICK_SEARCH_QUERY_KEY); searchQuery = savedInstanceState.getString(QUICK_SEARCH_QUERY_KEY);
double lat = savedInstanceState.getDouble(QUICK_SEARCH_LAT_KEY, Double.NaN);
double lon = savedInstanceState.getDouble(QUICK_SEARCH_LON_KEY, Double.NaN);
if (!Double.isNaN(lat) && !Double.isNaN(lon)) {
centerLatLon = new LatLon(lat, lon);
}
interruptedSearch = savedInstanceState.getBoolean(QUICK_SEARCH_SEARCHING_KEY, false); interruptedSearch = savedInstanceState.getBoolean(QUICK_SEARCH_SEARCHING_KEY, false);
} }
if (searchQuery == null) { if (searchQuery == null) {
searchQuery = getArguments().getString(QUICK_SEARCH_QUERY_KEY); 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 (!Double.isNaN(lat) && !Double.isNaN(lon)) {
centerLatLon = new LatLon(lat, lon);
}
newSearch = true; newSearch = true;
} }
if (searchQuery == null) if (searchQuery == null)
@ -265,6 +278,9 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
viewPager = (LockableViewPager) view.findViewById(R.id.pager); viewPager = (LockableViewPager) view.findViewById(R.id.pager);
pagerAdapter = new SearchFragmentPagerAdapter(getChildFragmentManager(), getResources()); pagerAdapter = new SearchFragmentPagerAdapter(getChildFragmentManager(), getResources());
viewPager.setAdapter(pagerAdapter); viewPager.setAdapter(pagerAdapter);
if (centerLatLon != null) {
viewPager.setCurrentItem(1);
}
tabLayout = (TabLayout) view.findViewById(R.id.tab_layout); tabLayout = (TabLayout) view.findViewById(R.id.tab_layout);
tabLayout.setupWithViewPager(viewPager); tabLayout.setupWithViewPager(viewPager);
@ -322,6 +338,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
searchEditText.setSelection(newText.length()); searchEditText.setSelection(newText.length());
} else if (useMapCenter && location != null) { } else if (useMapCenter && location != null) {
useMapCenter = false; useMapCenter = false;
centerLatLon = null;
updateUseMapCenterUI(); updateUseMapCenterUI();
startLocationUpdate(); startLocationUpdate();
LatLon centerLatLon = new LatLon(location.getLatitude(), location.getLongitude()); LatLon centerLatLon = new LatLon(location.getLatitude(), location.getLongitude());
@ -349,9 +366,11 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
updateClearButtonVisibility(true); updateClearButtonVisibility(true);
addMainSearchFragment(); addMainSearchFragment();
if (centerLatLon == null) {
searchEditText.requestFocus(); searchEditText.requestFocus();
AndroidUtils.softKeyboardDelayed(searchEditText); AndroidUtils.softKeyboardDelayed(searchEditText);
} }
}
public String getText() { public String getText() {
return searchEditText.getText().toString(); return searchEditText.getText().toString();
@ -420,19 +439,26 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
} }
location = app.getLocationProvider().getLastKnownLocation(); location = app.getLocationProvider().getLastKnownLocation();
LatLon searchLatLon;
if (centerLatLon == null) {
LatLon clt = mapActivity.getMapView().getCurrentRotatedTileBox().getCenterLatLon(); LatLon clt = mapActivity.getMapView().getCurrentRotatedTileBox().getCenterLatLon();
LatLon centerLatLon = clt; searchLatLon = clt;
searchEditText.setHint(R.string.search_poi_category_hint); searchEditText.setHint(R.string.search_poi_category_hint);
if (location != null) { if (location != null) {
double d = MapUtils.getDistance(clt, location.getLatitude(), location.getLongitude()); double d = MapUtils.getDistance(clt, location.getLatitude(), location.getLongitude());
if (d < DISTANCE_THRESHOLD) { if (d < DISTANCE_THRESHOLD) {
centerLatLon = new LatLon(location.getLatitude(), location.getLongitude()); searchLatLon = new LatLon(location.getLatitude(), location.getLongitude());
} else { } else {
useMapCenter = true; useMapCenter = true;
} }
} }
} else {
searchLatLon = centerLatLon;
useMapCenter = true;
}
SearchSettings settings = searchUICore.getSearchSettings().setOriginalLocation( SearchSettings settings = searchUICore.getSearchSettings().setOriginalLocation(
new LatLon(centerLatLon.getLatitude(), centerLatLon.getLongitude())); new LatLon(searchLatLon.getLatitude(), searchLatLon.getLongitude()));
settings = settings.setLang(locale); settings = settings.setLang(locale);
searchUICore.updateSettings(settings); searchUICore.updateSettings(settings);
searchUICore.setOnResultsComplete(new Runnable() { searchUICore.setOnResultsComplete(new Runnable() {
@ -462,6 +488,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
public void onSaveInstanceState(Bundle outState) { public void onSaveInstanceState(Bundle outState) {
outState.putString(QUICK_SEARCH_QUERY_KEY, searchQuery); outState.putString(QUICK_SEARCH_QUERY_KEY, searchQuery);
outState.putBoolean(QUICK_SEARCH_SEARCHING_KEY, searching); outState.putBoolean(QUICK_SEARCH_SEARCHING_KEY, searching);
if (centerLatLon != null) {
outState.putDouble(QUICK_SEARCH_LAT_KEY, centerLatLon.getLatitude());
outState.putDouble(QUICK_SEARCH_LON_KEY, centerLatLon.getLongitude());
}
} }
@Override @Override
@ -522,7 +552,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
} }
private void updateClearButtonAndHint() { private void updateClearButtonAndHint() {
if (useMapCenter && searchEditText.length() == 0) { if (useMapCenter && location != null && searchEditText.length() == 0) {
LatLon latLon = searchUICore.getSearchSettings().getOriginalLocation(); LatLon latLon = searchUICore.getSearchSettings().getOriginalLocation();
double d = MapUtils.getDistance(latLon, location.getLatitude(), location.getLongitude()); double d = MapUtils.getDistance(latLon, location.getLatitude(), location.getLongitude());
String dist = OsmAndFormatter.getFormattedDistance((float) d, app); String dist = OsmAndFormatter.getFormattedDistance((float) d, app);
@ -536,7 +566,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
private void updateClearButtonVisibility(boolean show) { private void updateClearButtonVisibility(boolean show) {
if (show) { if (show) {
clearButton.setVisibility(searchEditText.length() > 0 || useMapCenter ? View.VISIBLE : View.GONE); clearButton.setVisibility(searchEditText.length() > 0 || (useMapCenter && location != null) ? View.VISIBLE : View.GONE);
} else { } else {
clearButton.setVisibility(View.GONE); clearButton.setVisibility(View.GONE);
} }
@ -846,7 +876,8 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
} }
} }
public static boolean showInstance(final MapActivity mapActivity, final String searchQuery) { public static boolean showInstance(final MapActivity mapActivity, final String searchQuery,
final LatLon latLon) {
try { try {
if (mapActivity.isActivityDestroyed()) { if (mapActivity.isActivityDestroyed()) {
@ -855,6 +886,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(QUICK_SEARCH_QUERY_KEY, searchQuery); bundle.putString(QUICK_SEARCH_QUERY_KEY, searchQuery);
if (latLon != null) {
bundle.putDouble(QUICK_SEARCH_LAT_KEY, latLon.getLatitude());
bundle.putDouble(QUICK_SEARCH_LON_KEY, latLon.getLongitude());
}
QuickSearchDialogFragment fragment = new QuickSearchDialogFragment(); QuickSearchDialogFragment fragment = new QuickSearchDialogFragment();
fragment.setArguments(bundle); fragment.setArguments(bundle);
fragment.show(mapActivity.getSupportFragmentManager(), TAG); fragment.show(mapActivity.getSupportFragmentManager(), TAG);