Disabled extended accessibility tricks on Android versions 4.0 and

higher where equivalent means are provided by system natively.
This commit is contained in:
Igor B. Poretsky 2013-03-01 05:09:01 +04:00
parent 6ea8d82000
commit b3e12061e0
6 changed files with 15 additions and 13 deletions

View file

@ -9,6 +9,7 @@ import net.osmand.plus.access.AccessibilityMode;
import net.osmand.plus.access.RelativeDirectionStyle;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SettingsActivity;
import android.os.Build;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
@ -110,8 +111,9 @@ public class AccessibilityPlugin extends OsmandPlugin {
R.string.scroll_map_by_gestures_descr));
cat.addPreference(activity.createCheckBoxPreference(settings.USE_SHORT_OBJECT_NAMES, R.string.use_short_object_names,
R.string.use_short_object_names_descr));
cat.addPreference(activity.createCheckBoxPreference(settings.ACCESSIBILITY_EXTENSIONS, R.string.accessibility_extensions,
R.string.accessibility_extensions));
if (Build.VERSION.SDK_INT < 14) // Build.VERSION_CODES.ICE_CREAM_SANDWICH
cat.addPreference(activity.createCheckBoxPreference(settings.ACCESSIBILITY_EXTENSIONS, R.string.accessibility_extensions,
R.string.accessibility_extensions));
}

View file

@ -34,14 +34,14 @@ public class AccessibleAlertBuilder extends Builder {
@Override
public Builder setMessage(CharSequence msg) {
if (((OsmandApplication) context.getApplicationContext()).getSettings().ACCESSIBILITY_EXTENSIONS.get())
if (((OsmandApplication) context.getApplicationContext()).getInternalAPI().accessibilityExtensions())
return setView(TextMessage.makeView(context, msg, R.layout.alert));
return super.setMessage(msg);
}
@Override
public Builder setMessage(int msgid) {
if (((OsmandApplication) context.getApplicationContext()).getSettings().ACCESSIBILITY_EXTENSIONS.get())
if (((OsmandApplication) context.getApplicationContext()).getInternalAPI().accessibilityExtensions())
return setView(TextMessage.makeView(context, msgid, R.layout.alert));
return super.setMessage(msgid);
}

View file

@ -43,7 +43,7 @@ public class AccessibleContent extends ArrayList<View> {
}
public boolean dispatchTouchEvent(MotionEvent event, Callback callback) {
if (((OsmandApplication) ctx.getApplicationContext()).getSettings().ACCESSIBILITY_EXTENSIONS.get()) {
if (((OsmandApplication) ctx.getApplicationContext()).getInternalAPI().accessibilityExtensions()) {
int action = event.getAction();
View newTouch;
switch (action) {

View file

@ -36,15 +36,15 @@ public class ExplorableTextView extends TextView {
}
public OsmandSettings getSettings(){
return ((OsmandApplication) getContext().getApplicationContext()).getSettings();
private boolean accessibilityExtensions() {
return ((OsmandApplication) getContext().getApplicationContext()).getInternalAPI().accessibilityExtensions();
}
// Overridden callback methods to provide accessible exploration means.
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
if (!getSettings().ACCESSIBILITY_EXTENSIONS.get())
if (!accessibilityExtensions())
return super.dispatchPopulateAccessibilityEvent(event);
cursorTrackingEnabled = false;
boolean result = super.dispatchPopulateAccessibilityEvent(event);
@ -65,7 +65,7 @@ public class ExplorableTextView extends TextView {
@Override
protected MovementMethod getDefaultMovementMethod() {
if (getSettings().ACCESSIBILITY_EXTENSIONS.get())
if (accessibilityExtensions())
return ArrowKeyMovementMethod.getInstance();
return super.getDefaultMovementMethod();
}
@ -73,7 +73,7 @@ public class ExplorableTextView extends TextView {
@Override
protected void onTextChanged(CharSequence text, int start, int before, int after) {
super.onTextChanged(text, start, before, after);
if (getSettings().ACCESSIBILITY_EXTENSIONS.get() && !isFocused()) {
if (accessibilityExtensions() && !isFocused()) {
selectionLength = Math.min(text.length(), AccessibilityEvent.MAX_TEXT_LENGTH);
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED);
}
@ -82,7 +82,7 @@ public class ExplorableTextView extends TextView {
@Override
protected void onSelectionChanged(int start, int end) {
super.onSelectionChanged(start, end);
if (getSettings().ACCESSIBILITY_EXTENSIONS.get() && cursorTrackingEnabled && isFocused()) {
if (accessibilityExtensions() && cursorTrackingEnabled && isFocused()) {
if (end >= getText().length()) {
cursor = getText().length();
} else if (cursor != end) {

View file

@ -111,7 +111,7 @@ public class TipsAndTricksActivity {
dlg.setContentView(R.layout.tips_and_tricks);
dlg.getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
final TextView tipDescription = (TextView) dlg.findViewById(R.id.TipDescription);
if (!((OsmandApplication)ctx.getApplicationContext()).getSettings().ACCESSIBILITY_EXTENSIONS.get())
if (!((OsmandApplication)ctx.getApplicationContext()).getInternalAPI().accessibilityExtensions())
tipDescription.setMovementMethod(ScrollingMovementMethod.getInstance());
int nextInd = 0;
final TIntArrayList toShow = new TIntArrayList();

View file

@ -60,7 +60,7 @@ public class InternalOsmAndAPIImpl implements InternalOsmAndAPI {
}
public boolean accessibilityExtensions() {
return app.getSettings().ACCESSIBILITY_EXTENSIONS.get();
return (Build.VERSION.SDK_INT < 14) ? app.getSettings().ACCESSIBILITY_EXTENSIONS.get() : false;
}
@Override