added keyboard open/close event
* prevent updating location if keyboard is open...otherwise it will close immediately
This commit is contained in:
parent
c8085931eb
commit
fab4a7e586
@ -23,6 +23,7 @@ import android.content.res.Configuration;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class IITC_Mobile extends Activity {
|
public class IITC_Mobile extends Activity {
|
||||||
@ -35,6 +36,7 @@ public class IITC_Mobile extends Activity {
|
|||||||
private boolean user_loc = false;
|
private boolean user_loc = false;
|
||||||
private LocationManager loc_mngr = null;
|
private LocationManager loc_mngr = null;
|
||||||
private LocationListener loc_listener = null;
|
private LocationListener loc_listener = null;
|
||||||
|
private boolean keyboad_open = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -59,6 +61,21 @@ public class IITC_Mobile extends Activity {
|
|||||||
};
|
};
|
||||||
sharedPref.registerOnSharedPreferenceChangeListener(listener);
|
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() {
|
||||||
|
if ((iitc_view.getRootView().getHeight() - iitc_view.getHeight()) >
|
||||||
|
iitc_view.getRootView().getHeight()/3) {
|
||||||
|
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
|
// Acquire a reference to the system Location Manager
|
||||||
loc_mngr = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
|
loc_mngr = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
|
||||||
|
|
||||||
@ -254,9 +271,11 @@ public class IITC_Mobile extends Activity {
|
|||||||
// throw away all positions with accuracy > 100 meters
|
// throw away all positions with accuracy > 100 meters
|
||||||
// should avoid gps glitches
|
// should avoid gps glitches
|
||||||
if (loc.getAccuracy() < 100) {
|
if (loc.getAccuracy() < 100) {
|
||||||
|
if (keyboad_open == false) {
|
||||||
iitc_view.loadUrl("javascript: " +
|
iitc_view.loadUrl("javascript: " +
|
||||||
"window.plugin.userLocation.updateLocation( " +
|
"window.plugin.userLocation.updateLocation( " +
|
||||||
loc.getLatitude() + ", " + loc.getLongitude() + ");");
|
loc.getLatitude() + ", " + loc.getLongitude() + ");");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user