|
@@ -18,6 +18,7 @@ import android.support.v7.app.AlertDialog;
|
|
|
import android.support.v7.app.AppCompatActivity;
|
|
import android.support.v7.app.AppCompatActivity;
|
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
|
|
|
+import android.view.KeyEvent;
|
|
|
import android.view.MenuItem;
|
|
import android.view.MenuItem;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.webkit.SslErrorHandler;
|
|
import android.webkit.SslErrorHandler;
|
|
@@ -171,6 +172,56 @@ public class MainActivity extends AppCompatActivity implements RAWebView.WebView
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
|
|
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
|
|
|
|
|
+
|
|
|
|
|
+ executeGoBackJS();
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ return super.onKeyDown(keyCode, event);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void executeGoBackJS() {
|
|
|
|
|
+
|
|
|
|
|
+ String js = "goBack()";
|
|
|
|
|
+ mWebView.evaluateJavascript(js, new ValueCallback<String>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onReceiveValue(String value) {
|
|
|
|
|
+
|
|
|
|
|
+ Log.d(TAG, "GoBack ReceiveValue: " + value);
|
|
|
|
|
+
|
|
|
|
|
+ if (value.equals("false")) {
|
|
|
|
|
+
|
|
|
|
|
+ runOnUiThread(new Runnable() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run() {
|
|
|
|
|
+ new AlertDialog.Builder(mCtx)
|
|
|
|
|
+ .setTitle("Warning")
|
|
|
|
|
+ .setMessage("are you sure to exit?")
|
|
|
|
|
+ .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
+ finish();
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .setNegativeButton("No", new DialogInterface.OnClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .show();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ } else if (value.equals("true")) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void clickReload() {
|
|
private void clickReload() {
|
|
|
mEmptyContainer.setVisibility(View.GONE);
|
|
mEmptyContainer.setVisibility(View.GONE);
|
|
|
mWebView.loadUrl(mURL);
|
|
mWebView.loadUrl(mURL);
|