Change sensor setup logic.
Now it activates only if enable in the settings and the screen is off while navigation. Remove router checkbox from preferences
This commit is contained in:
parent
794a76ae99
commit
4716f94500
5 changed files with 28 additions and 31 deletions
|
@ -74,16 +74,15 @@
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="turn_screen_on"
|
android:key="turn_screen_on"
|
||||||
|
android:layout="@layout/preference_category_summary"
|
||||||
|
android:summary="@string/wake_on_voice_descr"
|
||||||
android:title="@string/wake_on_voice">
|
android:title="@string/wake_on_voice">
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="turn_screen_on_time_int"
|
android:key="turn_screen_on_time_int"
|
||||||
android:summary="@string/turn_screen_on_time_descr"
|
android:summary="@string/turn_screen_on_time_descr"
|
||||||
android:title="@string/shared_string_time"/>
|
android:title="@string/shared_string_time"/>
|
||||||
<CheckBoxPreference
|
|
||||||
android:key="turn_screen_on_router"
|
|
||||||
android:summary="@string/wake_on_voice_descr"
|
|
||||||
android:title="@string/turn_screen_on_router"/>
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="turn_screen_on_sensor"
|
android:key="turn_screen_on_sensor"
|
||||||
android:summary="@string/turn_screen_on_sensor_descr"
|
android:summary="@string/turn_screen_on_sensor_descr"
|
||||||
|
|
|
@ -1387,17 +1387,21 @@ public class OsmandSettings {
|
||||||
KEEP_INFORMING.setModeDefaultValue(ApplicationMode.PEDESTRIAN, 0);
|
KEEP_INFORMING.setModeDefaultValue(ApplicationMode.PEDESTRIAN, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final CommonPreference<Integer> TURN_SCREEN_ON_TIME_INT = new IntPreference("turn_screen_on_time_int", 0).makeGlobal();
|
public final CommonPreference<Integer> TURN_SCREEN_ON_TIME_INT = new IntPreference("turn_screen_on_time_int", 0).makeProfile();
|
||||||
|
|
||||||
public final CommonPreference<Boolean> TURN_SCREEN_ON_ROUTER = new BooleanPreference("turn_screen_on_router", false).makeProfile();
|
|
||||||
|
|
||||||
{
|
{
|
||||||
TURN_SCREEN_ON_ROUTER.setModeDefaultValue(ApplicationMode.CAR, false);
|
TURN_SCREEN_ON_TIME_INT.setModeDefaultValue(ApplicationMode.CAR, 0);
|
||||||
TURN_SCREEN_ON_ROUTER.setModeDefaultValue(ApplicationMode.BICYCLE, false);
|
TURN_SCREEN_ON_TIME_INT.setModeDefaultValue(ApplicationMode.BICYCLE, 0);
|
||||||
TURN_SCREEN_ON_ROUTER.setModeDefaultValue(ApplicationMode.PEDESTRIAN, false);
|
TURN_SCREEN_ON_TIME_INT.setModeDefaultValue(ApplicationMode.PEDESTRIAN, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final CommonPreference<Boolean> TURN_SCREEN_ON_SENSOR = new BooleanPreference("turn_screen_on_sensor", false).makeGlobal();
|
public final CommonPreference<Boolean> TURN_SCREEN_ON_SENSOR = new BooleanPreference("turn_screen_on_sensor", false).makeProfile();
|
||||||
|
|
||||||
|
{
|
||||||
|
TURN_SCREEN_ON_SENSOR.setModeDefaultValue(ApplicationMode.CAR, false);
|
||||||
|
TURN_SCREEN_ON_SENSOR.setModeDefaultValue(ApplicationMode.BICYCLE, false);
|
||||||
|
TURN_SCREEN_ON_SENSOR.setModeDefaultValue(ApplicationMode.PEDESTRIAN, false);
|
||||||
|
}
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
// try without AUTO_FOLLOW_ROUTE_NAV (see forum discussion 'Simplify our navigation preference menu')
|
// try without AUTO_FOLLOW_ROUTE_NAV (see forum discussion 'Simplify our navigation preference menu')
|
||||||
|
|
|
@ -48,7 +48,6 @@ import net.osmand.SecondSplashScreenFragment;
|
||||||
import net.osmand.StateChangedListener;
|
import net.osmand.StateChangedListener;
|
||||||
import net.osmand.ValueHolder;
|
import net.osmand.ValueHolder;
|
||||||
import net.osmand.access.MapAccessibilityActions;
|
import net.osmand.access.MapAccessibilityActions;
|
||||||
import net.osmand.aidl.OsmandAidlApi;
|
|
||||||
import net.osmand.aidl.OsmandAidlApi.AMapPointUpdateListener;
|
import net.osmand.aidl.OsmandAidlApi.AMapPointUpdateListener;
|
||||||
import net.osmand.aidl.map.ALatLon;
|
import net.osmand.aidl.map.ALatLon;
|
||||||
import net.osmand.aidl.maplayer.point.AMapPoint;
|
import net.osmand.aidl.maplayer.point.AMapPoint;
|
||||||
|
@ -88,7 +87,6 @@ import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
||||||
import net.osmand.plus.dialogs.CrashBottomSheetDialogFragment;
|
import net.osmand.plus.dialogs.CrashBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.dialogs.RateUsBottomSheetDialogFragment;
|
import net.osmand.plus.dialogs.RateUsBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.dialogs.SendAnalyticsBottomSheetDialogFragment;
|
import net.osmand.plus.dialogs.SendAnalyticsBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.dialogs.RateUsBottomSheetDialog;
|
|
||||||
import net.osmand.plus.dialogs.WhatsNewDialogFragment;
|
import net.osmand.plus.dialogs.WhatsNewDialogFragment;
|
||||||
import net.osmand.plus.dialogs.XMasDialogFragment;
|
import net.osmand.plus.dialogs.XMasDialogFragment;
|
||||||
import net.osmand.plus.download.DownloadActivity;
|
import net.osmand.plus.download.DownloadActivity;
|
||||||
|
@ -1295,6 +1293,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
stopped = false;
|
stopped = false;
|
||||||
|
lockHelper.setSensor(false); //switch off sensor when activity active
|
||||||
getMyApplication().getNotificationHelper().showNotifications();
|
getMyApplication().getNotificationHelper().showNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1313,6 +1312,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
onPauseActivity();
|
onPauseActivity();
|
||||||
}
|
}
|
||||||
stopped = true;
|
stopped = true;
|
||||||
|
lockHelper.refreshSensorSettings();
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1415,7 +1415,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
getMapView().refreshMap(true);
|
getMapView().refreshMap(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
lockHelper.refreshProfilesSettings();
|
lockHelper.refreshRouterSettings();
|
||||||
getMapView().refreshMap(true);
|
getMapView().refreshMap(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -193,7 +193,6 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
+ getString(R.string.int_seconds);
|
+ getString(R.string.int_seconds);
|
||||||
}
|
}
|
||||||
registerListPreference(settings.TURN_SCREEN_ON_TIME_INT, screen, screenPowerSaveNames, screenPowerSaveValues);
|
registerListPreference(settings.TURN_SCREEN_ON_TIME_INT, screen, screenPowerSaveNames, screenPowerSaveValues);
|
||||||
registerBooleanPreference(settings.TURN_SCREEN_ON_ROUTER, screen);
|
|
||||||
registerBooleanPreference(settings.TURN_SCREEN_ON_SENSOR, screen);
|
registerBooleanPreference(settings.TURN_SCREEN_ON_SENSOR, screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,12 +395,9 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
super.onPreferenceChange(preference, newValue);
|
super.onPreferenceChange(preference, newValue);
|
||||||
if (id.equals(settings.TURN_SCREEN_ON_ROUTER.getId())) {
|
if (id.equals(settings.TURN_SCREEN_ON_TIME_INT.getId())) {
|
||||||
boolean isRoutingListnerEnabled = Boolean.valueOf(newValue.toString());
|
boolean isRoutingListenerEnabled = Integer.valueOf(newValue.toString()) > 0;
|
||||||
getMyApplication().getLockHelper().setVoiceRouterListener(isRoutingListnerEnabled);
|
getMyApplication().getLockHelper().setVoiceRouterListener(isRoutingListenerEnabled);
|
||||||
} else if (id.equals(settings.TURN_SCREEN_ON_SENSOR.getId())) {
|
|
||||||
boolean isSensorEnabled = Boolean.valueOf(newValue.toString());
|
|
||||||
getMyApplication().getLockHelper().setSensor(isSensorEnabled);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import android.hardware.SensorManager;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
@ -59,8 +58,6 @@ public class LockHelper implements SensorEventListener {
|
||||||
unlockEvent();
|
unlockEvent();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
refreshGlobalSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void releaseWakeLocks() {
|
private void releaseWakeLocks() {
|
||||||
|
@ -98,10 +95,10 @@ public class LockHelper implements SensorEventListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unlockEvent() {
|
public void unlockEvent() {
|
||||||
int screenPowerSave = app.getSettings().TURN_SCREEN_ON_TIME_INT.get();
|
int unlockTime = app.getSettings().TURN_SCREEN_ON_TIME_INT.get();
|
||||||
|
|
||||||
if (screenPowerSave > 0) {
|
if (unlockTime > 0) {
|
||||||
timedUnlock(screenPowerSave * 1000L);
|
timedUnlock(unlockTime * 1000L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,13 +133,14 @@ public class LockHelper implements SensorEventListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshProfilesSettings() {
|
public void refreshRouterSettings() {
|
||||||
boolean isVRListenerEnabled = settings.TURN_SCREEN_ON_ROUTER.get();
|
boolean isVRListenerEnabled = settings.TURN_SCREEN_ON_TIME_INT.get() > 0;
|
||||||
setVoiceRouterListener(isVRListenerEnabled);
|
setVoiceRouterListener(isVRListenerEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshGlobalSettings() {
|
public void refreshSensorSettings() {
|
||||||
boolean isSensorEnabled = settings.TURN_SCREEN_ON_SENSOR.get();
|
boolean isSensorEnabled = settings.TURN_SCREEN_ON_SENSOR.get()
|
||||||
|
&& app.getRoutingHelper().isFollowingMode();
|
||||||
setSensor(isSensorEnabled);
|
setSensor(isSensorEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue