Merge pull request #11360 from osmandapp/Fix_10997
Fix external input device
This commit is contained in:
commit
4ef66d93a7
2 changed files with 26 additions and 9 deletions
|
@ -53,7 +53,11 @@ public class MapActivityKeyListener implements KeyEvent.Callback {
|
|||
uiHandler.sendMessageDelayed(msg, LONG_KEYPRESS_DELAY);
|
||||
}
|
||||
return true;
|
||||
} else if (settings.USE_VOLUME_BUTTONS_AS_ZOOM.get()) {
|
||||
} else if (mapScrollHelper.isAvailableKeyCode(keyCode)) {
|
||||
return mapScrollHelper.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
if (settings.USE_VOLUME_BUTTONS_AS_ZOOM.get()) {
|
||||
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
|
||||
mapActivity.changeZoom(-1);
|
||||
return true;
|
||||
|
@ -61,10 +65,6 @@ public class MapActivityKeyListener implements KeyEvent.Callback {
|
|||
mapActivity.changeZoom(1);
|
||||
return true;
|
||||
}
|
||||
} else if (settings.EXTERNAL_INPUT_DEVICE.get() != NO_EXTERNAL_DEVICE) {
|
||||
return true;
|
||||
} else if (mapScrollHelper.isScrollingDirectionKeyCode(keyCode)) {
|
||||
return mapScrollHelper.onKeyDown(keyCode, event);
|
||||
}
|
||||
return app.getAidlApi().onKeyEvent(event);
|
||||
}
|
||||
|
@ -94,6 +94,8 @@ public class MapActivityKeyListener implements KeyEvent.Callback {
|
|||
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
|
||||
} else if (keyCode == KeyEvent.KEYCODE_D) {
|
||||
mapActivity.getMapViewTrackingUtilities().switchRotateMapMode();
|
||||
} else if (mapScrollHelper.isAvailableKeyCode(keyCode)) {
|
||||
return mapScrollHelper.onKeyUp(keyCode, event);
|
||||
} else if (settings.EXTERNAL_INPUT_DEVICE.get() == PARROT_EXTERNAL_DEVICE) {
|
||||
// Parrot device has only dpad left and right
|
||||
if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
|
||||
|
@ -118,8 +120,6 @@ public class MapActivityKeyListener implements KeyEvent.Callback {
|
|||
mapActivity.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
} else if (mapScrollHelper.isScrollingDirectionKeyCode(keyCode)) {
|
||||
return mapScrollHelper.onKeyUp(keyCode, event);
|
||||
} else if (settings.EXTERNAL_INPUT_DEVICE.get() == GENERIC_EXTERNAL_DEVICE) {
|
||||
if (keyCode == KeyEvent.KEYCODE_MINUS) {
|
||||
mapActivity.changeZoom(-1);
|
||||
|
|
|
@ -3,12 +3,16 @@ package net.osmand.plus.helpers;
|
|||
import android.view.KeyEvent;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.osmand.plus.settings.backend.OsmandSettings.PARROT_EXTERNAL_DEVICE;
|
||||
import static net.osmand.plus.settings.backend.OsmandSettings.WUNDERLINQ_EXTERNAL_DEVICE;
|
||||
|
||||
public class ScrollHelper {
|
||||
|
||||
private final static int LONG_PRESS_TIME_MS = 250;
|
||||
|
@ -135,8 +139,21 @@ public class ScrollHelper {
|
|||
this.onScrollEventListener = onScrollEventListener;
|
||||
}
|
||||
|
||||
public boolean isScrollingDirectionKeyCode(int keyCode) {
|
||||
return availableDirections.containsKey(keyCode);
|
||||
public boolean isAvailableKeyCode(int keyCode) {
|
||||
return availableDirections.containsKey(keyCode)
|
||||
&& !isOverrideBySelectedExternalDevice(keyCode);
|
||||
}
|
||||
|
||||
public boolean isOverrideBySelectedExternalDevice(int keyCode) {
|
||||
OsmandSettings settings = app.getSettings();
|
||||
|
||||
if (settings.EXTERNAL_INPUT_DEVICE.get() == PARROT_EXTERNAL_DEVICE) {
|
||||
return keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT;
|
||||
|
||||
} else if (settings.EXTERNAL_INPUT_DEVICE.get() == WUNDERLINQ_EXTERNAL_DEVICE) {
|
||||
return keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<Direction> getLastDirections() {
|
||||
|
|
Loading…
Reference in a new issue