sort members
This commit is contained in:
parent
18fe655c82
commit
5654eae8bd
@ -27,15 +27,15 @@ import java.util.TreeMap;
|
|||||||
|
|
||||||
public class IITC_WebViewClient extends WebViewClient {
|
public class IITC_WebViewClient extends WebViewClient {
|
||||||
|
|
||||||
|
private static final String DOMAIN = IITC_FileManager.DOMAIN;
|
||||||
|
private static final ByteArrayInputStream EMPTY = new ByteArrayInputStream("".getBytes());
|
||||||
private static final ByteArrayInputStream STYLE = new ByteArrayInputStream(
|
private static final ByteArrayInputStream STYLE = new ByteArrayInputStream(
|
||||||
"body, #dashboard_container, #map_canvas { background: #000 !important; }"
|
"body, #dashboard_container, #map_canvas { background: #000 !important; }"
|
||||||
.getBytes());
|
.getBytes());
|
||||||
private static final ByteArrayInputStream EMPTY = new ByteArrayInputStream("".getBytes());
|
|
||||||
private static final String DOMAIN = IITC_FileManager.DOMAIN;
|
|
||||||
|
|
||||||
private final String mIitcPath;
|
|
||||||
private boolean mIitcInjected = false;
|
|
||||||
private final IITC_Mobile mIitc;
|
private final IITC_Mobile mIitc;
|
||||||
|
private boolean mIitcInjected = false;
|
||||||
|
private final String mIitcPath;
|
||||||
private final IITC_TileManager mTileManager;
|
private final IITC_TileManager mTileManager;
|
||||||
|
|
||||||
public IITC_WebViewClient(final IITC_Mobile iitc) {
|
public IITC_WebViewClient(final IITC_Mobile iitc) {
|
||||||
@ -44,22 +44,43 @@ public class IITC_WebViewClient extends WebViewClient {
|
|||||||
mIitcPath = Environment.getExternalStorageDirectory().getPath() + "/IITC_Mobile/";
|
mIitcPath = Environment.getExternalStorageDirectory().getPath() + "/IITC_Mobile/";
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable https
|
@SuppressLint("InflateParams")
|
||||||
@Override
|
// no other way for AlertDialog
|
||||||
public void onReceivedSslError(final WebView view, final SslErrorHandler handler, final SslError error) {
|
private Dialog createSignInDialog(final HttpAuthHandler handler, final String host, final String realm,
|
||||||
handler.proceed();
|
final String username, final String password) {
|
||||||
}
|
final View v = mIitc.getLayoutInflater().inflate(R.layout.dialog_http_authentication, null);
|
||||||
|
final TextView tvUsername = (TextView) v.findViewById(R.id.username);
|
||||||
|
final TextView tvPassword = (TextView) v.findViewById(R.id.password);
|
||||||
|
final String title = String.format(mIitc.getString(R.string.sign_in_to), host, realm);
|
||||||
|
|
||||||
@Override
|
if (username != null)
|
||||||
public void onPageFinished(final WebView view, final String url) {
|
tvUsername.setText(username);
|
||||||
if (url.startsWith("http://www.ingress.com/intel")
|
if (password != null)
|
||||||
|| url.startsWith("https://www.ingress.com/intel")) {
|
tvPassword.setText(password);
|
||||||
if (mIitcInjected) return;
|
|
||||||
Log.d("injecting iitc..");
|
return new AlertDialog.Builder(mIitc)
|
||||||
loadScripts((IITC_WebView) view);
|
.setView(v)
|
||||||
mIitcInjected = true;
|
.setTitle(title)
|
||||||
}
|
.setCancelable(true)
|
||||||
super.onPageFinished(view, url);
|
.setPositiveButton(R.string.sign_in_action, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(final DialogInterface dialog, final int id) {
|
||||||
|
handler.proceed(tvUsername.getText().toString(), tvPassword.getText().toString());
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(final DialogInterface dialog, final int id) {
|
||||||
|
dialog.cancel();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
|
@Override
|
||||||
|
public void onCancel(final DialogInterface dialog) {
|
||||||
|
handler.cancel();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadScripts(final IITC_WebView view) {
|
private void loadScripts(final IITC_WebView view) {
|
||||||
@ -96,6 +117,41 @@ public class IITC_WebViewClient extends WebViewClient {
|
|||||||
view.loadJS(js);
|
view.loadJS(js);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageFinished(final WebView view, final String url) {
|
||||||
|
if (url.startsWith("http://www.ingress.com/intel")
|
||||||
|
|| url.startsWith("https://www.ingress.com/intel")) {
|
||||||
|
if (mIitcInjected) return;
|
||||||
|
Log.d("injecting iitc..");
|
||||||
|
loadScripts((IITC_WebView) view);
|
||||||
|
mIitcInjected = true;
|
||||||
|
}
|
||||||
|
super.onPageFinished(view, url);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceivedHttpAuthRequest(final WebView view, final HttpAuthHandler handler, final String host,
|
||||||
|
final String realm) {
|
||||||
|
String username = null;
|
||||||
|
String password = null;
|
||||||
|
|
||||||
|
final boolean reuseHttpAuthUsernamePassword = handler.useHttpAuthUsernamePassword();
|
||||||
|
|
||||||
|
if (reuseHttpAuthUsernamePassword && view != null) {
|
||||||
|
final String[] credentials = view.getHttpAuthUsernamePassword(host, realm);
|
||||||
|
if (credentials != null && credentials.length == 2) {
|
||||||
|
username = credentials[0];
|
||||||
|
password = credentials[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (username != null && password != null) {
|
||||||
|
handler.proceed(username, password);
|
||||||
|
} else {
|
||||||
|
createSignInDialog(handler, host, realm, username, password).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this method is called automatically when the Google login form is opened.
|
* this method is called automatically when the Google login form is opened.
|
||||||
*/
|
*/
|
||||||
@ -106,6 +162,16 @@ public class IITC_WebViewClient extends WebViewClient {
|
|||||||
// mIitc.onReceivedLoginRequest(this, view, realm, account, args);
|
// mIitc.onReceivedLoginRequest(this, view, realm, account, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// enable https
|
||||||
|
@Override
|
||||||
|
public void onReceivedSslError(final WebView view, final SslErrorHandler handler, final SslError error) {
|
||||||
|
handler.proceed();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
mIitcInjected = false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check every external resource if it's okay to load it and maybe replace it with our own content.
|
* Check every external resource if it's okay to load it and maybe replace it with our own content.
|
||||||
* This is used to block loading Niantic resources which aren’t required and to inject IITC early into the site.
|
* This is used to block loading Niantic resources which aren’t required and to inject IITC early into the site.
|
||||||
@ -174,70 +240,4 @@ public class IITC_WebViewClient extends WebViewClient {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onReceivedHttpAuthRequest(final WebView view, final HttpAuthHandler handler, final String host,
|
|
||||||
final String realm) {
|
|
||||||
String username = null;
|
|
||||||
String password = null;
|
|
||||||
|
|
||||||
final boolean reuseHttpAuthUsernamePassword = handler.useHttpAuthUsernamePassword();
|
|
||||||
|
|
||||||
if (reuseHttpAuthUsernamePassword && view != null) {
|
|
||||||
final String[] credentials = view.getHttpAuthUsernamePassword(host, realm);
|
|
||||||
if (credentials != null && credentials.length == 2) {
|
|
||||||
username = credentials[0];
|
|
||||||
password = credentials[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (username != null && password != null) {
|
|
||||||
handler.proceed(username, password);
|
|
||||||
} else {
|
|
||||||
createSignInDialog(handler, host, realm, username, password).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
|
||||||
// no other way for AlertDialog
|
|
||||||
public Dialog createSignInDialog(final HttpAuthHandler handler, final String host, final String realm,
|
|
||||||
final String username, final String password) {
|
|
||||||
final View v = mIitc.getLayoutInflater().inflate(R.layout.dialog_http_authentication, null);
|
|
||||||
final TextView tvUsername = (TextView) v.findViewById(R.id.username);
|
|
||||||
final TextView tvPassword = (TextView) v.findViewById(R.id.password);
|
|
||||||
final String title = String.format(mIitc.getString(R.string.sign_in_to), host, realm);
|
|
||||||
|
|
||||||
if (username != null)
|
|
||||||
tvUsername.setText(username);
|
|
||||||
if (password != null)
|
|
||||||
tvPassword.setText(password);
|
|
||||||
|
|
||||||
return new AlertDialog.Builder(mIitc)
|
|
||||||
.setView(v)
|
|
||||||
.setTitle(title)
|
|
||||||
.setCancelable(true)
|
|
||||||
.setPositiveButton(R.string.sign_in_action, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(final DialogInterface dialog, final int id) {
|
|
||||||
handler.proceed(tvUsername.getText().toString(), tvPassword.getText().toString());
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(final DialogInterface dialog, final int id) {
|
|
||||||
dialog.cancel();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
|
||||||
@Override
|
|
||||||
public void onCancel(final DialogInterface dialog) {
|
|
||||||
handler.cancel();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reset() {
|
|
||||||
mIitcInjected = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user