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