Don't show the no folder case in feed edit dialog folder list for freshrss accounts as a freshrss feed's folder can't be null

This commit is contained in:
Shinokuni 2019-09-18 22:50:53 +02:00
parent c696b6c28d
commit 2c8ddf5030
2 changed files with 25 additions and 7 deletions

View File

@ -5,20 +5,27 @@ public class AccountConfig {
public static final AccountConfig LOCAL = new AccountConfigBuilder()
.setFeedUrlEditable(true)
.setFolderCreation(true)
.setNoFolderCase(false)
.build();
public static final AccountConfig NEXTNEWS = new AccountConfigBuilder()
.setFeedUrlEditable(false)
.setFolderCreation(true)
.setNoFolderCase(false)
.build();
public static final AccountConfig FRESHRSS = new AccountConfigBuilder()
.setFeedUrlEditable(false)
.setFolderCreation(false)
.setNoFolderCase(true)
.build();
private boolean feedUrlEditable;
private boolean folderCreation;
private boolean noFolderCase;
public boolean isFeedUrlEditable() {
return feedUrlEditable;
}
@ -27,16 +34,20 @@ public class AccountConfig {
return folderCreation;
}
private boolean folderCreation;
public boolean isNoFolderCase() {
return noFolderCase;
}
public AccountConfig(boolean feedUrlEditable, boolean folderCreation) {
this.feedUrlEditable = feedUrlEditable;
this.folderCreation = folderCreation;
public AccountConfig(AccountConfigBuilder builder) {
this.feedUrlEditable = builder.feedUrlEditable;
this.folderCreation = builder.folderCreation;
this.noFolderCase = builder.noFolderCase;
}
public static class AccountConfigBuilder {
private boolean feedUrlEditable;
private boolean folderCreation;
private boolean noFolderCase;
public AccountConfigBuilder setFeedUrlEditable(boolean feedUrlEditable) {
this.feedUrlEditable = feedUrlEditable;
@ -48,8 +59,13 @@ public class AccountConfig {
return this;
}
public AccountConfigBuilder setNoFolderCase(boolean noFolderCase) {
this.noFolderCase = noFolderCase;
return this;
}
public AccountConfig build() {
return new AccountConfig(feedUrlEditable, folderCreation);
return new AccountConfig(this);
}
}
}

View File

@ -16,9 +16,9 @@ import androidx.lifecycle.ViewModelProviders;
import com.google.android.material.textfield.TextInputEditText;
import com.readrops.app.R;
import com.readrops.app.activities.ManageFeedsFoldersActivity;
import com.readrops.app.database.entities.account.Account;
import com.readrops.app.database.entities.Feed;
import com.readrops.app.database.entities.Folder;
import com.readrops.app.database.entities.account.Account;
import com.readrops.app.database.pojo.FeedWithFolder;
import com.readrops.app.viewmodels.ManageFeedsFoldersViewModel;
@ -71,7 +71,9 @@ public class EditFeedDialog extends DialogFragment implements AdapterView.OnItem
viewModel.getFolders().observe(this, folders -> {
values = new TreeMap<>(String::compareTo);
values.put(getString(R.string.no_folder), 0);
if (!account.getAccountType().getAccountConfig().isNoFolderCase())
values.put(getString(R.string.no_folder), 0);
for (Folder folder : folders) {
values.put(folder.getName(), folder.getId());