private dd(Context context, ab abVar, boolean z, boolean z2, l lVar, db dbVar) {
   super(context);
   this.mg = new Object();
   this.pZ = context;
   this.mF = abVar;
   this.qb = z;
   this.nP = lVar;
   this.mG = dbVar;
   setBackgroundColor(0);
   WebSettings settings = getSettings();
   settings.setJavaScriptEnabled(true);
   settings.setSavePassword(false);
   settings.setSupportMultipleWindows(true);
   settings.setJavaScriptCanOpenWindowsAutomatically(true);
   cv.a(context, dbVar.pU, settings);
   if (VERSION.SDK_INT >= 17) {
     cx.a(getContext(), settings);
   } else if (VERSION.SDK_INT >= 11) {
     cw.a(getContext(), settings);
   }
   setDownloadListener(this);
   if (VERSION.SDK_INT >= 11) {
     this.pY = new dg(this, z2);
   } else {
     this.pY = new de(this, z2);
   }
   setWebViewClient(this.pY);
   if (VERSION.SDK_INT >= 14) {
     setWebChromeClient(new dh(this));
   } else if (VERSION.SDK_INT >= 11) {
     setWebChromeClient(new df(this));
   }
   bf();
 }
Esempio n. 2
0
 public static void initializeSettings(WebSettings settings, Context context) {
   settings.setJavaScriptEnabled(true);
   settings.setJavaScriptCanOpenWindowsAutomatically(true);
   settings.setUserAgentString(settings.getUserAgentString() + DB.USER_AGENT);
   settings.setSupportMultipleWindows(true);
   settings.setSaveFormData(false);
   settings.setSavePassword(false); // 设置为true,系统会弹出AlertDialog确认框
   if (API < 18) {
     settings.setAppCacheMaxSize(Long.MAX_VALUE);
   }
   if (API < 17) {
     settings.setEnableSmoothTransition(true);
   }
   if (API < 19) {
     settings.setDatabasePath(context.getFilesDir().getAbsolutePath() + "/databases");
   }
   settings.setDomStorageEnabled(true);
   settings.setAppCachePath(context.getCacheDir().toString());
   settings.setAppCacheEnabled(true);
   settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
   settings.setGeolocationDatabasePath(context.getCacheDir().getAbsolutePath());
   settings.setAllowFileAccess(true);
   settings.setDatabaseEnabled(true);
   settings.setSupportZoom(true);
   settings.setBuiltInZoomControls(true);
   settings.setDisplayZoomControls(false);
   settings.setAllowContentAccess(true);
   settings.setDefaultTextEncodingName("utf-8");
   /*if (API > 16) {
   	settings.setAllowFileAccessFromFileURLs(false);
   	settings.setAllowUniversalAccessFromFileURLs(false);
   }*/
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                .setAction("Action", null)
                .show();
          }
        });

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle =
        new ActionBarDrawerToggle(
            this,
            drawer,
            toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    // WebView
    mwebView = (WebView) findViewById(R.id.myWebView);
    WebSettings webSettings = mwebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    // improve webView performance
    mwebView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
    mwebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    mwebView.getSettings().setAppCacheEnabled(true);
    mwebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    webSettings.setDomStorageEnabled(true);
    webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
    webSettings.setUseWideViewPort(true);
    webSettings.setSavePassword(true);
    webSettings.setSaveFormData(true);
    webSettings.setEnableSmoothTransition(true);

    mwebView.loadUrl("http://www.newsweek.com");
    // force links open in webview only
    mwebView.setWebViewClient(new MyWebviewClient());
  }
Esempio n. 4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home);
    // -------------------------------TabView
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    viewPager = (ViewPager) findViewById(R.id.viewpager);
    setupViewPager(viewPager);

    tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
    // --------------------------------------

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle =
        new ActionBarDrawerToggle(
            this,
            drawer,
            toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    // WebView
    mwebView = (WebView) findViewById(R.id.myWebView);
    WebSettings webSettings = mwebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    // improve webView performance
    mwebView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
    mwebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    mwebView.getSettings().setAppCacheEnabled(true);
    mwebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    webSettings.setDomStorageEnabled(true);
    webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
    webSettings.setUseWideViewPort(true);
    webSettings.setSavePassword(true);
    webSettings.setSaveFormData(true);
    webSettings.setEnableSmoothTransition(true);

    mwebView.loadUrl("http://www.newsweek.com");
    // force links open in webview only
    mwebView.setWebViewClient(new MyWebviewClient());
  }
Esempio n. 5
0
  public AdWebView(
      AdViewContainer parent,
      MASTAdLog log,
      DisplayMetrics metrics,
      boolean mraid,
      boolean handleClicks) {
    super(parent.getContext());
    this.setId(getIdForView());

    adViewContainer = parent;
    adLog = log;
    // this.metrics = metrics;
    supportMraid = mraid;
    // launchBrowserOnClicks = handleClicks;

    // dataToInject = null;
    defferedJavascript = new StringBuffer();

    // Clients for javascript and other integration
    setWebChromeClient(new AdWebChromeClient());
    setWebViewClient(new AdWebViewClient(parent.getContext()));

    // Customize settings for web view
    WebSettings webSettings = getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setSavePassword(false);
    webSettings.setSaveFormData(false);
    webSettings.setSupportZoom(false);
    webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);

    // apply standard properties
    setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);

    if (supportMraid) {
      javascriptInterface = new JavascriptInterface(parent, this);
      mraidInterface = new MraidInterface(parent, this);

      /*mraidScript = FileUtils.readTextFromJar(parent.getContext(),
      "/js/mraid.js");*/
    }

    // System.out.println("mraid script read: " + mraidScript);

    if (handleClicks) {
      adClickHandler = new AdClickHandler(adViewContainer);
    }
  }
Esempio n. 6
0
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.sousuoactivity1);

      editText = (EditText) findViewById(R.id.editText);
      tips = (TextView) findViewById(R.id.tips);
      submit1 = (Button) findViewById(R.id.submit);
      webView = (WebView) findViewById(R.id.toutput);

      webSettings = webView.getSettings();
      webSettings.setSaveFormData(false);
      webSettings.setSavePassword(false);
      webSettings.setSupportZoom(false);

      webView.setWebViewClient(
          new WebViewClient() {
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
              view.loadUrl(url);
              return true;
            }
          });

      submit1.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              Toast.makeText(Search.this, "aaaaaaaaaaaa", Toast.LENGTH_SHORT).show();
              if (editText.getText().toString().length() == 0) {
                Toast.makeText(Search.this, "请输入查询的词", Toast.LENGTH_SHORT).show();
                return;
              } else {
                tips.setVisibility(TextView.VISIBLE);
                webView.setVisibility(WebView.VISIBLE);
                handler.post(
                    new Runnable() {
                      @Override
                      public void run() {
                        webView.loadUrl(
                            "http://www.baike.com/wiki/" + editText.getText().toString());
                      }
                    });
              }
            }
          });
    }
Esempio n. 7
0
  @SuppressLint("SetJavaScriptEnabled")
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log_OC.d(TAG, "onCreateView");

    // Inflate layout of the dialog
    View rootView =
        inflater.inflate(
            R.layout.sso_dialog,
            container,
            false); // null parent view because it will go in the dialog layout
    mSsoWebView = (WebView) rootView.findViewById(R.id.sso_webview);

    mWebViewClient.setTargetUrl(mTargetUrl);
    mSsoWebView.setWebViewClient(mWebViewClient);

    if (savedInstanceState == null) {
      Log_OC.d(TAG, "   initWebView start");
      CookieManager cookieManager = CookieManager.getInstance();
      cookieManager.setAcceptCookie(true);
      cookieManager.removeAllCookie();
      mSsoWebView.loadUrl(mInitialUrl);

    } else {
      Log_OC.d(TAG, "   restoreWebView start");
      WebBackForwardList history =
          mSsoWebView.restoreState(savedInstanceState.getBundle(KEY_WEBVIEW_STATE));
      if (history == null) {
        Log_OC.e(TAG, "Error restoring WebView state ; back to starting URL");
        mSsoWebView.loadUrl(mInitialUrl);
      }
    }

    WebSettings webSettings = mSsoWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setLoadWithOverviewMode(false);
    webSettings.setSavePassword(false);
    webSettings.setUserAgentString(WebdavClient.USER_AGENT);
    webSettings.setSaveFormData(false);

    return rootView;
  }
  private void initView() {
    // To change body of created methods use File | Settings | File Templates.

    webView = (WebView) findViewById(R.id.webView);
    WebSettings webSettings = webView.getSettings();
    webSettings.setSavePassword(false);
    webSettings.setSaveFormData(false);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setSupportZoom(true);
    webView.setOnTouchListener(this);

    if (mNavLeftButton == null) {
      mNavLeftButton = (ImageView) findViewById(R.id.nav_left_image);
    }
    mNavLeftButton.setVisibility(View.VISIBLE);
    mNavLeftButton.setOnClickListener(this);

    loadData();
  }
Esempio n. 9
0
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);
    mWebView = (WebView) findViewById(R.id.webview);

    WebSettings webSettings = mWebView.getSettings();
    webSettings.setSavePassword(false);
    webSettings.setSaveFormData(false);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setSupportZoom(false);

    mWebView.setWebChromeClient(new MyWebChromeClient());

    mWebView.addJavascriptInterface(new DemoJavaScriptInterface(), "demo");

    setCustomUserAgent();

    mWebView.loadUrl("file:///android_asset/demo.html");
  }
Esempio n. 10
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.oauthactivity_layout);
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(false);
    actionBar.setTitle(getString(R.string.login));
    webView = (WebView) findViewById(R.id.webView);
    webView.setWebViewClient(new WeiboWebViewClient());

    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setSaveFormData(false);
    settings.setSavePassword(false);
    settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    settings.setRenderPriority(WebSettings.RenderPriority.HIGH);

    CookieSyncManager.createInstance(this);
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.removeAllCookie();
  }
Esempio n. 11
0
  /** Initialize the WebView options to the ones define by user. */
  public void initializeOptions() {
    WebSettings settings = getSettings();

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());

    settings.setJavaScriptEnabled(
        prefs.getBoolean(Constants.PREFERENCES_BROWSER_ENABLE_JAVASCRIPT, true));
    settings.setLoadsImagesAutomatically(
        prefs.getBoolean(Constants.PREFERENCES_BROWSER_ENABLE_IMAGES, true));
    settings.setSaveFormData(
        prefs.getBoolean(Constants.PREFERENCES_BROWSER_ENABLE_FORM_DATA, true));
    settings.setSavePassword(
        prefs.getBoolean(Constants.PREFERENCES_BROWSER_ENABLE_PASSWORDS, true));
    settings.setDefaultZoom(
        ZoomDensity.valueOf(
            prefs.getString(
                Constants.PREFERENCES_BROWSER_DEFAULT_ZOOM_LEVEL, ZoomDensity.MEDIUM.toString())));
    settings.setUserAgentString(
        prefs.getString(Constants.PREFERENCES_BROWSER_USER_AGENT, Constants.USER_AGENT_DEFAULT));

    settings.setPluginState(
        PluginState.valueOf(
            prefs.getString(
                Constants.PREFERENCES_BROWSER_ENABLE_PLUGINS, PluginState.ON_DEMAND.toString())));

    CookieManager.getInstance()
        .setAcceptCookie(prefs.getBoolean(Constants.PREFERENCES_BROWSER_ENABLE_COOKIES, true));

    // Technical settings
    // settings.setUseWideViewPort(true);
    settings.setSupportMultipleWindows(true);
    setLongClickable(true);
    setScrollbarFadingEnabled(true);
    setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    setDrawingCacheEnabled(true);

    settings.setAppCacheEnabled(true);
    settings.setDatabaseEnabled(true);
    settings.setDomStorageEnabled(true);
  }
Esempio n. 12
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mWebView = (WebView) findViewById(R.id.webview);

    url = getIntent().getStringExtra("url");
    title = getIntent().getStringExtra("title");
    page = 0;

    WebSettings webSettings = mWebView.getSettings();
    webSettings.setSavePassword(false);
    webSettings.setSaveFormData(false);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setSupportZoom(false);

    mWebView.setWebChromeClient(new MyWebChromeClient());

    mWebView.addJavascriptInterface(new AiGouJavaScriptInterface(), "aigou");

    mWebView.loadUrl("file:///android_asset/www/category-show.html");
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Config.LOGD) Log.i(LOGTAG, "onCreate");
    if (context == null) context = getApplicationContext();

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    // prepare connection to TwitterService for post processing: call to twitterLogin(pin) (OAuth
    // pin handover)
    Intent serviceIntent = new Intent(this, TwitterService.class);
    bindService(serviceIntent, serviceConnection, BIND_AUTO_CREATE);

    if (myWebView == null) {
      myWebView = new WebView(this);
      if (myWebView != null) {
        WebSettings webSettings = myWebView.getSettings();
        if (webSettings != null) {
          webSettings.setJavaScriptEnabled(true);
          webSettings.setSavePassword(false);
          webSettings.setSaveFormData(false);
        }

        myWebView.setWebViewClient(new MyWebViewClient()); // onPageFinished(), etc.
        myWebView.setWebChromeClient(new MyWebChromeClient()); // onJsAlert(), etc.
        setContentView(myWebView);

        // fetch the OAuth web document..
        String webpath = getIntent().getStringExtra("argAuthorizationURL");
        if (Config.LOGD) Log.i(LOGTAG, "loadUrl(" + webpath + ") ...");
        myWebView.loadUrl(webpath);
        if (Config.LOGD) Log.i(LOGTAG, "done initializing myWebView, mService=" + mService);
        // --> OAuth-pin post-processing -> MyWebViewClient.onPageFinished() and
        // MyWebChromeClient.onJsAlert()
      }
    }

    if (Config.LOGD) Log.i(LOGTAG, "done onCreate()");
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.multiplechoicemultipleanswer);

    QuestionHeaderBox = (WebView) findViewById(R.id.MQuestionHeaderBox);
    Table = (TableLayout) findViewById(R.id.MQtable);
    BtnContinue = (Button) findViewById(R.id.MContinue);
    BtnReason = (Button) findViewById(R.id.MultipleChoiceMultipleShowReason);

    BtnContinue.setOnClickListener(this);
    BtnContinue.setTag(2); // I am using this to identify the continue button
    BtnContinue.setVisibility(View.INVISIBLE);

    BtnReason.setOnClickListener(this);
    BtnReason.setTag(3); // I am using this to identify the Reason Button
    BtnReason.setVisibility(View.INVISIBLE);

    View LLView = findViewById(R.id.LLMultipleMultiple);
    View root = LLView.getRootView();
    root.setBackgroundColor(Color.BLACK);

    cache = ((LocalCache) getApplicationContext());

    WebSettings websettings = QuestionHeaderBox.getSettings();
    websettings.setJavaScriptEnabled(true);
    websettings.setSavePassword(false);
    websettings.setSaveFormData(false);
    websettings.setSupportZoom(true);
    websettings.setBuiltInZoomControls(true);

    Bundle getBasket = getIntent().getExtras();
    Integer _id = getBasket.getInt("_id");

    GetQuestion(_id);
    GetAnswers(_id);
  }
Esempio n. 15
0
  @SuppressLint("SetJavaScriptEnabled")
  @SuppressWarnings("deprecation")
  private void initWebViewSettings() {
    this.setInitialScale(0);
    this.setVerticalScrollBarEnabled(false);
    // TODO: The Activity is the one that should call requestFocus().
    if (shouldRequestFocusOnInit()) {
      this.requestFocusFromTouch();
    }
    this.setInitialScale(0);
    this.setVerticalScrollBarEnabled(false);
    if (shouldRequestFocusOnInit()) {
      this.requestFocusFromTouch();
    }
    // Enable JavaScript
    final WebSettings settings = this.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);

    // Set the nav dump for HTC 2.x devices (disabling for ICS, deprecated entirely for Jellybean
    // 4.2)
    try {
      Method gingerbread_getMethod =
          WebSettings.class.getMethod("setNavDump", new Class[] {boolean.class});

      String manufacturer = android.os.Build.MANUFACTURER;
      Log.d(TAG, "CordovaWebView is running on device made by: " + manufacturer);
      if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB
          && android.os.Build.MANUFACTURER.contains("HTC")) {
        gingerbread_getMethod.invoke(settings, true);
      }
    } catch (NoSuchMethodException e) {
      Log.d(TAG, "We are on a modern version of Android, we will deprecate HTC 2.3 devices in 2.8");
    } catch (IllegalArgumentException e) {
      Log.d(TAG, "Doing the NavDump failed with bad arguments");
    } catch (IllegalAccessException e) {
      Log.d(
          TAG, "This should never happen: IllegalAccessException means this isn't Android anymore");
    } catch (InvocationTargetException e) {
      Log.d(
          TAG,
          "This should never happen: InvocationTargetException means this isn't Android anymore.");
    }

    // We don't save any form data in the application
    settings.setSaveFormData(false);
    settings.setSavePassword(false);

    // Jellybean rightfully tried to lock this down. Too bad they didn't give us a whitelist
    // while we do this
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
      Level16Apis.enableUniversalAccess(settings);
    }
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
      Level17Apis.setMediaPlaybackRequiresUserGesture(settings, false);
    }
    // Enable database
    // We keep this disabled because we use or shim to get around DOM_EXCEPTION_ERROR_16
    String databasePath =
        getContext().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
    settings.setDatabaseEnabled(true);
    settings.setDatabasePath(databasePath);

    // Determine whether we're in debug or release mode, and turn on Debugging!
    ApplicationInfo appInfo = getContext().getApplicationContext().getApplicationInfo();
    if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0
        && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
      enableRemoteDebugging();
    }

    settings.setGeolocationDatabasePath(databasePath);

    // Enable DOM storage
    settings.setDomStorageEnabled(true);

    // Enable built-in geolocation
    settings.setGeolocationEnabled(true);

    // Enable AppCache
    // Fix for CB-2282
    settings.setAppCacheMaxSize(5 * 1048576);
    settings.setAppCachePath(databasePath);
    settings.setAppCacheEnabled(true);

    // Fix for CB-1405
    // Google issue 4641
    settings.getUserAgentString();

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
    if (this.receiver == null) {
      this.receiver =
          new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
              settings.getUserAgentString();
            }
          };
      getContext().registerReceiver(this.receiver, intentFilter);
    }
    // end CB-1405
  }
Esempio n. 16
0
  public LGameWeb(
      final LGameAndroid2DActivity activity, final WebProcess webProcess, final String url) {

    super(activity);
    this.url = url;
    this.activity = activity;
    // 允许显示滚动条
    this.setHorizontalScrollBarEnabled(true);
    // 清空原有的缓存数据
    this.clearCache(true);
    // 隐藏当前View
    this.setVisible(false);
    // 不要背景图
    this.setBackgroundDrawable(null);
    // 进行细节设置
    webSettings = getSettings();
    // 数据库访问权限开启
    webSettings.setAllowFileAccess(true);
    // 密码保存与Form信息不保存
    webSettings.setSavePassword(false);
    webSettings.setSaveFormData(false);
    // 响应JavaScript事件
    webSettings.setJavaScriptEnabled(true);
    // 允许JavaScript脚本打开新的窗口
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    // 允许自动加载图像资源
    webSettings.setLoadsImagesAutomatically(true);
    // 不支持网页缩放
    webSettings.setSupportZoom(false);

    // 当流程监听存在时
    if (webProcess != null) {
      setWebViewClient(
          new WebViewClient() {

            public void onPageStarted(WebView view, String url, Bitmap favicon) {
              webProcess.onPageStarted(url, favicon);
              super.onPageStarted(view, url, favicon);
            }

            public void onPageFinished(WebView view, String url) {
              webProcess.onPageFinished(url);
              super.onPageFinished(view, url);
            }

            public void onLoadResource(WebView view, String url) {
              webProcess.onLoadResource(url);
              super.onLoadResource(view, url);
            }

            public boolean shouldOverrideUrlLoading(WebView view, String url) {
              webProcess.shouldOverrideUrlLoading(url);
              return super.shouldOverrideUrlLoading(view, url);
            }

            public void onReceivedHttpAuthRequest(
                WebView view, HttpAuthHandler handler, String host, String realm) {
              webProcess.onReceivedHttpAuthRequest(handler, host, realm);
              super.onReceivedHttpAuthRequest(view, handler, host, realm);
            }
          });
    }

    // 加载进度条
    final ProgressBar progress = new ProgressBar(activity);
    activity.addView(progress, Location.CENTER);
    setWebChromeClient(
        new WebChromeClient() {
          public void onProgressChanged(final WebView view, final int newProgress) {
            LSystem.post(
                new Runnable() {
                  public void run() {
                    progress.setProgress(newProgress);
                    progress.setVisibility(newProgress == 100 ? View.GONE : View.VISIBLE);
                    if (newProgress == 100) {
                      activity.removeView(progress);
                    }
                    setVisible(newProgress == 100 ? true : false);
                  }
                });
          }
        });

    if (url != null) {
      loadUrl(url);
    }
  }
  @Override
  protected void onStart() {
    super.onStart();

    try {
      jsonSrc = FileUtils.readFromAssetsFile(that, "json2.js");
      androidJsSrc = FileUtils.readFromAssetsFile(that, "android.js");
    } catch (IOException e1) {
      throw new RuntimeException(e1);
    }

    mObserver = new HtmlEventObserver();

    // TODO
    // RpcReceiverManager mFacadeManager = getRpcReceiverManager();
    // mFacadeManager.getReceiver(EventFacade.class).addGlobalEventObserver(mObserver);
    // mAPIWrapperSource = generateAPIWrapper();

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, config.getLOG_TAG());
    mWebView.setKeepScreenOn(true);

    mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    mWebView.setScrollbarFadingEnabled(false);
    mWebView.setVerticalScrollBarEnabled(false);
    mWebView.setHorizontalScrollBarEnabled(false);
    mWebView.setScrollContainer(false);

    WebSettings webSettings = mWebView.getSettings();
    webSettings.setSavePassword(false);
    webSettings.setSaveFormData(false);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setPluginsEnabled(true);

    webSettings.setSupportZoom(false);
    webSettings.setSupportZoom(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);

    mWebView.addJavascriptInterface(mWrapper, "_rpc_wrapper");
    mWebView.addJavascriptInterface(
        new Object() {

          @SuppressWarnings("unused")
          public void register(String event, int id) {
            mObserver.register(event, id);
          }
        },
        "_callback_wrapper");

    if (Build.VERSION.SDK_INT >= 5) {
      try {
        Method m1 = WebSettings.class.getMethod("setDomStorageEnabled", new Class[] {Boolean.TYPE});
        m1.invoke(webSettings, Boolean.TRUE);

        Method m2 = WebSettings.class.getMethod("setDatabaseEnabled", new Class[] {Boolean.TYPE});
        m2.invoke(webSettings, Boolean.TRUE);

        Method m3 = WebSettings.class.getMethod("setDatabasePath", new Class[] {String.class});
        m3.invoke(webSettings, this.getFilesDir().getParent() + "/databases/");
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    mWebView.setWebChromeClient(new WebChromeClient() {});

    mWebView.setWebViewClient(
        new WebViewClient() {
          //        	public void onReceivedError(WebView view, int errorCode, String description,
          // String failingUrl) {
          //        		Toast.makeText(that, "Error: " + description, Toast.LENGTH_SHORT).show();
          //        	}
        });

    webSettings.setCacheMode(WebSettings.LOAD_NORMAL);

    if (Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT < 14) {
      mWebView.setSystemUiVisibility(WebView.STATUS_BAR_HIDDEN);
    } else if (Build.VERSION.SDK_INT >= 14) {
      mWebView.setSystemUiVisibility(WebView.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
    }

    mWebView.loadUrl("javascript:" + jsonSrc);
    mWebView.loadUrl("javascript:" + androidJsSrc);
    mWebView.loadUrl("javascript:" + mAPIWrapperSource);
    Log.d(
        config.getLOG_TAG(),
        "Launch Webview: "
            + "file://"
            + this.getFilesDir().getAbsolutePath()
            + "/"
            + config.getMAIN_SCRIPT_NAME());
    mWebView.loadUrl(
        "file://" + this.getFilesDir().getAbsolutePath() + "/" + config.getMAIN_SCRIPT_NAME());
  }
Esempio n. 18
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.resultpage);

    webView = (WebView) findViewById(R.id.webViewResults);
    Refresh = (Button) findViewById(R.id.ResultRefresh);
    Progress = (ProgressBar) findViewById(R.id.ResultsprogressBar);
    Refresh.setEnabled(false);
    Progress.setVisibility(View.VISIBLE);
    Refresh.setOnClickListener(this);
    WebSettings websettings = webView.getSettings();
    websettings.setJavaScriptEnabled(true);
    websettings.setSavePassword(false);
    websettings.setSaveFormData(false);
    websettings.setSupportZoom(true);
    websettings.setDefaultZoom(ZoomDensity.MEDIUM);
    websettings.setAppCacheEnabled(false);

    webView.setWebViewClient(
        new WebViewClient() {

          public void onPageFinished(WebView view, String url) {
            if (Progress.getVisibility() == View.VISIBLE) {
              Progress.setVisibility(View.INVISIBLE);
            }
          }

          /*@Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {

          	view.loadUrl(url);

          	return true;
          }*/

        });

    /*webView.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress)
        {
        	activity.setTitle("Loading...");
            activity.setProgress(progress * 100);

            if(progress == 100)
                activity.setTitle(R.string.app_name);
        }

        public void onPageFinished(WebView view, String url) {

            if (Progress.getVisibility() == View.VISIBLE) {
            	Progress.setVisibility(View.INVISIBLE);

            }
        }
    });

    webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
        {
            // Handle the error
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url)
        {

            view.loadUrl(url);

            Progress.setVisibility( View.INVISIBLE);
            return true;
        }
    });*/

    LoadWebView();
  }
Esempio n. 19
0
  // 封装WebView
  public static void wrapWebView(Context context, WebView webView, WebViewClient webclient) {
    WebSettings webSettings = webView.getSettings();
    webSettings.setSavePassword(false);
    webSettings.setSaveFormData(false);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setSupportZoom(false);

    // 设置定位可用
    if (context != null) {
      webSettings.setDatabaseEnabled(true);
      String dir =
          context.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();

      // 启用地理定位
      webSettings.setGeolocationEnabled(true);
      // 设置定位的数据库路径
      webSettings.setGeolocationDatabasePath(dir);

      // 最重要的方法,一定要设置,这就是出不来的主要原因

      webSettings.setDomStorageEnabled(true);
    }
    //
    webView.setWebChromeClient(
        new WebChromeClient() {
          @Override
          public void onGeolocationPermissionsShowPrompt(String origin, Callback callback) {
            callback.invoke(origin, true, false);
            super.onGeolocationPermissionsShowPrompt(origin, callback);
          }
        });
    webView.setWebViewClient(webclient);
    // webView.setWebViewClient(new WebViewClient() {
    //
    // // 加载链接
    // @Override
    // public boolean shouldOverrideUrlLoading(WebView view, String url) {
    // view.loadUrl(url);
    // return true;
    // }
    //
    // // 链接开始加载时
    // @Override
    // public void onPageStarted(WebView view, String url, Bitmap favicon) {
    // super.onPageStarted(view, url, favicon);
    // if (progress != null) {
    // progress.setVisibility(View.VISIBLE);
    // }
    // }
    //
    // // 链接加载完成
    // @Override
    // public void onPageFinished(WebView view, String url) {
    // super.onPageFinished(view, url);
    // if (progress != null) {
    // progress.setVisibility(View.GONE);
    // }
    // }
    //
    // @Override
    // public void onReceivedSslError(WebView view, SslErrorHandler handler,
    // SslError error) {
    // super.onReceivedSslError(view, handler, error);
    // }
    //
    // // webview无网络情况下的人性化处理
    // @Override
    // public void onReceivedError(WebView view, int errorCode, String
    // description, String failingUrl) {
    // super.onReceivedError(view, errorCode, description, failingUrl);
    // view.loadData("", "text/html", "utf-8");
    // Toast.makeText(view.getContext(), "网络不给力",
    // android.widget.Toast.LENGTH_LONG).show();
    // }
    // });
  }
Esempio n. 20
0
  private void setWebView() {
    webSet = web.getSettings();
    webSet.setSavePassword(false);
    webSet.setAllowFileAccess(false);
    webSet.setJavaScriptEnabled(true);
    webSet.setSaveFormData(false);
    webSet.setSupportZoom(true);
    webSet.setBuiltInZoomControls(true);
    webSet.setCacheMode(WebSettings.LOAD_NO_CACHE);
    layout.setScrollBarStyle(SCROLLBARS_OUTSIDE_OVERLAY);

    web.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            v.requestFocus();
            return false;
          }
        });
    web.setWebChromeClient(
        new WebChromeClient() { // 设置网页加载的进度条
          public void onProgressChanged(WebView view, int newProgress) {
            if (dialog_flag == true) {
              _showLoading();
              dialog_flag = false;
            }
            if (newProgress == 100) {
              dismissLoading();
              dialog_flag = true;
            }
          }

          // 设置应用程序的标题
          public void onReceivedTitle(WebView view, String title) {
            super.onReceivedTitle(view, title);
          }
        });
    web.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            v.requestFocus();
            return false;
          }
        });
    /*
     *
     * URL = ztspeechandroid://OAuthActivity?oauth_token=
     * f11203c98d813b227204254e3c148884&oauth_verifier=871525
     */
    web.setWebViewClient(
        new WebViewClient() {
          @Override
          public void onPageStarted(WebView view, String url, Bitmap favicon) {
            LogInfo.LogOut(TAG, "WebView onPageStarted...");
            LogInfo.LogOut(TAG, "URL = " + url);
            if (url != null) {
              if (url.indexOf("checkType=verifycode") != -1) {
                int start = url.indexOf("checkType=verifycode&v=") + 23;
                String verifyCode = url.substring(start, start + 6);
                oAuth.setOauthVerifier(verifyCode);
                view.destroyDrawingCache();
                handler.sendMessage(
                    Message.obtain(
                        handler, ZtspeechWeiboManager.CONSTENT_TENCENT_WEIBO_REGIST, oAuth));
              } else if (url.contains("ztspeechandroid")) {
                // handler.sendMessage(Message.obtain(handler,
                // ZtspeechWeiboManager.CONSTENT_SINA_WEIBO_REGIST,
                // url));
              }
            }
            super.onPageStarted(view, url, favicon);
          }
        });
  }
Esempio n. 21
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_help);

    webview = V.get(this, R.id.webView);
    bOk = V.get(this, R.id.bOk);
    bCancel = V.get(this, R.id.bCancel);
    View panelFaqOnly = V.get(this, R.id.panelFaqOnly);
    TextView tMessage = V.get(this, R.id.tMessage);

    WebSettings webSettings = webview.getSettings();
    webSettings.setSavePassword(false);
    webSettings.setSaveFormData(false);
    webSettings.setJavaScriptEnabled(false);
    webSettings.setSupportZoom(true);
    webSettings.setBuiltInZoomControls(true);

    bOk.setOnClickListener(bOk_click);
    bCancel.setOnClickListener(bCancel_click);

    final String page = getIntent().getStringExtra(EXTRA_page);
    okIntent = getIntent().getParcelableExtra(EXTRA_okIntent);

    String message = getIntent().getStringExtra(EXTRA_message);
    tMessage.setText(message);

    final boolean showMessagePanel = getIntent().getBooleanExtra(EXTRA_showMessagePanel, false);
    if (!showMessagePanel) {
      panelFaqOnly.setVisibility(View.GONE);
    }

    if (page != null) {
      webview.loadUrl("file:///android_asset/" + page);
    }

    webview.setWebViewClient(
        new WebViewClient() {
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
            final Uri uri = Uri.parse(url);
            final String scheme = uri.getScheme();

            if ("http".equals(scheme) || "https".equals(scheme)) {
              // open in external browser
              final Intent intent = new Intent(Intent.ACTION_VIEW);
              intent.setData(uri);
              startActivity(intent);
              return true;
            }

            if ("bible".equals(scheme)) {
              // try to decode using OSIS format
              final String ssp = uri.getSchemeSpecificPart();
              final IntArrayList ariRanges = TargetDecoder.decode("o:" + ssp);
              if (ariRanges == null || ariRanges.size() == 0) {
                new AlertDialog.Builder(HelpActivity.this)
                    .setMessage(getString(R.string.alamat_tidak_sah_alamat, url))
                    .setPositiveButton(R.string.ok, null)
                    .show();
              } else {
                final VersesDialog dialog = VersesDialog.newInstance(ariRanges);
                dialog.show(getSupportFragmentManager(), VersesDialog.class.getSimpleName());
                dialog.setListener(
                    new VersesDialog.VersesDialogListener() {
                      @Override
                      public void onVerseSelected(final VersesDialog dialog, final int ari) {
                        Log.d(TAG, "Verse link clicked from page");
                        final Intent intent = Launcher.openAppAtBibleLocation(ari);
                        startActivity(intent);
                      }
                    });
              }
              return true;
            }
            return false;
          }

          @Override
          public void onPageFinished(final WebView view, final String url) {
            super.onPageFinished(view, url);

            setTitle(view.getTitle());
          }
        });
  }
Esempio n. 22
0
  public WebFrame(Activity context, boolean allowNavigation, boolean scroll, boolean showExit) {
    super(context);
    initCompatibility();
    mActivity = context;
    mWebView = new WebView(context);
    mWebView.setVerticalScrollBarEnabled(scroll);
    mWebView.setHorizontalScrollBarEnabled(scroll);
    mWebView.setBackgroundColor(Color.TRANSPARENT);
    setLayer(mWebView);
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setSavePassword(false);
    webSettings.setSaveFormData(false);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setPluginsEnabled(true);
    webSettings.setSupportZoom(enableZoom);
    webSettings.setBuiltInZoomControls(enableZoom);
    mWebViewClient = new WebViewClient(mActivity, allowNavigation);
    mWebView.setWebViewClient(mWebViewClient);

    final Activity localContext = context;
    if (showExit) {
      ImageView bg = new ImageView(context);
      bg.setBackgroundColor(Color.TRANSPARENT);
      addView(
          bg,
          new FrameLayout.LayoutParams(
              android.view.ViewGroup.LayoutParams.FILL_PARENT,
              android.view.ViewGroup.LayoutParams.FILL_PARENT,
              Gravity.CENTER));
      addView(
          mWebView,
          new FrameLayout.LayoutParams(
              android.view.ViewGroup.LayoutParams.FILL_PARENT,
              android.view.ViewGroup.LayoutParams.FILL_PARENT,
              Gravity.CENTER));
      mExitButton = new ImageView(context);
      mExitButton.setAdjustViewBounds(false);
      mExitButton.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              localContext.finish();
            }
          });
      int buttonSize =
          (int)
              TypedValue.applyDimension(
                  TypedValue.COMPLEX_UNIT_DIP, 35, getResources().getDisplayMetrics());
      mExitButton.setImageDrawable(
          ResourceManager.getStaticResource(
              context, ResourceManager.DEFAULT_SKIP_IMAGE_RESOURCE_ID));
      FrameLayout.LayoutParams params =
          new FrameLayout.LayoutParams(buttonSize, buttonSize, Gravity.TOP | Gravity.RIGHT);
      int margin =
          (int)
              TypedValue.applyDimension(
                  TypedValue.COMPLEX_UNIT_DIP, 6, getResources().getDisplayMetrics());
      params.topMargin = margin;
      params.rightMargin = margin;
      addView(mExitButton, params);
    } else {
      addView(
          mWebView,
          new FrameLayout.LayoutParams(
              android.view.ViewGroup.LayoutParams.FILL_PARENT,
              android.view.ViewGroup.LayoutParams.FILL_PARENT,
              Gravity.CENTER));
    }
  }