コード例 #1
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   super.onCreateOptionsMenu(menu);
   MenuInflater inflater = getMenuInflater();
   inflater.inflate(R.menu.view_activity_menu, menu);
   return true;
 }
コード例 #2
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   super.onCreateOptionsMenu(menu);
   MenuInflater inflater = getMenuInflater();
   inflater.inflate(R.menu.main_menu, menu);
   setupSearch(menu);
   return true;
 }
コード例 #3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.add_bookmark);

    Intent intent = getIntent();

    if (Intent.ACTION_SEND.equals(intent.getAction()) && intent.hasExtra(Intent.EXTRA_TEXT)) {
      bookmark = new Bookmark();

      ShareCompat.IntentReader reader = ShareCompat.IntentReader.from(this);

      String url = StringUtils.getUrl(reader.getText().toString());
      bookmark.setUrl(url);

      if (reader.getSubject() != null) bookmark.setDescription(reader.getSubject());

      if (url.equals("")) {
        Toast.makeText(this, R.string.add_bookmark_invalid_url, Toast.LENGTH_LONG).show();
      }

      if (intent.hasExtra(Constants.EXTRA_DESCRIPTION)) {
        bookmark.setDescription(intent.getStringExtra(Constants.EXTRA_DESCRIPTION));
      }
      bookmark.setNotes(intent.getStringExtra(Constants.EXTRA_NOTES));
      bookmark.setTagString(intent.getStringExtra(Constants.EXTRA_TAGS));
      bookmark.setShared(!intent.getBooleanExtra(Constants.EXTRA_PRIVATE, privateDefault));

      try {
        Bookmark old = BookmarkManager.GetByUrl(bookmark.getUrl(), this);
        bookmark = old.copy();
      } catch (Exception e) {

      }

    } else if (Intent.ACTION_EDIT.equals(intent.getAction())) {
      int id = Integer.parseInt(intent.getData().getLastPathSegment());
      try {
        bookmark = BookmarkManager.GetById(id, this);
        oldBookmark = bookmark.copy();

        update = true;
      } catch (ContentNotFoundException e) {
        e.printStackTrace();
      }
    }

    if (update) setTitle(getString(R.string.add_bookmark_edit_title));
    else setTitle(getString(R.string.add_bookmark_add_title));

    frag =
        (AddBookmarkFragment)
            getSupportFragmentManager().findFragmentById(R.id.add_bookmark_fragment);
    frag.loadBookmark(bookmark, oldBookmark);
  }
コード例 #4
0
  public void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);

    username = savedInstanceState.getString(STATE_USERNAME);

    if (findViewById(R.id.maincontent) != null) {
      lastSelected = (Bookmark) savedInstanceState.getSerializable(STATE_LASTBOOKMARK);
      lastViewType = (BookmarkViewType) savedInstanceState.getSerializable(STATE_LASTVIEWTYPE);
      setBookmarkView(lastSelected, lastViewType);
    }
  }
コード例 #5
0
  @Override
  public void onSaveInstanceState(Bundle savedInstanceState) {
    if (lastSelected != null && lastViewType != null) {
      savedInstanceState.putSerializable(STATE_LASTBOOKMARK, lastSelected);
      savedInstanceState.putSerializable(STATE_LASTVIEWTYPE, lastViewType);
    }

    savedInstanceState.putString(STATE_USERNAME, username);

    super.onSaveInstanceState(savedInstanceState);
  }
コード例 #6
0
  @Override
  public void onBackPressed() {
    super.onBackPressed();

    Fragment tagFrag = getSupportFragmentManager().findFragmentById(R.id.tagcontent);
    View panelBtn = findViewById(R.id.panel_collapse_button);

    if (tagFrag != null && panelBtn != null) {
      if (tagFrag.isVisible()) findViewById(R.id.panel_collapse_button).setVisibility(View.GONE);
      else findViewById(R.id.panel_collapse_button).setVisibility(View.VISIBLE);
    }
  }
コード例 #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);
    }
  }
コード例 #8
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.browse_bookmarks);

    Intent intent = getIntent();

    Uri data = intent.getData();
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction t = fm.beginTransaction();

    if (fm.findFragmentById(R.id.listcontent) == null) {
      Fragment bookmarkFrag = new Fragment();

      if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        Bundle searchData = intent.getBundleExtra(SearchManager.APP_DATA);

        if (searchData != null) {
          tagname = searchData.getString("tagname");
          username = searchData.getString("username");
          unread = searchData.getBoolean("unread");
        }

        String query = intent.getStringExtra(SearchManager.QUERY);

        if (intent.hasExtra("username")) {
          username = intent.getStringExtra("username");
        }

        bookmarkFrag = new BrowseBookmarksFragment();
        ((BrowseBookmarksFragment) bookmarkFrag).setSearchQuery(query, username, tagname, unread);
      } else if (!Constants.ACTION_SEARCH_SUGGESTION.equals(intent.getAction())) {
        if (data != null) {

          if (data.getUserInfo() != "") {
            username = data.getUserInfo();
          } else username = mAccount.name;

          tagname = data.getQueryParameter("tagname");
          unread = data.getQueryParameter("unread") != null;
          path = data.getPath();
        }

        if (isMyself()) {
          bookmarkFrag = new BrowseBookmarksFragment();
          ((BrowseBookmarksFragment) bookmarkFrag).setQuery(username, tagname, unread);
        } else {
          bookmarkFrag = new BrowseBookmarkFeedFragment();
          ((BrowseBookmarkFeedFragment) bookmarkFrag).setQuery(username, tagname);
        }
      }

      t.add(R.id.listcontent, bookmarkFrag);
    }

    BrowseTagsFragment tagFrag = (BrowseTagsFragment) fm.findFragmentById(R.id.tagcontent);
    if (tagFrag != null) {
      tagFrag.setAccount(username);
      tagFrag.setAction("notpick");
    }

    if (path.contains("tags")) {
      t.hide(fm.findFragmentById(R.id.maincontent));
      findViewById(R.id.panel_collapse_button).setVisibility(View.GONE);
    } else {
      if (tagFrag != null) {
        t.hide(tagFrag);
      }
    }

    Fragment addFrag = fm.findFragmentById(R.id.addcontent);
    if (addFrag != null) {
      t.hide(addFrag);
    }

    t.commit();
  }