From 32570c1453c5c4224c0087e59aacfb7a51efd6a4 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 2 Nov 2020 20:32:03 +0100 Subject: [PATCH] Added button to go to Android sync settings --- .../eu/faircode/email/FragmentAccount.java | 16 ++++++++++++++ app/src/main/res/layout/fragment_account.xml | 22 ++++++++++++++----- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentAccount.java b/app/src/main/java/eu/faircode/email/FragmentAccount.java index 62fb3406d0..18fe897a40 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAccount.java +++ b/app/src/main/java/eu/faircode/email/FragmentAccount.java @@ -26,6 +26,7 @@ import android.graphics.Color; import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.provider.Settings; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; @@ -43,6 +44,7 @@ import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.EditText; +import android.widget.ImageButton; import android.widget.RadioGroup; import android.widget.ScrollView; import android.widget.Spinner; @@ -71,6 +73,7 @@ import javax.mail.Folder; import static android.app.Activity.RESULT_OK; import static com.google.android.material.textfield.TextInputLayout.END_ICON_NONE; import static com.google.android.material.textfield.TextInputLayout.END_ICON_PASSWORD_TOGGLE; +import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_GMAIL; import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_OAUTH; import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_PASSWORD; @@ -89,6 +92,7 @@ public class FragmentAccount extends FragmentBase { private RadioGroup rgEncryption; private CheckBox cbInsecure; private EditText etPort; + private ImageButton ibAccount; private EditText etUser; private TextInputLayout tilPassword; private TextView tvCharacters; @@ -193,6 +197,7 @@ public class FragmentAccount extends FragmentBase { etPort = view.findViewById(R.id.etPort); rgEncryption = view.findViewById(R.id.rgEncryption); cbInsecure = view.findViewById(R.id.cbInsecure); + ibAccount = view.findViewById(R.id.ibAccount); etUser = view.findViewById(R.id.etUser); tilPassword = view.findViewById(R.id.tilPassword); tvCharacters = view.findViewById(R.id.tvCharacters); @@ -316,6 +321,16 @@ public class FragmentAccount extends FragmentBase { } }); + ibAccount.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent sync = new Intent(Settings.ACTION_SYNC_SETTINGS) + .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + if (sync.resolveActivity(v.getContext().getPackageManager()) != null) + v.getContext().startActivity(sync); + } + }); + tilPassword.getEditText().addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { @@ -1494,6 +1509,7 @@ public class FragmentAccount extends FragmentBase { tilPassword.setEnabled(false); btnCertificate.setEnabled(false); } + ibAccount.setEnabled(auth == AUTH_TYPE_GMAIL); cbOnDemand.setEnabled(cbSynchronize.isChecked()); cbPrimary.setEnabled(cbSynchronize.isChecked()); diff --git a/app/src/main/res/layout/fragment_account.xml b/app/src/main/res/layout/fragment_account.xml index 37ffc64091..c4cfdd12c5 100644 --- a/app/src/main/res/layout/fragment_account.xml +++ b/app/src/main/res/layout/fragment_account.xml @@ -224,14 +224,26 @@ + app:layout_constraintBottom_toBottomOf="@id/ibAccount" + app:layout_constraintEnd_toStartOf="@+id/ibAccount" + app:layout_constraintStart_toStartOf="parent" /> + + + app:layout_constraintTop_toBottomOf="@id/ibAccount" /> @@ -978,7 +990,7 @@ android:layout_width="0dp" android:layout_height="0dp" app:constraint_referenced_ids=" - tvUser,etUser,tvPassword,tilPassword,tvCaseSensitive,btnCertificate,tvCertificate,tvRealm,etRealm, + tvUser,ibAccount,etUser,tvPassword,tilPassword,tvCaseSensitive,btnCertificate,tvCertificate,tvRealm,etRealm, tvName,tvNameRemark,etName, tvColor,btnColor,tvColorHint,tvColorPro" />