Ejemplo n.º 1
0
  public static Intent ViewBookmark(
      Bookmark b, BookmarkViewType type, String account, Context context) {
    Intent viewBookmark = new Intent(context, ViewBookmark.class);
    viewBookmark.setAction(Intent.ACTION_VIEW);
    viewBookmark.addCategory(Intent.CATEGORY_DEFAULT);
    viewBookmark.putExtra("com.pindroid.BookmarkViewType", type);
    Uri.Builder data = new Uri.Builder();
    data.scheme(Constants.CONTENT_SCHEME);
    data.encodedAuthority(account + "@" + BookmarkContentProvider.AUTHORITY);
    data.appendEncodedPath("bookmarks");

    if (b.getId() != 0) {
      data.appendEncodedPath(Integer.toString(b.getId()));
    } else {
      data.appendEncodedPath(Integer.toString(0));
      data.appendQueryParameter("url", b.getUrl());
      data.appendQueryParameter("title", b.getDescription());
      data.appendQueryParameter("notes", b.getNotes());
      data.appendQueryParameter("tags", b.getTagString());
      data.appendQueryParameter("time", Long.toString(b.getTime()));
      data.appendQueryParameter("account", b.getAccount());
    }
    viewBookmark.setData(data.build());

    return viewBookmark;
  }
Ejemplo n.º 2
0
  public void onBookmarkOpen(Bookmark b) {
    String url = b.getUrl();

    if (!url.startsWith("http")) {
      url = "http://" + url;
    }

    startActivity(IntentHelper.OpenInBrowser(url));
  }
Ejemplo n.º 3
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.menu_addbookmark:
       startActivity(IntentHelper.AddBookmark(bookmark.getUrl(), mAccount.name, this));
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
Ejemplo n.º 4
0
 public void onBookmarkOpen(Bookmark b) {
   if (b != null) {
     if (findViewById(R.id.maincontent) != null) {
       lastSelected = b;
       lastViewType = BookmarkViewType.WEB;
       setBookmarkView(b, BookmarkViewType.WEB);
     } else {
       startActivity(IntentHelper.OpenInBrowser(b.getUrl()));
     }
   }
 }
Ejemplo n.º 5
0
  public static Intent EditBookmark(Bookmark b, String account, Context context) {
    Intent editBookmark = new Intent(context, AddBookmark.class);
    editBookmark.setAction(Intent.ACTION_EDIT);
    Uri.Builder data = new Uri.Builder();
    data.scheme(Constants.CONTENT_SCHEME);
    data.encodedAuthority(account + "@" + BookmarkContentProvider.AUTHORITY);
    data.appendEncodedPath("bookmarks");
    data.appendEncodedPath(Integer.toString(b.getId()));
    editBookmark.setData(data.build());

    return editBookmark;
  }
Ejemplo n.º 6
0
  public void onBookmarkRead(Bookmark b) {
    String url = b.getUrl();

    if (!url.startsWith("http")) {
      url = "http://" + url;
    }

    try {
      startActivity(
          IntentHelper.OpenInBrowser(Constants.ARTICLE_READ_URL + URLEncoder.encode(url, "UTF-8")));
    } catch (UnsupportedEncodingException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Ejemplo n.º 7
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.view_bookmark);

    setTitle(R.string.view_bookmark_title);

    Intent intent = getIntent();

    if (Intent.ACTION_VIEW.equals(intent.getAction())) {

      Uri data = intent.getData();

      if (data != null) {
        path = data.getPath();
        username = data.getUserInfo();

      } else username = mAccount.name;

      bookmark = new Bookmark();

      if (path.contains("/bookmarks")) {
        if (isMyself()) {
          int id = Integer.parseInt(data.getLastPathSegment());
          bookmark.setId(id);
        } else {
          bookmark.setDescription(data.getQueryParameter("title"));
          bookmark.setUrl(data.getQueryParameter("url"));
          bookmark.setNotes(data.getQueryParameter("notes"));
          bookmark.setTime(Long.parseLong(data.getQueryParameter("time")));
          if (!data.getQueryParameter("tags").equals("null"))
            bookmark.setTagString(data.getQueryParameter("tags"));
          bookmark.setAccount(data.getQueryParameter("account"));
        }
      }

      BookmarkViewType type =
          (BookmarkViewType) intent.getSerializableExtra("com.pindroid.BookmarkViewType");
      if (type == null) type = BookmarkViewType.VIEW;

      ViewBookmarkFragment frag =
          (ViewBookmarkFragment)
              getSupportFragmentManager().findFragmentById(R.id.view_bookmark_fragment);
      frag.setBookmark(bookmark, type);
    }
  }
Ejemplo n.º 8
0
 public void onBookmarkShare(Bookmark b) {
   Intent sendIntent = IntentHelper.SendBookmark(b.getUrl(), b.getDescription());
   startActivity(Intent.createChooser(sendIntent, getString(R.string.share_chooser_title)));
 }
Ejemplo n.º 9
0
 public void onBookmarkMark(Bookmark b) {
   if (b != null && isMyself() && b.getToRead()) {
     b.setToRead(false);
     BookmarkManager.UpdateBookmark(b, mAccount.name, this);
   }
 }
Ejemplo n.º 10
0
 public void onBookmarkAdd(Bookmark b) {
   if (b != null) {
     startActivity(IntentHelper.AddBookmark(b.getUrl(), mAccount.name, this));
   }
 }