Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
f7b7c24c82
4 changed files with 50 additions and 0 deletions
|
@ -365,6 +365,7 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os
|
||||||
|
|
||||||
private void startLocationUpdate() {
|
private void startLocationUpdate() {
|
||||||
OsmandApplication app = getMyApplication();
|
OsmandApplication app = getMyApplication();
|
||||||
|
app.getLocationProvider().removeCompassListener(app.getLocationProvider().getNavigationInfo());
|
||||||
app.getLocationProvider().addCompassListener(this);
|
app.getLocationProvider().addCompassListener(this);
|
||||||
app.getLocationProvider().addLocationListener(this);
|
app.getLocationProvider().addLocationListener(this);
|
||||||
myLocation = app.getLocationProvider().getLastKnownLocation();
|
myLocation = app.getLocationProvider().getLastKnownLocation();
|
||||||
|
@ -375,6 +376,7 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os
|
||||||
OsmandApplication app = getMyApplication();
|
OsmandApplication app = getMyApplication();
|
||||||
app.getLocationProvider().removeLocationListener(this);
|
app.getLocationProvider().removeLocationListener(this);
|
||||||
app.getLocationProvider().removeCompassListener(this);
|
app.getLocationProvider().removeCompassListener(this);
|
||||||
|
app.getLocationProvider().addCompassListener(app.getLocationProvider().getNavigationInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showOnMap() {
|
private void showOnMap() {
|
||||||
|
@ -424,13 +426,18 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os
|
||||||
LatLon latLon = null;
|
LatLon latLon = null;
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
latLon = new LatLon(location.getLatitude(), location.getLongitude());
|
latLon = new LatLon(location.getLatitude(), location.getLongitude());
|
||||||
|
((QuickSearchDialogFragment)getParentFragment()).getNavigationInfo().updateLocation(location);
|
||||||
}
|
}
|
||||||
updateLocationUI(latLon, heading);
|
updateLocationUI(latLon, heading);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLocationUI(LatLon latLon, Float heading) {
|
private void updateLocationUI(LatLon latLon, Float heading) {
|
||||||
if (latLon != null && !paused) {
|
if (latLon != null && !paused) {
|
||||||
|
QuickSearchDialogFragment dialogFragment = (QuickSearchDialogFragment) getParentFragment();
|
||||||
|
dialogFragment.getAccessibilityAssistant().lockEvents();
|
||||||
updateCompassVisibility(coordsView, latLon, heading);
|
updateCompassVisibility(coordsView, latLon, heading);
|
||||||
|
dialogFragment.getAccessibilityAssistant().unlockEvents();
|
||||||
|
dialogFragment.getNavigationInfo().updateTargetDirection(currentLatLon, heading.floatValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,8 @@ import android.widget.Toast;
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.ResultMatcher;
|
import net.osmand.ResultMatcher;
|
||||||
|
import net.osmand.access.AccessibilityAssistant;
|
||||||
|
import net.osmand.access.NavigationInfo;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.osm.AbstractPoiType;
|
import net.osmand.osm.AbstractPoiType;
|
||||||
|
@ -126,6 +128,9 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
private ImageButton clearButton;
|
private ImageButton clearButton;
|
||||||
|
|
||||||
|
private AccessibilityAssistant accessibilityAssistant;
|
||||||
|
private NavigationInfo navigationInfo;
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private QuickSearchHelper searchHelper;
|
private QuickSearchHelper searchHelper;
|
||||||
private SearchUICore searchUICore;
|
private SearchUICore searchUICore;
|
||||||
|
@ -159,6 +164,8 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
app = getMyApplication();
|
app = getMyApplication();
|
||||||
|
navigationInfo = new NavigationInfo(app);
|
||||||
|
accessibilityAssistant = new AccessibilityAssistant(getActivity());
|
||||||
boolean isLightTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
|
boolean isLightTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
|
||||||
int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
|
int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
|
||||||
setStyle(STYLE_NO_FRAME, themeId);
|
setStyle(STYLE_NO_FRAME, themeId);
|
||||||
|
@ -598,6 +605,14 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
return searchEditText.getText().toString();
|
return searchEditText.getText().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AccessibilityAssistant getAccessibilityAssistant() {
|
||||||
|
return accessibilityAssistant;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NavigationInfo getNavigationInfo() {
|
||||||
|
return navigationInfo;
|
||||||
|
}
|
||||||
|
|
||||||
public void hideKeyboard() {
|
public void hideKeyboard() {
|
||||||
if (searchEditText.hasFocus()) {
|
if (searchEditText.hasFocus()) {
|
||||||
AndroidUtils.hideSoftKeyboard(getActivity(), searchEditText);
|
AndroidUtils.hideSoftKeyboard(getActivity(), searchEditText);
|
||||||
|
@ -621,6 +636,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
updateUseMapCenterUI();
|
updateUseMapCenterUI();
|
||||||
updateLocationUI(mapCenter, null);
|
updateLocationUI(mapCenter, null);
|
||||||
}
|
}
|
||||||
|
app.getLocationProvider().removeCompassListener(app.getLocationProvider().getNavigationInfo());
|
||||||
getDialog().show();
|
getDialog().show();
|
||||||
paused = false;
|
paused = false;
|
||||||
hidden = false;
|
hidden = false;
|
||||||
|
@ -639,6 +655,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
hideProgressBar();
|
hideProgressBar();
|
||||||
updateClearButtonVisibility(true);
|
updateClearButtonVisibility(true);
|
||||||
getDialog().hide();
|
getDialog().hide();
|
||||||
|
app.getLocationProvider().addCompassListener(app.getLocationProvider().getNavigationInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeSearch() {
|
public void closeSearch() {
|
||||||
|
@ -802,6 +819,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startLocationUpdate() {
|
private void startLocationUpdate() {
|
||||||
|
app.getLocationProvider().removeCompassListener(app.getLocationProvider().getNavigationInfo());
|
||||||
app.getLocationProvider().addCompassListener(this);
|
app.getLocationProvider().addCompassListener(this);
|
||||||
app.getLocationProvider().addLocationListener(this);
|
app.getLocationProvider().addLocationListener(this);
|
||||||
location = app.getLocationProvider().getLastKnownLocation();
|
location = app.getLocationProvider().getLastKnownLocation();
|
||||||
|
@ -811,6 +829,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
private void stopLocationUpdate() {
|
private void stopLocationUpdate() {
|
||||||
app.getLocationProvider().removeLocationListener(this);
|
app.getLocationProvider().removeLocationListener(this);
|
||||||
app.getLocationProvider().removeCompassListener(this);
|
app.getLocationProvider().removeCompassListener(this);
|
||||||
|
app.getLocationProvider().addCompassListener(app.getLocationProvider().getNavigationInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showProgressBar() {
|
private void showProgressBar() {
|
||||||
|
@ -1333,6 +1352,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
LatLon latLon = null;
|
LatLon latLon = null;
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
latLon = new LatLon(location.getLatitude(), location.getLongitude());
|
latLon = new LatLon(location.getLatitude(), location.getLongitude());
|
||||||
|
navigationInfo.updateLocation(location);
|
||||||
}
|
}
|
||||||
updateLocationUI(latLon, heading);
|
updateLocationUI(latLon, heading);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.search;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.support.v4.view.ViewCompat;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -14,6 +15,7 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
|
import net.osmand.access.AccessibilityAssistant;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
@ -32,6 +34,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private Activity activity;
|
private Activity activity;
|
||||||
|
private AccessibilityAssistant accessibilityAssistant;
|
||||||
|
|
||||||
private LatLon location;
|
private LatLon location;
|
||||||
private Float heading;
|
private Float heading;
|
||||||
|
@ -70,6 +73,10 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
dp1 = AndroidUtils.dpToPx(app, 1f);
|
dp1 = AndroidUtils.dpToPx(app, 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAccessibilityAssistant(AccessibilityAssistant accessibilityAssistant) {
|
||||||
|
this.accessibilityAssistant = accessibilityAssistant;
|
||||||
|
}
|
||||||
|
|
||||||
public OnSelectionListener getSelectionListener() {
|
public OnSelectionListener getSelectionListener() {
|
||||||
return selectionListener;
|
return selectionListener;
|
||||||
}
|
}
|
||||||
|
@ -352,6 +359,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ViewCompat.setAccessibilityDelegate(view, accessibilityAssistant);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
|
@ -114,6 +115,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
dialogFragment = (QuickSearchDialogFragment) getParentFragment();
|
dialogFragment = (QuickSearchDialogFragment) getParentFragment();
|
||||||
listAdapter = new QuickSearchListAdapter(getMyApplication(), getActivity());
|
listAdapter = new QuickSearchListAdapter(getMyApplication(), getActivity());
|
||||||
|
listAdapter.setAccessibilityAssistant(dialogFragment.getAccessibilityAssistant());
|
||||||
listAdapter.setUseMapCenter(dialogFragment.isUseMapCenter());
|
listAdapter.setUseMapCenter(dialogFragment.isUseMapCenter());
|
||||||
setListAdapter(listAdapter);
|
setListAdapter(listAdapter);
|
||||||
ListView listView = getListView();
|
ListView listView = getListView();
|
||||||
|
@ -297,7 +299,20 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
||||||
if (listAdapter != null && !touching && !scrolling) {
|
if (listAdapter != null && !touching && !scrolling) {
|
||||||
listAdapter.setLocation(latLon);
|
listAdapter.setLocation(latLon);
|
||||||
listAdapter.setHeading(heading);
|
listAdapter.setHeading(heading);
|
||||||
|
dialogFragment.getAccessibilityAssistant().lockEvents();
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
|
dialogFragment.getAccessibilityAssistant().unlockEvents();
|
||||||
|
final View selected = dialogFragment.getAccessibilityAssistant().getFocusedView();
|
||||||
|
if (selected != null) {
|
||||||
|
try {
|
||||||
|
int position = getListView().getPositionForView(selected);
|
||||||
|
if ((position != AdapterView.INVALID_POSITION) && (position >= getListView().getHeaderViewsCount())) {
|
||||||
|
dialogFragment.getNavigationInfo().updateTargetDirection(listAdapter.getItem(position - getListView().getHeaderViewsCount()).getSearchResult().location, heading.floatValue());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue