handle edit-text events correctly
This commit is contained in:
@ -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() + ");");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user