made sensor orientation optional due to high cpu load
This commit is contained in:
@ -85,6 +85,8 @@
|
|||||||
<string name="pref_plugins_title">Available plugins</string>
|
<string name="pref_plugins_title">Available plugins</string>
|
||||||
<string name="pref_user_loc">Display user location</string>
|
<string name="pref_user_loc">Display user location</string>
|
||||||
<string name="pref_user_loc_sum">Show users position on map</string>
|
<string name="pref_user_loc_sum">Show users position on map</string>
|
||||||
|
<string name="pref_user_loc_sensor">Use sensor orientation</string>
|
||||||
|
<string name="pref_user_loc_sensor_sum">Fancier but eats battery packs for breakfast</string>
|
||||||
<string name="pref_user_zoom">Show zoom control</string>
|
<string name="pref_user_zoom">Show zoom control</string>
|
||||||
<string name="pref_user_zoom_sum">Shows +/- buttons even on multitouch capable devices.</string>
|
<string name="pref_user_zoom_sum">Shows +/- buttons even on multitouch capable devices.</string>
|
||||||
<string name="pref_fullscreen">Hide in fullscreen mode</string>
|
<string name="pref_fullscreen">Hide in fullscreen mode</string>
|
||||||
|
@ -19,6 +19,12 @@
|
|||||||
android:key="pref_user_loc"
|
android:key="pref_user_loc"
|
||||||
android:summary="@string/pref_user_loc_sum"
|
android:summary="@string/pref_user_loc_sum"
|
||||||
android:title="@string/pref_user_loc"/>
|
android:title="@string/pref_user_loc"/>
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="pref_user_loc_sensor"
|
||||||
|
android:dependency="pref_user_loc"
|
||||||
|
android:summary="@string/pref_user_loc_sensor_sum"
|
||||||
|
android:title="@string/pref_user_loc_sensor"/>
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="pref_user_zoom"
|
android:key="pref_user_zoom"
|
||||||
|
@ -89,7 +89,8 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis
|
|||||||
mIitcWebView.updateFullscreenStatus();
|
mIitcWebView.updateFullscreenStatus();
|
||||||
|
|
||||||
mUserLocation = new IITC_UserLocation(this);
|
mUserLocation = new IITC_UserLocation(this);
|
||||||
mUserLocation.setEnabled(mSharedPrefs.getBoolean("pref_user_loc", false));
|
mUserLocation.setLocationEnabled(mSharedPrefs.getBoolean("pref_user_loc", false));
|
||||||
|
mUserLocation.setSensorEnabled(mSharedPrefs.getBoolean("pref_user_loc_sensor", true));
|
||||||
|
|
||||||
// pass ActionBar to helper because we deprecated getActionBar
|
// pass ActionBar to helper because we deprecated getActionBar
|
||||||
mNavigationHelper = new IITC_NavigationHelper(this, super.getActionBar());
|
mNavigationHelper = new IITC_NavigationHelper(this, super.getActionBar());
|
||||||
@ -112,7 +113,9 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis
|
|||||||
mDesktopMode = sharedPreferences.getBoolean("pref_force_desktop", false);
|
mDesktopMode = sharedPreferences.getBoolean("pref_force_desktop", false);
|
||||||
mNavigationHelper.onPrefChanged();
|
mNavigationHelper.onPrefChanged();
|
||||||
} else if (key.equals("pref_user_loc")) {
|
} else if (key.equals("pref_user_loc")) {
|
||||||
mUserLocation.setEnabled(sharedPreferences.getBoolean("pref_user_loc", false));
|
mUserLocation.setLocationEnabled(sharedPreferences.getBoolean("pref_user_loc", false));
|
||||||
|
} else if (key.equals("pref_user_loc_sensor")) {
|
||||||
|
mUserLocation.setSensorEnabled(sharedPreferences.getBoolean("pref_user_loc_sensor", true));
|
||||||
} else if (key.equals("pref_fullscreen")) {
|
} else if (key.equals("pref_fullscreen")) {
|
||||||
mIitcWebView.updateFullscreenStatus();
|
mIitcWebView.updateFullscreenStatus();
|
||||||
mNavigationHelper.onPrefChanged();
|
mNavigationHelper.onPrefChanged();
|
||||||
|
@ -12,7 +12,8 @@ import android.os.Bundle;
|
|||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
|
|
||||||
public class IITC_UserLocation implements LocationListener, SensorEventListener {
|
public class IITC_UserLocation implements LocationListener, SensorEventListener {
|
||||||
private boolean mEnabled = false;
|
private boolean mLocationEnabled = false;
|
||||||
|
private boolean mSensorEnabled = false;
|
||||||
private IITC_Mobile mIitc;
|
private IITC_Mobile mIitc;
|
||||||
private Location mLastLocation = null;
|
private Location mLastLocation = null;
|
||||||
private LocationManager mLocationManager;
|
private LocationManager mLocationManager;
|
||||||
@ -49,7 +50,7 @@ public class IITC_UserLocation implements LocationListener, SensorEventListener
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mSensorAccelerometer != null && mSensorMagnetometer != null) {
|
if (mSensorAccelerometer != null && mSensorMagnetometer != null && mSensorEnabled) {
|
||||||
mSensorManager.registerListener(this, mSensorAccelerometer, SensorManager.SENSOR_DELAY_UI);
|
mSensorManager.registerListener(this, mSensorAccelerometer, SensorManager.SENSOR_DELAY_UI);
|
||||||
mSensorManager.registerListener(this, mSensorMagnetometer, SensorManager.SENSOR_DELAY_UI);
|
mSensorManager.registerListener(this, mSensorMagnetometer, SensorManager.SENSOR_DELAY_UI);
|
||||||
}
|
}
|
||||||
@ -61,7 +62,7 @@ public class IITC_UserLocation implements LocationListener, SensorEventListener
|
|||||||
|
|
||||||
mLocationManager.removeUpdates(this);
|
mLocationManager.removeUpdates(this);
|
||||||
|
|
||||||
if (mSensorAccelerometer != null && mSensorMagnetometer != null) {
|
if (mSensorAccelerometer != null && mSensorMagnetometer != null && mSensorEnabled) {
|
||||||
mSensorManager.unregisterListener(this, mSensorAccelerometer);
|
mSensorManager.unregisterListener(this, mSensorAccelerometer);
|
||||||
mSensorManager.unregisterListener(this, mSensorMagnetometer);
|
mSensorManager.unregisterListener(this, mSensorMagnetometer);
|
||||||
}
|
}
|
||||||
@ -69,7 +70,7 @@ public class IITC_UserLocation implements LocationListener, SensorEventListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateListeners() {
|
private void updateListeners() {
|
||||||
if (mRunning && mEnabled)
|
if (mRunning && mLocationEnabled)
|
||||||
registerListeners();
|
registerListeners();
|
||||||
else
|
else
|
||||||
unregisterListeners();
|
unregisterListeners();
|
||||||
@ -102,10 +103,17 @@ public class IITC_UserLocation implements LocationListener, SensorEventListener
|
|||||||
updateListeners();
|
updateListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabled(boolean enabled) {
|
public void setLocationEnabled(boolean enabled) {
|
||||||
if (enabled == mEnabled) return;
|
if (enabled == mLocationEnabled) return;
|
||||||
|
|
||||||
mEnabled = enabled;
|
mLocationEnabled = enabled;
|
||||||
|
updateListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSensorEnabled(boolean enabled) {
|
||||||
|
if (enabled == mSensorEnabled) return;
|
||||||
|
|
||||||
|
mSensorEnabled = enabled;
|
||||||
updateListeners();
|
updateListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user