Primary depends on synchronize

pull/12/merge
M66B 6 years ago
parent 2e33cc65e0
commit 3313e944ed

@ -37,6 +37,7 @@ import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Spinner;
@ -63,8 +64,8 @@ public class FragmentAccount extends FragmentEx {
private EditText etPort;
private EditText etUser;
private TextInputLayout tilPassword;
private CheckBox cbPrimary;
private CheckBox cbSynchronize;
private CheckBox cbPrimary;
private Button btnOk;
private ProgressBar pbCheck;
// TODO: loading spinner
@ -99,8 +100,8 @@ public class FragmentAccount extends FragmentEx {
etPort = view.findViewById(R.id.etPort);
etUser = view.findViewById(R.id.etUser);
tilPassword = view.findViewById(R.id.tilPassword);
cbPrimary = view.findViewById(R.id.cbPrimary);
cbSynchronize = view.findViewById(R.id.cbSynchronize);
cbPrimary = view.findViewById(R.id.cbPrimary);
btnOk = view.findViewById(R.id.btnOk);
pbCheck = view.findViewById(R.id.pbCheck);
@ -128,6 +129,13 @@ public class FragmentAccount extends FragmentEx {
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() {
@Override
public void onClick(View v) {
@ -141,8 +149,8 @@ public class FragmentAccount extends FragmentEx {
args.putString("port", etPort.getText().toString());
args.putString("user", etUser.getText().toString());
args.putString("password", tilPassword.getEditText().getText().toString());
args.putBoolean("primary", cbPrimary.isChecked());
args.putBoolean("synchronize", cbSynchronize.isChecked());
args.putBoolean("primary", cbPrimary.isChecked());
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));
etUser.setText(account == null ? null : account.user);
tilPassword.getEditText().setText(account == null ? null : account.password);
cbPrimary.setChecked(account == null ? true : account.primary);
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.user = user;
account.password = Objects.requireNonNull(args.getString("password"));
account.primary = args.getBoolean("primary");
account.synchronize = args.getBoolean("synchronize");
account.primary = (account.synchronize && args.getBoolean("primary"));
// Check IMAP server
List<EntityFolder> folders = new ArrayList<>();

@ -64,8 +64,8 @@ public class FragmentIdentity extends FragmentEx {
private EditText etPort;
private EditText etUser;
private TextInputLayout tilPassword;
private CheckBox cbPrimary;
private CheckBox cbSynchronize;
private CheckBox cbPrimary;
private Button btnOk;
private ProgressBar pbCheck;
// TODO: loading spinner
@ -95,8 +95,8 @@ public class FragmentIdentity extends FragmentEx {
etPort = view.findViewById(R.id.etPort);
etUser = view.findViewById(R.id.etUser);
tilPassword = view.findViewById(R.id.tilPassword);
cbPrimary = view.findViewById(R.id.cbPrimary);
cbSynchronize = view.findViewById(R.id.cbSynchronize);
cbPrimary = view.findViewById(R.id.cbPrimary);
btnOk = view.findViewById(R.id.btnOk);
pbCheck = view.findViewById(R.id.pbCheck);
@ -146,6 +146,13 @@ public class FragmentIdentity extends FragmentEx {
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() {
@Override
public void onClick(View v) {
@ -162,8 +169,8 @@ public class FragmentIdentity extends FragmentEx {
args.putString("port", etPort.getText().toString());
args.putString("user", etUser.getText().toString());
args.putString("password", tilPassword.getEditText().getText().toString());
args.putBoolean("primary", cbPrimary.isChecked());
args.putBoolean("synchronize", cbSynchronize.isChecked());
args.putBoolean("primary", cbPrimary.isChecked());
getLoaderManager().restartLoader(ActivityView.LOADER_IDENTITY_PUT, args, putLoaderCallbacks).forceLoad();
}
@ -180,8 +187,9 @@ public class FragmentIdentity extends FragmentEx {
etPort.setText(identity == null ? null : Long.toString(identity.port));
etUser.setText(identity == null ? null : identity.user);
tilPassword.getEditText().setText(identity == null ? null : identity.password);
cbPrimary.setChecked(identity == null ? true : identity.primary);
cbSynchronize.setChecked(identity == null ? true : identity.synchronize);
cbPrimary.setChecked(identity == null ? true : identity.primary);
cbPrimary.setEnabled(identity == null ? true : identity.synchronize);
}
});
@ -226,8 +234,8 @@ public class FragmentIdentity extends FragmentEx {
identity.starttls = starttls;
identity.user = Objects.requireNonNull(args.getString("user"));
identity.password = Objects.requireNonNull(args.getString("password"));
identity.primary = args.getBoolean("primary");
identity.synchronize = args.getBoolean("synchronize");
identity.primary = (identity.synchronize && args.getBoolean("primary"));
if (TextUtils.isEmpty(identity.name))
throw new IllegalArgumentException(getContext().getString(R.string.title_no_name));

@ -159,22 +159,22 @@
</android.support.design.widget.TextInputLayout>
<CheckBox
android:id="@+id/cbPrimary"
android:id="@+id/cbSynchronize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_primary_account"
android:text="@string/title_synchronize_account"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tilPassword" />
<CheckBox
android:id="@+id/cbSynchronize"
android:id="@+id/cbPrimary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_synchronize_account"
android:text="@string/title_primary_account"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbPrimary" />
app:layout_constraintTop_toBottomOf="@id/cbSynchronize" />
<Button
android:id="@+id/btnOk"
@ -183,7 +183,7 @@
android:layout_marginTop="12dp"
android:text="@android:string/ok"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbSynchronize" />
app:layout_constraintTop_toBottomOf="@id/cbPrimary" />
<ProgressBar
android:id="@+id/pbCheck"

@ -211,22 +211,22 @@
</android.support.design.widget.TextInputLayout>
<CheckBox
android:id="@+id/cbPrimary"
android:id="@+id/cbSynchronize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_primary_identity"
android:text="@string/title_synchronize_identity"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tilPassword" />
<CheckBox
android:id="@+id/cbSynchronize"
android:id="@+id/cbPrimary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_synchronize_identity"
android:text="@string/title_primary_identity"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbPrimary" />
app:layout_constraintTop_toBottomOf="@id/cbSynchronize" />
<Button
android:id="@+id/btnOk"
@ -235,7 +235,7 @@
android:layout_marginTop="12dp"
android:text="@android:string/ok"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbSynchronize" />
app:layout_constraintTop_toBottomOf="@id/cbPrimary" />
<ProgressBar
android:id="@+id/pbCheck"

Loading…
Cancel
Save