@Override protected void onXWalkReady() { StringBuffer mess = new StringBuffer(); mess.append("Test Purpose: \n\n") .append("Verifies OnReceivedHttpAuthRequest API can be invoked in XWalkResourceClient.\n\n") .append("Expected Result:\n\n") .append("Test passes if the host name will be shown and it is 'httpbin.org'"); new AlertDialog.Builder(this) .setTitle("Info") .setMessage(mess.toString()) .setPositiveButton("confirm", null) .show(); mTextView = (TextView) findViewById(R.id.httpauth_request_label); mXWalkView = (XWalkView) findViewById(R.id.xwalk_view); mXWalkView.load("http://httpbin.org/basic-auth/user/passwd", null); mXWalkView.setResourceClient( new XWalkResourceClient(mXWalkView) { @Override public void onReceivedHttpAuthRequest( XWalkView view, XWalkHttpAuthHandler handler, String host, String realm) { // TODO Auto-generated method stub super.onReceivedHttpAuthRequest(view, handler, host, realm); mTextView.setText(host); } }); }
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_device_detail); mWeb = (XWalkView) findViewById(R.id.id_device_web); // 传过来的设备信息 Intent i = getIntent(); pid = getPid(i.getStringExtra("detail")); cid = getCid(i.getStringExtra("detail")); mid = getMid(i.getStringExtra("detail")); tid = i.getStringExtra("tid"); String lang = getResources().getConfiguration().locale.getLanguage() + "-" + getResources().getConfiguration().locale.getCountry(); String user = ((TelephonyManager) DeviceDetailActivity.this.getSystemService(TELEPHONY_SERVICE)) .getDeviceId(); detailProgressBar = CustomProgress.show( DeviceDetailActivity.this, getResources().getString(R.string.login_loadding).toString(), true, null); mWeb.setResourceClient(new ResourceClient(mWeb)); if (mid != null && tid != null && Global.USERACCESSKEY != null && user != null) { mWeb.load( "http://app.hekr.me/android/" + mid + "/index.html?access_key=" + Global.USERACCESSKEY + "&tid=" + tid + "&lang=" + lang + "&user="******"file:///android_asset/www/js/testws.html") Log.i( "MyLog", "detail-url:" + "http://app.hekr.me/android/" + mid + "/index.html?access_key=" + Global.USERACCESSKEY + "&tid=" + tid + "&lang=" + lang + "&user=" + user); }
@Override public void setResourceClient(XWalkResourceClient client) { LOG.d(TAG, "*** XWalkCordovaView setResourceClient"); // XWalk calls this method from its constructor. if (client instanceof XWalkCordovaResourceClient) { LOG.d(TAG, "*** XWalkCordovaView setResourceClient client is XWalkCordovaResourceClient"); this.resourceClient = (XWalkCordovaResourceClient) client; } else { LOG.d(TAG, "*** XWalkCordovaView setResourceClient client is NOT XWalkCordovaResourceClient"); } super.setResourceClient(client); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_conference); statusCheck(); getActionBar().setTitle("ArmyMax : PHONE CALL"); url = getIntent().getExtras().getString("url"); getActionBar().setDisplayHomeAsUpEnabled(true); Log.e("XwalkURL", url); // Toast.makeText(this, url, Toast.LENGTH_LONG).show(); mXwalkView = (XWalkView) findViewById(R.id.conference); mXwalkView.setResourceClient(new MyResourceClient(mXwalkView)); mXwalkView.setUIClient(new MyUIClient(mXwalkView)); // mXwalkView.getSettings().setGeolocationEnabled(true); mXwalkView.clearCache(true); mXwalkView.load(url, null); }
@Nullable @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.main_fragment, container, false); this.xWalkWebView = (XWalkView) rootView.findViewById(R.id.xwalk_web_view); // turn on debugging XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true); final AlertDialog alertDialog = new AlertDialog.Builder(this.getActivity()).create(); mProgressBarDialog = ProgressDialog.show( this.getActivity(), getString(R.string.loading_title), getString(R.string.loading_text)); XWalkResourceClient myXWalkResourceClient = new XWalkResourceClient(this.xWalkWebView) { @Override public boolean shouldOverrideUrlLoading(XWalkView view, String url) { // Log.i(Constants.TAG, getString(R.string.url_click_log_text)); // view.load(url, null); // return true; return super.shouldOverrideUrlLoading(view, url); } @Override public void onLoadFinished(XWalkView view, String url) { Log.i(Constants.TAG, getString(R.string.url_load_finished_log_text) + url); if (mProgressBarDialog.isShowing()) { mProgressBarDialog.dismiss(); } super.onLoadFinished(view, url); } @Override public void onReceivedLoadError( XWalkView view, int errorCode, String description, String failingUrl) { Log.e(Constants.TAG, getString(R.string.error) + ": " + description); Toast.makeText( ETMainFragment.this.getActivity(), getString(R.string.error_toast) + description, Toast.LENGTH_SHORT) .show(); alertDialog.setTitle(getString(R.string.error)); alertDialog.setMessage(description); // TODO: possibly set click listener for positive button alertDialog.show(); super.onReceivedLoadError(view, errorCode, description, failingUrl); } }; xWalkWebView.setResourceClient(myXWalkResourceClient); // WebSettings settings = xWalkWebView.getSettings(); // settings.setJavaScriptEnabled(true); // xWalkWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); // // final AlertDialog alertDialog = new AlertDialog.Builder(this.getActivity()).create(); // mProgressBarDialog = ProgressDialog.show(this.getActivity(), // getString(R.string.loading_title), getString(R.string.loading_text)); // // xWalkWebView.setWebViewClient(new WebViewClient() { // public boolean shouldOverrideUrlLoading(WebView view, String url) { // Log.i(Constants.TAG, getString(R.string.url_click_log_text)); // view.loadUrl(url); // return true; // } // // public void onPageFinished(WebView view, String url) { // Log.i(Constants.TAG, getString(R.string.url_load_finished_log_text) + url); // if (mProgressBarDialog.isShowing()) { // mProgressBarDialog.dismiss(); // } // } // // public void onReceivedError(WebView view, int errorCode, String description, // String failingUrl) { // Log.e(Constants.TAG, getString(R.string.error) + ": " + description); // Toast.makeText(ETMainFragment.this.getActivity(), // getString(R.string.error_toast) + description, Toast.LENGTH_SHORT).show(); // alertDialog.setTitle(getString(R.string.error)); // alertDialog.setMessage(description); // //TODO: possibly set click listener for positive button // alertDialog.show(); // } // }); // xWalkWebView.loadUrl(Constants.URL); xWalkWebView.load(Constants.URL, null); return rootView; }