/**
  * XWalkView 用load()方法load 比较长的js会有问题
  *
  * @param url
  */
 public void loadUrl(String url) {
   if (url != null && url.startsWith("javascript:")) {
     super.evaluateJavascript(url, null);
   } else {
     super.load(url, null);
   }
 }
  @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);
          }
        });
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    XWalkPreferences.setValue(XWalkPreferences.ANIMATABLE_XWALK_VIEW, true);

    setContentView(R.layout.multi_texture_views);
    RelativeLayout parent = (RelativeLayout) findViewById(R.id.multi_texture_views);
    textDes = (TextView) findViewById(R.id.multiViews_des);
    textDes.setText(
        "This sample demonstrates Multiple TextureViews can be shown"
            + " in order. A,B,C views are TextureViews, D,E,F views are WebViews, "
            + "the sort order of A,B,C are the same with D,E,F when rotate or "
            + "restore the screen. Click \"Resize\" button to enlarge or reduce the views.");
    mResizeButton = (Button) findViewById(R.id.run_resize);
    LinearLayout btnLay = (LinearLayout) findViewById(R.id.toolbar2);
    btnLay.setY(180);
    btnLay.setX(550);
    root = (RelativeLayout) findViewById(R.id.root_views);
    for (int i = 0; i < 3; i++) {
      XWalkView xWalkView = new XWalkView(this, this);
      xWalkView.setX(i * 100);
      xWalkView.setY(130 + (i + 1) * 60);
      xWalkView.load(
          null,
          String.format(
              "<html><head><meta name='viewport' content='width=device-width'/></head>"
                  + "<body style='background-color: %s;'><h1>%s</h1></body></html>",
              i % 2 == 0 ? "white" : "grey", i == 0 ? "A" : i == 1 ? "B" : "C"));
      root.addView(xWalkView, 200, 200);
    }

    for (int i = 3; i < 6; i++) {
      WebView webView = new WebView(this);
      webView.setX(i * 100);
      webView.setY(130 + (i + 1) * 60);
      webView.loadData(
          String.format(
              "<html><body style='background-color: %s'><h1>%s</h1></body></html>",
              i % 2 == 0 ? "white" : "grey", i == 3 ? "D" : i == 4 ? "E" : "F"),
          "text/html",
          "utf-8");
      root.addView(webView, 200, 200);
    }

    setContentView(parent);
    mResizeButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (sizeFlag) {
              resize(root, 200, 200);
              sizeFlag = false;
            } else {
              resize(root, 400, 400);
              sizeFlag = true;
            }
          }
        });
  }
Ejemplo n.º 4
0
 @Override
 public void onResume() {
   super.onResume();
   if (xWalkWebView != null) {
     xWalkWebView.resumeTimers();
     xWalkWebView.onShow();
   }
 }
Ejemplo n.º 5
0
 @Override
 public void onPause() {
   super.onPause();
   if (xWalkWebView != null) {
     xWalkWebView.pauseTimers();
     xWalkWebView.onHide();
   }
 }
Ejemplo n.º 6
0
 @Override
 protected void onPause() {
   super.onPause();
   DataUser.setContext(null);
   if (mXwalkView != null) {
     mXwalkView.pauseTimers();
     mXwalkView.onHide();
   }
 }
Ejemplo n.º 7
0
 @Override
 protected void onResume() {
   DataUser.setContext(this);
   super.onResume();
   if (mXwalkView != null) {
     mXwalkView.resumeTimers();
     mXwalkView.onShow();
   }
 }
  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);
  }
Ejemplo n.º 9
0
  /**
   * Notify the host application that a page has started loading. This method is called once for
   * each main frame load so a page with iframes or framesets will call onPageStarted one time for
   * the main frame.
   *
   * <p>In Crosswalk, this method is called for iframe navigations where the scheme is something
   * other than http or https, which includes assets with the Cordova project, so we have to test
   * for that, and not reset plugins in that case.
   *
   * @param view The webview initiating the callback.
   * @param url The url of the page.
   */
  @Override
  public void onPageStarted(XWalkView view, String url) {

    // Only proceed if this is a top-level navigation
    if (view.getUrl() != null && view.getUrl().equals(url)) {
      // Flush stale messages.
      appView.onPageReset();
      // Broadcast message that page has loaded
      appView.getPluginManager().postMessage("onPageStarted", url);
    }
  }
Ejemplo n.º 10
0
 @Override
 public void onDestroy() {
   super.onDestroy();
   if (xWalkWebView != null) {
     xWalkWebView.onDestroy();
   }
 }
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   if (mXWalkView != null) {
     mXWalkView.saveState(outState);
   }
 }
 @Override
 protected void onXWalkReady() {
   StringBuffer mess = new StringBuffer();
   mess.append("Test Purpose: \n\n")
       .append(
           "Verifies XWalkView can restore html5 sessionStorage value when screen rotates.\n\n")
       .append("Test  Step:\n")
       .append("1. Turn on android system auto rotate setting.\n")
       .append("2. Load the page and you get 'myname: null'.\n")
       .append("3. Rotate the screen and click the button.\n")
       .append("4. The 'myname: ' value should be changed to 'jack'.\n")
       .append("Expected Result:\n\n")
       .append("Test passes if sessionStorage value changed to 'jack' when screen rotates.");
   new AlertDialog.Builder(this)
       .setTitle("Info")
       .setMessage(mess.toString())
       .setPositiveButton("confirm", null)
       .show();
   mRestoreBtn = (Button) findViewById(R.id.restore_btn);
   mRestoreBtn.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           if (mXWalkView != null) {
             mXWalkView.restoreState(mStoredBundle);
           }
         }
       });
   mXWalkView.load("file:///android_asset/session_storage_test.html", null);
 }
  @Override
  protected void onXWalkReady() {
    StringBuffer mess = new StringBuffer();
    mess.append("Test Purpose: \n\n")
        .append(
            "Verifies XWalkView can work with theme-color meta tag by setting XWalkPreferences.ENABLE_THEME_COLOR. Notice this feature only works on Android Lollipop or later.\n\n")
        .append("Test  Step:\n\n")
        .append("1. Default XWalkPreferences theme-color is enabled, just load the page.\n")
        .append("2. Click android recent-apps button to see our app status.\n")
        .append("Expected Result:\n\n")
        .append("Test passes if recent app list can show red toolbar XWalkView.");
    new AlertDialog.Builder(this)
        .setTitle("Info")
        .setMessage(mess.toString())
        .setPositiveButton("confirm", null)
        .show();

    mXWalkView.load("file:///android_asset/red_toolbar_theme.html", null);

    Button bt = (Button) findViewById(R.id.refresh_button);
    themeValue = (TextView) findViewById(R.id.theme_colcr_preference);
    bt.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Boolean value = XWalkPreferences.getBooleanValue(XWalkPreferences.ENABLE_THEME_COLOR);
            themeValue.setText("XWalkPreferences.ENABLE_THEME_COLOR is " + value);
          }
        });
  }
Ejemplo n.º 14
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   if (mXwalkView != null) {
     mXwalkView.onDestroy();
   }
 }
 @Override
 public void setUIClient(XWalkUIClient client) {
   // XWalk calls this method from its constructor.
   if (client instanceof XWalkCordovaUiClient) {
     this.uiClient = (XWalkCordovaUiClient) client;
   }
   super.setUIClient(client);
 }
  @Override
  public final void onXWalkInitCompleted() {
    StringBuffer mess = new StringBuffer();
    mess.append("Test Purpose: \n\n")
        .append("Verifies XWalkView can forward and backward history.\n\n")
        .append("Test  Step:\n\n")
        .append("1. Search some in baidu page, and click some some searched links.\n")
        .append("2. Click the go backward button and then cilck go forward button.\n\n")
        .append("Expected Result:\n\n")
        .append("Test passes if app history can go backward and go forward.");
    new AlertDialog.Builder(this)
        .setTitle("Info")
        .setMessage(mess.toString())
        .setPositiveButton("confirm", null)
        .show();

    setContentView(R.layout.navigation_layout);
    mPrevButton = (ImageButton) findViewById(R.id.prev);
    mNextButton = (ImageButton) findViewById(R.id.next);
    mXWalkView = (XWalkView) findViewById(R.id.xwalkview);

    text1 = (TextView) super.findViewById(R.id.text1);
    text2 = (TextView) super.findViewById(R.id.text2);
    text3 = (TextView) super.findViewById(R.id.text3);

    mPrevButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            // Go backward
            if (mXWalkView != null && mXWalkView.getNavigationHistory().canGoBack()) {
              mXWalkView
                  .getNavigationHistory()
                  .navigate(XWalkNavigationHistory.Direction.BACKWARD, 1);
            }
            XWalkNavigationItem navigationItem = mXWalkView.getNavigationHistory().getCurrentItem();
            showNavigationItemInfo(navigationItem);
          }
        });

    mNextButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            // Go forward
            if (mXWalkView != null && mXWalkView.getNavigationHistory().canGoForward()) {
              mXWalkView
                  .getNavigationHistory()
                  .navigate(XWalkNavigationHistory.Direction.FORWARD, 1);
            }
            XWalkNavigationItem navigationItem = mXWalkView.getNavigationHistory().getCurrentItem();
            showNavigationItemInfo(navigationItem);
          }
        });

    mXWalkView.load("http://www.baidu.com/", null);
  }
  @Override
  public final void onXWalkInitCompleted() {

    setContentView(R.layout.xwview_transparent_layout);
    StringBuffer mess = new StringBuffer();
    mess.append("Test Purpose: \n\n")
        .append(
            "Check XWalkView's transparent feature whether display the view under the webview.\n\n")
        .append("Expected Result:\n\n")
        .append("Test passes if you can see button view & blue imageview");
    new AlertDialog.Builder(this)
        .setTitle("Info")
        .setMessage(mess.toString())
        .setPositiveButton("confirm", null)
        .show();
    mXWalkView = (XWalkView) findViewById(R.id.xwalkview_transparent);
    mXWalkView.setZOrderOnTop(true);
    mXWalkView.setBackgroundColor(0);
    mXWalkView.load("http://www.baidu.com/", null);
  }
Ejemplo n.º 18
0
  @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);
  }
Ejemplo n.º 19
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (mXwalkView != null) {
     mXwalkView.onActivityResult(requestCode, resultCode, data);
   }
   /*
    * mXwalkView.load("http://150.107.31.5/dev/app/conference.php?room=test"
    * , null); mXwalkView.load("http://aquariospace.com:3000/room/main/",
    * null); mXwalkView.load("https://tawk.com/armymax", null);
    * mXwalkView.load("https://talky.io/armymax", null);
    */
 }
 @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
  public final void onXWalkInitCompleted() {
    setContentView(R.layout.activity_xwalk_view_with_on_unhandled_keyevent);
    mXWalkView = (XWalkView) findViewById(R.id.xwalk_view);
    mTextView = (TextView) findViewById(R.id.unhandled_keyevent_label);

    StringBuffer mess = new StringBuffer();
    mess.append("Test Purpose: \n\n")
        .append("Verifies XWalkView UI Client can override 'onUnhandledKeyEvent' method.\n\n")
        .append("Test  Step:\n\n")
        .append("1. Load baidu webpage.\n")
        .append("2. Input any words in the input field.\n")
        .append("Expected Result:\n\n")
        .append("Test passes if text shows \"onUnhandledKeyEvent is invoked\".");
    new AlertDialog.Builder(this)
        .setTitle("Info")
        .setMessage(mess.toString())
        .setPositiveButton("confirm", null)
        .show();

    mXWalkView.setUIClient(new UIClient(mXWalkView));
    mXWalkView.load("http://www.baidu.com/", null);
  }
  @Override
  protected void onXWalkReady() {
    StringBuffer mess = new StringBuffer();
    mess.append("Test Purpose: \n\n")
        .append("Verifies XWalkView Window can forbid screenshot.\n\n")
        .append("Test  Step:\n\n")
        .append("1. Press the power button and the volume down button at the same time.\n")
        .append("2. Android system should prevent the window screenshot.\n")
        .append("Expected Result:\n\n")
        .append("Test passes if system prevent the window screenshot.");
    new AlertDialog.Builder(this)
        .setTitle("Info")
        .setMessage(mess.toString())
        .setPositiveButton("confirm", null)
        .show();

    mXWalkView.load("http://www.baidu.com/", null);
  }
  @Override
  public void onHideCustomView() {
    Activity activity = mView.getActivity();

    if (mCustomView == null || activity == null) return;

    // Clear the activity fullscreen flag.
    if (!mOriginalFullscreen) {
      activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

    // Remove video view from activity's ContentView.
    FrameLayout decor = (FrameLayout) activity.getWindow().getDecorView();
    decor.removeView(mCustomView);
    mCustomViewCallback.onCustomViewHidden();

    mCustomView = null;
    mCustomViewCallback = null;
  }
Ejemplo n.º 24
0
  private void showHttpAuthDialog(
      final XWalkHttpAuthHandler handler, final String host, final String realm) {
    LinearLayout layout = new LinearLayout(mContext);
    final EditText userNameEditText = new EditText(mContext);
    final EditText passwordEditText = new EditText(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPaddingRelative(10, 0, 10, 20);
    userNameEditText.setHint(R.string.http_auth_user_name);
    passwordEditText.setHint(R.string.http_auth_password);
    layout.addView(userNameEditText);
    layout.addView(passwordEditText);

    final Activity curActivity = mView.getActivity();
    AlertDialog.Builder httpAuthDialog = new AlertDialog.Builder(curActivity);
    httpAuthDialog
        .setTitle(R.string.http_auth_title)
        .setView(layout)
        .setCancelable(false)
        .setPositiveButton(
            R.string.http_auth_log_in,
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int whichButton) {
                String userName = userNameEditText.getText().toString();
                String password = passwordEditText.getText().toString();
                setHttpAuthUsernamePassword(host, realm, userName, password);
                handler.proceed(userName, password);
                dialog.dismiss();
              }
            })
        .setNegativeButton(
            android.R.string.cancel,
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int whichButton) {
                handler.cancel();
                dialog.dismiss();
              }
            })
        .create()
        .show();
  }
  @Override
  public void onShowCustomView(View view, CustomViewCallback callback) {
    Activity activity = mView.getActivity();

    if (mCustomView != null || activity == null) {
      callback.onCustomViewHidden();
      return;
    }

    mCustomView = view;
    mCustomViewCallback = callback;

    if ((activity.getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
        != 0) {
      mOriginalFullscreen = true;
    } else {
      mOriginalFullscreen = false;
    }

    // Set the activity to be fullscreen first.
    if (!mOriginalFullscreen) {
      activity
          .getWindow()
          .setFlags(
              WindowManager.LayoutParams.FLAG_FULLSCREEN,
              WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

    // Add the video view to the activity's ContentView.
    activity
        .getWindow()
        .addContentView(
            view,
            new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT,
                Gravity.CENTER));
  }
Ejemplo n.º 26
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection

    switch (item.getItemId()) {
      case android.R.id.home:
        Intent upIntent = new Intent(this, AChatActivity.class);
        if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
          TaskStackBuilder.from(this).addNextIntent(upIntent).startActivities();
          finish();
        } else {
          NavUtils.navigateUpTo(this, upIntent);
        }
        return true;

      case R.id.action_refresh:
        mXwalkView.load(url, null);
        return true;

      default:
        return super.onOptionsItemSelected(item);
    }
  }
Ejemplo n.º 27
0
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   // TODO(yongsheng): Pass it to extensions.
   mXwalkView.onActivityResult(requestCode, resultCode, data);
 }
Ejemplo n.º 28
0
 @Override
 public void onPause() {
   // TODO(yongsheng): Pass it to extensions.
   mXwalkView.onPause();
 }
 protected void onDestroy() {
   super.onDestroy();
   if (mWeb != null) {
     mWeb.onDestroy();
   }
 }
Ejemplo n.º 30
0
 @Override
 public void disableRemoteDebugging() {
   mXwalkView.disableRemoteDebugging();
 }