Merge pull request #7171 from kconger/master

Add External Input Device support
This commit is contained in:
vshcherb 2019-07-07 14:26:10 +02:00 committed by GitHub
commit ccbd9b0d3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 17 deletions

View file

@ -1920,6 +1920,12 @@
<string name="contribution_activity">Install version</string>
<string name="choose_osmand_theme_descr">Choose how the app looks.</string>
<string name="choose_osmand_theme">App theme</string>
<string name="external_input_device">External input devices</string>
<string name="external_input_device_descr">Select a device such as a generic keyboard or WunderLINQ for external controls.</string>
<string name="sett_no_ext_input">None</string>
<string name="sett_generic_ext_input">Generic Keyboard</string>
<string name="sett_wunderlinq_ext_input">WunderLINQ</string>
<string name="sett_parrot_ext_input">Parrot</string>
<string name="accessibility_options">Accessibility options</string>
<string name="select_address_activity">Select address</string>
<string name="favourites_list_activity">Select Favorite</string>
@ -2434,8 +2440,6 @@
<string name="i_am_here">I am here</string>
<string name="zoom_by_trackball_descr">Change map zooming by horizontal trackball movement.</string>
<string name="zoom_by_trackball">Use trackball for zoom control</string>
<string name="zoom_by_wunderlinq_descr">Change map zooming by scrolling the wheel up and down. Escape returns you to the WunderLINQ App.</string>
<string name="zoom_by_wunderlinq">Use WunderLINQ for control</string>
<string name="accessibility_preferences_descr">Accessibility related preferences.</string>
<string name="arrival_distance_factor_early">Early</string>
<string name="arrival_distance_factor_normally">Normal</string>

View file

@ -15,6 +15,7 @@
<PreferenceCategory android:title="@string/misc_pref_title" android:key="misc">
<ListPreference android:key="osmand_theme" android:title="@string/choose_osmand_theme" android:summary="@string/choose_osmand_theme_descr"></ListPreference>
<ListPreference android:key="external_input_device" android:title="@string/external_input_device" android:summary="@string/external_input_device_descr"></ListPreference>
</PreferenceCategory>
<PreferenceCategory android:title="@string/settings_privacy">
<PreferenceScreen android:title="@string/proxy_pref_title" android:description="@string/proxy_pref_descr" android:key="proxy">

View file

@ -101,10 +101,6 @@ public class SettingsAccessibilityActivity extends SettingsBaseActivity {
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));
cat.addPreference(createCheckBoxPreference(settings.ZOOM_BY_WUNDERLINQ, R.string.zoom_by_wunderlinq,
R.string.zoom_by_wunderlinq_descr));
}

View file

@ -1050,15 +1050,6 @@ public class OsmandSettings {
// 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();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> ZOOM_BY_WUNDERLINQ =
new BooleanAccessibilityPreference("zoom_by_wunderlinq", false).makeGlobal();
// magnetic field doesn'torkmost of the time on some phones
public final OsmandPreference<Boolean> USE_MAGNETIC_FIELD_SENSOR_COMPASS = new BooleanPreference("use_magnetic_field_sensor_compass", false).makeGlobal().cache();
@ -1507,6 +1498,9 @@ public class OsmandSettings {
public final OsmandPreference<Boolean> ANIMATE_MY_LOCATION = new BooleanPreference("animate_my_location", true).makeGlobal().cache();
public final OsmandPreference<Integer> EXTERNAL_INPUT_DEVICE =
new IntPreference("external_input_device", 0).makeGlobal();
public final OsmandPreference<Boolean> ROUTE_MAP_MARKERS_START_MY_LOC = new BooleanPreference("route_map_markers_start_my_loc", false).makeGlobal().cache();
public final OsmandPreference<Boolean> ROUTE_MAP_MARKERS_ROUND_TRIP = new BooleanPreference("route_map_markers_round_trip", false).makeGlobal().cache();
@ -2752,6 +2746,10 @@ public class OsmandSettings {
public static final int OSMAND_DARK_THEME = 0;
public static final int OSMAND_LIGHT_THEME = 1;
public static final int NO_EXTERNAL_DEVICE = 0;
public static final int GENERIC_EXTERNAL_DEVICE = 1;
public static final int WUNDERLINQ_EXTERNAL_DEVICE = 2;
public static final int PARROT_EXTERNAL_DEVICE = 3;
public final CommonPreference<Integer> SEARCH_TAB =
new IntPreference("SEARCH_TAB", 0).makeGlobal().cache();

View file

@ -1486,7 +1486,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
// repeat count 0 doesn't work for samsung, 1 doesn't work for lg
toggleDrawer();
return true;
} else if (settings.ZOOM_BY_TRACKBALL.get()) {
} else if (settings.EXTERNAL_INPUT_DEVICE.get() == 3) {
// Parrot device has only dpad left and right
if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
changeZoom(-1);
@ -1495,7 +1495,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
changeZoom(1);
return true;
}
} else if (settings.ZOOM_BY_WUNDERLINQ.get()) {
} else if (settings.EXTERNAL_INPUT_DEVICE.get() == 2) {
// WunderLINQ device, motorcycle smart phone control
if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
changeZoom(-1);
@ -1510,6 +1510,14 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
startActivity(intent);
return true;
}
} else if (settings.EXTERNAL_INPUT_DEVICE.get() == 1) {
if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
changeZoom(-1);
return true;
} else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
changeZoom(1);
return true;
}
} else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT
|| keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_DPAD_UP) {
int dx = keyCode == KeyEvent.KEYCODE_DPAD_RIGHT ? 15 : (keyCode == KeyEvent.KEYCODE_DPAD_LEFT ? -15 : 0);

View file

@ -498,6 +498,11 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
new String[]{getString(R.string.dark_theme), getString(R.string.light_theme)}, new Integer[]{OsmandSettings.OSMAND_DARK_THEME,
OsmandSettings.OSMAND_LIGHT_THEME});
registerListPreference(
settings.EXTERNAL_INPUT_DEVICE, misc,
new String[]{getString(R.string.sett_no_ext_input), getString(R.string.sett_generic_ext_input), getString(R.string.sett_wunderlinq_ext_input), getString(R.string.sett_parrot_ext_input)}, new Integer[]{OsmandSettings.NO_EXTERNAL_DEVICE,
OsmandSettings.GENERIC_EXTERNAL_DEVICE, OsmandSettings.WUNDERLINQ_EXTERNAL_DEVICE, OsmandSettings.PARROT_EXTERNAL_DEVICE});
misc.addPreference(createCheckBoxPreference(settings.USE_KALMAN_FILTER_FOR_COMPASS, R.string.use_kalman_filter_compass, R.string.use_kalman_filter_compass_descr));
misc.addPreference(createCheckBoxPreference(settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS, R.string.use_magnetic_sensor, R.string.use_magnetic_sensor_descr));
misc.addPreference(createCheckBoxPreference(settings.DO_NOT_USE_ANIMATIONS, R.string.do_not_use_animations, R.string.do_not_use_animations_descr));