diff options
10 files changed, 899 insertions, 921 deletions
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/DetailActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/DetailActivity.java index 8ef07abf..cd263d87 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/DetailActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/DetailActivity.java @@ -172,15 +172,13 @@ public class DetailActivity extends OnlineActivity implements HeadlinesEventList @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: + if (item.getItemId() == android.R.id.home) { onBackPressed(); - return true; - default: - Log.d(TAG, "onOptionsItemSelected, unhandled id=" + item.getItemId()); - return super.onOptionsItemSelected(item); - } - } + return true; + } + Log.d(TAG, "onOptionsItemSelected, unhandled id=" + item.getItemId()); + return super.onOptionsItemSelected(item); + } @Override public void onResume() { diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java index 3ef4fdd5..876b3894 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java @@ -216,50 +216,48 @@ public class FeedCategoriesFragment extends BaseFeedlistFragment implements OnIt public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item .getMenuInfo(); - - switch (item.getItemId()) { - case R.id.browse_headlines: - if (true) { - FeedCategory cat = getCategoryAtPosition(info.position); - if (cat != null) { - m_activity.onCatSelected(cat, true); - //setSelectedCategory(cat); - } - } - return true; - case R.id.browse_feeds: - if (true) { - FeedCategory cat = getCategoryAtPosition(info.position); - if (cat != null) { - m_activity.onCatSelected(cat, false); - //cf.setSelectedCategory(cat); - } - } - return true; - case R.id.create_shortcut: - if (true) { - FeedCategory cat = getCategoryAtPosition(info.position); - if (cat != null) { - m_activity.createCategoryShortcut(cat); - //cf.setSelectedCategory(cat); - } - } - return true; - case R.id.catchup_category: - if (true) { - final FeedCategory cat = getCategoryAtPosition(info.position); - if (cat != null) { - m_activity.catchupDialog(new Feed(cat.id, cat.title, true)); - } - } - return true; - - default: - Log.d(TAG, "onContextItemSelected, unhandled id=" + item.getItemId()); - return super.onContextItemSelected(item); - } - } + int itemId = item.getItemId(); + if (itemId == R.id.browse_headlines) { + if (true) { + FeedCategory cat = getCategoryAtPosition(info.position); + if (cat != null) { + m_activity.onCatSelected(cat, true); + //setSelectedCategory(cat); + } + } + return true; + } else if (itemId == R.id.browse_feeds) { + if (true) { + FeedCategory cat = getCategoryAtPosition(info.position); + if (cat != null) { + m_activity.onCatSelected(cat, false); + //cf.setSelectedCategory(cat); + } + } + return true; + } else if (itemId == R.id.create_shortcut) { + if (true) { + FeedCategory cat = getCategoryAtPosition(info.position); + if (cat != null) { + m_activity.createCategoryShortcut(cat); + //cf.setSelectedCategory(cat); + } + } + return true; + } else if (itemId == R.id.catchup_category) { + if (true) { + final FeedCategory cat = getCategoryAtPosition(info.position); + + if (cat != null) { + m_activity.catchupDialog(new Feed(cat.id, cat.title, true)); + } + } + return true; + } + Log.d(TAG, "onContextItemSelected, unhandled id=" + item.getItemId()); + return super.onContextItemSelected(item); + } @Override public void onCreateContextMenu(ContextMenu menu, View v, diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java index 5199d299..c415eee9 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java @@ -237,75 +237,73 @@ public class FeedsFragment extends BaseFeedlistFragment implements OnItemClickLi public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item .getMenuInfo(); - switch (item.getItemId()) { - case R.id.browse_headlines: - if (true) { - Feed feed = getFeedAtPosition(info.position); - if (feed != null) { - m_activity.onFeedSelected(feed); - } - } - return true; - case R.id.browse_feeds: - if (true) { - Feed feed = getFeedAtPosition(info.position); - if (feed != null) { - m_activity.onCatSelected(new FeedCategory(feed.id, feed.title, feed.unread), false); - } - } - return true; - case R.id.unsubscribe_feed: - if (true) { - final Feed feed = getFeedAtPosition(info.position); - - AlertDialog.Builder builder = new AlertDialog.Builder( - m_activity) - .setMessage(getString(R.string.unsubscribe_from_prompt, feed.title)) - .setPositiveButton(R.string.unsubscribe, - new Dialog.OnClickListener() { - public void onClick(DialogInterface dialog, - int which) { - - m_activity.unsubscribeFeed(feed); - - } - }) - .setNegativeButton(R.string.dialog_cancel, - new Dialog.OnClickListener() { - public void onClick(DialogInterface dialog, - int which) { - - } - }); - - AlertDialog dlg = builder.create(); - dlg.show(); - } - - return true; - case R.id.create_shortcut: - if (true) { - Feed feed = getFeedAtPosition(info.position); - if (feed != null) { - m_activity.createFeedShortcut(feed); - } - } - return true; - case R.id.catchup_feed: - if (true) { - Feed feed = getFeedAtPosition(info.position); - - if (feed != null) { - m_activity.catchupDialog(feed); - } - } - return true; - - default: - Log.d(TAG, "onContextItemSelected, unhandled id=" + item.getItemId()); - return super.onContextItemSelected(item); - } - } + int itemId = item.getItemId(); + if (itemId == R.id.browse_headlines) { + if (true) { + Feed feed = getFeedAtPosition(info.position); + if (feed != null) { + m_activity.onFeedSelected(feed); + } + } + return true; + } else if (itemId == R.id.browse_feeds) { + if (true) { + Feed feed = getFeedAtPosition(info.position); + if (feed != null) { + m_activity.onCatSelected(new FeedCategory(feed.id, feed.title, feed.unread), false); + } + } + return true; + } else if (itemId == R.id.unsubscribe_feed) { + if (true) { + final Feed feed = getFeedAtPosition(info.position); + + AlertDialog.Builder builder = new AlertDialog.Builder( + m_activity) + .setMessage(getString(R.string.unsubscribe_from_prompt, feed.title)) + .setPositiveButton(R.string.unsubscribe, + new Dialog.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + + m_activity.unsubscribeFeed(feed); + + } + }) + .setNegativeButton(R.string.dialog_cancel, + new Dialog.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + + } + }); + + AlertDialog dlg = builder.create(); + dlg.show(); + } + + return true; + } else if (itemId == R.id.create_shortcut) { + if (true) { + Feed feed = getFeedAtPosition(info.position); + if (feed != null) { + m_activity.createFeedShortcut(feed); + } + } + return true; + } else if (itemId == R.id.catchup_feed) { + if (true) { + Feed feed = getFeedAtPosition(info.position); + + if (feed != null) { + m_activity.catchupDialog(feed); + } + } + return true; + } + Log.d(TAG, "onContextItemSelected, unhandled id=" + item.getItemId()); + return super.onContextItemSelected(item); + } @Override public void onCreateContextMenu(ContextMenu menu, View v, diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/GalleryActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/GalleryActivity.java index 570a586c..e0cb2cea 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/GalleryActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/GalleryActivity.java @@ -361,44 +361,43 @@ public class GalleryActivity extends CommonActivity { public boolean onImageMenuItemSelected(MenuItem item, GalleryEntry entry) { String url = entry.url; - switch (item.getItemId()) { - case R.id.article_img_open: - if (url != null) { - try { - openUri(Uri.parse(url)); - } catch (Exception e) { - e.printStackTrace(); - toast(R.string.error_other_error); - } - } - return true; - case R.id.article_img_copy: - if (url != null) { - copyToClipboard(url); + int itemId = item.getItemId(); + if (itemId == R.id.article_img_open) { + if (url != null) { + try { + openUri(Uri.parse(url)); + } catch (Exception e) { + e.printStackTrace(); + toast(R.string.error_other_error); } - return true; - case R.id.article_img_share: - if (url != null) { - if (entry.type == GalleryEntry.GalleryEntryType.TYPE_IMAGE) { - Log.d(TAG, "image sharing image from URL=" + url); + } + return true; + } else if (itemId == R.id.article_img_copy) { + if (url != null) { + copyToClipboard(url); + } + return true; + } else if (itemId == R.id.article_img_share) { + if (url != null) { + if (entry.type == GalleryEntry.GalleryEntryType.TYPE_IMAGE) { + Log.d(TAG, "image sharing image from URL=" + url); - shareImageFromUri(url); - } - } - return true; - case R.id.article_img_share_url: - if (url != null) { - shareText(url); - } - return true; - case R.id.article_img_view_caption: - if (url != null) { - displayImageCaption(url, m_content); + shareImageFromUri(url); } - return true; - default: - Log.d(TAG, "onImageMenuItemSelected, unhandled id=" + item.getItemId()); - return false; + } + return true; + } else if (itemId == R.id.article_img_share_url) { + if (url != null) { + shareText(url); + } + return true; + } else if (itemId == R.id.article_img_view_caption) { + if (url != null) { + displayImageCaption(url, m_content); + } + return true; } + Log.d(TAG, "onImageMenuItemSelected, unhandled id=" + item.getItemId()); + return false; } } diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java index e1fa2b4c..d45ff934 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java @@ -161,68 +161,67 @@ public class HeadlinesFragment extends StateSavedFragment { if (article == null) return false; - switch (item.getItemId()) { - case R.id.set_labels: - m_activity.editArticleLabels(article); - return true; - case R.id.article_set_note: - m_activity.editArticleNote(article); - return true; - case R.id.headlines_article_unread: - article.unread = !article.unread; - m_activity.saveArticleUnread(article); - m_adapter.notifyItemChanged(position); - return true; - case R.id.headlines_article_link_copy: - m_activity.copyToClipboard(article.link); - return true; - case R.id.headlines_article_link_open: - m_activity.openUri(Uri.parse(article.link)); - - if (article.unread) { - article.unread = false; - m_activity.saveArticleUnread(article); - - m_adapter.notifyItemChanged(position); - } - return true; - case R.id.headlines_share_article: - m_activity.shareArticle(article); - return true; - case R.id.catchup_above: - if (true) { - - final Article fa = article; - - AlertDialog.Builder builder = new AlertDialog.Builder( - m_activity) - .setMessage(R.string.confirm_catchup_above) - .setPositiveButton(R.string.dialog_ok, - new Dialog.OnClickListener() { - public void onClick(DialogInterface dialog, - int which) { - - catchupAbove(fa); - - } - }) - .setNegativeButton(R.string.dialog_cancel, - new Dialog.OnClickListener() { - public void onClick(DialogInterface dialog, - int which) { - - } - }); - - AlertDialog dialog = builder.create(); - dialog.show(); - } - return true; - default: - Log.d(TAG, "onArticleMenuItemSelected, unhandled id=" + item.getItemId()); - return false; - } - } + int itemId = item.getItemId(); + if (itemId == R.id.set_labels) { + m_activity.editArticleLabels(article); + return true; + } else if (itemId == R.id.article_set_note) { + m_activity.editArticleNote(article); + return true; + } else if (itemId == R.id.headlines_article_unread) { + article.unread = !article.unread; + m_activity.saveArticleUnread(article); + m_adapter.notifyItemChanged(position); + return true; + } else if (itemId == R.id.headlines_article_link_copy) { + m_activity.copyToClipboard(article.link); + return true; + } else if (itemId == R.id.headlines_article_link_open) { + m_activity.openUri(Uri.parse(article.link)); + + if (article.unread) { + article.unread = false; + m_activity.saveArticleUnread(article); + + m_adapter.notifyItemChanged(position); + } + return true; + } else if (itemId == R.id.headlines_share_article) { + m_activity.shareArticle(article); + return true; + } else if (itemId == R.id.catchup_above) { + if (true) { + + final Article fa = article; + + AlertDialog.Builder builder = new AlertDialog.Builder( + m_activity) + .setMessage(R.string.confirm_catchup_above) + .setPositiveButton(R.string.dialog_ok, + new Dialog.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + + catchupAbove(fa); + + } + }) + .setNegativeButton(R.string.dialog_cancel, + new Dialog.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + + } + }); + + AlertDialog dialog = builder.create(); + dialog.show(); + } + return true; + } + Log.d(TAG, "onArticleMenuItemSelected, unhandled id=" + item.getItemId()); + return false; + } private void catchupAbove(Article article) { ArticleList articles = getAllArticles(); @@ -1217,26 +1216,25 @@ public class HeadlinesFragment extends StateSavedFragment { Uri mediaUri = Uri.parse(article.flavorStreamUri != null ? article.flavorStreamUri : article.flavorImageUri); - switch (item.getItemId()) { - case R.id.article_img_open: - m_activity.openUri(mediaUri); - return true; - case R.id.article_img_copy: - m_activity.copyToClipboard(mediaUri.toString()); - return true; - case R.id.article_img_share: - m_activity.shareImageFromUri(mediaUri.toString()); - return true; - case R.id.article_img_share_url: - m_activity.shareText(mediaUri.toString()); - return true; - case R.id.article_img_view_caption: - m_activity.displayImageCaption(article.flavorImageUri, article.content); - return true; - default: - return false; - } - } + int itemId = item.getItemId(); + if (itemId == R.id.article_img_open) { + m_activity.openUri(mediaUri); + return true; + } else if (itemId == R.id.article_img_copy) { + m_activity.copyToClipboard(mediaUri.toString()); + return true; + } else if (itemId == R.id.article_img_share) { + m_activity.shareImageFromUri(mediaUri.toString()); + return true; + } else if (itemId == R.id.article_img_share_url) { + m_activity.shareText(mediaUri.toString()); + return true; + } else if (itemId == R.id.article_img_view_caption) { + m_activity.displayImageCaption(article.flavorImageUri, article.content); + return true; + } + return false; + } }); popup.show(); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java index 520fdded..7591774d 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java @@ -331,44 +331,43 @@ public class MasterActivity extends OnlineActivity implements HeadlinesEventList return true; } - switch (item.getItemId()) { - case R.id.headlines_toggle_sort_order: + if (item.getItemId() == R.id.headlines_toggle_sort_order) { LinkedHashMap<String, String> sortModes = getSortModes(); - CharSequence[] sortTitles = sortModes.values().toArray(new CharSequence[0]); - final CharSequence[] sortNames = sortModes.keySet().toArray(new CharSequence[0]); + CharSequence[] sortTitles = sortModes.values().toArray(new CharSequence[0]); + final CharSequence[] sortNames = sortModes.keySet().toArray(new CharSequence[0]); - String currentMode = getSortMode(); + String currentMode = getSortMode(); - int i = 0; - int selectedIndex = 0; + int i = 0; + int selectedIndex = 0; - for (CharSequence tmp : sortNames) { - if (tmp.equals(currentMode)) { - selectedIndex = i; - break; - } + for (CharSequence tmp : sortNames) { + if (tmp.equals(currentMode)) { + selectedIndex = i; + break; + } - ++i; - } + ++i; + } AlertDialog.Builder builder = new AlertDialog.Builder(this) .setTitle(getString(R.string.headlines_sort_articles_title)) .setSingleChoiceItems( - sortTitles, + sortTitles, selectedIndex, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - try { + try { // Log.d(TAG, "sort selected index:" + which + ": " + sortNames[which]); - setSortMode((String)sortNames[which]); + setSortMode((String) sortNames[which]); - } catch (IndexOutOfBoundsException e) { - e.printStackTrace(); - } + } catch (IndexOutOfBoundsException e) { + e.printStackTrace(); + } dialog.cancel(); @@ -380,11 +379,10 @@ public class MasterActivity extends OnlineActivity implements HeadlinesEventList dialog.show(); return true; - default: - Log.d(TAG, "onOptionsItemSelected, unhandled id=" + item.getItemId()); - return super.onOptionsItemSelected(item); - } - } + } + Log.d(TAG, "onOptionsItemSelected, unhandled id=" + item.getItemId()); + return super.onOptionsItemSelected(item); + } @Override public void onBackPressed() { diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java index 2350187e..69fc8141 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java @@ -439,53 +439,52 @@ public class OnlineActivity extends CommonActivity { .getMenuInfo(); */ final ArticlePager ap = (ArticlePager)getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE); - - switch (item.getItemId()) { - case R.id.article_img_open: - if (getLastContentImageHitTestUrl() != null) { - try { - openUri(Uri.parse(getLastContentImageHitTestUrl())); - } catch (Exception e) { - e.printStackTrace(); - toast(R.string.error_other_error); - } - } - return true; - case R.id.article_img_copy: - if (getLastContentImageHitTestUrl() != null) { - copyToClipboard(getLastContentImageHitTestUrl()); - } - return true; - case R.id.article_img_share: - if (getLastContentImageHitTestUrl() != null) { - shareImageFromUri(getLastContentImageHitTestUrl()); - } - return true; - case R.id.article_img_share_url: - if (getLastContentImageHitTestUrl() != null) { - shareText(getLastContentImageHitTestUrl()); - } - return true; - case R.id.article_img_view_caption: - if (getLastContentImageHitTestUrl() != null) { - displayImageCaption(getLastContentImageHitTestUrl(), ap.getSelectedArticle().content); + + int itemId = item.getItemId(); + if (itemId == R.id.article_img_open) { + if (getLastContentImageHitTestUrl() != null) { + try { + openUri(Uri.parse(getLastContentImageHitTestUrl())); + } catch (Exception e) { + e.printStackTrace(); + toast(R.string.error_other_error); + } } return true; - case R.id.article_link_share: - if (ap != null && ap.getSelectedArticle() != null) { - shareArticle(ap.getSelectedArticle()); - } - return true; - case R.id.article_link_copy: - if (ap != null && ap.getSelectedArticle() != null) { - copyToClipboard(ap.getSelectedArticle().link); - } - return true; - default: - Log.d(TAG, "onContextItemSelected, unhandled id=" + item.getItemId()); - return super.onContextItemSelected(item); - } - } + } else if (itemId == R.id.article_img_copy) { + if (getLastContentImageHitTestUrl() != null) { + copyToClipboard(getLastContentImageHitTestUrl()); + } + return true; + } else if (itemId == R.id.article_img_share) { + if (getLastContentImageHitTestUrl() != null) { + shareImageFromUri(getLastContentImageHitTestUrl()); + } + return true; + } else if (itemId == R.id.article_img_share_url) { + if (getLastContentImageHitTestUrl() != null) { + shareText(getLastContentImageHitTestUrl()); + } + return true; + } else if (itemId == R.id.article_img_view_caption) { + if (getLastContentImageHitTestUrl() != null) { + displayImageCaption(getLastContentImageHitTestUrl(), ap.getSelectedArticle().content); + } + return true; + } else if (itemId == R.id.article_link_share) { + if (ap != null && ap.getSelectedArticle() != null) { + shareArticle(ap.getSelectedArticle()); + } + return true; + } else if (itemId == R.id.article_link_copy) { + if (ap != null && ap.getSelectedArticle() != null) { + copyToClipboard(ap.getSelectedArticle().link); + } + return true; + } + Log.d(TAG, "onContextItemSelected, unhandled id=" + item.getItemId()); + return super.onContextItemSelected(item); + } public void displayAttachments(Article article) { if (article != null && article.attachments != null && article.attachments.size() > 0) { @@ -543,11 +542,11 @@ public class OnlineActivity extends CommonActivity { final HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES); final ArticlePager ap = (ArticlePager)getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE); - switch (item.getItemId()) { - case R.id.subscribe_to_feed: - Intent subscribe = new Intent(OnlineActivity.this, SubscribeActivity.class); - startActivityForResult(subscribe, 0); - return true; + int itemId = item.getItemId(); + if (itemId == R.id.subscribe_to_feed) { + Intent subscribe = new Intent(OnlineActivity.this, SubscribeActivity.class); + startActivityForResult(subscribe, 0); + return true; /*case R.id.toggle_attachments: if (true) { Article article = ap.getSelectedArticle(); @@ -560,230 +559,230 @@ public class OnlineActivity extends CommonActivity { /*case R.id.logout: logout(); return true;*/ - case R.id.login: - login(); - return true; + } else if (itemId == R.id.login) { + login(); + return true; /*case R.id.go_offline: switchOffline(); return true;*/ - case R.id.article_set_note: - if (ap != null && ap.getSelectedArticle() != null) { - editArticleNote(ap.getSelectedArticle()); - } - return true; - case R.id.preferences: - Intent intent = new Intent(OnlineActivity.this, - PreferencesActivity.class); - startActivityForResult(intent, 0); - return true; - case R.id.search: - if (hf != null) { - Dialog dialog = new Dialog(this); + } else if (itemId == R.id.article_set_note) { + if (ap != null && ap.getSelectedArticle() != null) { + editArticleNote(ap.getSelectedArticle()); + } + return true; + } else if (itemId == R.id.preferences) { + Intent intent = new Intent(OnlineActivity.this, + PreferencesActivity.class); + startActivityForResult(intent, 0); + return true; + } else if (itemId == R.id.search) { + if (hf != null) { + Dialog dialog = new Dialog(this); - final EditText edit = new EditText(this); + final EditText edit = new EditText(this); - AlertDialog.Builder builder = new AlertDialog.Builder(this) - .setTitle(R.string.search) - .setPositiveButton(getString(R.string.search), - new OnClickListener() { + AlertDialog.Builder builder = new AlertDialog.Builder(this) + .setTitle(R.string.search) + .setPositiveButton(getString(R.string.search), + new OnClickListener() { - @Override - public void onClick(DialogInterface dialog, - int which) { - - String query = edit.getText().toString().trim(); - - hf.setSearchQuery(query); + @Override + public void onClick(DialogInterface dialog, + int which) { - } - }) - .setNegativeButton(getString(R.string.cancel), - new OnClickListener() { + String query = edit.getText().toString().trim(); - @Override - public void onClick(DialogInterface dialog, - int which) { - - // + hf.setSearchQuery(query); - } - }).setView(edit); - - dialog = builder.create(); - dialog.show(); - } - return true; - case R.id.headlines_mark_as_read: - if (hf != null) { + } + }) + .setNegativeButton(getString(R.string.cancel), + new OnClickListener() { - Feed feed = hf.getFeed(); + @Override + public void onClick(DialogInterface dialog, + int which) { - if (feed != null) { - catchupDialog(hf.getFeed()); - } - } - return true; - case R.id.headlines_display_mode: - if (hf != null) { - Dialog dialog = new Dialog(this); + // - String headlineMode = m_prefs.getString("headline_mode", "HL_DEFAULT"); - String[] headlineModeNames = getResources().getStringArray(R.array.headline_mode_names); - final String[] headlineModeValues = getResources().getStringArray(R.array.headline_mode_values); + } + }).setView(edit); - int selectedIndex = Arrays.asList(headlineModeValues).indexOf(headlineMode); + dialog = builder.create(); + dialog.show(); + } + return true; + } else if (itemId == R.id.headlines_mark_as_read) { + if (hf != null) { - AlertDialog.Builder builder = new AlertDialog.Builder(this) - .setTitle(R.string.headlines_set_view_mode) - .setSingleChoiceItems(headlineModeNames, - selectedIndex, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, - int which) { - dialog.cancel(); + Feed feed = hf.getFeed(); - SharedPreferences.Editor editor = m_prefs.edit(); - editor.putString("headline_mode", headlineModeValues[which]); - editor.apply(); + if (feed != null) { + catchupDialog(hf.getFeed()); + } + } + return true; + } else if (itemId == R.id.headlines_display_mode) { + if (hf != null) { + Dialog dialog = new Dialog(this); - Intent intent = getIntent(); + String headlineMode = m_prefs.getString("headline_mode", "HL_DEFAULT"); + String[] headlineModeNames = getResources().getStringArray(R.array.headline_mode_names); + final String[] headlineModeValues = getResources().getStringArray(R.array.headline_mode_values); - Feed feed = hf.getFeed(); + int selectedIndex = Arrays.asList(headlineModeValues).indexOf(headlineMode); - if (feed != null) { - intent.putExtra("feed_id", feed.id); - intent.putExtra("feed_is_cat", feed.is_cat); - intent.putExtra("feed_title", feed.title); - } + AlertDialog.Builder builder = new AlertDialog.Builder(this) + .setTitle(R.string.headlines_set_view_mode) + .setSingleChoiceItems(headlineModeNames, + selectedIndex, new OnClickListener() { + @Override + public void onClick(DialogInterface dialog, + int which) { + dialog.cancel(); - finish(); + SharedPreferences.Editor editor = m_prefs.edit(); + editor.putString("headline_mode", headlineModeValues[which]); + editor.apply(); - startActivity(intent); - overridePendingTransition(0, 0); - } - }); + Intent intent = getIntent(); - dialog = builder.create(); - dialog.show(); + Feed feed = hf.getFeed(); - } - return true; - case R.id.headlines_view_mode: - if (hf != null) { - Dialog dialog = new Dialog(this); - - String viewMode = getViewMode(); - - //Log.d(TAG, "viewMode:" + getViewMode()); - - int selectedIndex = 0; - - if (viewMode.equals("all_articles")) { - selectedIndex = 1; - } else if (viewMode.equals("marked")) { - selectedIndex = 2; - } else if (viewMode.equals("published")) { - selectedIndex = 3; - } else if (viewMode.equals("unread")) { - selectedIndex = 4; - } - - AlertDialog.Builder builder = new AlertDialog.Builder(this) - .setTitle(R.string.headlines_set_view_mode) - .setSingleChoiceItems( - new String[] { - getString(R.string.headlines_adaptive), - getString(R.string.headlines_all_articles), - getString(R.string.headlines_starred), - getString(R.string.headlines_published), - getString(R.string.headlines_unread) }, - selectedIndex, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, - int which) { - switch (which) { - case 0: - setViewMode("adaptive"); - break; - case 1: - setViewMode("all_articles"); - break; - case 2: - setViewMode("marked"); - break; - case 3: - setViewMode("published"); - break; - case 4: - setViewMode("unread"); - break; - } - dialog.cancel(); + if (feed != null) { + intent.putExtra("feed_id", feed.id); + intent.putExtra("feed_is_cat", feed.is_cat); + intent.putExtra("feed_title", feed.title); + } - refresh(); - } - }); + finish(); - dialog = builder.create(); - dialog.show(); + startActivity(intent); + overridePendingTransition(0, 0); + } + }); - } - return true; - case R.id.headlines_select: - if (hf != null) { - Dialog dialog = new Dialog(this); - AlertDialog.Builder builder = new AlertDialog.Builder(this) - .setTitle(R.string.headlines_select_dialog) - .setSingleChoiceItems( - new String[] { - getString(R.string.headlines_select_all), - getString(R.string.headlines_select_unread), - getString(R.string.headlines_select_none) }, - 0, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, - int which) { - switch (which) { - case 0: - hf.setSelection(HeadlinesFragment.ArticlesSelection.ALL); - break; - case 1: - hf.setSelection(HeadlinesFragment.ArticlesSelection.UNREAD); - break; - case 2: - hf.setSelection(HeadlinesFragment.ArticlesSelection.NONE); - break; - } - dialog.cancel(); - invalidateOptionsMenu(); - } - }); + dialog = builder.create(); + dialog.show(); - dialog = builder.create(); - dialog.show(); - } - return true; + } + return true; + } else if (itemId == R.id.headlines_view_mode) { + if (hf != null) { + Dialog dialog = new Dialog(this); + + String viewMode = getViewMode(); + + //Log.d(TAG, "viewMode:" + getViewMode()); + + int selectedIndex = 0; + + if (viewMode.equals("all_articles")) { + selectedIndex = 1; + } else if (viewMode.equals("marked")) { + selectedIndex = 2; + } else if (viewMode.equals("published")) { + selectedIndex = 3; + } else if (viewMode.equals("unread")) { + selectedIndex = 4; + } + + AlertDialog.Builder builder = new AlertDialog.Builder(this) + .setTitle(R.string.headlines_set_view_mode) + .setSingleChoiceItems( + new String[]{ + getString(R.string.headlines_adaptive), + getString(R.string.headlines_all_articles), + getString(R.string.headlines_starred), + getString(R.string.headlines_published), + getString(R.string.headlines_unread)}, + selectedIndex, new OnClickListener() { + @Override + public void onClick(DialogInterface dialog, + int which) { + switch (which) { + case 0: + setViewMode("adaptive"); + break; + case 1: + setViewMode("all_articles"); + break; + case 2: + setViewMode("marked"); + break; + case 3: + setViewMode("published"); + break; + case 4: + setViewMode("unread"); + break; + } + dialog.cancel(); + + refresh(); + } + }); + + dialog = builder.create(); + dialog.show(); + + } + return true; + } else if (itemId == R.id.headlines_select) { + if (hf != null) { + Dialog dialog = new Dialog(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this) + .setTitle(R.string.headlines_select_dialog) + .setSingleChoiceItems( + new String[]{ + getString(R.string.headlines_select_all), + getString(R.string.headlines_select_unread), + getString(R.string.headlines_select_none)}, + 0, new OnClickListener() { + @Override + public void onClick(DialogInterface dialog, + int which) { + switch (which) { + case 0: + hf.setSelection(HeadlinesFragment.ArticlesSelection.ALL); + break; + case 1: + hf.setSelection(HeadlinesFragment.ArticlesSelection.UNREAD); + break; + case 2: + hf.setSelection(HeadlinesFragment.ArticlesSelection.NONE); + break; + } + dialog.cancel(); + invalidateOptionsMenu(); + } + }); + + dialog = builder.create(); + dialog.show(); + } + return true; /* case R.id.share_article: if (ap != null) { shareArticle(ap.getSelectedArticle()); } return true; */ - case R.id.toggle_marked: - if (ap != null && ap.getSelectedArticle() != null) { - Article a = ap.getSelectedArticle(); - a.marked = !a.marked; - saveArticleMarked(a); - if (hf != null) hf.notifyUpdated(); - } - return true; - case R.id.toggle_unread: - if (ap != null && ap.getSelectedArticle() != null) { - Article a = ap.getSelectedArticle(); - a.unread = !a.unread; - saveArticleUnread(a); - if (hf != null) hf.notifyUpdated(); - } - return true; + } else if (itemId == R.id.toggle_marked) { + if (ap != null && ap.getSelectedArticle() != null) { + Article a = ap.getSelectedArticle(); + a.marked = !a.marked; + saveArticleMarked(a); + if (hf != null) hf.notifyUpdated(); + } + return true; + } else if (itemId == R.id.toggle_unread) { + if (ap != null && ap.getSelectedArticle() != null) { + Article a = ap.getSelectedArticle(); + a.unread = !a.unread; + saveArticleUnread(a); + if (hf != null) hf.notifyUpdated(); + } + return true; /* case R.id.selection_select_none: if (hf != null) { ArticleList selected = hf.getSelectedArticles(); @@ -794,105 +793,104 @@ public class OnlineActivity extends CommonActivity { } } return true; */ - case R.id.selection_toggle_unread: - if (hf != null) { - ArticleList selected = hf.getSelectedArticles(); + } else if (itemId == R.id.selection_toggle_unread) { + if (hf != null) { + ArticleList selected = hf.getSelectedArticles(); - if (selected.size() > 0) { - for (Article a : selected) - a.unread = !a.unread; + if (selected.size() > 0) { + for (Article a : selected) + a.unread = !a.unread; - toggleArticlesUnread(selected); - hf.notifyUpdated(); - invalidateOptionsMenu(); - } - } - return true; - case R.id.selection_toggle_marked: - if (hf != null) { - ArticleList selected = hf.getSelectedArticles(); + toggleArticlesUnread(selected); + hf.notifyUpdated(); + invalidateOptionsMenu(); + } + } + return true; + } else if (itemId == R.id.selection_toggle_marked) { + if (hf != null) { + ArticleList selected = hf.getSelectedArticles(); - if (selected.size() > 0) { - for (Article a : selected) - a.marked = !a.marked; + if (selected.size() > 0) { + for (Article a : selected) + a.marked = !a.marked; - toggleArticlesMarked(selected); - hf.notifyUpdated(); - invalidateOptionsMenu(); - } - } - return true; - case R.id.selection_toggle_published: - if (hf != null) { - ArticleList selected = hf.getSelectedArticles(); + toggleArticlesMarked(selected); + hf.notifyUpdated(); + invalidateOptionsMenu(); + } + } + return true; + } else if (itemId == R.id.selection_toggle_published) { + if (hf != null) { + ArticleList selected = hf.getSelectedArticles(); - if (selected.size() > 0) { - for (Article a : selected) - a.published = !a.published; + if (selected.size() > 0) { + for (Article a : selected) + a.published = !a.published; - toggleArticlesPublished(selected); - hf.notifyUpdated(); - invalidateOptionsMenu(); - } - } - return true; - case R.id.toggle_published: - if (ap != null && ap.getSelectedArticle() != null) { - Article a = ap.getSelectedArticle(); - a.published = !a.published; - saveArticlePublished(a); - if (hf != null) hf.notifyUpdated(); - } - return true; - case R.id.catchup_above: - if (hf != null) { + toggleArticlesPublished(selected); + hf.notifyUpdated(); + invalidateOptionsMenu(); + } + } + return true; + } else if (itemId == R.id.toggle_published) { + if (ap != null && ap.getSelectedArticle() != null) { + Article a = ap.getSelectedArticle(); + a.published = !a.published; + saveArticlePublished(a); + if (hf != null) hf.notifyUpdated(); + } + return true; + } else if (itemId == R.id.catchup_above) { + if (hf != null) { - AlertDialog.Builder builder = new AlertDialog.Builder( - OnlineActivity.this) - .setMessage(R.string.confirm_catchup_above) - .setPositiveButton(R.string.dialog_ok, - new Dialog.OnClickListener() { - public void onClick(DialogInterface dialog, - int which) { + AlertDialog.Builder builder = new AlertDialog.Builder( + OnlineActivity.this) + .setMessage(R.string.confirm_catchup_above) + .setPositiveButton(R.string.dialog_ok, + new OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { - catchupAbove(hf, ap); + catchupAbove(hf, ap); - } - }) - .setNegativeButton(R.string.dialog_cancel, - new Dialog.OnClickListener() { - public void onClick(DialogInterface dialog, - int which) { + } + }) + .setNegativeButton(R.string.dialog_cancel, + new OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { - } - }); + } + }); - AlertDialog dialog = builder.create(); - dialog.show(); + AlertDialog dialog = builder.create(); + dialog.show(); - } - return true; - case R.id.set_labels: - if (ap != null && ap.getSelectedArticle() != null) { - if (getApiLevel() != 7) { - editArticleLabels(ap.getSelectedArticle()); - } else { - toast(R.string.server_function_not_available); - } - - } - return true; + } + return true; + } else if (itemId == R.id.set_labels) { + if (ap != null && ap.getSelectedArticle() != null) { + if (getApiLevel() != 7) { + editArticleLabels(ap.getSelectedArticle()); + } else { + toast(R.string.server_function_not_available); + } + + } + return true; /*case R.id.update_headlines: if (hf != null) { //m_pullToRefreshAttacher.setRefreshing(true); hf.refresh(false, true); } return true;*/ - default: - Log.d(TAG, "onOptionsItemSelected, unhandled id=" + item.getItemId()); - return super.onOptionsItemSelected(item); - } - } + } + Log.d(TAG, "onOptionsItemSelected, unhandled id=" + item.getItemId()); + return super.onOptionsItemSelected(item); + } private void catchupAbove(HeadlinesFragment hf, ArticlePager ap) { if (ap != null && ap.getSelectedArticle() != null) { diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/PreferencesActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/PreferencesActivity.java index af321a5a..2f8237bd 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/PreferencesActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/PreferencesActivity.java @@ -36,13 +36,11 @@ public class PreferencesActivity extends CommonActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); + if (item.getItemId() == android.R.id.home) { + onBackPressed(); + return true; } + return super.onOptionsItemSelected(item); } } diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineActivity.java index 5b63356d..4c2e92a7 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineActivity.java @@ -100,54 +100,53 @@ public class OfflineActivity extends CommonActivity { .getMenuInfo(); */ final OfflineArticlePager ap = (OfflineArticlePager)getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE); - - switch (item.getItemId()) { - case R.id.article_img_open: - if (getLastContentImageHitTestUrl() != null) { - try { - openUri(Uri.parse(getLastContentImageHitTestUrl())); - } catch (Exception e) { - e.printStackTrace(); - toast(R.string.error_other_error); - } - } - return true; - case R.id.article_img_copy: - if (getLastContentImageHitTestUrl() != null) { - copyToClipboard(getLastContentImageHitTestUrl()); - } - return true; - case R.id.article_img_share: - if (getLastContentImageHitTestUrl() != null) { - shareImageFromUri(getLastContentImageHitTestUrl()); - } - return true; - case R.id.article_img_share_url: - if (getLastContentImageHitTestUrl() != null) { - shareText(getLastContentImageHitTestUrl()); - } - return true; - case R.id.article_img_view_caption: - if (getLastContentImageHitTestUrl() != null) { - String content = ""; - - Cursor article = getArticleById(ap.getSelectedArticleId()); - - if (article != null) { - content = article.getString(article.getColumnIndex("content")); - article.close(); - } + int itemId = item.getItemId(); + if (itemId == R.id.article_img_open) { + if (getLastContentImageHitTestUrl() != null) { + try { + openUri(Uri.parse(getLastContentImageHitTestUrl())); + } catch (Exception e) { + e.printStackTrace(); + toast(R.string.error_other_error); + } + } + return true; + } else if (itemId == R.id.article_img_copy) { + if (getLastContentImageHitTestUrl() != null) { + copyToClipboard(getLastContentImageHitTestUrl()); + } + return true; + } else if (itemId == R.id.article_img_share) { + if (getLastContentImageHitTestUrl() != null) { + shareImageFromUri(getLastContentImageHitTestUrl()); + } + return true; + } else if (itemId == R.id.article_img_share_url) { + if (getLastContentImageHitTestUrl() != null) { + shareText(getLastContentImageHitTestUrl()); + } + return true; + } else if (itemId == R.id.article_img_view_caption) { + if (getLastContentImageHitTestUrl() != null) { + + String content = ""; + + Cursor article = getArticleById(ap.getSelectedArticleId()); - displayImageCaption(getLastContentImageHitTestUrl(), content); + if (article != null) { + content = article.getString(article.getColumnIndex("content")); + article.close(); + } + + displayImageCaption(getLastContentImageHitTestUrl(), content); } return true; - default: - Log.d(TAG, "onContextItemSelected, unhandled id=" + item.getItemId()); - return super.onContextItemSelected(item); - } - - } + } + Log.d(TAG, "onContextItemSelected, unhandled id=" + item.getItemId()); + return super.onContextItemSelected(item); + + } @Override public void onCreate(Bundle savedInstanceState) { @@ -244,303 +243,299 @@ public class OfflineActivity extends CommonActivity { final OfflineArticlePager oap = (OfflineArticlePager) getSupportFragmentManager() .findFragmentByTag(FRAG_ARTICLE); - switch (item.getItemId()) { - /* case android.R.id.home: + int itemId = item.getItemId();/* case android.R.id.home: finish(); - return true; */ - /* case R.id.headlines_toggle_sidebar: + return true; *//* case R.id.headlines_toggle_sidebar: if (true && !isSmallScreen()) { SharedPreferences.Editor editor = m_prefs.edit(); editor.putBoolean("headlines_hide_sidebar", !m_prefs.getBoolean("headlines_hide_sidebar", false)); editor.commit(); - + if (ohf != null && ohf.isAdded()) { ohf.getView().setVisibility(m_prefs.getBoolean("headlines_hide_sidebar", false) ? View.GONE : View.VISIBLE); } } - return true; */ - /*case R.id.go_online: + return true; *//*case R.id.go_online: switchOnline(); return true;*/ - case R.id.search: - if (ohf != null) { - Dialog dialog = new Dialog(this); - - final EditText edit = new EditText(this); - - AlertDialog.Builder builder = new AlertDialog.Builder(this) - .setTitle(R.string.search) - .setPositiveButton(getString(R.string.search), - new OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, - int which) { - - String query = edit.getText().toString().trim(); - - ohf.setSearchQuery(query); - - } - }) - .setNegativeButton(getString(R.string.cancel), - new OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, - int which) { - - // - - } - }).setView(edit); - - dialog = builder.create(); - dialog.show(); - } - - return true; - case R.id.preferences: - Intent intent = new Intent(this, PreferencesActivity.class); - startActivityForResult(intent, 0); - return true; - case R.id.headlines_view_mode: - if (ohf != null) { - Dialog dialog = new Dialog(this); - - String viewMode = getViewMode(); - - //Log.d(TAG, "viewMode:" + getViewMode()); + if (itemId == R.id.search) { + if (ohf != null) { + Dialog dialog = new Dialog(this); - int selectedIndex = 0; - - if (viewMode.equals("all_articles")) { - selectedIndex = 0; - } else if (viewMode.equals("marked")) { - selectedIndex = 1; - } else if (viewMode.equals("published")) { - selectedIndex = 2; - } else if (viewMode.equals("unread")) { - selectedIndex = 3; - } - - AlertDialog.Builder builder = new AlertDialog.Builder(this) - .setTitle(R.string.headlines_set_view_mode) - .setSingleChoiceItems( - new String[] { - /* getString(R.string.headlines_adaptive), */ - getString(R.string.headlines_all_articles), - getString(R.string.headlines_starred), - getString(R.string.headlines_published), - getString(R.string.headlines_unread) }, - selectedIndex, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, - int which) { - switch (which) { + final EditText edit = new EditText(this); + + AlertDialog.Builder builder = new AlertDialog.Builder(this) + .setTitle(R.string.search) + .setPositiveButton(getString(R.string.search), + new OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, + int which) { + + String query = edit.getText().toString().trim(); + + ohf.setSearchQuery(query); + + } + }) + .setNegativeButton(getString(R.string.cancel), + new OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, + int which) { + + // + + } + }).setView(edit); + + dialog = builder.create(); + dialog.show(); + } + + return true; + } else if (itemId == R.id.preferences) { + Intent intent = new Intent(this, PreferencesActivity.class); + startActivityForResult(intent, 0); + return true; + } else if (itemId == R.id.headlines_view_mode) { + if (ohf != null) { + Dialog dialog = new Dialog(this); + + String viewMode = getViewMode(); + + //Log.d(TAG, "viewMode:" + getViewMode()); + + int selectedIndex = 0; + + if (viewMode.equals("all_articles")) { + selectedIndex = 0; + } else if (viewMode.equals("marked")) { + selectedIndex = 1; + } else if (viewMode.equals("published")) { + selectedIndex = 2; + } else if (viewMode.equals("unread")) { + selectedIndex = 3; + } + + AlertDialog.Builder builder = new AlertDialog.Builder(this) + .setTitle(R.string.headlines_set_view_mode) + .setSingleChoiceItems( + new String[]{ + /* getString(R.string.headlines_adaptive), */ + getString(R.string.headlines_all_articles), + getString(R.string.headlines_starred), + getString(R.string.headlines_published), + getString(R.string.headlines_unread)}, + selectedIndex, new OnClickListener() { + @Override + public void onClick(DialogInterface dialog, + int which) { + switch (which) { /* case 0: setViewMode("adaptive"); break; */ - case 0: - setViewMode("all_articles"); - break; - case 1: - setViewMode("marked"); - break; - case 2: - setViewMode("published"); - break; - case 3: - setViewMode("unread"); - break; - } - dialog.cancel(); - - refresh(); - } - }); - - dialog = builder.create(); - dialog.show(); + case 0: + setViewMode("all_articles"); + break; + case 1: + setViewMode("marked"); + break; + case 2: + setViewMode("published"); + break; + case 3: + setViewMode("unread"); + break; + } + dialog.cancel(); + + refresh(); + } + }); + + dialog = builder.create(); + dialog.show(); - } - return true; - case R.id.headlines_select: - if (ohf != null) { - Dialog dialog = new Dialog(this); - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(R.string.headlines_select_dialog); - - builder.setSingleChoiceItems(new String[] { - getString(R.string.headlines_select_all), - getString(R.string.headlines_select_unread), - getString(R.string.headlines_select_none) }, 0, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, - int which) { - - selectArticles(ohf.getFeedId(), ohf.getFeedIsCat(), which); - invalidateOptionsMenu(); - refresh(); - - dialog.cancel(); - } - }); - - dialog = builder.create(); - dialog.show(); - } - return true; - case R.id.headlines_mark_as_read: - if (ohf != null) { - final int feedId = ohf.getFeedId(); - final boolean isCat = ohf.getFeedIsCat(); - - int count = getUnreadArticleCount(feedId, isCat); - - if (count > 0) { - AlertDialog.Builder builder = new AlertDialog.Builder( - OfflineActivity.this) - .setMessage(getResources().getQuantityString(R.plurals.mark_num_headlines_as_read, count, count)) - .setPositiveButton(R.string.catchup, - new Dialog.OnClickListener() { - public void onClick(DialogInterface dialog, - int which) { - - catchupFeed(feedId, isCat); - - } - }) - .setNegativeButton(R.string.dialog_cancel, - new Dialog.OnClickListener() { - public void onClick(DialogInterface dialog, - int which) { - - } - }); - - AlertDialog dlg = builder.create(); - dlg.show(); - } - } - return true; + } + return true; + } else if (itemId == R.id.headlines_select) { + if (ohf != null) { + Dialog dialog = new Dialog(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(R.string.headlines_select_dialog); + + builder.setSingleChoiceItems(new String[]{ + getString(R.string.headlines_select_all), + getString(R.string.headlines_select_unread), + getString(R.string.headlines_select_none)}, 0, + new OnClickListener() { + @Override + public void onClick(DialogInterface dialog, + int which) { + + selectArticles(ohf.getFeedId(), ohf.getFeedIsCat(), which); + invalidateOptionsMenu(); + refresh(); + + dialog.cancel(); + } + }); + + dialog = builder.create(); + dialog.show(); + } + return true; + } else if (itemId == R.id.headlines_mark_as_read) { + if (ohf != null) { + final int feedId = ohf.getFeedId(); + final boolean isCat = ohf.getFeedIsCat(); + + int count = getUnreadArticleCount(feedId, isCat); + + if (count > 0) { + AlertDialog.Builder builder = new AlertDialog.Builder( + OfflineActivity.this) + .setMessage(getResources().getQuantityString(R.plurals.mark_num_headlines_as_read, count, count)) + .setPositiveButton(R.string.catchup, + new OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + + catchupFeed(feedId, isCat); + + } + }) + .setNegativeButton(R.string.dialog_cancel, + new OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + + } + }); + + AlertDialog dlg = builder.create(); + dlg.show(); + } + } + return true; /* case R.id.share_article: if (true) { int articleId = oap.getSelectedArticleId(); - + shareArticle(articleId); } return true; */ - case R.id.toggle_marked: - if (oap != null) { - int articleId = oap.getSelectedArticleId(); - - SQLiteStatement stmt = getDatabase().compileStatement( - "UPDATE articles SET modified = 1, modified_marked = 1, marked = NOT marked WHERE " - + BaseColumns._ID + " = ?"); - stmt.bindLong(1, articleId); - stmt.execute(); - stmt.close(); - - refresh(); - } - return true; - case R.id.toggle_unread: - if (oap != null) { - int articleId = oap.getSelectedArticleId(); - - SQLiteStatement stmt = getDatabase().compileStatement( - "UPDATE articles SET modified = 1, unread = NOT unread WHERE " - + BaseColumns._ID + " = ?"); - stmt.bindLong(1, articleId); - stmt.execute(); - stmt.close(); - - refresh(); - } - return true; + } else if (itemId == R.id.toggle_marked) { + if (oap != null) { + int articleId = oap.getSelectedArticleId(); + + SQLiteStatement stmt = getDatabase().compileStatement( + "UPDATE articles SET modified = 1, modified_marked = 1, marked = NOT marked WHERE " + + BaseColumns._ID + " = ?"); + stmt.bindLong(1, articleId); + stmt.execute(); + stmt.close(); + + refresh(); + } + return true; + } else if (itemId == R.id.toggle_unread) { + if (oap != null) { + int articleId = oap.getSelectedArticleId(); + + SQLiteStatement stmt = getDatabase().compileStatement( + "UPDATE articles SET modified = 1, unread = NOT unread WHERE " + + BaseColumns._ID + " = ?"); + stmt.bindLong(1, articleId); + stmt.execute(); + stmt.close(); + + refresh(); + } + return true; /* case R.id.selection_select_none: - deselectAllArticles(); + deselectAllArticles(); return true; */ - case R.id.selection_toggle_unread: - if (getSelectedArticleCount() > 0) { - SQLiteStatement stmt = getDatabase() - .compileStatement( - "UPDATE articles SET modified = 1, unread = NOT unread WHERE selected = 1"); - stmt.execute(); - stmt.close(); - - refresh(); - } - return true; - case R.id.selection_toggle_marked: - if (getSelectedArticleCount() > 0) { - SQLiteStatement stmt = getDatabase() - .compileStatement( - "UPDATE articles SET modified = 1, modified_marked = 1, marked = NOT marked WHERE selected = 1"); - stmt.execute(); - stmt.close(); - - refresh(); - } - return true; - case R.id.selection_toggle_published: - if (getSelectedArticleCount() > 0) { - SQLiteStatement stmt = getDatabase() - .compileStatement( - "UPDATE articles SET modified = 1, modified_published = 1, published = NOT published WHERE selected = 1"); - stmt.execute(); - stmt.close(); - - refresh(); - } - return true; - case R.id.toggle_published: - if (oap != null) { - int articleId = oap.getSelectedArticleId(); - - SQLiteStatement stmt = getDatabase().compileStatement( - "UPDATE articles SET modified = 1, modified_published = 1, published = NOT published WHERE " - + BaseColumns._ID + " = ?"); - stmt.bindLong(1, articleId); - stmt.execute(); - stmt.close(); - - refresh(); - } - return true; - case R.id.catchup_above: - if (oap != null) { - AlertDialog.Builder builder = new AlertDialog.Builder( - OfflineActivity.this) - .setMessage(R.string.confirm_catchup_above) - .setPositiveButton(R.string.dialog_ok, - new Dialog.OnClickListener() { - public void onClick(DialogInterface dialog, - int which) { - - catchupAbove(oap); - - } - }) - .setNegativeButton(R.string.dialog_cancel, - new Dialog.OnClickListener() { - public void onClick(DialogInterface dialog, - int which) { - - } - }); - - AlertDialog dlg = builder.create(); - dlg.show(); - } - return true; - default: - Log.d(TAG, "onOptionsItemSelected, unhandled id=" + item.getItemId()); - return super.onOptionsItemSelected(item); - } - } + } else if (itemId == R.id.selection_toggle_unread) { + if (getSelectedArticleCount() > 0) { + SQLiteStatement stmt = getDatabase() + .compileStatement( + "UPDATE articles SET modified = 1, unread = NOT unread WHERE selected = 1"); + stmt.execute(); + stmt.close(); + + refresh(); + } + return true; + } else if (itemId == R.id.selection_toggle_marked) { + if (getSelectedArticleCount() > 0) { + SQLiteStatement stmt = getDatabase() + .compileStatement( + "UPDATE articles SET modified = 1, modified_marked = 1, marked = NOT marked WHERE selected = 1"); + stmt.execute(); + stmt.close(); + + refresh(); + } + return true; + } else if (itemId == R.id.selection_toggle_published) { + if (getSelectedArticleCount() > 0) { + SQLiteStatement stmt = getDatabase() + .compileStatement( + "UPDATE articles SET modified = 1, modified_published = 1, published = NOT published WHERE selected = 1"); + stmt.execute(); + stmt.close(); + + refresh(); + } + return true; + } else if (itemId == R.id.toggle_published) { + if (oap != null) { + int articleId = oap.getSelectedArticleId(); + + SQLiteStatement stmt = getDatabase().compileStatement( + "UPDATE articles SET modified = 1, modified_published = 1, published = NOT published WHERE " + + BaseColumns._ID + " = ?"); + stmt.bindLong(1, articleId); + stmt.execute(); + stmt.close(); + + refresh(); + } + return true; + } else if (itemId == R.id.catchup_above) { + if (oap != null) { + AlertDialog.Builder builder = new AlertDialog.Builder( + OfflineActivity.this) + .setMessage(R.string.confirm_catchup_above) + .setPositiveButton(R.string.dialog_ok, + new OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + + catchupAbove(oap); + + } + }) + .setNegativeButton(R.string.dialog_cancel, + new OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + + } + }); + + AlertDialog dlg = builder.create(); + dlg.show(); + } + return true; + } + Log.d(TAG, "onOptionsItemSelected, unhandled id=" + item.getItemId()); + return super.onOptionsItemSelected(item); + } private void catchupAbove(OfflineArticlePager oap) { int articleId = oap.getSelectedArticleId(); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/share/CommonShareActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/share/CommonShareActivity.java index a1044988..e810f49f 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/share/CommonShareActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/share/CommonShareActivity.java @@ -94,18 +94,16 @@ public abstract class CommonShareActivity extends CommonActivity { } public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.preferences: - Intent intent = new Intent(CommonShareActivity.this, - PreferencesActivity.class); - startActivityForResult(intent, 0); - return true; - default: - Log.d(TAG, - "onOptionsItemSelected, unhandled id=" + item.getItemId()); - return super.onOptionsItemSelected(item); - } - } + if (item.getItemId() == R.id.preferences) { + Intent intent = new Intent(CommonShareActivity.this, + PreferencesActivity.class); + startActivityForResult(intent, 0); + return true; + } + Log.d(TAG, + "onOptionsItemSelected, unhandled id=" + item.getItemId()); + return super.onOptionsItemSelected(item); + } @Override public boolean onCreateOptionsMenu(Menu menu) { |