示例#1
0
  @Override
  public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_MENU) {
      if (!contentView.isDrawerOpen(browserListView)) contentView.openDrawer(browserListView);
      else contentView.closeDrawer(browserListView);
      return true;
    }
    if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
      // Finder is active, close it then
      if (bar.findViewById(R.id.finder) != null) {
        SetupLayouts.dismissFindBar();
        return true;
      } else {

        CustomWebView WV = (CustomWebView) webLayout.findViewById(R.id.browser_page);

        if (WV != null) {
          if (WV.canGoBack()) {
            if (!MainActivity.contentView.isDrawerOpen(MainActivity.browserListView)) WV.goBack();
            return true;
          }
        }
        if ((WV != null && WV.canGoBack() == false) || webWindows.size() == 0) {
          doExiting();
        }
      }
      return true;
    }
    return false;
  };
示例#2
0
 public static void closeVideoViewIfOpen() {
   try {
     CustomWebView WV =
         (CustomWebView) contentView.findViewById(R.id.web_holder).findViewById(R.id.browser_page);
     if (WV != null) if (WV.isVideoPlaying()) WV.getChromeClient().onHideCustomView();
   } catch (Exception e) {
   }
   ;
 }
示例#3
0
  protected static void clearTraces() {
    CustomWebView WV = (CustomWebView) webLayout.findViewById(R.id.browser_page);
    if (WV != null) {
      WV.clearHistory();
      WV.clearCache(true);
    }

    WebViewDatabase wDB = WebViewDatabase.getInstance(activity);
    wDB.clearFormData();

    CookieSyncManager.createInstance(activity);
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.removeAllCookie();
    // Usefull for future commits:
    //			cookieManager.setAcceptCookie(false)
    //
    //			WebView webview = new WebView(this);
    //			WebSettings ws = webview.getSettings();
    //			ws.setSaveFormData(false);
    //			ws.setSavePassword(false); // Not needed for API level 18 or greater (deprecat
  }
示例#4
0
  public static void browserSearch() {
    if (webWindows.size() == 0) {
      webWindows.add(new CustomWebView(MainActivity.activity, null, null));
      ((ViewGroup) webLayout.findViewById(R.id.webviewholder)).removeAllViews();
      ((ViewGroup) webLayout.findViewById(R.id.webviewholder)).addView(webWindows.get(0));
    }

    CustomWebView WV = (CustomWebView) webLayout.findViewById(R.id.browser_page);

    WV.stopLoading();
    if (SetupLayouts.actionBarNum == 2)
      ((EditText) bar.findViewById(R.id.browser_searchbar)).clearFocus();
    String q = ((EditText) bar.findViewById(R.id.browser_searchbar)).getText().toString();
    if (q.contains(".") && !q.contains(" ")) {
      if (q.startsWith("http://") || q.startsWith("https://")) WV.loadUrl(q);
      else if (q.startsWith("www.")) WV.loadUrl("http://" + q);
      else if (q.startsWith("file:")) WV.loadUrl(q);
      else WV.loadUrl("http://" + q);
    } else if (q.startsWith("about:home")) WV.loadUrl(assetHomePage);
    else if (q.startsWith("about:") || q.startsWith("file:")) WV.loadUrl(q);
    else WV.loadUrl(Properties.webpageProp.engine + q.replace(" ", "%20").replace("+", "%2B"));
  }
示例#5
0
  public void browserActionClicked(View v) {
    Handler handler = new Handler();
    Runnable r =
        new Runnable() {
          public void run() {
            contentView.closeDrawers();
          }
        };
    if (v.getId() != R.id.browser_bookmark) handler.postDelayed(r, 500);

    if (webWindows.size() == 0) {
      webWindows.add(new CustomWebView(MainActivity.this, null, null));
      ((ViewGroup) webLayout.findViewById(R.id.webviewholder)).removeAllViews();
      ((ViewGroup) webLayout.findViewById(R.id.webviewholder)).addView(webWindows.get(0));
    }

    Message msg = new Message();
    final CustomWebView WV = (CustomWebView) webLayout.findViewById(R.id.browser_page);
    switch (v.getId()) {
      case R.id.browser_home:
        WV.loadUrl(mPrefs.getString("browserhome", assetHomePage));
        WV.clearHistory();
        break;
      case R.id.browser_share:
        Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Link");
        sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, WV.getUrl());
        startActivity(
            Intent.createChooser(sharingIntent, getResources().getString(R.string.share)));
        break;
      case R.id.browser_back:
        WV.goBack();
        break;
      case R.id.browser_forward:
        WV.goForward();
        break;
      case R.id.browser_refresh:
        if (WV.getProgress() != 100) WV.stopLoading();
        else WV.reload();
        break;
      case R.id.browser_bookmark:
        ImageButton BI = (ImageButton) MainActivity.bar.findViewById(R.id.browser_bookmark);
        // Find out if already a bookmark
        String url = WV.getUrl();
        if (WV != null && url != null) {
          String bookmarkName =
              BookmarksActivity.bookmarksMgr.root.containsBookmarkDeep(WV.getUrl());

          if (bookmarkName != null) {
            BookmarksActivity.bookmarksMgr.root.removeBookmarkDeep(bookmarkName);
            BI.setImageResource(R.drawable.btn_omnibox_bookmark_normal);
            System.out.println("BOOKMARK REMOVED!!");
          } else {
            Bookmark newBookmark = new Bookmark(url, WV.getTitle());

            try {
              Bitmap b = WV.getFavicon();
              if (b.getRowBytes() > 1) {
                new File(getApplicationInfo().dataDir + "/icons/").mkdirs();
                URL wvURL = new URL(url);
                String pathToFavicon = getApplicationInfo().dataDir + "/icons/" + wvURL.getHost();
                FileOutputStream out = new FileOutputStream(pathToFavicon);
                WV.getFavicon().compress(Bitmap.CompressFormat.PNG, 100, out);
                out.flush();
                out.close();
                Log.d("LB", "FAVICON SAVED AT " + pathToFavicon + "BITMAP IS " + b);
                newBookmark.setPathToFavicon(pathToFavicon);
              } else {

              }
            } catch (Exception e) {
              e.printStackTrace();
            }
            ;

            BookmarksActivity.bookmarksMgr.root.addBookmark(newBookmark);
            BI.setImageResource(R.drawable.btn_omnibox_bookmark_selected_normal);
            System.out.println("BOOKMARK SET!!");
          }

          BookmarksActivity.bookmarksMgr.saveBookmarksManager();
          CustomToolbar.colorizeToolbar(
              toolbar, Properties.appProp.primaryIntColor, MainActivity.activity);
        }
        break;
      case R.id.browser_find_on_page:
        actionBarControls.show();
        actionBarControls.lock(true);
        SetupLayouts.setUpFindBar();
        setUpFindBarListeners();
        suggestionsAdapter = null;
        // Focus on Find Bar
        TextView findText = (TextView) bar.findViewById(R.id.find_searchbar);
        findText.requestFocus();
        imm.showSoftInput(findText, InputMethodManager.SHOW_IMPLICIT);
        break;
      case R.id.browser_open_bookmarks:
        startActivity(new Intent(ctxt, BookmarksActivity.class));
        break;
      case R.id.browser_set_home:
        mPrefs.edit().putString("browserhome", WV.getUrl()).commit();
        msg.obj = WV.getTitle() + " set";
        msg.what = 1;
        messageHandler.sendMessage(msg);
        break;

      case R.id.browser_settings:
        if (mNotificationManager != null) mNotificationManager.cancel(1);
        startActivity(new Intent(ctxt, SettingsV2.class));
        onStop();
        android.os.Process.killProcess(android.os.Process.myPid());
        break;
      case R.id.browser_exit:
        doExiting();
        break;
      case R.id.browser_toggle_desktop:
        mGlobalPrefs
            .edit()
            .putBoolean("usedesktopview", !Properties.webpageProp.useDesktopView)
            .commit();
        Properties.webpageProp.useDesktopView = !Properties.webpageProp.useDesktopView;

        for (int I = 0; I < webWindows.size(); I++) {
          if (Properties.webpageProp.useDesktopView) {
            webWindows
                .get(I)
                .getSettings()
                .setUserAgentString(webWindows.get(I).createUserAgentString("desktop"));
            webWindows.get(I).getSettings().setLoadWithOverviewMode(true);
          } else {
            webWindows
                .get(I)
                .getSettings()
                .setUserAgentString(webWindows.get(I).createUserAgentString("mobile"));
            webWindows.get(I).getSettings().setLoadWithOverviewMode(false);
          }
          webWindows.get(I).reload();
        }
        break;
    }
  }