Browse Source

Limit synchronizing folders to 25

main
M66B 6 years ago
parent
commit
ff99597008
3 changed files with 26 additions and 3 deletions
  1. +1
    -1
      .idea/misc.xml
  2. +4
    -0
      app/src/main/java/eu/faircode/email/DaoFolder.java
  3. +21
    -2
      app/src/main/java/eu/faircode/email/FragmentFolder.java

+ 1
- 1
.idea/misc.xml View File

@ -30,7 +30,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">


+ 4
- 0
app/src/main/java/eu/faircode/email/DaoFolder.java View File

@ -90,6 +90,10 @@ public interface DaoFolder {
" WHERE account = :account AND type = :type")
EntityFolder getFolderByType(long account, String type);
@Query("SELECT COUNT(folder.id) FROM folder" +
" WHERE account = :account AND `synchronize`")
int getFolderSyncCount(long account);
// For debug/crash info
@Query("SELECT folder.* FROM folder" +
" JOIN account ON account.id = folder.account" +


+ 21
- 2
app/src/main/java/eu/faircode/email/FragmentFolder.java View File

@ -61,6 +61,8 @@ public class FragmentFolder extends FragmentEx {
private long id = -1;
private long account = -1;
private static final int MAX_FOLDER_SYNC = 25;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -295,14 +297,13 @@ public class FragmentFolder extends FragmentEx {
private boolean once = false;
@Override
public void onChanged(@Nullable EntityFolder folder) {
public void onChanged(@Nullable final EntityFolder folder) {
if (once)
return;
once = true;
if (savedInstanceState == null) {
etRename.setText(folder == null ? null : folder.name);
cbSynchronize.setChecked(folder == null ? true : folder.synchronize);
cbUnified.setChecked(folder == null ? false : folder.unified);
etAfter.setText(Integer.toString(folder == null ? EntityFolder.DEFAULT_USER_SYNC : folder.after));
}
@ -311,9 +312,27 @@ public class FragmentFolder extends FragmentEx {
pbWait.setVisibility(View.GONE);
Helper.setViewsEnabled(view, true);
etRename.setEnabled(folder == null || EntityFolder.USER.equals(folder.type));
cbSynchronize.setEnabled(false);
btnSave.setEnabled(true);
ibDelete.setEnabled(true);
ibDelete.setVisibility(folder == null ? View.GONE : View.VISIBLE);
Bundle args = new Bundle();
args.putLong("account", folder == null ? account : folder.account);
new SimpleTask<Integer>() {
@Override
protected Integer onLoad(Context context, Bundle args) {
long account = args.getLong("account");
return DB.getInstance(context).folder().getFolderSyncCount(account);
}
@Override
protected void onLoaded(Bundle args, Integer count) {
cbSynchronize.setChecked((folder == null || folder.synchronize) && count < MAX_FOLDER_SYNC);
cbSynchronize.setEnabled(count < MAX_FOLDER_SYNC);
}
}.load(FragmentFolder.this, args);
}
});
}


Loading…
Cancel
Save