コード例 #1
0
  /**
   * Perform the bookmarks export.
   *
   * @param fileName The export file name.
   */
  private void doExportBookmarks(String fileName) {
    if (ApplicationUtils.checkCardState(this)) {
      mProgressDialog =
          ProgressDialog.show(
              this,
              this.getResources().getString(R.string.Commons_PleaseWait),
              this.getResources().getString(R.string.BookmarksListActivity_ExportingBookmarks));

      new XmlBookmarksExporter(fileName);
    }
  }
コード例 #2
0
  @TargetApi(8)
  @Override
  public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) {

    StringBuilder sb = new StringBuilder();

    sb.append(view.getResources().getString(R.string.Commons_SslWarningsHeader));
    sb.append("\n\n");

    if (error.hasError(SslError.SSL_UNTRUSTED)) {
      sb.append(" - ");
      sb.append(view.getResources().getString(R.string.Commons_SslUntrusted));
      sb.append("\n");
    }

    if (error.hasError(SslError.SSL_IDMISMATCH)) {
      sb.append(" - ");
      sb.append(view.getResources().getString(R.string.Commons_SslIDMismatch));
      sb.append("\n");
    }

    if (error.hasError(SslError.SSL_EXPIRED)) {
      sb.append(" - ");
      sb.append(view.getResources().getString(R.string.Commons_SslExpired));
      sb.append("\n");
    }

    if (error.hasError(SslError.SSL_NOTYETVALID)) {
      sb.append(" - ");
      sb.append(view.getResources().getString(R.string.Commons_SslNotYetValid));
      sb.append("\n");
    }

    ApplicationUtils.showContinueCancelDialog(
        view.getContext(),
        android.R.drawable.ic_dialog_info,
        view.getResources().getString(R.string.Commons_SslWarning),
        sb.toString(),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            handler.proceed();
          }
        },
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            handler.cancel();
          }
        });
  }
コード例 #3
0
 /** Show a confirmation dialog for bookmarks clearing. Perform the clear if required. */
 private void clearBookmarks() {
   ApplicationUtils.showYesNoDialog(
       this,
       android.R.drawable.ic_dialog_alert,
       R.string.BookmarksListActivity_ClearBookmarks,
       R.string.Commons_NoUndoMessage,
       new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
           dialog.dismiss();
           doClearBookmarks();
         }
       });
 }
コード例 #4
0
  /** Display a confirmation dialog and perform the bookmarks export. */
  private void exportBookmarks() {

    final String fileName = DateUtils.getNowForFileName() + ".xml";

    ApplicationUtils.showOkCancelDialog(
        this,
        android.R.drawable.ic_dialog_info,
        this.getString(R.string.BookmarksListActivity_ExportDialogTitle),
        String.format(
            this.getString(R.string.BookmarksListActivity_ExportDialogMessage),
            IOUtils.getBookmarksExportFolder().getAbsolutePath() + "/" + fileName),
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {

            doExportBookmarks(fileName);
          }
        });
  }
コード例 #5
0
  @Override
  public void onPageStarted(WebView view, String url, Bitmap favicon) {

    // Some magic here: when performing WebView.loadDataWithBaseURL, the url is
    // "file:///android_asset/startpage,
    // whereas when the doing a "previous" or "next", the url is "about:start", and we need to
    // perform the
    // loadDataWithBaseURL here, otherwise it won't load.
    if (url.equals(Constants.URL_ABOUT_START)) {
      view.loadDataWithBaseURL(
          "file:///android_asset/startpage/",
          ApplicationUtils.getStartPage(view.getContext()),
          "text/html",
          "UTF-8",
          "about:start");
    }

    ((CustomWebView) view).notifyPageStarted();
    mMainActivity.onPageStarted(url);

    super.onPageStarted(view, url, favicon);
  }
コード例 #6
0
  /** Fill the bookmark to the list UI. */
  private void fillData() {
    mCursor =
        BookmarksProviderWrapper.getStockBookmarks(
            getContentResolver(),
            PreferenceManager.getDefaultSharedPreferences(this)
                .getInt(Constants.PREFERENCES_BOOKMARKS_SORT_MODE, 0));
    startManagingCursor(mCursor);

    String[] from = new String[] {Browser.BookmarkColumns.TITLE, Browser.BookmarkColumns.URL};
    int[] to = new int[] {R.id.BookmarkRow_Title, R.id.BookmarkRow_Url};

    mCursorAdapter =
        new BookmarksCursorAdapter(
            this,
            R.layout.bookmark_row,
            mCursor,
            from,
            to,
            ApplicationUtils.getFaviconSizeForBookmarks(this));

    mList.setAdapter(mCursorAdapter);

    setAnimation();
  }
コード例 #7
0
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();

    Intent i;
    BookmarkItem bookmarkItem =
        BookmarksProviderWrapper.getStockBookmarkById(getContentResolver(), info.id);

    switch (item.getItemId()) {
      case MENU_OPEN_IN_TAB:
        i = new Intent();
        i.putExtra(Constants.EXTRA_ID_NEW_TAB, true);

        if (bookmarkItem != null) {
          i.putExtra(Constants.EXTRA_ID_URL, bookmarkItem.getUrl());
        } else {
          i.putExtra(
              Constants.EXTRA_ID_URL,
              PreferenceManager.getDefaultSharedPreferences(BookmarksListActivity.this)
                  .getString(Constants.PREFERENCES_GENERAL_HOME_PAGE, Constants.URL_ABOUT_START));
        }

        if (getParent() != null) {
          getParent().setResult(RESULT_OK, i);
        } else {
          setResult(RESULT_OK, i);
        }

        finish();
        return true;

      case MENU_EDIT_BOOKMARK:
        if (bookmarkItem != null) {
          i = new Intent(this, EditBookmarkActivity.class);
          i.putExtra(Constants.EXTRA_ID_BOOKMARK_ID, info.id);
          i.putExtra(Constants.EXTRA_ID_BOOKMARK_TITLE, bookmarkItem.getTitle());
          i.putExtra(Constants.EXTRA_ID_BOOKMARK_URL, bookmarkItem.getUrl());

          startActivityForResult(i, ACTIVITY_EDIT_BOOKMARK);
        }
        return true;

      case MENU_COPY_URL:
        if (bookmarkItem != null) {
          ApplicationUtils.copyTextToClipboard(
              this, bookmarkItem.getUrl(), getString(R.string.Commons_UrlCopyToastMessage));
        }
        return true;

      case MENU_SHARE:
        if (bookmarkItem != null) {
          ApplicationUtils.sharePage(this, bookmarkItem.getTitle(), bookmarkItem.getUrl());
        }
        return true;

      case MENU_DELETE_BOOKMARK:
        // mDbAdapter.deleteBookmark(info.id);
        BookmarksProviderWrapper.deleteStockBookmark(getContentResolver(), info.id);
        fillData();
        return true;
      default:
        return super.onContextItemSelected(item);
    }
  }