From be4c807226d4ba105d770373180964be422c61ff Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 14 Aug 2022 15:12:20 +0200 Subject: [PATCH] Added POP3/recent Gmail/web --- .../java/eu/faircode/email/FragmentOAuth.java | 23 +++++++++++++++++++ app/src/main/res/layout/fragment_oauth.xml | 19 +++++++++++---- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentOAuth.java b/app/src/main/java/eu/faircode/email/FragmentOAuth.java index 66feab0edb..7c2d3f64d8 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOAuth.java +++ b/app/src/main/java/eu/faircode/email/FragmentOAuth.java @@ -45,6 +45,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.CheckBox; +import android.widget.CompoundButton; import android.widget.EditText; import android.widget.ScrollView; import android.widget.TextView; @@ -105,6 +106,7 @@ public class FragmentOAuth extends FragmentBase { private String personal; private String address; private boolean pop; + private boolean recent; private boolean update; private ViewGroup view; @@ -117,6 +119,7 @@ public class FragmentOAuth extends FragmentBase { private EditText etTenant; private CheckBox cbInboundOnly; private CheckBox cbPop; + private CheckBox cbRecent; private CheckBox cbUpdate; private Button btnOAuth; private ContentLoadingProgressBar pbOAuth; @@ -147,6 +150,7 @@ public class FragmentOAuth extends FragmentBase { personal = args.getString("personal"); address = args.getString("address"); pop = args.getBoolean("pop", false); + recent = args.getBoolean("recent", false); update = args.getBoolean("update", true); } @@ -167,6 +171,7 @@ public class FragmentOAuth extends FragmentBase { etTenant = view.findViewById(R.id.etTenant); cbInboundOnly = view.findViewById(R.id.cbInboundOnly); cbPop = view.findViewById(R.id.cbPop); + cbRecent = view.findViewById(R.id.cbRecent); cbUpdate = view.findViewById(R.id.cbUpdate); btnOAuth = view.findViewById(R.id.btnOAuth); pbOAuth = view.findViewById(R.id.pbOAuth); @@ -192,6 +197,13 @@ public class FragmentOAuth extends FragmentBase { } }); + cbPop.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean checked) { + cbRecent.setVisibility(checked && "gmail".equals(id) ? View.VISIBLE : View.GONE); + } + }); + if ("gmail".equals(id)) { // https://developers.google.com/identity/branding-guidelines final Context context = getContext(); @@ -251,6 +263,7 @@ public class FragmentOAuth extends FragmentBase { etEmail.setVisibility(askAccount ? View.VISIBLE : View.GONE); grpTenant.setVisibility(askTenant ? View.VISIBLE : View.GONE); cbPop.setVisibility(pop ? View.VISIBLE : View.GONE); + cbRecent.setVisibility(View.GONE); pbOAuth.setVisibility(View.GONE); tvConfiguring.setVisibility(View.GONE); tvGmailHint.setVisibility("gmail".equals(id) ? View.VISIBLE : View.GONE); @@ -261,6 +274,7 @@ public class FragmentOAuth extends FragmentBase { etTenant.setText(null); cbInboundOnly.setChecked(false); cbPop.setChecked(false); + cbRecent.setChecked(false); cbUpdate.setChecked(update); return view; @@ -317,6 +331,7 @@ public class FragmentOAuth extends FragmentBase { etTenant.setEnabled(false); cbInboundOnly.setEnabled(false); cbPop.setEnabled(false); + cbRecent.setEnabled(false); cbUpdate.setEnabled(false); btnOAuth.setEnabled(false); pbOAuth.setVisibility(View.VISIBLE); @@ -466,6 +481,7 @@ public class FragmentOAuth extends FragmentBase { etTenant.setEnabled(true); cbInboundOnly.setEnabled(true); cbPop.setEnabled(true); + cbRecent.setEnabled(true); cbUpdate.setEnabled(true); AuthorizationResponse auth = AuthorizationResponse.fromIntent(data); @@ -554,6 +570,7 @@ public class FragmentOAuth extends FragmentBase { args.putString("address", etEmail.getText().toString().trim()); args.putBoolean("inbound_only", cbInboundOnly.isChecked()); args.putBoolean("pop", cbPop.isChecked()); + args.putBoolean("recent", cbRecent.isChecked()); args.putBoolean("update", cbUpdate.isChecked()); new SimpleTask() { @@ -579,6 +596,7 @@ public class FragmentOAuth extends FragmentBase { String address = args.getString("address"); boolean inbound_only = args.getBoolean("inbound_only"); boolean pop = args.getBoolean("pop"); + boolean recent = args.getBoolean("recent"); EmailProvider provider = EmailProvider.getProvider(context, id); if (provider.pop == null) @@ -761,6 +779,9 @@ public class FragmentOAuth extends FragmentBase { if (ani == null || !ani.isConnected()) throw new IllegalArgumentException(context.getString(R.string.title_no_internet)); + if (pop && recent && "gmail".equals(id)) + username = "recent:" + username; + Log.i("OAuth username=" + username); for (Pair identity : identities) Log.i("OAuth identity=" + identity.first + "/" + identity.second); @@ -951,6 +972,7 @@ public class FragmentOAuth extends FragmentBase { etTenant.setEnabled(true); cbInboundOnly.setEnabled(true); cbPop.setEnabled(true); + cbRecent.setEnabled(true); cbUpdate.setEnabled(true); btnOAuth.setEnabled(true); pbOAuth.setVisibility(View.GONE); @@ -989,6 +1011,7 @@ public class FragmentOAuth extends FragmentBase { etTenant.setEnabled(true); cbInboundOnly.setEnabled(true); cbPop.setEnabled(true); + cbRecent.setEnabled(true); cbUpdate.setEnabled(true); btnOAuth.setEnabled(true); pbOAuth.setVisibility(View.GONE); diff --git a/app/src/main/res/layout/fragment_oauth.xml b/app/src/main/res/layout/fragment_oauth.xml index e70540e994..f37f0fa2ec 100644 --- a/app/src/main/res/layout/fragment_oauth.xml +++ b/app/src/main/res/layout/fragment_oauth.xml @@ -30,10 +30,10 @@ android:layout_marginTop="6dp" android:drawableEnd="@drawable/twotone_open_in_new_12" android:drawablePadding="6dp" - app:drawableTint="?android:attr/textColorLink" android:text="@string/title_privacy_policy" android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textColor="?android:attr/textColorLink" + app:drawableTint="?android:attr/textColorLink" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvTitle" /> @@ -110,6 +110,17 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/cbInboundOnly" /> + + + app:layout_constraintTop_toBottomOf="@id/cbRecent" />