added persistent zoom level option ( see https://plus.google.com/112875802603603993788/posts/K5zLYyAWQkE )
This commit is contained in:
parent
7c85e7247b
commit
4781ea9627
@ -75,7 +75,7 @@ window.plugin.userLocation.onZoomEnd = function() {
|
||||
}
|
||||
};
|
||||
|
||||
window.plugin.userLocation.locate = function(lat, lng, accuracy) {
|
||||
window.plugin.userLocation.locate = function(lat, lng, accuracy, persistentZoom) {
|
||||
if(window.plugin.userLocation.follow) {
|
||||
window.plugin.userLocation.follow = false;
|
||||
if(typeof android !== 'undefined' && android && android.setFollowMode)
|
||||
@ -94,7 +94,7 @@ window.plugin.userLocation.locate = function(lat, lng, accuracy) {
|
||||
|
||||
// an extremely close view is pretty pointless (especially with maps that support zoom level 20+)
|
||||
// so limit to 17 (enough to see all portals)
|
||||
zoom = Math.min(zoom,17);
|
||||
zoom = (persistentZoom) ? map.getZoom() : Math.min(zoom,17);
|
||||
|
||||
if(window.map.getCenter().distanceTo(latlng) < 10) {
|
||||
window.plugin.userLocation.follow = true;
|
||||
|
@ -105,6 +105,8 @@
|
||||
<string name="pref_plugins_sum">Plugins extend/modify the IITC experience. Most plugins known from desktop IITC can be found here.</string>
|
||||
<string name="pref_plugins_title">Available plugins</string>
|
||||
<string name="pref_user_location">Display user location on map</string>
|
||||
<string name="pref_persistent_zoom">Persistent zoom level</string>
|
||||
<string name="pref_persistent_zoom_sum">Don\'t change zoom level when locate button is pressed</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_fullscreen">Hide in fullscreen mode</string>
|
||||
|
@ -61,6 +61,11 @@
|
||||
android:key="pref_press_twice_to_exit"
|
||||
android:summary="@string/pref_press_twice_to_exit_sum"
|
||||
android:title="@string/pref_press_twice_to_exit"/>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="pref_persistent_zoom"
|
||||
android:summary="@string/pref_persistent_zoom_sum"
|
||||
android:title="@string/pref_persistent_zoom"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:key="pref_mics"
|
||||
|
@ -83,6 +83,7 @@ public class IITC_Mobile extends Activity
|
||||
private boolean mReloadNeeded = false;
|
||||
private boolean mIsLoading = true;
|
||||
private boolean mShowMapInDebug = false;
|
||||
private boolean mPersistentZoom = false;
|
||||
private final Stack<String> mDialogStack = new Stack<String>();
|
||||
private String mPermalink = null;
|
||||
private String mSearchTerm = null;
|
||||
@ -143,6 +144,8 @@ public class IITC_Mobile extends Activity
|
||||
final String[] menuDefaults = getResources().getStringArray(R.array.pref_android_menu_default);
|
||||
mAdvancedMenu = mSharedPrefs.getStringSet("pref_android_menu", new HashSet<String>(Arrays.asList(menuDefaults)));
|
||||
|
||||
mPersistentZoom = mSharedPrefs.getBoolean("pref_persistent_zoom", false);
|
||||
|
||||
// get fullscreen status from settings
|
||||
mIitcWebView.updateFullscreenStatus();
|
||||
|
||||
@ -180,6 +183,9 @@ public class IITC_Mobile extends Activity
|
||||
if (mUserLocation.setLocationMode(mode))
|
||||
mReloadNeeded = true;
|
||||
return;
|
||||
} else if (key.equals("pref_persistent_zoom")) {
|
||||
mPersistentZoom = mSharedPrefs.getBoolean("pref_persistent_zoom", false);
|
||||
return;
|
||||
} else if (key.equals("pref_fullscreen")) {
|
||||
mIitcWebView.updateFullscreenStatus();
|
||||
mNavigationHelper.onPrefChanged();
|
||||
@ -570,10 +576,11 @@ public class IITC_Mobile extends Activity
|
||||
|
||||
if (mUserLocation.hasCurrentLocation()) {
|
||||
// if gps location is displayed we can use a better location without any costs
|
||||
mUserLocation.locate();
|
||||
mUserLocation.locate(mPersistentZoom);
|
||||
} else {
|
||||
// get location from network by default
|
||||
mIitcWebView.loadUrl("javascript: window.map.locate({setView : true});");
|
||||
mIitcWebView.loadUrl("javascript: window.map.locate({setView : true" +
|
||||
(mPersistentZoom ? ", maxZoom : map.getZoom()" : "") + "});");
|
||||
}
|
||||
return true;
|
||||
case R.id.action_settings: // start settings activity
|
||||
|
@ -100,7 +100,7 @@ public class IITC_UserLocation implements LocationListener, SensorEventListener
|
||||
return mFollowing;
|
||||
}
|
||||
|
||||
public void locate() {
|
||||
public void locate(final boolean persistentZoom) {
|
||||
// do not touch the javascript while iitc boots
|
||||
if (mIitc.isLoading()) return;
|
||||
|
||||
@ -109,7 +109,8 @@ public class IITC_UserLocation implements LocationListener, SensorEventListener
|
||||
|
||||
mIitc.getWebView().loadJS("if(window.plugin && window.plugin.userLocation)"
|
||||
+ "window.plugin.userLocation.locate("
|
||||
+ location.getLatitude() + ", " + location.getLongitude() + ", " + location.getAccuracy() + ");");
|
||||
+ location.getLatitude() + ", " + location.getLongitude() + ", "
|
||||
+ location.getAccuracy() + ", " + persistentZoom + ");");
|
||||
}
|
||||
|
||||
public void onStart() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user