mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-04 02:28:18 +00:00
Use radio button for SSL/STARTTLS
This commit is contained in:
parent
f6fde69b4a
commit
310fd98151
6 changed files with 76 additions and 36 deletions
|
@ -53,6 +53,7 @@ import android.widget.CheckBox;
|
|||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
@ -95,7 +96,7 @@ public class FragmentAccount extends FragmentBase {
|
|||
|
||||
private Button btnAuthorize;
|
||||
private EditText etHost;
|
||||
private CheckBox cbStartTls;
|
||||
private RadioGroup rgEncryption;
|
||||
private CheckBox cbInsecure;
|
||||
private EditText etPort;
|
||||
private EditText etUser;
|
||||
|
@ -173,7 +174,7 @@ public class FragmentAccount extends FragmentBase {
|
|||
btnAuthorize = view.findViewById(R.id.btnAuthorize);
|
||||
etHost = view.findViewById(R.id.etHost);
|
||||
etPort = view.findViewById(R.id.etPort);
|
||||
cbStartTls = view.findViewById(R.id.cbStartTls);
|
||||
rgEncryption = view.findViewById(R.id.rgEncryption);
|
||||
cbInsecure = view.findViewById(R.id.cbInsecure);
|
||||
etUser = view.findViewById(R.id.etUser);
|
||||
tilPassword = view.findViewById(R.id.tilPassword);
|
||||
|
@ -247,7 +248,7 @@ public class FragmentAccount extends FragmentBase {
|
|||
|
||||
etHost.setText(provider.imap_host);
|
||||
etPort.setText(provider.imap_host == null ? null : Integer.toString(provider.imap_port));
|
||||
cbStartTls.setChecked(provider.imap_starttls);
|
||||
rgEncryption.check(provider.imap_starttls ? R.id.radio_starttls : R.id.radio_ssl);
|
||||
|
||||
etUser.setTag(null);
|
||||
etUser.setText(null);
|
||||
|
@ -290,10 +291,10 @@ public class FragmentAccount extends FragmentBase {
|
|||
}
|
||||
});
|
||||
|
||||
cbStartTls.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
rgEncryption.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
etPort.setHint(checked ? "143" : "993");
|
||||
public void onCheckedChanged(RadioGroup group, int id) {
|
||||
etPort.setHint(id == R.id.radio_starttls ? "143" : "993");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -433,7 +434,7 @@ public class FragmentAccount extends FragmentBase {
|
|||
btnAutoConfig.setEnabled(false);
|
||||
|
||||
btnAuthorize.setVisibility(View.GONE);
|
||||
cbStartTls.setVisibility(View.GONE);
|
||||
rgEncryption.setVisibility(View.GONE);
|
||||
cbInsecure.setVisibility(View.GONE);
|
||||
tilPassword.setPasswordVisibilityToggleEnabled(id < 0);
|
||||
|
||||
|
@ -485,7 +486,7 @@ public class FragmentAccount extends FragmentBase {
|
|||
protected void onExecuted(Bundle args, EmailProvider provider) {
|
||||
etHost.setText(provider.imap_host);
|
||||
etPort.setText(Integer.toString(provider.imap_port));
|
||||
cbStartTls.setChecked(provider.imap_starttls);
|
||||
rgEncryption.check(provider.imap_starttls ? R.id.radio_starttls : R.id.radio_ssl);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -503,7 +504,7 @@ public class FragmentAccount extends FragmentBase {
|
|||
args.putLong("id", id);
|
||||
args.putInt("auth_type", auth_type);
|
||||
args.putString("host", etHost.getText().toString());
|
||||
args.putBoolean("starttls", cbStartTls.isChecked());
|
||||
args.putBoolean("starttls", rgEncryption.getCheckedRadioButtonId() == R.id.radio_starttls);
|
||||
args.putBoolean("insecure", cbInsecure.isChecked());
|
||||
args.putString("port", etPort.getText().toString());
|
||||
args.putString("user", etUser.getText().toString());
|
||||
|
@ -741,7 +742,7 @@ public class FragmentAccount extends FragmentBase {
|
|||
|
||||
args.putInt("auth_type", auth_type);
|
||||
args.putString("host", etHost.getText().toString());
|
||||
args.putBoolean("starttls", cbStartTls.isChecked());
|
||||
args.putBoolean("starttls", rgEncryption.getCheckedRadioButtonId() == R.id.radio_starttls);
|
||||
args.putBoolean("insecure", cbInsecure.isChecked());
|
||||
args.putString("port", etPort.getText().toString());
|
||||
args.putString("user", etUser.getText().toString());
|
||||
|
@ -1130,7 +1131,7 @@ public class FragmentAccount extends FragmentBase {
|
|||
etPort.setText(Long.toString(account.port));
|
||||
}
|
||||
|
||||
cbStartTls.setChecked(account == null ? false : account.starttls);
|
||||
rgEncryption.check(account != null && account.starttls ? R.id.radio_starttls : R.id.radio_ssl);
|
||||
cbInsecure.setChecked(account == null ? false : account.insecure);
|
||||
|
||||
etUser.setTag(account == null || auth_type == Helper.AUTH_TYPE_PASSWORD ? null : account.user);
|
||||
|
|
|
@ -43,6 +43,7 @@ import android.widget.CheckBox;
|
|||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
@ -90,7 +91,7 @@ public class FragmentIdentity extends FragmentBase {
|
|||
private EditText etDomain;
|
||||
private Button btnAutoConfig;
|
||||
private EditText etHost;
|
||||
private CheckBox cbStartTls;
|
||||
private RadioGroup rgEncryption;
|
||||
private CheckBox cbInsecure;
|
||||
private EditText etPort;
|
||||
private EditText etUser;
|
||||
|
@ -159,7 +160,7 @@ public class FragmentIdentity extends FragmentBase {
|
|||
btnAutoConfig = view.findViewById(R.id.btnAutoConfig);
|
||||
|
||||
etHost = view.findViewById(R.id.etHost);
|
||||
cbStartTls = view.findViewById(R.id.cbStartTls);
|
||||
rgEncryption = view.findViewById(R.id.rgEncryption);
|
||||
cbInsecure = view.findViewById(R.id.cbInsecure);
|
||||
etPort = view.findViewById(R.id.etPort);
|
||||
etUser = view.findViewById(R.id.etUser);
|
||||
|
@ -224,7 +225,7 @@ public class FragmentIdentity extends FragmentBase {
|
|||
// This is needed because the spinner might be invisible
|
||||
etHost.setText(provider.smtp_host);
|
||||
etPort.setText(Integer.toString(provider.smtp_port));
|
||||
cbStartTls.setChecked(provider.smtp_starttls);
|
||||
rgEncryption.check(provider.smtp_starttls ? R.id.radio_starttls : R.id.radio_ssl);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -347,7 +348,7 @@ public class FragmentIdentity extends FragmentBase {
|
|||
// Set associated host/port/starttls
|
||||
etHost.setText(provider.smtp_host);
|
||||
etPort.setText(position == 0 ? null : Integer.toString(provider.smtp_port));
|
||||
cbStartTls.setChecked(provider.smtp_starttls);
|
||||
rgEncryption.check(provider.smtp_starttls ? R.id.radio_starttls : R.id.radio_ssl);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -377,10 +378,10 @@ public class FragmentIdentity extends FragmentBase {
|
|||
}
|
||||
});
|
||||
|
||||
cbStartTls.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
rgEncryption.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
etPort.setHint(checked ? "587" : "465");
|
||||
public void onCheckedChanged(RadioGroup group, int id) {
|
||||
etPort.setHint(id == R.id.radio_starttls ? "587" : "465");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -446,7 +447,7 @@ public class FragmentIdentity extends FragmentBase {
|
|||
protected void onExecuted(Bundle args, EmailProvider provider) {
|
||||
etHost.setText(provider.smtp_host);
|
||||
etPort.setText(Integer.toString(provider.smtp_port));
|
||||
cbStartTls.setChecked(provider.smtp_starttls);
|
||||
rgEncryption.check(provider.smtp_starttls ? R.id.radio_starttls : R.id.radio_ssl);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -484,7 +485,7 @@ public class FragmentIdentity extends FragmentBase {
|
|||
args.putLong("account", account == null ? -1 : account.id);
|
||||
args.putInt("auth_type", auth_type);
|
||||
args.putString("host", etHost.getText().toString());
|
||||
args.putBoolean("starttls", cbStartTls.isChecked());
|
||||
args.putBoolean("starttls", rgEncryption.getCheckedRadioButtonId() == R.id.radio_starttls);
|
||||
args.putBoolean("insecure", cbInsecure.isChecked());
|
||||
args.putString("port", etPort.getText().toString());
|
||||
args.putString("user", etUser.getText().toString());
|
||||
|
@ -754,7 +755,7 @@ public class FragmentIdentity extends FragmentBase {
|
|||
TextUtils.isEmpty(identity.signature) ? null : HtmlHelper.fromHtml(identity.signature));
|
||||
|
||||
etHost.setText(identity == null ? null : identity.host);
|
||||
cbStartTls.setChecked(identity == null ? false : identity.starttls);
|
||||
rgEncryption.check(identity != null && identity.starttls ? R.id.radio_starttls : R.id.radio_ssl);
|
||||
cbInsecure.setChecked(identity == null ? false : identity.insecure);
|
||||
etPort.setText(identity == null ? null : Long.toString(identity.port));
|
||||
etUser.setTag(identity == null || auth_type == Helper.AUTH_TYPE_PASSWORD ? null : identity.user);
|
||||
|
|
|
@ -121,14 +121,30 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvHost" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbStartTls"
|
||||
android:layout_width="wrap_content"
|
||||
<!-- SSL/STARTTLS -->
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/rgEncryption"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_starttls"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/etHost" />
|
||||
app:layout_constraintTop_toBottomOf="@id/etHost">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/radio_ssl"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/title_ssl" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/radio_starttls"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:text="@string/title_starttls" />
|
||||
</RadioGroup>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbInsecure"
|
||||
|
@ -137,7 +153,7 @@
|
|||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_allow_insecure"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbStartTls" />
|
||||
app:layout_constraintTop_toBottomOf="@id/rgEncryption" />
|
||||
|
||||
<!-- port -->
|
||||
|
||||
|
@ -697,7 +713,7 @@
|
|||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="
|
||||
tvDomain,tvDomainHint,etDomain,btnAutoConfig,
|
||||
tvImap,tvPopSupport,tvHost,etHost,cbStartTls,cbInsecure,tvPort,etPort" />
|
||||
tvImap,tvPopSupport,tvHost,etHost,rgEncryption,cbInsecure,tvPort,etPort" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpAuthorize"
|
||||
|
|
|
@ -274,16 +274,30 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvHost" />
|
||||
|
||||
<!-- STARTTLS -->
|
||||
<!-- SSL/STARTTLS -->
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbStartTls"
|
||||
android:layout_width="wrap_content"
|
||||
<RadioGroup
|
||||
android:id="@+id/rgEncryption"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_starttls"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/etHost" />
|
||||
app:layout_constraintTop_toBottomOf="@id/etHost">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/radio_ssl"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/title_ssl" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/radio_starttls"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:text="@string/title_starttls" />
|
||||
</RadioGroup>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbInsecure"
|
||||
|
@ -292,7 +306,7 @@
|
|||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_allow_insecure"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbStartTls" />
|
||||
app:layout_constraintTop_toBottomOf="@id/rgEncryption" />
|
||||
|
||||
<!-- port -->
|
||||
|
||||
|
@ -594,7 +608,7 @@
|
|||
app:constraint_referenced_ids="
|
||||
tvProvider,spProvider,
|
||||
tvDomain,tvDomainHint,etDomain,btnAutoConfig,
|
||||
tvSmtp,tvHost,etHost,cbStartTls,cbInsecure,tvPort,etPort,
|
||||
tvSmtp,tvHost,etHost,rgEncryption,cbInsecure,tvPort,etPort,
|
||||
tvUser,etUser,tvPassword,tilPassword,
|
||||
tvRealm,etRealm,
|
||||
cbUseIp,tvUseIpHint,
|
||||
|
|
|
@ -234,6 +234,7 @@
|
|||
<string name="title_provider">Provider</string>
|
||||
<string name="title_custom">Custom</string>
|
||||
<string name="title_host">Host name</string>
|
||||
<string name="title_ssl" translatable="false">SSL</string>
|
||||
<string name="title_starttls" translatable="false">STARTTLS</string>
|
||||
<string name="title_allow_insecure">Allow insecure connections</string>
|
||||
<string name="title_port">Port number</string>
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
<item name="android:buttonStyle">@style/buttonStyle</item>
|
||||
<item name="android:buttonStyleSmall">@style/buttonStyleSmall</item>
|
||||
<item name="android:buttonStyleToggle">@style/buttonStyleToggle</item>
|
||||
<item name="android:radioButtonStyle">@style/radioButtonStyle</item>
|
||||
</style>
|
||||
|
||||
<style name="AppThemeDark" parent="Base.Theme.AppCompat">
|
||||
|
@ -49,6 +50,7 @@
|
|||
<item name="android:buttonStyle">@style/buttonStyle</item>
|
||||
<item name="android:buttonStyleSmall">@style/buttonStyleSmall</item>
|
||||
<item name="android:buttonStyleToggle">@style/buttonStyleToggle</item>
|
||||
<item name="android:radioButtonStyle">@style/radioButtonStyle</item>
|
||||
</style>
|
||||
|
||||
<style name="AppThemeBlack" parent="AppThemeDark">
|
||||
|
@ -89,4 +91,9 @@
|
|||
<style name="buttonStyleToggle" parent="Base.Widget.AppCompat.Button">
|
||||
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Medium</item>
|
||||
</style>
|
||||
|
||||
<style name="radioButtonStyle" parent="Base.Widget.AppCompat.CompoundButton.RadioButton">
|
||||
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Small</item>
|
||||
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Reference in a new issue