- added long click support to disable/enabled all layers
- some refactoring
This commit is contained in:
@ -39,28 +39,28 @@ public class IITC_Mobile extends Activity {
|
||||
|
||||
private static final int REQUEST_LOGIN = 1;
|
||||
|
||||
private IITC_WebView iitc_view;
|
||||
private OnSharedPreferenceChangeListener listener;
|
||||
private final String intel_url = "https://www.ingress.com/intel";
|
||||
private boolean is_loc_enabled = false;
|
||||
private Location last_location = null;
|
||||
private LocationManager loc_mngr = null;
|
||||
private LocationListener loc_listener = null;
|
||||
private boolean fullscreen_mode = false;
|
||||
private boolean fullscreen_actionbar = false;
|
||||
private ActionBar actionBar;
|
||||
private IITC_WebView mIitcWebView;
|
||||
private OnSharedPreferenceChangeListener mSharedPrefChangeListener;
|
||||
private final String mIntelUrl = "https://www.ingress.com/intel";
|
||||
private boolean mIsLocEnabled = false;
|
||||
private Location mLastLocation = null;
|
||||
private LocationManager mLocMngr = null;
|
||||
private LocationListener mLocListener = null;
|
||||
private boolean mFullscreenMode = false;
|
||||
private boolean mFullscreenActionbar = false;
|
||||
private ActionBar mActionBar;
|
||||
private IITC_DeviceAccountLogin mLogin;
|
||||
private MenuItem searchMenuItem;
|
||||
private boolean desktop = false;
|
||||
private boolean reload_needed = false;
|
||||
private final ArrayList<String> dialogStack = new ArrayList<String>();
|
||||
private SharedPreferences sharedPref;
|
||||
private MenuItem mSearchMenuItem;
|
||||
private boolean mDesktopMode = false;
|
||||
private boolean mReloadNeeded = false;
|
||||
private final ArrayList<String> mDialogStack = new ArrayList<String>();
|
||||
private SharedPreferences mSharedPrefs;
|
||||
|
||||
// Used for custom back stack handling
|
||||
private final ArrayList<Integer> backStack = new ArrayList<Integer>();
|
||||
private boolean backStack_push = true;
|
||||
private int currentPane = android.R.id.home;
|
||||
private boolean back_button_pressed = false;
|
||||
private final ArrayList<Integer> mBackStack = new ArrayList<Integer>();
|
||||
private boolean mBackStackPush = true;
|
||||
private int mCurrentPane = android.R.id.home;
|
||||
private boolean mBackButtonPressed = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -70,38 +70,38 @@ public class IITC_Mobile extends Activity {
|
||||
requestWindowFeature(Window.FEATURE_PROGRESS);
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
iitc_view = (IITC_WebView) findViewById(R.id.iitc_webview);
|
||||
mIitcWebView = (IITC_WebView) findViewById(R.id.iitc_webview);
|
||||
|
||||
// fetch actionbar, set display flags, title and enable home button
|
||||
actionBar = this.getActionBar();
|
||||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME
|
||||
mActionBar = this.getActionBar();
|
||||
mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME
|
||||
| ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_TITLE);
|
||||
actionBar.setTitle(getString(R.string.app_name));
|
||||
mActionBar.setTitle(getString(R.string.app_name));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
||||
actionBar.setHomeButtonEnabled(true);
|
||||
mActionBar.setHomeButtonEnabled(true);
|
||||
|
||||
// do something if user changed something in the settings
|
||||
sharedPref = PreferenceManager
|
||||
mSharedPrefs = PreferenceManager
|
||||
.getDefaultSharedPreferences(this);
|
||||
listener = new OnSharedPreferenceChangeListener() {
|
||||
mSharedPrefChangeListener = new OnSharedPreferenceChangeListener() {
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(
|
||||
SharedPreferences sharedPreferences, String key) {
|
||||
if (key.equals("pref_force_desktop")) {
|
||||
desktop = sharedPreferences.getBoolean("pref_force_desktop", false);
|
||||
if (desktop) {
|
||||
mDesktopMode = sharedPreferences.getBoolean("pref_force_desktop", false);
|
||||
if (mDesktopMode) {
|
||||
setActionBarHomeEnabledWithUp(false);
|
||||
actionBar.setTitle(getString(R.string.app_name));
|
||||
} else actionBar.setHomeButtonEnabled(true);
|
||||
mActionBar.setTitle(getString(R.string.app_name));
|
||||
} else mActionBar.setHomeButtonEnabled(true);
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
if (key.equals("pref_user_loc"))
|
||||
is_loc_enabled = sharedPreferences.getBoolean("pref_user_loc",
|
||||
mIsLocEnabled = sharedPreferences.getBoolean("pref_user_loc",
|
||||
false);
|
||||
if (key.equals("pref_fullscreen_actionbar")) {
|
||||
fullscreen_actionbar = sharedPreferences.getBoolean("pref_fullscreen_actionbar",
|
||||
mFullscreenActionbar = sharedPreferences.getBoolean("pref_fullscreen_actionbar",
|
||||
false);
|
||||
if (fullscreen_mode)
|
||||
if (mFullscreenMode)
|
||||
IITC_Mobile.this.getActionBar().hide();
|
||||
// no iitc reload needed here
|
||||
return;
|
||||
@ -110,25 +110,25 @@ public class IITC_Mobile extends Activity {
|
||||
if (key.equals("pref_press_twice_to_exit") || key.equals("pref_share_selected_tab"))
|
||||
return;
|
||||
|
||||
reload_needed = true;
|
||||
mReloadNeeded = true;
|
||||
}
|
||||
};
|
||||
sharedPref.registerOnSharedPreferenceChangeListener(listener);
|
||||
mSharedPrefs.registerOnSharedPreferenceChangeListener(mSharedPrefChangeListener);
|
||||
|
||||
// enable/disable desktop mode on menu create and url load
|
||||
desktop = sharedPref.getBoolean("pref_force_desktop", false);
|
||||
// enable/disable mDesktopMode mode on menu create and url load
|
||||
mDesktopMode = mSharedPrefs.getBoolean("pref_force_desktop", false);
|
||||
|
||||
// Acquire a reference to the system Location Manager
|
||||
loc_mngr = (LocationManager) this
|
||||
mLocMngr = (LocationManager) this
|
||||
.getSystemService(Context.LOCATION_SERVICE);
|
||||
|
||||
// Define a listener that responds to location updates
|
||||
loc_listener = new LocationListener() {
|
||||
// Define a mSharedPrefChangeListener that responds to location updates
|
||||
mLocListener = new LocationListener() {
|
||||
public void onLocationChanged(Location location) {
|
||||
// Called when a new location is found by the network location
|
||||
// provider.
|
||||
drawMarker(location);
|
||||
last_location = location;
|
||||
mLastLocation = location;
|
||||
}
|
||||
|
||||
public void onStatusChanged(String provider, int status,
|
||||
@ -142,20 +142,20 @@ public class IITC_Mobile extends Activity {
|
||||
}
|
||||
};
|
||||
|
||||
is_loc_enabled = sharedPref.getBoolean("pref_user_loc", false);
|
||||
if (is_loc_enabled) {
|
||||
// Register the listener with the Location Manager to receive
|
||||
mIsLocEnabled = mSharedPrefs.getBoolean("pref_user_loc", false);
|
||||
if (mIsLocEnabled) {
|
||||
// Register the mSharedPrefChangeListener with the Location Manager to receive
|
||||
// location updates
|
||||
loc_mngr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
|
||||
0, 0, loc_listener);
|
||||
loc_mngr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
|
||||
loc_listener);
|
||||
mLocMngr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
|
||||
0, 0, mLocListener);
|
||||
mLocMngr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
|
||||
mLocListener);
|
||||
}
|
||||
|
||||
fullscreen_actionbar = sharedPref.getBoolean("pref_fullscreen_actionbar", false);
|
||||
mFullscreenActionbar = mSharedPrefs.getBoolean("pref_fullscreen_actionbar", false);
|
||||
|
||||
// Clear the back stack
|
||||
backStack.clear();
|
||||
mBackStack.clear();
|
||||
setActionBarHomeEnabledWithUp(false);
|
||||
|
||||
handleIntent(getIntent(), true);
|
||||
@ -208,17 +208,17 @@ public class IITC_Mobile extends Activity {
|
||||
String query = intent.getStringExtra(SearchManager.QUERY);
|
||||
query = query.replace("'", "''");
|
||||
final SearchView searchView =
|
||||
(SearchView) searchMenuItem.getActionView();
|
||||
(SearchView) mSearchMenuItem.getActionView();
|
||||
searchView.setQuery(query, false);
|
||||
searchView.clearFocus();
|
||||
actionBar.setTitle(getString(R.string.app_name));
|
||||
mActionBar.setTitle(getString(R.string.app_name));
|
||||
backStackUpdate(android.R.id.home);
|
||||
iitc_view.loadUrl("javascript:search('" + query + "');");
|
||||
mIitcWebView.loadUrl("javascript:search('" + query + "');");
|
||||
return;
|
||||
}
|
||||
|
||||
if (onCreate) {
|
||||
this.loadUrl(intel_url);
|
||||
this.loadUrl(mIntelUrl);
|
||||
}
|
||||
}
|
||||
|
||||
@ -273,23 +273,23 @@ public class IITC_Mobile extends Activity {
|
||||
|
||||
// enough idle...let's do some work
|
||||
Log.d("iitcm", "resuming...setting reset idleTimer");
|
||||
iitc_view.loadUrl("javascript: window.idleTime = 0");
|
||||
iitc_view.loadUrl("javascript: window.renderUpdateStatus()");
|
||||
iitc_view.updateCaching();
|
||||
mIitcWebView.loadUrl("javascript: window.idleTime = 0");
|
||||
mIitcWebView.loadUrl("javascript: window.renderUpdateStatus()");
|
||||
mIitcWebView.updateCaching();
|
||||
|
||||
if (is_loc_enabled) {
|
||||
// Register the listener with the Location Manager to receive
|
||||
if (mIsLocEnabled) {
|
||||
// Register the mSharedPrefChangeListener with the Location Manager to receive
|
||||
// location updates
|
||||
loc_mngr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
|
||||
0, 0, loc_listener);
|
||||
loc_mngr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
|
||||
loc_listener);
|
||||
mLocMngr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
|
||||
0, 0, mLocListener);
|
||||
mLocMngr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
|
||||
mLocListener);
|
||||
}
|
||||
|
||||
if (reload_needed) {
|
||||
if (mReloadNeeded) {
|
||||
Log.d("iitcm", "preference had changed...reload needed");
|
||||
this.loadUrl(intel_url);
|
||||
reload_needed = false;
|
||||
this.loadUrl(mIntelUrl);
|
||||
mReloadNeeded = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,25 +312,25 @@ public class IITC_Mobile extends Activity {
|
||||
Log.d("iitcm",
|
||||
"connected to mobile net...abort all running requests");
|
||||
// cancel all current requests
|
||||
iitc_view.loadUrl("javascript: window.requests.abort()");
|
||||
mIitcWebView.loadUrl("javascript: window.requests.abort()");
|
||||
// set idletime to maximum...no need for more
|
||||
iitc_view.loadUrl("javascript: window.idleTime = 999");
|
||||
mIitcWebView.loadUrl("javascript: window.idleTime = 999");
|
||||
} else if (wifi.getState() == NetworkInfo.State.CONNECTED
|
||||
|| wifi.getState() == NetworkInfo.State.CONNECTING) {
|
||||
iitc_view.loadUrl("javascript: window.idleTime = 999");
|
||||
mIitcWebView.loadUrl("javascript: window.idleTime = 999");
|
||||
}
|
||||
} else {
|
||||
Log.d("iitcm",
|
||||
"no mobile internet module detected...check wifi state");
|
||||
if (wifi.getState() == NetworkInfo.State.CONNECTED
|
||||
|| wifi.getState() == NetworkInfo.State.CONNECTING) {
|
||||
iitc_view.loadUrl("javascript: window.idleTime = 999");
|
||||
mIitcWebView.loadUrl("javascript: window.idleTime = 999");
|
||||
}
|
||||
}
|
||||
Log.d("iitcm", "stopping iitcm");
|
||||
|
||||
if (is_loc_enabled)
|
||||
loc_mngr.removeUpdates(loc_listener);
|
||||
if (mIsLocEnabled)
|
||||
mLocMngr.removeUpdates(mLocListener);
|
||||
|
||||
super.onStop();
|
||||
}
|
||||
@ -340,18 +340,18 @@ public class IITC_Mobile extends Activity {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
||||
Log.d("iitcm", "configuration changed...restoring...reset idleTimer");
|
||||
iitc_view.loadUrl("javascript: window.idleTime = 0");
|
||||
iitc_view.loadUrl("javascript: window.renderUpdateStatus()");
|
||||
mIitcWebView.loadUrl("javascript: window.idleTime = 0");
|
||||
mIitcWebView.loadUrl("javascript: window.renderUpdateStatus()");
|
||||
}
|
||||
|
||||
// we want a self defined behavior for the back button
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// first kill all open iitc dialogs
|
||||
if (!dialogStack.isEmpty()) {
|
||||
int last = dialogStack.size() - 1;
|
||||
String id = dialogStack.get(last);
|
||||
iitc_view.loadUrl("javascript: " +
|
||||
if (!mDialogStack.isEmpty()) {
|
||||
int last = mDialogStack.size() - 1;
|
||||
String id = mDialogStack.get(last);
|
||||
mIitcWebView.loadUrl("javascript: " +
|
||||
"var selector = $(window.DIALOGS['" + id + "']); " +
|
||||
"selector.dialog('close'); " +
|
||||
"selector.remove();");
|
||||
@ -359,22 +359,22 @@ public class IITC_Mobile extends Activity {
|
||||
}
|
||||
// exit fullscreen mode if it is enabled and action bar is disabled
|
||||
// or the back stack is empty
|
||||
if (fullscreen_mode && (backStack.isEmpty() || fullscreen_actionbar)) {
|
||||
if (mFullscreenMode && (mBackStack.isEmpty() || mFullscreenActionbar)) {
|
||||
this.toggleFullscreen();
|
||||
} else if (!backStack.isEmpty()) {
|
||||
// Pop last item from backStack and pretend the relevant menu item was clicked
|
||||
} else if (!mBackStack.isEmpty()) {
|
||||
// Pop last item from backstack and pretend the relevant menu item was clicked
|
||||
backStackPop();
|
||||
} else {
|
||||
if (back_button_pressed || !sharedPref.getBoolean("pref_press_twice_to_exit", false))
|
||||
if (mBackButtonPressed || !mSharedPrefs.getBoolean("pref_press_twice_to_exit", false))
|
||||
super.onBackPressed();
|
||||
else {
|
||||
back_button_pressed = true;
|
||||
mBackButtonPressed = true;
|
||||
Toast.makeText(this, "Press twice to exit", Toast.LENGTH_SHORT).show();
|
||||
// reset back button after 2 seconds
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
back_button_pressed = false;
|
||||
mBackButtonPressed = false;
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
@ -382,42 +382,42 @@ public class IITC_Mobile extends Activity {
|
||||
}
|
||||
|
||||
private void setActionBarHomeEnabledWithUp(boolean enabled) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(enabled);
|
||||
mActionBar.setDisplayHomeAsUpEnabled(enabled);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
||||
actionBar.setHomeButtonEnabled(enabled);
|
||||
mActionBar.setHomeButtonEnabled(enabled);
|
||||
}
|
||||
|
||||
public void backStackPop() {
|
||||
// shouldn't be called when back stack is empty
|
||||
// catch wrong usage
|
||||
if (backStack.isEmpty()) {
|
||||
if (mBackStack.isEmpty()) {
|
||||
// Empty back stack means we should be at home (ie map) screen
|
||||
setActionBarHomeEnabledWithUp(false);
|
||||
actionBar.setTitle(getString(R.string.app_name));
|
||||
iitc_view.loadUrl("javascript: window.show('map');");
|
||||
mActionBar.setTitle(getString(R.string.app_name));
|
||||
mIitcWebView.loadUrl("javascript: window.show('map');");
|
||||
return;
|
||||
}
|
||||
int index = backStack.size() - 1;
|
||||
int itemId = backStack.remove(index);
|
||||
backStack_push = false;
|
||||
int index = mBackStack.size() - 1;
|
||||
int itemId = mBackStack.remove(index);
|
||||
mBackStackPush = false;
|
||||
handleMenuItemSelected(itemId);
|
||||
}
|
||||
|
||||
public void backStackUpdate(int itemId) {
|
||||
// ensure no double adds
|
||||
if (itemId == currentPane) return;
|
||||
if (itemId == mCurrentPane) return;
|
||||
if (itemId == android.R.id.home) {
|
||||
backStack.clear();
|
||||
backStack_push = true;
|
||||
mBackStack.clear();
|
||||
mBackStackPush = true;
|
||||
} else {
|
||||
if (backStack_push)
|
||||
backStack.add(currentPane);
|
||||
if (mBackStackPush)
|
||||
mBackStack.add(mCurrentPane);
|
||||
else
|
||||
backStack_push = true;
|
||||
mBackStackPush = true;
|
||||
}
|
||||
|
||||
currentPane = itemId;
|
||||
if (backStack.size() >= 1) {
|
||||
mCurrentPane = itemId;
|
||||
if (mBackStack.size() >= 1) {
|
||||
setActionBarHomeEnabledWithUp(true);
|
||||
} else {
|
||||
// if we popped our last item from stack...illustrate it on home button
|
||||
@ -432,14 +432,14 @@ public class IITC_Mobile extends Activity {
|
||||
getMenuInflater().inflate(R.menu.main, menu);
|
||||
// Get the SearchView and set the searchable configuration
|
||||
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
|
||||
this.searchMenuItem = menu.findItem(R.id.menu_search);
|
||||
this.mSearchMenuItem = menu.findItem(R.id.menu_search);
|
||||
final SearchView searchView =
|
||||
(SearchView) searchMenuItem.getActionView();
|
||||
(SearchView) mSearchMenuItem.getActionView();
|
||||
// Assumes current activity is the searchable activity
|
||||
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
|
||||
searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
|
||||
// enable/disable desktop menu
|
||||
enableDesktopUI(menu, desktop);
|
||||
// enable/disable mDesktopMode menu
|
||||
enableDesktopUI(menu, mDesktopMode);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -454,65 +454,65 @@ public class IITC_Mobile extends Activity {
|
||||
public boolean handleMenuItemSelected(int itemId) {
|
||||
switch (itemId) {
|
||||
case android.R.id.home:
|
||||
iitc_view.loadUrl("javascript: window.show('map');");
|
||||
mIitcWebView.loadUrl("javascript: window.show('map');");
|
||||
return true;
|
||||
case R.id.reload_button:
|
||||
actionBar.setTitle(getString(R.string.app_name));
|
||||
backStack.clear();
|
||||
mActionBar.setTitle(getString(R.string.app_name));
|
||||
mBackStack.clear();
|
||||
setActionBarHomeEnabledWithUp(false);
|
||||
// iitc starts on map after reload
|
||||
currentPane = android.R.id.home;
|
||||
this.loadUrl(intel_url);
|
||||
mCurrentPane = android.R.id.home;
|
||||
this.loadUrl(mIntelUrl);
|
||||
return true;
|
||||
case R.id.toggle_fullscreen:
|
||||
toggleFullscreen();
|
||||
return true;
|
||||
case R.id.layer_chooser:
|
||||
// Force map view to handle potential issue with back stack
|
||||
if (!backStack.isEmpty() && currentPane != android.R.id.home)
|
||||
iitc_view.loadUrl("javascript: window.show('map');");
|
||||
if (!mBackStack.isEmpty() && mCurrentPane != android.R.id.home)
|
||||
mIitcWebView.loadUrl("javascript: window.show('map');");
|
||||
// the getLayers function calls the setLayers method of IITC_JSInterface
|
||||
iitc_view.loadUrl("javascript: window.layerChooser.getLayers()");
|
||||
mIitcWebView.loadUrl("javascript: window.layerChooser.getLayers()");
|
||||
return true;
|
||||
// get the users current location and focus it on map
|
||||
case R.id.locate:
|
||||
iitc_view.loadUrl("javascript: window.show('map');");
|
||||
mIitcWebView.loadUrl("javascript: window.show('map');");
|
||||
// get location from network by default
|
||||
if (!is_loc_enabled) {
|
||||
iitc_view.loadUrl("javascript: " +
|
||||
if (!mIsLocEnabled) {
|
||||
mIitcWebView.loadUrl("javascript: " +
|
||||
"window.map.locate({setView : true, maxZoom: 15});");
|
||||
// if gps location is displayed we can use a better location without any costs
|
||||
} else {
|
||||
if (last_location != null)
|
||||
iitc_view.loadUrl("javascript: window.map.setView(new L.LatLng(" +
|
||||
last_location.getLatitude() + "," +
|
||||
last_location.getLongitude() + "), 15);");
|
||||
if (mLastLocation != null)
|
||||
mIitcWebView.loadUrl("javascript: window.map.setView(new L.LatLng(" +
|
||||
mLastLocation.getLatitude() + "," +
|
||||
mLastLocation.getLongitude() + "), 15);");
|
||||
}
|
||||
return true;
|
||||
// start settings activity
|
||||
case R.id.action_settings:
|
||||
Intent intent = new Intent(this, IITC_Settings.class);
|
||||
intent.putExtra("iitc_version", iitc_view.getWebViewClient()
|
||||
intent.putExtra("iitc_version", mIitcWebView.getWebViewClient()
|
||||
.getIITCVersion());
|
||||
startActivity(intent);
|
||||
return true;
|
||||
case R.id.menu_info:
|
||||
iitc_view.loadUrl("javascript: window.show('info');");
|
||||
mIitcWebView.loadUrl("javascript: window.show('info');");
|
||||
return true;
|
||||
case R.id.menu_full:
|
||||
iitc_view.loadUrl("javascript: window.show('full');");
|
||||
mIitcWebView.loadUrl("javascript: window.show('full');");
|
||||
return true;
|
||||
case R.id.menu_compact:
|
||||
iitc_view.loadUrl("javascript: window.show('compact');");
|
||||
mIitcWebView.loadUrl("javascript: window.show('compact');");
|
||||
return true;
|
||||
case R.id.menu_public:
|
||||
iitc_view.loadUrl("javascript: window.show('public');");
|
||||
mIitcWebView.loadUrl("javascript: window.show('public');");
|
||||
return true;
|
||||
case R.id.menu_faction:
|
||||
iitc_view.loadUrl("javascript: window.show('faction');");
|
||||
mIitcWebView.loadUrl("javascript: window.show('faction');");
|
||||
return true;
|
||||
case R.id.menu_debug:
|
||||
iitc_view.loadUrl("javascript: window.show('debug')");
|
||||
mIitcWebView.loadUrl("javascript: window.show('debug')");
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@ -521,7 +521,7 @@ public class IITC_Mobile extends Activity {
|
||||
|
||||
private void loadIITC() {
|
||||
try {
|
||||
iitc_view.getWebViewClient().loadIITC_JS(this);
|
||||
mIitcWebView.getWebViewClient().loadIITC_JS(this);
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
} catch (NullPointerException e2) {
|
||||
@ -529,9 +529,9 @@ public class IITC_Mobile extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
// vp=f enables desktop mode...vp=m is the defaul mobile view
|
||||
// vp=f enables mDesktopMode mode...vp=m is the defaul mobile view
|
||||
private String addUrlParam(String url) {
|
||||
if (desktop)
|
||||
if (mDesktopMode)
|
||||
return (url + "?vp=f");
|
||||
else
|
||||
return (url + "?vp=m");
|
||||
@ -543,7 +543,7 @@ public class IITC_Mobile extends Activity {
|
||||
showSplashScreen();
|
||||
url = addUrlParam(url);
|
||||
loadIITC();
|
||||
iitc_view.loadUrl(url);
|
||||
mIitcWebView.loadUrl(url);
|
||||
}
|
||||
|
||||
// update the user location marker on the map
|
||||
@ -551,25 +551,25 @@ public class IITC_Mobile extends Activity {
|
||||
// throw away all positions with accuracy > 100 meters
|
||||
// should avoid gps glitches
|
||||
if (loc.getAccuracy() < 100) {
|
||||
iitc_view.loadUrl("javascript: "
|
||||
mIitcWebView.loadUrl("javascript: "
|
||||
+ "window.plugin.userLocation.updateLocation( "
|
||||
+ loc.getLatitude() + ", " + loc.getLongitude() + ");");
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleFullscreen() {
|
||||
if (fullscreen_mode) {
|
||||
if (fullscreen_actionbar)
|
||||
if (mFullscreenMode) {
|
||||
if (mFullscreenActionbar)
|
||||
this.getActionBar().show();
|
||||
this.fullscreen_mode = false;
|
||||
this.mFullscreenMode = false;
|
||||
} else {
|
||||
if (fullscreen_actionbar) {
|
||||
if (mFullscreenActionbar) {
|
||||
this.getActionBar().hide();
|
||||
// show a toast with instructions to exit the fc mode again
|
||||
Toast.makeText(this, "Press back button to exit fullscreen",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
this.fullscreen_mode = true;
|
||||
this.mFullscreenMode = true;
|
||||
}
|
||||
// toggle notification bar
|
||||
WindowManager.LayoutParams attrs = getWindow().getAttributes();
|
||||
@ -578,7 +578,7 @@ public class IITC_Mobile extends Activity {
|
||||
}
|
||||
|
||||
public IITC_WebView getWebView() {
|
||||
return this.iitc_view;
|
||||
return this.mIitcWebView;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -608,7 +608,7 @@ public class IITC_Mobile extends Activity {
|
||||
public void onReceivedLoginRequest(IITC_WebViewClient client, WebView view,
|
||||
String realm, String account, String args) {
|
||||
Log.d("iitcm", "logging in...set caching mode to default");
|
||||
iitc_view.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
|
||||
mIitcWebView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
|
||||
mLogin = new IITC_DeviceAccountLogin(this, view, client);
|
||||
mLogin.startLogin(realm, account, args);
|
||||
}
|
||||
@ -638,23 +638,23 @@ public class IITC_Mobile extends Activity {
|
||||
// focused dialogs should be closed first
|
||||
public void setFocusedDialog(String id) {
|
||||
Log.d("iitcm", "Dialog " + id + " focused");
|
||||
dialogStack.remove(id);
|
||||
dialogStack.add(id);
|
||||
mDialogStack.remove(id);
|
||||
mDialogStack.add(id);
|
||||
}
|
||||
|
||||
// called by the javascript interface
|
||||
public void dialogOpened(String id, boolean open) {
|
||||
if (open) {
|
||||
Log.d("iitcm", "Dialog " + id + " added");
|
||||
dialogStack.add(id);
|
||||
mDialogStack.add(id);
|
||||
} else {
|
||||
Log.d("iitcm", "Dialog " + id + " closed");
|
||||
dialogStack.remove(id);
|
||||
mDialogStack.remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
public void showSplashScreen() {
|
||||
if (!sharedPref.getBoolean("pref_disable_splash", false)) {
|
||||
if (!mSharedPrefs.getBoolean("pref_disable_splash", false)) {
|
||||
findViewById(R.id.iitc_webview).setVisibility(View.GONE);
|
||||
findViewById(R.id.imageLoading).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
Reference in New Issue
Block a user