Added button to go to Android sync settings

This commit is contained in:
M66B 2020-11-02 20:32:03 +01:00
parent 7809d4a4cd
commit 32570c1453
2 changed files with 33 additions and 5 deletions

View File

@ -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());

View File

@ -224,14 +224,26 @@
<eu.faircode.email.FixedTextView
android:id="@+id/tvUser"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:labelFor="@+id/etUser"
android:text="@string/title_user"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etPort" />
app:layout_constraintBottom_toBottomOf="@id/ibAccount"
app:layout_constraintEnd_toStartOf="@+id/ibAccount"
app:layout_constraintStart_toStartOf="parent" />
<ImageButton
android:id="@+id/ibAccount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:paddingEnd="12dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/etPort"
app:srcCompat="@drawable/twotone_account_box_24" />
<eu.faircode.email.EditTextPlain
android:id="@+id/etUser"
@ -241,7 +253,7 @@
android:inputType="text"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvUser" />
app:layout_constraintTop_toBottomOf="@id/ibAccount" />
<!-- password -->
@ -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" />