Skip to content

Commit

Permalink
Move "Show only unread articles" to the toolbar
Browse files Browse the repository at this point in the history
This patch moves "Show only unread articles" to the toolbar, inside the
three dots as discussed in #1026

Signed-off-by: Marcus Nilsson <marcus.nilsson@genarp.com>
  • Loading branch information
mkanilsson committed Sep 12, 2023
1 parent 175c116 commit 07b81d4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements

public static HashSet<Long> stayUnreadItems = new HashSet<>();

private MenuItem menuItemOnlyUnread;
private MenuItem menuItemDownloadMoreItems;

@VisibleForTesting(otherwise = PROTECTED)
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
}
}

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions News-Android-App/src/main/res/menu/news_reader.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
android:orderInCategory="97"
android:title="@string/menu_markAllAsRead"/>

<item
android:id="@+id/menu_toggleShowOnlyUnread"
android:orderInCategory="98"
android:title="@string/pref_title_ShowOnlyUnread"
android:checkable="true"
app:showAsAction="never" />

<item
android:id="@+id/action_add_new_feed"
android:orderInCategory="101"
Expand Down

0 comments on commit 07b81d4

Please sign in to comment.