diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java index d7e2a47f..0763caa0 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java @@ -20,11 +20,9 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.res.Configuration; -import android.graphics.Rect; import android.util.Log; import android.view.Menu; import android.view.MenuItem; -import android.view.ViewTreeObserver.OnGlobalLayoutListener; import android.view.WindowManager; import android.widget.Toast; @@ -37,7 +35,6 @@ public class IITC_Mobile extends Activity { private boolean user_loc = false; private LocationManager loc_mngr = null; private LocationListener loc_listener = null; - private boolean keyboad_open = false; private boolean fullscreen_mode = false; private boolean fullscreen_actionbar = false; private ActionBar actionBar; @@ -81,30 +78,6 @@ public class IITC_Mobile extends Activity { }; sharedPref.registerOnSharedPreferenceChangeListener(listener); - // we need this one to prevent location updates to javascript when - // keyboard is open - // it closes on updates - iitc_view.getViewTreeObserver().addOnGlobalLayoutListener( - new OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - Rect r = new Rect(); - // r will be populated with the coordinates of your view - // that area still visible. - iitc_view.getWindowVisibleDisplayFrame(r); - - int screenHeight = iitc_view.getRootView().getHeight(); - int heightDiff = screenHeight - (r.bottom - r.top); - boolean visible = heightDiff > screenHeight / 3; - if (visible == true) { - Log.d("iitcm", "Open Keyboard..."); - IITC_Mobile.this.keyboad_open = true; - } else { - Log.d("iitcm", "Close Keyboard..."); - IITC_Mobile.this.keyboad_open = false; - } - } - }); // Acquire a reference to the system Location Manager loc_mngr = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); @@ -359,11 +332,9 @@ public class IITC_Mobile extends Activity { // throw away all positions with accuracy > 100 meters // should avoid gps glitches if (loc.getAccuracy() < 100) { - if (keyboad_open == false) { - iitc_view.loadUrl("javascript: " - + "window.plugin.userLocation.updateLocation( " - + loc.getLatitude() + ", " + loc.getLongitude() + ");"); - } + iitc_view.loadUrl("javascript: " + + "window.plugin.userLocation.updateLocation( " + + loc.getLatitude() + ", " + loc.getLongitude() + ");"); } } diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java index ba63e570..b10f12de 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java @@ -73,6 +73,13 @@ public class IITC_WebView extends WebView { @Override public void loadUrl(String url) { + // if in edit text mode, don't load javascript otherwise the keyboard closes. + HitTestResult testResult = this.getHitTestResult(); + if (url.startsWith("javascript:") && testResult != null && testResult.getType() == HitTestResult.EDIT_TEXT_TYPE) + { + Log.d("iitcm", "in insert mode. do not load script."); + return; + } if (!url.startsWith("javascript:")) { // force https if enabled in settings SharedPreferences sharedPref = PreferenceManager