|
|
@ -44,6 +44,7 @@ import javax.mail.Session; |
|
|
|
|
|
|
|
import androidx.annotation.NonNull; |
|
|
|
import androidx.annotation.Nullable; |
|
|
|
import androidx.constraintlayout.widget.Group; |
|
|
|
import androidx.lifecycle.Observer; |
|
|
|
|
|
|
|
public class FragmentFolder extends FragmentEx { |
|
|
@ -54,10 +55,12 @@ public class FragmentFolder extends FragmentEx { |
|
|
|
private CheckBox cbSynchronize; |
|
|
|
private CheckBox cbUnified; |
|
|
|
private EditText etAfter; |
|
|
|
private EditText etInterval; |
|
|
|
private Button btnSave; |
|
|
|
private ImageButton ibDelete; |
|
|
|
private ProgressBar pbSave; |
|
|
|
private ProgressBar pbWait; |
|
|
|
private Group grpInterval; |
|
|
|
|
|
|
|
private long id = -1; |
|
|
|
private long account = -1; |
|
|
@ -86,10 +89,12 @@ public class FragmentFolder extends FragmentEx { |
|
|
|
cbSynchronize = view.findViewById(R.id.cbSynchronize); |
|
|
|
cbUnified = view.findViewById(R.id.cbUnified); |
|
|
|
etAfter = view.findViewById(R.id.etAfter); |
|
|
|
etInterval = view.findViewById(R.id.etInterval); |
|
|
|
btnSave = view.findViewById(R.id.btnSave); |
|
|
|
ibDelete = view.findViewById(R.id.ibDelete); |
|
|
|
pbSave = view.findViewById(R.id.pbSave); |
|
|
|
pbWait = view.findViewById(R.id.pbWait); |
|
|
|
grpInterval = view.findViewById(R.id.grpInterval); |
|
|
|
|
|
|
|
btnSave.setOnClickListener(new View.OnClickListener() { |
|
|
|
@Override |
|
|
@ -108,6 +113,7 @@ public class FragmentFolder extends FragmentEx { |
|
|
|
args.putBoolean("unified", cbUnified.isChecked()); |
|
|
|
args.putBoolean("synchronize", cbSynchronize.isChecked()); |
|
|
|
args.putString("after", etAfter.getText().toString()); |
|
|
|
args.putString("interval", etInterval.getText().toString()); |
|
|
|
|
|
|
|
new SimpleTask<Void>() { |
|
|
|
@Override |
|
|
@ -120,10 +126,12 @@ public class FragmentFolder extends FragmentEx { |
|
|
|
boolean unified = args.getBoolean("unified"); |
|
|
|
boolean synchronize = args.getBoolean("synchronize"); |
|
|
|
String after = args.getString("after"); |
|
|
|
String interval = args.getString("interval"); |
|
|
|
|
|
|
|
if (TextUtils.isEmpty(display) || display.equals(name)) |
|
|
|
display = null; |
|
|
|
int days = (TextUtils.isEmpty(after) ? EntityFolder.DEFAULT_USER_SYNC : Integer.parseInt(after)); |
|
|
|
Integer poll_interval = (TextUtils.isEmpty(interval) ? null : Integer.parseInt(interval)); |
|
|
|
|
|
|
|
IMAPStore istore = null; |
|
|
|
DB db = DB.getInstance(getContext()); |
|
|
@ -157,6 +165,7 @@ public class FragmentFolder extends FragmentEx { |
|
|
|
create.unified = unified; |
|
|
|
create.synchronize = synchronize; |
|
|
|
create.after = days; |
|
|
|
create.poll_interval = poll_interval; |
|
|
|
db.folder().insertFolder(create); |
|
|
|
} else { |
|
|
|
Log.i(Helper.TAG, "Renaming folder=" + name); |
|
|
@ -171,7 +180,7 @@ public class FragmentFolder extends FragmentEx { |
|
|
|
|
|
|
|
if (folder != null) { |
|
|
|
Log.i(Helper.TAG, "Updating folder=" + name); |
|
|
|
db.folder().setFolderProperties(id, name, display, hide, synchronize, unified, days); |
|
|
|
db.folder().setFolderProperties(id, name, display, hide, synchronize, unified, days, poll_interval); |
|
|
|
if (!synchronize) |
|
|
|
db.folder().setFolderError(id, null); |
|
|
|
} |
|
|
@ -294,6 +303,7 @@ public class FragmentFolder extends FragmentEx { |
|
|
|
ibDelete.setVisibility(View.GONE); |
|
|
|
pbSave.setVisibility(View.GONE); |
|
|
|
pbWait.setVisibility(View.VISIBLE); |
|
|
|
grpInterval.setVisibility(View.GONE); |
|
|
|
|
|
|
|
return view; |
|
|
|
} |
|
|
@ -320,12 +330,14 @@ public class FragmentFolder extends FragmentEx { |
|
|
|
cbUnified.setChecked(folder == null ? false : folder.unified); |
|
|
|
cbSynchronize.setChecked(folder == null || folder.synchronize); |
|
|
|
etAfter.setText(Integer.toString(folder == null ? EntityFolder.DEFAULT_USER_SYNC : folder.after)); |
|
|
|
etInterval.setText(folder == null || folder.poll_interval == null ? null : Integer.toString(folder.poll_interval)); |
|
|
|
} |
|
|
|
|
|
|
|
// Consider previous save as cancelled |
|
|
|
pbWait.setVisibility(View.GONE); |
|
|
|
Helper.setViewsEnabled(view, true); |
|
|
|
etRename.setEnabled(folder == null || EntityFolder.USER.equals(folder.type)); |
|
|
|
grpInterval.setVisibility(folder == null || EntityFolder.USER.equals(folder.type) ? View.VISIBLE : View.GONE); |
|
|
|
btnSave.setEnabled(true); |
|
|
|
ibDelete.setVisibility(folder == null || !EntityFolder.USER.equals(folder.type) ? View.GONE : View.VISIBLE); |
|
|
|
} |
|
|
|