Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-04-27 22:24:37 +02:00
commit db7e718f92
18 changed files with 386 additions and 32 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -2011,4 +2011,8 @@
<string name="access_disable_wrong_direction_recalc">Не менять маршрут при неверном направлении движения</string>
<string name="access_disable_wrong_direction_recalc_descr">Предотвращает автоматический пересчет маршрута при неверном направлении движения</string>
<string name="access_no_destination">Пункт назначения не задан</string>
<string name="access_direction_audio_feedback">Звуковая индикация направления</string>
<string name="access_direction_audio_feedback_descr">Индицировать звуком направление на целевую точку</string>
<string name="access_direction_haptic_feedback">Тактильная индикация направления</string>
<string name="access_direction_haptic_feedback_descr">Индицировать вибрацией направление на целевую точку</string>
</resources>

View file

@ -9,6 +9,11 @@
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="access_direction_audio_feedback">Direction audio feedback</string>
<string name="access_direction_audio_feedback_descr">Indicate target point direction by sound</string>
<string name="access_direction_haptic_feedback">Direction haptic feedback</string>
<string name="access_direction_haptic_feedback_descr">Indicate target point direction by vibration</string>
<string name="use_osm_live_routing_description">Enable navigation for OSM Live changes (Beta)</string>
<string name="use_osm_live_routing">OSM Live navigation</string>
<string name="access_no_destination">Destination is not set</string>

View file

@ -0,0 +1,136 @@
package net.osmand.access;
import android.app.Activity;
import android.os.Build;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.SparseArray;
import android.view.View;
import android.view.View.AccessibilityDelegate;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import net.osmand.plus.OsmandApplication;
public class AccessibilityAssistant extends AccessibilityDelegate implements OnPageChangeListener {
private final Activity hostActivity;
private final OsmandApplication app;
private volatile boolean discourageUiUpdates;
private volatile boolean eventsLocked;
private volatile View focusedView;
private SparseArray<View> monitoredPages;
private View visiblePage;
private int visiblePageId;
public AccessibilityAssistant(Activity activity) {
hostActivity = activity;
app = (OsmandApplication)(activity.getApplication());
discourageUiUpdates = false;
eventsLocked = false;
focusedView = null;
monitoredPages = new SparseArray<View>();
visiblePage = null;
visiblePageId = 0;
}
public boolean isUiUpdateDiscouraged() {
return discourageUiUpdates && app.accessibilityEnabled();
}
public View getFocusedView() {
return focusedView;
}
public void lockEvents() {
eventsLocked = true;
}
public void unlockEvents() {
if (!hostActivity.getWindow().getDecorView().post(new Runnable() {
@Override
public void run() {
eventsLocked = false;
}
}))
eventsLocked = false;
}
public void forgetFocus() {
focusedView = null;
}
public void registerPage(View page, int id) {
monitoredPages.put(id, page);
if (id == visiblePageId)
visiblePage = page;
page.setAccessibilityDelegate(this);
}
@Override
public boolean onRequestSendAccessibilityEvent(ViewGroup host, View child, AccessibilityEvent event) {
return ((monitoredPages.indexOfValue(host) < 0) || (host == visiblePage)) && super.onRequestSendAccessibilityEvent(host, child, event);
}
@Override
public void sendAccessibilityEvent(View host, int eventType) {
boolean passed = !eventsLocked;
if (passed)
super.sendAccessibilityEvent(host, eventType);
notifyEvent(host, eventType, passed);
}
@Override
public void sendAccessibilityEventUnchecked(View host, AccessibilityEvent event) {
boolean passed = !eventsLocked;
int eventType = event.getEventType();
if (passed)
super.sendAccessibilityEventUnchecked(host, event);
notifyEvent(host, eventType, passed);
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
visiblePageId = position;
visiblePage = monitoredPages.get(position);
}
@Override
public void onPageScrollStateChanged(int state) {
}
private void processFocusChange(View view, boolean isFocused, boolean eventPassed) {
if (view.isClickable() && ((view instanceof ImageView) || (view instanceof ImageButton) || (view instanceof Button))) {
discourageUiUpdates = isFocused;
} else if (eventPassed || (Build.VERSION.SDK_INT != 17)) {
focusedView = isFocused ? view : null;
}
}
private void notifyEvent(View view, int eventType, boolean passed) {
if (Build.VERSION.SDK_INT >= 16) {
switch (eventType) {
case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED:
processFocusChange(view, true, passed);
break;
case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED:
processFocusChange(view, false, passed);
break;
default:
break;
}
}
}
}

View file

@ -1,6 +1,12 @@
package net.osmand.access;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import android.app.Activity;
import android.media.AudioManager;
import android.media.SoundPool;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
@ -8,12 +14,30 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
public class AccessibilityPlugin extends OsmandPlugin {
public static final int DIRECTION_NOTIFICATION = 1;
public static final int INCLINATION_LEFT = 2;
public static final int INCLINATION_RIGHT = 3;
private static final String ID = "osmand.accessibility";
private OsmandApplication app;
private SoundPool sounds;
private Map<Integer, Integer> soundIcons = new HashMap<Integer, Integer>();
public AccessibilityPlugin(OsmandApplication app) {
this.app = app;
}
@Override
public boolean init(final OsmandApplication app, Activity activity) {
sounds = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
if (sounds != null) {
soundIcons.put(DIRECTION_NOTIFICATION, loadSoundIcon("sounds/direction_notification.ogg"));
soundIcons.put(INCLINATION_LEFT, loadSoundIcon("sounds/inclination_left.ogg"));
soundIcons.put(INCLINATION_RIGHT, loadSoundIcon("sounds/inclination_right.ogg"));
}
return true;
}
@Override
public String getId() {
@ -40,6 +64,13 @@ public class AccessibilityPlugin extends OsmandPlugin {
return SettingsAccessibilityActivity.class;
}
@Override
public void disable(OsmandApplication app) {
if (sounds != null) {
sounds.release();
sounds = null;
}
}
@Override
public int getAssetResourceName() {
@ -50,4 +81,21 @@ public class AccessibilityPlugin extends OsmandPlugin {
public int getLogoResourceId() {
return R.drawable.ic_plugin_accessibility;
}
public void playSoundIcon(int iconId) {
if ((sounds != null) && soundIcons.containsKey(iconId)) {
int sound = soundIcons.get(iconId);
if (sound != 0)
sounds.play(sound, 1.0f, 1.0f, 0, 0, 1.0f);
}
}
private int loadSoundIcon(String path) {
try {
return sounds.load(app.getAssets().openFd(path), 1);
} catch (IOException e) {
return 0;
}
}
}

View file

@ -4,21 +4,27 @@ package net.osmand.access;
import android.content.Context;
import android.content.DialogInterface;
import android.os.SystemClock;
import android.os.Vibrator;
import android.support.v7.app.AlertDialog;
import net.osmand.Location;
import net.osmand.data.LatLon;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.access.RelativeDirectionStyle;
import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
import net.osmand.plus.routing.RoutingHelper;
import java.util.ArrayList;
import java.util.List;
public class NavigationInfo {
public class NavigationInfo implements OsmAndCompassListener, OsmAndLocationListener {
private static final float FULL_CIRCLE = 360.0f;
@ -95,6 +101,22 @@ public class NavigationInfo {
}
}
public Integer getInclination() {
if (value < 0) // unknown direction
return null;
final int nSectors = (style == RelativeDirectionStyle.CLOCKWISE) ? 12 : direction.length;
final int halfRound = nSectors / 2;
if (value == halfRound) // opposite direction
return null;
if (value > halfRound)
return value - nSectors;
return value;
}
protected int getValue() {
return value;
}
// The first argument must be not null as well as the currentLocation.
private int directionTo(final Location point, float heading) {
final float bearing = currentLocation.bearingTo(point) - heading;
@ -124,12 +146,16 @@ public class NavigationInfo {
R.string.north_west,
R.string.north_north_west};
private final long HAPTIC_INCLINATION_LEFT[] = { 0, 60 };
private final long HAPTIC_INCLINATION_RIGHT[] = { 0, 20, 80, 20 };
private final OsmandApplication app;
private final OsmandSettings settings;
private Location currentLocation;
private RelativeDirection lastDirection;
private long lastNotificationTime;
private volatile boolean autoAnnounce;
private volatile boolean targetDirectionFlag;
public NavigationInfo(OsmandApplication app) {
this.app = app;
@ -138,6 +164,7 @@ public class NavigationInfo {
lastDirection = new RelativeDirection();
lastNotificationTime = SystemClock.uptimeMillis();
autoAnnounce = false;
targetDirectionFlag = false;
}
private String getString(int id) {
@ -217,7 +244,8 @@ public class NavigationInfo {
return null;
}
public synchronized void setLocation(Location location) {
@Override
public synchronized void updateLocation(Location location) {
currentLocation = location;
if (autoAnnounce && app.accessibilityEnabled()) {
final TargetPoint point = app.getTargetPointsHelper().getPointToNavigate();
@ -246,6 +274,67 @@ public class NavigationInfo {
}
}
public synchronized void updateTargetDirection(final Location point, float heading) {
if ((currentLocation != null) && (point != null)) {
RelativeDirection direction = new RelativeDirection(point, heading);
Integer inclination = direction.getInclination();
if (targetDirectionFlag && ((inclination == null) || (inclination != 0))) {
targetDirectionFlag = false;
if (settings.DIRECTION_AUDIO_FEEDBACK.get()) {
AccessibilityPlugin accessibilityPlugin = OsmandPlugin.getEnabledPlugin(AccessibilityPlugin.class);
if (accessibilityPlugin != null) {
if (inclination == null) {
accessibilityPlugin.playSoundIcon(AccessibilityPlugin.DIRECTION_NOTIFICATION);
} else if (inclination > 0) {
accessibilityPlugin.playSoundIcon(AccessibilityPlugin.INCLINATION_LEFT);
} else {
accessibilityPlugin.playSoundIcon(AccessibilityPlugin.INCLINATION_RIGHT);
}
}
}
if (settings.DIRECTION_HAPTIC_FEEDBACK.get()) {
Vibrator haptic = (Vibrator)app.getSystemService(Context.VIBRATOR_SERVICE);
if ((haptic != null) && haptic.hasVibrator()) {
if (inclination == null) {
haptic.vibrate(200);
} else if (inclination > 0) {
haptic.vibrate(HAPTIC_INCLINATION_LEFT, -1);
} else {
haptic.vibrate(HAPTIC_INCLINATION_RIGHT, -1);
}
}
}
} else if ((!targetDirectionFlag) && (direction.getValue() == 0)) {
targetDirectionFlag = true;
}
}
}
public synchronized void updateTargetDirection(final LatLon point, float heading) {
if (point != null) {
Location destination = new Location("map"); //$NON-NLS-1$
destination.setLatitude(point.getLatitude());
destination.setLongitude(point.getLongitude());
updateTargetDirection(destination, heading);
}
}
@Override
public synchronized void updateCompassValue(float heading) {
RoutingHelper router = app.getRoutingHelper();
if (router.isFollowingMode() && router.isRouteCalculated()) {
synchronized (router) {
NextDirectionInfo nextDirection = router.getNextRouteDirectionInfo(new NextDirectionInfo(), true);
if (nextDirection != null) {
updateTargetDirection(router.getLocationFromRouteDirection(nextDirection.directionInfo), heading);
}
}
} else {
TargetPoint target = app.getTargetPointsHelper().getPointToNavigate();
updateTargetDirection((target != null) ? target.point : null, heading);
}
}
// Show all available info
public void show(final TargetPoint point, Float heading, Context ctx) {
final List<String> attributes = new ArrayList<String>();

View file

@ -96,6 +96,11 @@ public class SettingsAccessibilityActivity extends SettingsBaseActivity {
cat.addPreference(createCheckBoxPreference(settings.DISABLE_WRONG_DIRECTION_RECALC, R.string.access_disable_wrong_direction_recalc,
R.string.access_disable_wrong_direction_recalc_descr));
cat.addPreference(createCheckBoxPreference(settings.DIRECTION_AUDIO_FEEDBACK, R.string.access_direction_audio_feedback,
R.string.access_direction_audio_feedback_descr));
cat.addPreference(createCheckBoxPreference(settings.DIRECTION_HAPTIC_FEEDBACK, R.string.access_direction_haptic_feedback,
R.string.access_direction_haptic_feedback_descr));
cat.addPreference(createCheckBoxPreference(settings.ZOOM_BY_TRACKBALL, R.string.zoom_by_trackball,
R.string.zoom_by_trackball_descr));
}

View file

@ -225,6 +225,8 @@ public class OsmAndLocationProvider implements SensorEventListener {
USE_FILTER_FOR_COMPASS = settings.USE_KALMAN_FILTER_FOR_COMPASS;
currentPositionHelper = new CurrentPositionHelper(app);
locationSimulation = new OsmAndLocationSimulation(app, this);
addLocationListener(navigationInfo);
addCompassListener(navigationInfo);
}
public void resumeAllUpdates() {
@ -367,7 +369,7 @@ public class OsmAndLocationProvider implements SensorEventListener {
return null;
}
public void registerOrUnregisterCompassListener(boolean register) {
public synchronized void registerOrUnregisterCompassListener(boolean register) {
if (sensorRegistered && !register) {
Log.d(PlatformUtil.TAG, "Disable sensor"); //$NON-NLS-1$
((SensorManager) app.getSystemService(Context.SENSOR_SERVICE)).unregisterListener(this);
@ -440,6 +442,9 @@ public class OsmAndLocationProvider implements SensorEventListener {
return;
}
synchronized (this) {
if (!sensorRegistered) {
return;
}
inUpdateValue = true;
try {
float val = 0;
@ -544,7 +549,7 @@ public class OsmAndLocationProvider implements SensorEventListener {
}
}
public Float getHeading() {
public synchronized Float getHeading() {
// if (heading != null && lastValSin != avgValSin && System.currentTimeMillis() - lastHeadingCalcTime > 700) {
// avgValSin = lastValSin;
// avgValCos = lastValCos;
@ -641,9 +646,7 @@ public class OsmAndLocationProvider implements SensorEventListener {
public void pauseAllUpdates() {
stopLocationRequests();
SensorManager sensorMgr = (SensorManager) app.getSystemService(Context.SENSOR_SERVICE);
sensorMgr.unregisterListener(this);
sensorRegistered = false;
registerOrUnregisterCompassListener(false);
}
public static net.osmand.Location convertLocation(Location l, OsmandApplication app) {
@ -750,8 +753,6 @@ public class OsmAndLocationProvider implements SensorEventListener {
}
app.getSavingTrackHelper().updateLocation(location);
OsmandPlugin.updateLocationPlugins(location);
// 2. accessibility routing
navigationInfo.setLocation(location);
app.getRoutingHelper().updateLocation(location);
app.getWaypointHelper().locationChanged(location);
}
@ -782,10 +783,8 @@ public class OsmAndLocationProvider implements SensorEventListener {
app.getSavingTrackHelper().updateLocation(location);
OsmandPlugin.updateLocationPlugins(location);
}
// 2. accessibility routing
navigationInfo.setLocation(location);
// 3. routing
// 2. routing
net.osmand.Location updatedLocation = location;
if (routingHelper.isFollowingMode()) {
if (location == null || isPointAccurateForRouting(location)) {

View file

@ -798,6 +798,14 @@ public class OsmandSettings {
public final OsmandPreference<Boolean> DISABLE_WRONG_DIRECTION_RECALC =
new BooleanAccessibilityPreference("disable_wrong_direction_recalc", false).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> DIRECTION_AUDIO_FEEDBACK =
new BooleanAccessibilityPreference("direction_audio_feedback", false).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> DIRECTION_HAPTIC_FEEDBACK =
new BooleanAccessibilityPreference("direction_haptic_feedback", false).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> ZOOM_BY_TRACKBALL =
new BooleanAccessibilityPreference("zoom_by_trackball", false).makeGlobal();

View file

@ -9,6 +9,7 @@ import java.util.Formatter;
import java.util.List;
import java.util.Locale;
import net.osmand.access.AccessibilityAssistant;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.plus.OsmAndLocationProvider;
@ -31,8 +32,10 @@ import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.support.v7.app.ActionBar.OnNavigationListener;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
@ -66,9 +69,10 @@ public class SearchActivity extends TabActivity implements OsmAndLocationListene
private OsmandSettings settings;
List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>();
private boolean showOnlyOneTab;
private AccessibilityAssistant accessibilityAssistant;
private View spinnerView;
public interface SearchActivityChild {
public void locationUpdate(LatLon l);
@ -82,6 +86,7 @@ public class SearchActivity extends TabActivity implements OsmAndLocationListene
long t = System.currentTimeMillis();
setContentView(R.layout.tab_content);
settings = ((OsmandApplication) getApplication()).getSettings();
accessibilityAssistant = new AccessibilityAssistant(this);
showOnlyOneTab = getIntent() != null && getIntent().getBooleanExtra(SHOW_ONLY_ONE_TAB, false);
getSupportActionBar().setTitle("");
@ -196,8 +201,16 @@ public class SearchActivity extends TabActivity implements OsmAndLocationListene
getString(R.string.search_position_favorites),
getString(R.string.search_position_address)
}))
);
) {
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
View itemView = super.getDropDownView(position, convertView, parent);
itemView.setAccessibilityDelegate(accessibilityAssistant);
return itemView;
}
};
spinnerAdapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
spinnerView = LayoutInflater.from(spinnerAdapter.getContext()).inflate(R.layout.spinner_item, null);
getSupportActionBar().setListNavigationCallbacks(spinnerAdapter, new OnNavigationListener() {
@Override
@ -327,12 +340,18 @@ public class SearchActivity extends TabActivity implements OsmAndLocationListene
}
public void updateSearchPoint(LatLon searchPoint, String message, boolean showLoc){
spinnerAdapter.remove(spinnerAdapter.getItem(0));
String suffix = "";
String oldState = spinnerAdapter.getItem(0);
String newState = message;
if(showLoc && searchPoint != null){
suffix = formatLatLon(searchPoint);
newState += formatLatLon(searchPoint);
}
if (!oldState.equals(newState)) {
if (getSupportActionBar().getSelectedNavigationIndex() != 0) {
accessibilityAssistant.lockEvents();
}
spinnerAdapter.remove(oldState);
spinnerAdapter.insert(newState, 0);
}
spinnerAdapter.insert(message + suffix, 0);
this.searchPoint = searchPoint;
for(WeakReference<Fragment> ref : fragList) {
Fragment f = ref.get();
@ -343,6 +362,7 @@ public class SearchActivity extends TabActivity implements OsmAndLocationListene
}
}
getSupportActionBar().setSelectedNavigationItem(0);
accessibilityAssistant.unlockEvents();
}
public LatLon getSearchPoint() {

View file

@ -37,6 +37,7 @@ import android.widget.Toast;
import net.osmand.Location;
import net.osmand.ResultMatcher;
import net.osmand.access.AccessibilityAssistant;
import net.osmand.access.NavigationInfo;
import net.osmand.data.Amenity;
import net.osmand.data.LatLon;
@ -99,6 +100,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
private AmenityAdapter amenityAdapter;
private EditText searchFilter;
private View searchFilterLayout;
private NavigationInfo navigationInfo;
private boolean searchNearBy = false;
private net.osmand.Location location = null;
@ -106,6 +108,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
private Float heading = null;
private SearchAmenityTask currentSearchTask = null;
private AccessibilityAssistant accessibilityAssistant;
private OsmandApplication app;
private MenuItem showFilterItem;
@ -219,6 +222,8 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
setListAdapter(amenityAdapter);
searchFilterLayout = findViewById(R.id.SearchFilterLayout);
searchFilter = (EditText) findViewById(R.id.searchEditText);
accessibilityAssistant = new AccessibilityAssistant(this);
navigationInfo = new NavigationInfo(app);
searchFilter.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
@ -296,6 +301,9 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
searchFilter.setText(text);
searchFilterLayout.setVisibility(text.length() > 0 || isNameSearch() ? View.VISIBLE : View.GONE);
app.getLocationProvider().removeCompassListener(app.getLocationProvider().getNavigationInfo());
app.getLocationProvider().addCompassListener(this);
app.getLocationProvider().registerOrUnregisterCompassListener(true);
}
if (searchNearBy) {
@ -304,14 +312,6 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
app.getLocationProvider().resumeAllUpdates();
}
updateLocation(location);
// Freeze the direction arrows (reference is constant north) when Accessibility mode = ON, so screen can be read
// aloud without continuous updates
if (!app.accessibilityEnabled()) {
app.getLocationProvider().addCompassListener(this);
app.getLocationProvider().registerOrUnregisterCompassListener(true);
}
}
private void changeFilter(CharSequence s) {
@ -497,6 +497,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
amenityAdapter.notifyDataSetChanged();
lv.setSelectionFromTop(index, top);
updateButtonState();
navigationInfo.updateLocation(location);
}
}
@ -508,7 +509,9 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
float lastHeading = heading != null ? heading : 99;
heading = value;
if (heading != null && Math.abs(MapUtils.degreesDiff(lastHeading, heading)) > 5) {
accessibilityAssistant.lockEvents();
amenityAdapter.notifyDataSetChanged();
accessibilityAssistant.unlockEvents();
} else {
heading = lastHeading;
}
@ -523,19 +526,37 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
// msg.what = COMPASS_REFRESH_MSG_ID;
// uiHandler.sendMessageDelayed(msg, 100);
// }
final View selected = accessibilityAssistant.getFocusedView();
if (selected != null) {
try {
int position = getListView().getPositionForView(selected);
if (position != AdapterView.INVALID_POSITION) {
navigationInfo.updateTargetDirection(amenityAdapter.getItem(position).getLocation(), heading.floatValue());
}
} catch (Exception e) {
return;
}
}
}
@Override
protected void onPause() {
super.onPause();
app.getLocationProvider().pauseAllUpdates();
app.getLocationProvider().removeCompassListener(this);
app.getLocationProvider().addCompassListener(app.getLocationProvider().getNavigationInfo());
if (searchNearBy) {
app.getLocationProvider().pauseAllUpdates();
app.getLocationProvider().removeLocationListener(this);
}
if (!app.accessibilityEnabled()) {
app.getLocationProvider().removeCompassListener(this);
}
}
@Override
public void onDetachedFromWindow() {
accessibilityAssistant.forgetFocus();
}
@Override
public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
@ -771,6 +792,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
String poiType = OsmAndFormatter.getPoiStringWithoutType(amenity, app.getSettings().MAP_PREFERRED_LOCALE.get());
label.setText(poiType);
distanceText.setText(distance);
row.setAccessibilityDelegate(accessibilityAssistant);
return (row);
}
@ -826,7 +848,6 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
}
});
List<String> attributes = new ArrayList<String>();
NavigationInfo navigationInfo = app.getLocationProvider().getNavigationInfo();
String direction = navigationInfo.getDirectionString(amenity.getLocation(), heading);
if (direction != null) {
attributes.add(direction);

View file

@ -34,6 +34,7 @@ import android.widget.Toast;
import net.osmand.IProgress;
import net.osmand.PlatformUtil;
import net.osmand.access.AccessibilityAssistant;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.map.WorldRegion;
@ -101,6 +102,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
private BannerAndDownloadFreeVersion visibleBanner;
private ViewPager viewPager;
private AccessibilityAssistant accessibilityAssistant;
private String filter;
private String filterCat;
private String filterGroup;
@ -123,6 +125,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
if (!indexes.isDownloadedFromInternet) {
getDownloadThread().runReloadIndexFiles();
}
accessibilityAssistant = new AccessibilityAssistant(this);
setContentView(R.layout.download);
//noinspection ConstantConditions
@ -155,6 +158,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
viewPager.setAdapter(new TabActivity.OsmandFragmentPagerAdapter(getSupportFragmentManager(), mTabs));
mSlidingTabLayout.setViewPager(viewPager);
mSlidingTabLayout.setOnPageChangeListener(accessibilityAssistant);
viewPager.setCurrentItem(currentTab);
visibleBanner = new BannerAndDownloadFreeVersion(findViewById(R.id.mainLayout), this, true);
@ -172,6 +176,10 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
return downloadThread;
}
public AccessibilityAssistant getAccessibilityAssistant() {
return accessibilityAssistant;
}
@Override
public void onAttachFragment(Fragment fragment) {
fragSet.add(new WeakReference<Fragment>(fragment));
@ -246,6 +254,9 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
@Override
@UiThread
public void downloadInProgress() {
if (accessibilityAssistant.isUiUpdateDiscouraged())
return;
accessibilityAssistant.lockEvents();
visibleBanner.updateBannerInProgress();
showDownloadWorldMapIfNeeded();
for (WeakReference<Fragment> ref : fragSet) {
@ -254,6 +265,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
((DownloadEvents) f).downloadInProgress();
}
}
accessibilityAssistant.unlockEvents();
}

View file

@ -76,6 +76,7 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
groupId = "";
}
activity = (DownloadActivity) getActivity();
activity.getAccessibilityAssistant().registerPage(view, DownloadActivity.DOWNLOAD_TAB_NUMBER);
toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha));

View file

@ -83,7 +83,10 @@ public class ItemViewHolder {
descrTextView = (TextView) view.findViewById(R.id.description);
rightImageButton = (ImageView) view.findViewById(R.id.rightImageButton);
nameTextView = (TextView) view.findViewById(R.id.name);
view.setAccessibilityDelegate(context.getAccessibilityAssistant());
rightButton.setAccessibilityDelegate(context.getAccessibilityAssistant());
rightImageButton.setAccessibilityDelegate(context.getAccessibilityAssistant());
TypedValue typedValue = new TypedValue();
Resources.Theme theme = context.getTheme();

View file

@ -94,6 +94,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
View view = inflater.inflate(R.layout.local_index, container, false);
getDownloadActivity().setSupportProgressBarIndeterminateVisibility(false);
getDownloadActivity().getAccessibilityAssistant().registerPage(view, DownloadActivity.LOCAL_TAB_NUMBER);
ExpandableListView listView = (ExpandableListView) view.findViewById(android.R.id.list);
listAdapter = new LocalIndexesAdapter(getDownloadActivity());

View file

@ -41,7 +41,9 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.update_index_frament, container, false);
View view = inflater.inflate(R.layout.update_index_frament, container, false);
getMyActivity().getAccessibilityAssistant().registerPage(view, DownloadActivity.UPDATES_TAB_NUMBER);
return view;
}
@Override