Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 package org.mozilla.gecko.sync.setup.activities;
7 import org.mozilla.gecko.R;
8 import org.mozilla.gecko.background.common.log.Logger;
10 import android.app.Activity;
11 import android.net.Uri;
12 import android.os.Bundle;
13 import android.view.Window;
14 import android.webkit.WebChromeClient;
15 import android.webkit.WebView;
16 import android.webkit.WebViewClient;
18 /**
19 * Displays URI in an embedded WebView. Closes if there no URI is passed in.
20 * @author liuche
21 *
22 */
23 public class WebViewActivity extends SyncActivity {
24 private final static String LOG_TAG = "WebViewActivity";
26 @Override
27 public void onCreate(Bundle savedInstanceState) {
28 super.onCreate(savedInstanceState);
29 getWindow().requestFeature(Window.FEATURE_PROGRESS);
30 setContentView(R.layout.sync_setup_webview);
31 // Extract URI to launch from Intent.
32 Uri uri = this.getIntent().getData();
33 if (uri == null) {
34 Logger.debug(LOG_TAG, "No URI passed to display.");
35 finish();
36 return;
37 }
39 WebView wv = (WebView) findViewById(R.id.web_engine);
40 // Add a progress bar.
41 final Activity activity = this;
42 wv.setWebChromeClient(new WebChromeClient() {
43 @Override
44 public void onProgressChanged(WebView view, int progress) {
45 // Activities and WebViews measure progress with different scales.
46 // The progress meter will automatically disappear when we reach 100%
47 activity.setProgress(progress * 100);
48 }
49 });
50 wv.setWebViewClient(new WebViewClient() {
51 // Handle url loading in this WebView, instead of asking the ActivityManager.
52 @Override
53 public boolean shouldOverrideUrlLoading(WebView view, String url) {
54 view.loadUrl(url);
55 return false;
56 }
57 });
58 wv.loadUrl(uri.toString());
60 }
61 }