Search in sources :

Example 76 with WebView

use of android.webkit.WebView in project android_frameworks_base by ParanoidAndroid.

the class NetworkActivity method showErrorPage.

// Displays an error if the app is unable to load content.
private void showErrorPage() {
    setContentView(R.layout.main);
    // The specified network connection is not available. Displays error message.
    WebView myWebView = (WebView) findViewById(R.id.webview);
    myWebView.loadData(getResources().getString(R.string.connection_error), "text/html", null);
}
Also used : WebView(android.webkit.WebView)

Example 77 with WebView

use of android.webkit.WebView in project android_frameworks_base by ParanoidAndroid.

the class PowerTestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.v(LOGTAG, "onCreate, inst=" + Integer.toHexString(hashCode()));
    LinearLayout contentView = new LinearLayout(this);
    contentView.setOrientation(LinearLayout.VERTICAL);
    setContentView(contentView);
    setTitle("Idle");
    webView = new WebView(this);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
    webView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
    webViewClient = new SimpleWebViewClient();
    chromeClient = new SimpleChromeClient();
    webView.setWebViewClient(webViewClient);
    webView.setWebChromeClient(chromeClient);
    contentView.addView(webView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0f));
    handler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            switch(msg.what) {
                case MSG_TIMEOUT:
                    handleTimeout();
                    return;
                case MSG_NAVIGATE:
                    manualDelay = msg.arg2;
                    navigate(msg.getData().getString(MSG_NAV_URL), msg.arg1);
                    logTime = msg.getData().getBoolean(MSG_NAV_LOGTIME);
                    return;
            }
        }
    };
    pageDoneLock = new Object();
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) Message(android.os.Message) Handler(android.os.Handler) WebView(android.webkit.WebView) LinearLayout(android.widget.LinearLayout)

Example 78 with WebView

use of android.webkit.WebView in project android_frameworks_base by ParanoidAndroid.

the class ReliabilityTestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.v(LOGTAG, "onCreate, inst=" + Integer.toHexString(hashCode()));
    LinearLayout contentView = new LinearLayout(this);
    contentView.setOrientation(LinearLayout.VERTICAL);
    setContentView(contentView);
    setTitle("Idle");
    webView = new WebView(this);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
    webView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
    webViewClient = new SimpleWebViewClient();
    chromeClient = new SimpleChromeClient();
    webView.setWebViewClient(webViewClient);
    webView.setWebChromeClient(chromeClient);
    contentView.addView(webView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0f));
    handler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            switch(msg.what) {
                case MSG_TIMEOUT:
                    handleTimeout();
                    return;
                case MSG_NAVIGATE:
                    manualDelay = msg.arg2;
                    navigate(msg.getData().getString(MSG_NAV_URL), msg.arg1);
                    logTime = msg.getData().getBoolean(MSG_NAV_LOGTIME);
                    return;
            }
        }
    };
    pageDoneLock = new Object();
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) Message(android.os.Message) SslErrorHandler(android.webkit.SslErrorHandler) Handler(android.os.Handler) HttpAuthHandler(android.webkit.HttpAuthHandler) WebView(android.webkit.WebView) LinearLayout(android.widget.LinearLayout)

Example 79 with WebView

use of android.webkit.WebView in project android_frameworks_base by ParanoidAndroid.

the class TestShellActivity method onCreate.

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    requestWindowFeature(Window.FEATURE_PROGRESS);
    LinearLayout contentView = new LinearLayout(this);
    contentView.setOrientation(LinearLayout.VERTICAL);
    setContentView(contentView);
    CookieManager.setAcceptFileSchemeCookies(true);
    mWebView = new WebView(this);
    mWebViewClassic = WebViewClassic.fromWebView(mWebView);
    mEventSender = new WebViewEventSender(mWebView);
    mCallbackProxy = new CallbackProxy(mEventSender, this);
    mWebView.addJavascriptInterface(mCallbackProxy, "layoutTestController");
    mWebView.addJavascriptInterface(mCallbackProxy, "eventSender");
    setupWebViewForLayoutTests(mWebView, mCallbackProxy);
    contentView.addView(mWebView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0f));
    mWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
    // Expose window.gc function to JavaScript. JSC build exposes
    // this function by default, but V8 requires the flag to turn it on.
    // WebView::setJsFlags is noop in JSC build.
    mWebViewClassic.setJsFlags("--expose_gc");
    mHandler = new AsyncHandler();
    Intent intent = getIntent();
    if (intent != null) {
        executeIntent(intent);
    }
    // This is asynchronous, but it gets processed by WebCore before it starts loading pages.
    mWebViewClassic.setUseMockDeviceOrientation();
}
Also used : Intent(android.content.Intent) WebView(android.webkit.WebView) LinearLayout(android.widget.LinearLayout)

Example 80 with WebView

use of android.webkit.WebView in project android_frameworks_base by ParanoidAndroid.

the class ProfileActivity method onCreate.

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mInspectButton = (Button) findViewById(R.id.inspect);
    mCaptureButton = (ToggleButton) findViewById(R.id.capture);
    mVelocitySpinner = (Spinner) findViewById(R.id.velocity);
    mMovementSpinner = (Spinner) findViewById(R.id.movement);
    mUrl = (EditText) findViewById(R.id.url);
    mWeb = (ProfiledWebView) findViewById(R.id.web);
    setCallback(new ProfileCallback() {

        @SuppressWarnings("unchecked")
        @Override
        public void profileCallback(RunData data) {
            new StoreFileTask().execute(new Pair<String, RunData>(TEMP_FILENAME, data));
            Log.d("ProfileActivity", "stored " + data.frames.length + " frames in file");
            setTestingState(TestingState.STOP_TESTING);
        }
    });
    // Inspect button (opens PlaybackActivity)
    mInspectButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(ProfileActivity.this, PlaybackActivity.class));
        }
    });
    // Velocity spinner
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.velocity_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mVelocitySpinner.setAdapter(adapter);
    mVelocitySpinner.setOnItemSelectedListener(new VelocitySelectedListener());
    mVelocitySpinner.setSelection(3);
    // Movement spinner
    String[] content = { getResources().getString(R.string.movement_auto_scroll), getResources().getString(R.string.movement_manual), getResources().getString(R.string.movement_timed) };
    adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item, content);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mMovementSpinner.setAdapter(adapter);
    mMovementSpinner.setOnItemSelectedListener(new MovementSelectedListener());
    mMovementSpinner.setSelection(0);
    // Capture toggle button
    mCaptureButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mCaptureButton.isChecked()) {
                startViewProfiling(false);
            } else {
                mWeb.stopScrollTest();
            }
        }
    });
    // Custom profiling WebView
    mWeb.init(this);
    mWeb.setWebViewClient(new LoggingWebViewClient());
    // URL text entry
    mUrl.setOnEditorActionListener(new OnEditorActionListener() {

        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            String url = mUrl.getText().toString();
            mWeb.loadUrl(url);
            mWeb.requestFocus();
            return true;
        }
    });
    setTestingState(TestingState.NOT_TESTING);
}
Also used : Intent(android.content.Intent) View(android.view.View) AdapterView(android.widget.AdapterView) WebView(android.webkit.WebView) TextView(android.widget.TextView) KeyEvent(android.view.KeyEvent) OnClickListener(android.view.View.OnClickListener) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView) Pair(android.util.Pair)

Aggregations

WebView (android.webkit.WebView)328 WebViewClient (android.webkit.WebViewClient)108 View (android.view.View)82 WebSettings (android.webkit.WebSettings)48 Intent (android.content.Intent)42 SuppressLint (android.annotation.SuppressLint)37 WebChromeClient (android.webkit.WebChromeClient)37 TextView (android.widget.TextView)28 DialogInterface (android.content.DialogInterface)23 LinearLayout (android.widget.LinearLayout)23 ImageView (android.widget.ImageView)22 Bitmap (android.graphics.Bitmap)19 AlertDialog (android.app.AlertDialog)17 Test (org.junit.Test)15 Uri (android.net.Uri)12 Bundle (android.os.Bundle)12 Handler (android.os.Handler)11 WebResourceRequest (android.webkit.WebResourceRequest)11 Drawable (android.graphics.drawable.Drawable)10 Button (android.widget.Button)10