@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.view_activity_menu, menu); return true; }
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main_menu, menu); setupSearch(menu); return true; }
@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); }
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); } }
@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); }
@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); } }
@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); } }
@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(); }