|
@ -37,6 +37,7 @@ import android.widget.AdapterView; |
|
|
import android.widget.ArrayAdapter; |
|
|
import android.widget.ArrayAdapter; |
|
|
import android.widget.Button; |
|
|
import android.widget.Button; |
|
|
import android.widget.CheckBox; |
|
|
import android.widget.CheckBox; |
|
|
|
|
|
import android.widget.CompoundButton; |
|
|
import android.widget.EditText; |
|
|
import android.widget.EditText; |
|
|
import android.widget.ProgressBar; |
|
|
import android.widget.ProgressBar; |
|
|
import android.widget.Spinner; |
|
|
import android.widget.Spinner; |
|
@ -63,8 +64,8 @@ public class FragmentAccount extends FragmentEx { |
|
|
private EditText etPort; |
|
|
private EditText etPort; |
|
|
private EditText etUser; |
|
|
private EditText etUser; |
|
|
private TextInputLayout tilPassword; |
|
|
private TextInputLayout tilPassword; |
|
|
private CheckBox cbPrimary; |
|
|
|
|
|
private CheckBox cbSynchronize; |
|
|
private CheckBox cbSynchronize; |
|
|
|
|
|
private CheckBox cbPrimary; |
|
|
private Button btnOk; |
|
|
private Button btnOk; |
|
|
private ProgressBar pbCheck; |
|
|
private ProgressBar pbCheck; |
|
|
// TODO: loading spinner |
|
|
// TODO: loading spinner |
|
@ -99,8 +100,8 @@ public class FragmentAccount extends FragmentEx { |
|
|
etPort = view.findViewById(R.id.etPort); |
|
|
etPort = view.findViewById(R.id.etPort); |
|
|
etUser = view.findViewById(R.id.etUser); |
|
|
etUser = view.findViewById(R.id.etUser); |
|
|
tilPassword = view.findViewById(R.id.tilPassword); |
|
|
tilPassword = view.findViewById(R.id.tilPassword); |
|
|
cbPrimary = view.findViewById(R.id.cbPrimary); |
|
|
|
|
|
cbSynchronize = view.findViewById(R.id.cbSynchronize); |
|
|
cbSynchronize = view.findViewById(R.id.cbSynchronize); |
|
|
|
|
|
cbPrimary = view.findViewById(R.id.cbPrimary); |
|
|
btnOk = view.findViewById(R.id.btnOk); |
|
|
btnOk = view.findViewById(R.id.btnOk); |
|
|
pbCheck = view.findViewById(R.id.pbCheck); |
|
|
pbCheck = view.findViewById(R.id.pbCheck); |
|
|
|
|
|
|
|
@ -128,6 +129,13 @@ public class FragmentAccount extends FragmentEx { |
|
|
|
|
|
|
|
|
pbCheck.setVisibility(View.GONE); |
|
|
pbCheck.setVisibility(View.GONE); |
|
|
|
|
|
|
|
|
|
|
|
cbSynchronize.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { |
|
|
|
|
|
cbPrimary.setEnabled(checked); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
btnOk.setOnClickListener(new View.OnClickListener() { |
|
|
btnOk.setOnClickListener(new View.OnClickListener() { |
|
|
@Override |
|
|
@Override |
|
|
public void onClick(View v) { |
|
|
public void onClick(View v) { |
|
@ -141,8 +149,8 @@ public class FragmentAccount extends FragmentEx { |
|
|
args.putString("port", etPort.getText().toString()); |
|
|
args.putString("port", etPort.getText().toString()); |
|
|
args.putString("user", etUser.getText().toString()); |
|
|
args.putString("user", etUser.getText().toString()); |
|
|
args.putString("password", tilPassword.getEditText().getText().toString()); |
|
|
args.putString("password", tilPassword.getEditText().getText().toString()); |
|
|
args.putBoolean("primary", cbPrimary.isChecked()); |
|
|
|
|
|
args.putBoolean("synchronize", cbSynchronize.isChecked()); |
|
|
args.putBoolean("synchronize", cbSynchronize.isChecked()); |
|
|
|
|
|
args.putBoolean("primary", cbPrimary.isChecked()); |
|
|
|
|
|
|
|
|
getLoaderManager().restartLoader(ActivityView.LOADER_ACCOUNT_PUT, args, putLoaderCallbacks).forceLoad(); |
|
|
getLoaderManager().restartLoader(ActivityView.LOADER_ACCOUNT_PUT, args, putLoaderCallbacks).forceLoad(); |
|
|
} |
|
|
} |
|
@ -156,8 +164,9 @@ public class FragmentAccount extends FragmentEx { |
|
|
etPort.setText(account == null ? null : Long.toString(account.port)); |
|
|
etPort.setText(account == null ? null : Long.toString(account.port)); |
|
|
etUser.setText(account == null ? null : account.user); |
|
|
etUser.setText(account == null ? null : account.user); |
|
|
tilPassword.getEditText().setText(account == null ? null : account.password); |
|
|
tilPassword.getEditText().setText(account == null ? null : account.password); |
|
|
cbPrimary.setChecked(account == null ? true : account.primary); |
|
|
|
|
|
cbSynchronize.setChecked(account == null ? true : account.synchronize); |
|
|
cbSynchronize.setChecked(account == null ? true : account.synchronize); |
|
|
|
|
|
cbPrimary.setChecked(account == null ? true : account.primary); |
|
|
|
|
|
cbPrimary.setEnabled(account == null ? true : account.synchronize); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -198,8 +207,8 @@ public class FragmentAccount extends FragmentEx { |
|
|
account.port = Integer.parseInt(port); |
|
|
account.port = Integer.parseInt(port); |
|
|
account.user = user; |
|
|
account.user = user; |
|
|
account.password = Objects.requireNonNull(args.getString("password")); |
|
|
account.password = Objects.requireNonNull(args.getString("password")); |
|
|
account.primary = args.getBoolean("primary"); |
|
|
|
|
|
account.synchronize = args.getBoolean("synchronize"); |
|
|
account.synchronize = args.getBoolean("synchronize"); |
|
|
|
|
|
account.primary = (account.synchronize && args.getBoolean("primary")); |
|
|
|
|
|
|
|
|
// Check IMAP server |
|
|
// Check IMAP server |
|
|
List<EntityFolder> folders = new ArrayList<>(); |
|
|
List<EntityFolder> folders = new ArrayList<>(); |
|
|