mirror of https://github.com/readrops/Readrops.git
Add preference for showing/hiding feeds with no unread items left in drawer
This commit is contained in:
parent
489f52b13a
commit
1bfed8306d
|
@ -1,5 +1,7 @@
|
|||
package com.readrops.app.itemslist;
|
||||
|
||||
import static com.readrops.app.utils.Utils.drawableWithColor;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
|
@ -31,6 +33,7 @@ import com.mikepenz.materialdrawer.model.SecondaryDrawerItem;
|
|||
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
|
||||
import com.mikepenz.materialdrawer.model.interfaces.IProfile;
|
||||
import com.readrops.app.R;
|
||||
import com.readrops.app.utils.SharedPreferencesManager;
|
||||
import com.readrops.app.utils.customviews.CustomExpandableBadgeDrawerItem;
|
||||
import com.readrops.db.entities.Feed;
|
||||
import com.readrops.db.entities.Folder;
|
||||
|
@ -43,8 +46,6 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.readrops.app.utils.Utils.drawableWithColor;
|
||||
|
||||
public class DrawerManager {
|
||||
|
||||
public static final int ARTICLES_ITEM_ID = -5;
|
||||
|
@ -162,6 +163,8 @@ public class DrawerManager {
|
|||
addDefaultPlaces();
|
||||
|
||||
Map<SecondaryDrawerItem, Feed> feedsWithoutFolder = new HashMap<>();
|
||||
boolean showFeedsWithNoUnreadItems = Boolean.parseBoolean(SharedPreferencesManager
|
||||
.readString(SharedPreferencesManager.SharedPrefKey.HIDE_SHOW_FEEDS));
|
||||
|
||||
for (Map.Entry<Folder, List<Feed>> entry : folderListMap.entrySet()) {
|
||||
Folder folder = entry.getKey();
|
||||
|
@ -178,12 +181,26 @@ public class DrawerManager {
|
|||
expandableUnreadCount += feed.getUnreadCount();
|
||||
|
||||
SecondaryDrawerItem secondaryDrawerItem = createSecondaryItem(feed);
|
||||
secondaryDrawerItems.add(secondaryDrawerItem);
|
||||
|
||||
if (!showFeedsWithNoUnreadItems) {
|
||||
if (feed.getUnreadCount() > 0) {
|
||||
secondaryDrawerItems.add(secondaryDrawerItem);
|
||||
}
|
||||
} else {
|
||||
secondaryDrawerItems.add(secondaryDrawerItem);
|
||||
}
|
||||
|
||||
loadItemIcon(secondaryDrawerItem, feed);
|
||||
}
|
||||
|
||||
if (!secondaryDrawerItems.isEmpty()) {
|
||||
boolean showItem;
|
||||
if (!showFeedsWithNoUnreadItems) {
|
||||
showItem = expandableUnreadCount > 0;
|
||||
} else {
|
||||
showItem = true;
|
||||
}
|
||||
|
||||
if (!secondaryDrawerItems.isEmpty() && showItem) {
|
||||
badgeDrawerItem.withSubItems(secondaryDrawerItems);
|
||||
badgeDrawerItem.withBadge(String.valueOf(expandableUnreadCount));
|
||||
drawer.addItem(badgeDrawerItem);
|
||||
|
|
|
@ -90,6 +90,7 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
|
|||
public static final int MANAGE_ACCOUNT_REQUEST = 2;
|
||||
public static final int ITEM_REQUEST = 3;
|
||||
public static final int ADD_ACCOUNT_REQUEST = 4;
|
||||
public static final int SETTINGS_REQUEST = 5;
|
||||
|
||||
private ActivityMainBinding binding;
|
||||
private MainItemListAdapter adapter;
|
||||
|
@ -294,7 +295,7 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
|
|||
Intent intent = new Intent(getApplication(), SettingsActivity.class);
|
||||
intent.putExtra(SETTINGS,
|
||||
SettingsActivity.SettingsKey.SETTINGS.ordinal());
|
||||
startActivity(intent);
|
||||
startActivityForResult(intent, SETTINGS_REQUEST);
|
||||
break;
|
||||
}
|
||||
} else if (drawerItem instanceof SecondaryDrawerItem) {
|
||||
|
@ -591,7 +592,7 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
|
|||
sync(feeds);
|
||||
}
|
||||
|
||||
} else if (requestCode == MANAGE_ACCOUNT_REQUEST) {
|
||||
} else if (requestCode == MANAGE_ACCOUNT_REQUEST || requestCode == SETTINGS_REQUEST) {
|
||||
updateDrawerFeeds();
|
||||
|
||||
} else if (requestCode == ADD_ACCOUNT_REQUEST && resultCode == RESULT_OK && data != null) {
|
||||
|
|
|
@ -57,7 +57,8 @@ public final class SharedPreferencesManager {
|
|||
ITEMS_TO_PARSE_MAX_NB("items_to_parse_max_nb", "20"),
|
||||
OPEN_ITEMS_IN("open_items_in", "0"),
|
||||
DARK_THEME("dark_theme", "false"),
|
||||
AUTO_SYNCHRO("auto_synchro", "0");
|
||||
AUTO_SYNCHRO("auto_synchro", "0"),
|
||||
HIDE_SHOW_FEEDS("show_hide_feeds", "true");
|
||||
|
||||
@NonNull
|
||||
private String key;
|
||||
|
|
|
@ -138,5 +138,8 @@
|
|||
<string name="changelog">Journal des modifications</string>
|
||||
<string name="app_description">App distribuée sous la licence GPLv3</string>
|
||||
<string name="system">Thème du système</string>
|
||||
<string name="hide">Cacher</string>
|
||||
<string name="show">Afficher</string>
|
||||
<string name="show_hide_feeds">Afficher ou cacher les flux sans nouveaux items</string>
|
||||
|
||||
</resources>
|
|
@ -75,4 +75,15 @@
|
|||
<item>12</item>
|
||||
<item>24</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
<string-array name="show_hide_read_feeds">
|
||||
<item>@string/hide</item>
|
||||
<item>@string/show</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="show_hide_read_feeds_values">
|
||||
<item>false</item>
|
||||
<item>true</item>
|
||||
</string-array>
|
||||
</resources>
|
|
@ -144,4 +144,7 @@
|
|||
<string name="theme_value_light" translatable="false">light</string>
|
||||
<string name="theme_value_dark" translatable="false">dark</string>
|
||||
<string name="theme_value_system" translatable="false">system</string>
|
||||
<string name="hide">Hide</string>
|
||||
<string name="show">Show</string>
|
||||
<string name="show_hide_feeds">Show or hide feeds without new items</string>
|
||||
</resources>
|
|
@ -35,6 +35,15 @@
|
|||
android:entryValues="@array/synchro_values"
|
||||
android:key="auto_synchro"
|
||||
android:title="@string/auto_synchro" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="true"
|
||||
android:entries="@array/show_hide_read_feeds"
|
||||
android:entryValues="@array/show_hide_read_feeds_values"
|
||||
android:key="show_hide_feeds"
|
||||
android:title="@string/show_hide_feeds" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
</PreferenceScreen>
|
Loading…
Reference in New Issue