diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java index ab5b5524c..f1e2d0d89 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java @@ -140,6 +140,7 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements public static HashSet stayUnreadItems = new HashSet<>(); + private MenuItem menuItemOnlyUnread; private MenuItem menuItemDownloadMoreItems; @VisibleForTesting(otherwise = PROTECTED) @@ -671,6 +672,10 @@ private NewsReaderDetailFragment updateDetailFragment(long id, Boolean folder, L Long folderId; String title = null; + if (menuItemOnlyUnread != null) { + menuItemOnlyUnread.setVisible(true); + } + if(!folder) { feedId = id; folderId = optional_folder_id; @@ -682,8 +687,14 @@ private NewsReaderDetailFragment updateDetailFragment(long id, Boolean folder, L title = dbConn.getFolderById(id).getLabel(); } else if(idFolder == -10) { title = getString(R.string.allUnreadFeeds); + if (menuItemOnlyUnread != null) { + menuItemOnlyUnread.setVisible(false); + } } else if(idFolder == -11) { title = getString(R.string.starredFeeds); + if (menuItemOnlyUnread != null) { + menuItemOnlyUnread.setVisible(false); + } } } @@ -789,6 +800,9 @@ public boolean onCreateOptionsMenu(Menu menu) { menuItemDownloadMoreItems.setEnabled(false); MenuItem searchItem = menu.findItem(R.id.menu_search); + menuItemOnlyUnread = menu.findItem(R.id.menu_toggleShowOnlyUnread); + menuItemOnlyUnread.setChecked(mPrefs.getBoolean(SettingsActivity.CB_SHOWONLYUNREAD_STRING, false)); + menuItemOnlyUnread.setVisible(false); //Set expand listener to close keyboard searchItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() { @@ -857,7 +871,15 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) { return true; } else if (itemId == R.id.menu_update) { startSync(); - } else if (itemId == R.id.menu_StartImageCaching) { + } + else if (itemId == R.id.menu_toggleShowOnlyUnread) { + boolean newValue = !mPrefs.getBoolean(SettingsActivity.CB_SHOWONLYUNREAD_STRING, false); + mPrefs.edit().putBoolean(SettingsActivity.CB_SHOWONLYUNREAD_STRING, newValue).commit(); + item.setChecked(newValue); + getSlidingListFragment().reloadAdapter(); + updateCurrentRssView(); + } + else if (itemId == R.id.menu_StartImageCaching) { final DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(this); long highestItemId = dbConn.getLowestRssItemIdUnread(); diff --git a/News-Android-App/src/main/res/menu/news_reader.xml b/News-Android-App/src/main/res/menu/news_reader.xml index 47afe6a82..dcda008d1 100644 --- a/News-Android-App/src/main/res/menu/news_reader.xml +++ b/News-Android-App/src/main/res/menu/news_reader.xml @@ -40,6 +40,13 @@ android:orderInCategory="97" android:title="@string/menu_markAllAsRead"/> + +