Added POP3/recent Gmail/web

This commit is contained in:
M66B 2022-08-14 15:12:20 +02:00
parent e24dc6bc6b
commit be4c807226
2 changed files with 38 additions and 4 deletions

View File

@ -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<Void>() {
@ -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<String, String> 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);

View File

@ -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" />
<CheckBox
android:id="@+id/cbRecent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_setup_recent"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbPop" />
<CheckBox
android:id="@+id/cbUpdate"
android:layout_width="wrap_content"
@ -118,7 +129,7 @@
android:text="@string/title_setup_oauth_update"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbPop" />
app:layout_constraintTop_toBottomOf="@id/cbRecent" />
<Button
android:id="@+id/btnOAuth"
@ -206,10 +217,10 @@
android:backgroundTint="?attr/colorInfoBackground"
android:drawableEnd="@drawable/twotone_support_24"
android:drawablePadding="6dp"
app:drawableTint="?attr/colorInfoForeground"
android:text="@string/menu_faq"
android:textColor="?attr/colorInfoForeground"
android:textStyle="bold"
app:drawableTint="?attr/colorInfoForeground"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOfficeAuthHint" />
@ -221,10 +232,10 @@
android:backgroundTint="?attr/colorInfoBackground"
android:drawableEnd="@drawable/twotone_help_24"
android:drawablePadding="6dp"
app:drawableTint="?attr/colorInfoForeground"
android:text="@string/title_setup_help"
android:textColor="?attr/colorInfoForeground"
android:textStyle="bold"
app:drawableTint="?attr/colorInfoForeground"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOfficeAuthHint" />