more code formatting
This commit is contained in:
parent
7ea50c2d42
commit
d220ed3ac4
@ -63,10 +63,11 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback<Bundle> {
|
||||
private final WebView mWebView;
|
||||
|
||||
/**
|
||||
* This listener is invoked when an item in the account list is selected. (It is also used when the 'cancel' button
|
||||
* is clicked, (in which case `index` is <0)
|
||||
* This listener is invoked when an item in the account list is selected.
|
||||
* (It is also used when the 'cancel' button is clicked, (in which case `index` is <0)
|
||||
*/
|
||||
private final DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
|
||||
private final DialogInterface.OnClickListener onClickListener =
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int index) {
|
||||
if (index >= 0 && index < mAccounts.length) {
|
||||
@ -77,7 +78,8 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback<Bundle> {
|
||||
}
|
||||
};
|
||||
|
||||
public IITC_DeviceAccountLogin(IITC_Mobile activity, WebView webView, WebViewClient webViewClient) {
|
||||
public IITC_DeviceAccountLogin(IITC_Mobile activity, WebView webView,
|
||||
WebViewClient webViewClient) {
|
||||
mActivity = activity;
|
||||
mWebView = webView;
|
||||
mAccountManager = AccountManager.get(activity);
|
||||
@ -142,16 +144,17 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback<Bundle> {
|
||||
try {
|
||||
Intent launch = (Intent) value.getResult().get(AccountManager.KEY_INTENT);
|
||||
if (launch != null) {
|
||||
// There is a reason we need to start the given activity if we want an authentication token.
|
||||
// (Could be user confirmation or something else. Whatever, we have to start it)
|
||||
// IITC_Mobile will call it using startActivityForResult
|
||||
// There is a reason we need to start the given activity if we want an
|
||||
// authentication token. (Could be user confirmation or something else. Whatever,
|
||||
// we have to start it) IITC_Mobile will call it using startActivityForResult
|
||||
mActivity.startLoginActivity(launch);
|
||||
return;
|
||||
}
|
||||
|
||||
String result = value.getResult().getString(AccountManager.KEY_AUTHTOKEN);
|
||||
if (result != null) {
|
||||
// authentication succeded, we can load the given url, which will redirect back to the intel map
|
||||
// authentication succeded, we can load the given url, which will redirect
|
||||
// back to the intel map
|
||||
mWebView.loadUrl(result);
|
||||
mActivity.loginSucceeded();
|
||||
} else {
|
||||
@ -165,8 +168,8 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback<Bundle> {
|
||||
/**
|
||||
* start authentication
|
||||
* <p/>
|
||||
* if we already have a username (e.g. because the existing login has timed out), we can directly start
|
||||
* authentication if an account with that username is found.
|
||||
* if we already have a username (e.g. because the existing login has timed out),
|
||||
* we can directly start authentication if an account with that username is found.
|
||||
*/
|
||||
public void startLogin(String realm, String accountName, String args) {
|
||||
mAccounts = mAccountManager.getAccountsByType(realm);
|
||||
|
@ -120,7 +120,8 @@ public class IITC_JSInterface {
|
||||
|
||||
/*
|
||||
* the layer strings have a form like:
|
||||
* [{"layerId":27,"name":"MapQuest OSM","active":true},{"layerId":28,"name":"Default Ingress Map","active":false}]
|
||||
* [{"layerId":27,"name":"MapQuest OSM","active":true},
|
||||
* {"layerId":28,"name":"Default Ingress Map","active":false}]
|
||||
* Put it in a JSONArray and parse it
|
||||
*/
|
||||
JSONArray base_layersJSON = null;
|
||||
@ -215,7 +216,8 @@ public class IITC_JSInterface {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
||||
// activate clicked layer
|
||||
((IITC_Mobile) context).getWebView().loadUrl("javascript: window.layerChooser.showLayer("
|
||||
((IITC_Mobile) context).getWebView().loadUrl("javascript: " +
|
||||
"window.layerChooser.showLayer("
|
||||
+ layer_ids.get(overlay_layers[which]) + ","
|
||||
+ overlay_is_active[which] + ");");
|
||||
}
|
||||
@ -246,7 +248,8 @@ public class IITC_JSInterface {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// activate clicked layer
|
||||
((IITC_Mobile) context).getWebView().loadUrl("javascript: window.layerChooser.showLayer("
|
||||
((IITC_Mobile) context).getWebView().loadUrl("javascript: " +
|
||||
"window.layerChooser.showLayer("
|
||||
+ layer_ids.get(base_layers[which]) + ","
|
||||
+ true + ");");
|
||||
active_base_layer = which;
|
||||
|
@ -223,7 +223,8 @@ public class IITC_Mobile extends Activity {
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
ConnectivityManager conMan = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager conMan =
|
||||
(ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
|
||||
NetworkInfo mobile = conMan
|
||||
.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
|
||||
@ -284,7 +285,8 @@ public class IITC_Mobile extends Activity {
|
||||
"selector.remove();");
|
||||
return;
|
||||
}
|
||||
// exit fullscreen mode if it is enabled and action bar is disabled or the back stack is empty
|
||||
// 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)) {
|
||||
this.toggleFullscreen();
|
||||
} else if (!backStack.isEmpty()) {
|
||||
@ -405,7 +407,8 @@ public class IITC_Mobile extends Activity {
|
||||
iitc_view.loadUrl("javascript: window.show('map');");
|
||||
// get location from network by default
|
||||
if (!is_loc_enabled) {
|
||||
iitc_view.loadUrl("javascript: window.map.locate({setView : true, maxZoom: 15});");
|
||||
iitc_view.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)
|
||||
@ -508,8 +511,8 @@ public class IITC_Mobile extends Activity {
|
||||
}
|
||||
|
||||
/**
|
||||
* It can occur that in order to authenticate, an external activity has to be launched. (This could for example be a
|
||||
* confirmation dialog.)
|
||||
* It can occur that in order to authenticate, an external activity has to be launched.
|
||||
* (This could for example be a confirmation dialog.)
|
||||
*/
|
||||
public void startLoginActivity(Intent launch) {
|
||||
startActivityForResult(launch, REQUEST_LOGIN); // REQUEST_LOGIN is to recognize the result
|
||||
|
@ -128,7 +128,8 @@ public class IITC_SettingsFragment extends PreferenceFragment {
|
||||
}
|
||||
}
|
||||
|
||||
void addPluginPreference(PreferenceScreen root, String src, String plugin_key, boolean additional) {
|
||||
void addPluginPreference(PreferenceScreen root, String src, String plugin_key,
|
||||
boolean additional) {
|
||||
|
||||
// now parse plugin name, description and category
|
||||
String header = src.substring(src.indexOf("==UserScript=="),
|
||||
|
@ -95,7 +95,8 @@ public class IITC_WebView extends WebView {
|
||||
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) {
|
||||
if (url.startsWith("javascript:") && testResult != null &&
|
||||
testResult.getType() == HitTestResult.EDIT_TEXT_TYPE) {
|
||||
// let window.show(...) interupt input
|
||||
// window.show(...) is called if one of the action bar buttons
|
||||
// is clicked
|
||||
@ -151,7 +152,8 @@ public class IITC_WebView extends WebView {
|
||||
// is ticked as mobile hotspot or not.
|
||||
// --> IITC_WebView.isConnectedToWifi should return 'false' if connected to mobile hotspot
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
return ((wifi.getState() == NetworkInfo.State.CONNECTED) && !conMan.isActiveNetworkMetered());
|
||||
return ((wifi.getState() == NetworkInfo.State.CONNECTED) &&
|
||||
!conMan.isActiveNetworkMetered());
|
||||
}
|
||||
return (wifi.getState() == NetworkInfo.State.CONNECTED);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user