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;
|
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
|
* This listener is invoked when an item in the account list is selected.
|
||||||
* is clicked, (in which case `index` is <0)
|
* (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
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int index) {
|
public void onClick(DialogInterface dialog, int index) {
|
||||||
if (index >= 0 && index < mAccounts.length) {
|
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;
|
mActivity = activity;
|
||||||
mWebView = webView;
|
mWebView = webView;
|
||||||
mAccountManager = AccountManager.get(activity);
|
mAccountManager = AccountManager.get(activity);
|
||||||
@ -142,16 +144,17 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback<Bundle> {
|
|||||||
try {
|
try {
|
||||||
Intent launch = (Intent) value.getResult().get(AccountManager.KEY_INTENT);
|
Intent launch = (Intent) value.getResult().get(AccountManager.KEY_INTENT);
|
||||||
if (launch != null) {
|
if (launch != null) {
|
||||||
// There is a reason we need to start the given activity if we want an authentication token.
|
// There is a reason we need to start the given activity if we want an
|
||||||
// (Could be user confirmation or something else. Whatever, we have to start it)
|
// authentication token. (Could be user confirmation or something else. Whatever,
|
||||||
// IITC_Mobile will call it using startActivityForResult
|
// we have to start it) IITC_Mobile will call it using startActivityForResult
|
||||||
mActivity.startLoginActivity(launch);
|
mActivity.startLoginActivity(launch);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String result = value.getResult().getString(AccountManager.KEY_AUTHTOKEN);
|
String result = value.getResult().getString(AccountManager.KEY_AUTHTOKEN);
|
||||||
if (result != null) {
|
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);
|
mWebView.loadUrl(result);
|
||||||
mActivity.loginSucceeded();
|
mActivity.loginSucceeded();
|
||||||
} else {
|
} else {
|
||||||
@ -165,8 +168,8 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback<Bundle> {
|
|||||||
/**
|
/**
|
||||||
* start authentication
|
* start authentication
|
||||||
* <p/>
|
* <p/>
|
||||||
* if we already have a username (e.g. because the existing login has timed out), we can directly start
|
* if we already have a username (e.g. because the existing login has timed out),
|
||||||
* authentication if an account with that username is found.
|
* we can directly start authentication if an account with that username is found.
|
||||||
*/
|
*/
|
||||||
public void startLogin(String realm, String accountName, String args) {
|
public void startLogin(String realm, String accountName, String args) {
|
||||||
mAccounts = mAccountManager.getAccountsByType(realm);
|
mAccounts = mAccountManager.getAccountsByType(realm);
|
||||||
|
@ -120,7 +120,8 @@ public class IITC_JSInterface {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* the layer strings have a form like:
|
* 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
|
* Put it in a JSONArray and parse it
|
||||||
*/
|
*/
|
||||||
JSONArray base_layersJSON = null;
|
JSONArray base_layersJSON = null;
|
||||||
@ -215,7 +216,8 @@ public class IITC_JSInterface {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
||||||
// activate clicked layer
|
// 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]) + ","
|
+ layer_ids.get(overlay_layers[which]) + ","
|
||||||
+ overlay_is_active[which] + ");");
|
+ overlay_is_active[which] + ");");
|
||||||
}
|
}
|
||||||
@ -246,7 +248,8 @@ public class IITC_JSInterface {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
// activate clicked layer
|
// 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]) + ","
|
+ layer_ids.get(base_layers[which]) + ","
|
||||||
+ true + ");");
|
+ true + ");");
|
||||||
active_base_layer = which;
|
active_base_layer = which;
|
||||||
|
@ -223,7 +223,8 @@ public class IITC_Mobile extends Activity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
ConnectivityManager conMan = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager conMan =
|
||||||
|
(ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
|
||||||
NetworkInfo mobile = conMan
|
NetworkInfo mobile = conMan
|
||||||
.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
|
.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
|
||||||
@ -284,7 +285,8 @@ public class IITC_Mobile extends Activity {
|
|||||||
"selector.remove();");
|
"selector.remove();");
|
||||||
return;
|
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)) {
|
if (fullscreen_mode && (backStack.isEmpty() || fullscreen_actionbar)) {
|
||||||
this.toggleFullscreen();
|
this.toggleFullscreen();
|
||||||
} else if (!backStack.isEmpty()) {
|
} else if (!backStack.isEmpty()) {
|
||||||
@ -405,7 +407,8 @@ public class IITC_Mobile extends Activity {
|
|||||||
iitc_view.loadUrl("javascript: window.show('map');");
|
iitc_view.loadUrl("javascript: window.show('map');");
|
||||||
// get location from network by default
|
// get location from network by default
|
||||||
if (!is_loc_enabled) {
|
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
|
// if gps location is displayed we can use a better location without any costs
|
||||||
} else {
|
} else {
|
||||||
if (last_location != null)
|
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
|
* It can occur that in order to authenticate, an external activity has to be launched.
|
||||||
* confirmation dialog.)
|
* (This could for example be a confirmation dialog.)
|
||||||
*/
|
*/
|
||||||
public void startLoginActivity(Intent launch) {
|
public void startLoginActivity(Intent launch) {
|
||||||
startActivityForResult(launch, REQUEST_LOGIN); // REQUEST_LOGIN is to recognize the result
|
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
|
// now parse plugin name, description and category
|
||||||
String header = src.substring(src.indexOf("==UserScript=="),
|
String header = src.substring(src.indexOf("==UserScript=="),
|
||||||
|
@ -95,7 +95,8 @@ public class IITC_WebView extends WebView {
|
|||||||
public void loadUrl(String url) {
|
public void loadUrl(String url) {
|
||||||
// if in edit text mode, don't load javascript otherwise the keyboard closes.
|
// if in edit text mode, don't load javascript otherwise the keyboard closes.
|
||||||
HitTestResult testResult = this.getHitTestResult();
|
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
|
// let window.show(...) interupt input
|
||||||
// window.show(...) is called if one of the action bar buttons
|
// window.show(...) is called if one of the action bar buttons
|
||||||
// is clicked
|
// is clicked
|
||||||
@ -151,7 +152,8 @@ public class IITC_WebView extends WebView {
|
|||||||
// is ticked as mobile hotspot or not.
|
// is ticked as mobile hotspot or not.
|
||||||
// --> IITC_WebView.isConnectedToWifi should return 'false' if connected to mobile hotspot
|
// --> IITC_WebView.isConnectedToWifi should return 'false' if connected to mobile hotspot
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
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);
|
return (wifi.getState() == NetworkInfo.State.CONNECTED);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user