From d0dd9e677dff3658b2065f06959d0678d714c35b Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 6 Aug 2020 22:22:47 +0200 Subject: [PATCH] OAuth configuring --- .../java/eu/faircode/email/FragmentOAuth.java | 22 +++++++++++-------- app/src/main/res/layout/fragment_oauth.xml | 16 +++++--------- app/src/main/res/values/strings.xml | 1 + 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentOAuth.java b/app/src/main/java/eu/faircode/email/FragmentOAuth.java index a0a21be696..f4736219aa 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOAuth.java +++ b/app/src/main/java/eu/faircode/email/FragmentOAuth.java @@ -92,7 +92,7 @@ public class FragmentOAuth extends FragmentBase { private EditText etEmail; private Button btnOAuth; private ContentLoadingProgressBar pbOAuth; - private TextView tvAuthorized; + private TextView tvConfiguring; private TextView tvGmailHint; private TextView tvError; @@ -102,8 +102,6 @@ public class FragmentOAuth extends FragmentBase { private Group grpError; - private static final int OAUTH_TIMEOUT = 20 * 1000; // milliseconds - @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -129,7 +127,7 @@ public class FragmentOAuth extends FragmentBase { etEmail = view.findViewById(R.id.etEmail); btnOAuth = view.findViewById(R.id.btnOAuth); pbOAuth = view.findViewById(R.id.pbOAuth); - tvAuthorized = view.findViewById(R.id.tvAuthorized); + tvConfiguring = view.findViewById(R.id.tvConfiguring); tvGmailHint = view.findViewById(R.id.tvGmailHint); tvError = view.findViewById(R.id.tvError); @@ -160,7 +158,7 @@ public class FragmentOAuth extends FragmentBase { etName.setVisibility(askAccount ? View.VISIBLE : View.GONE); etEmail.setVisibility(askAccount ? View.VISIBLE : View.GONE); pbOAuth.setVisibility(View.GONE); - tvAuthorized.setVisibility(View.GONE); + tvConfiguring.setVisibility(View.GONE); tvGmailHint.setVisibility("gmail".equals(id) ? View.VISIBLE : View.GONE); hideError(); @@ -318,8 +316,6 @@ public class FragmentOAuth extends FragmentBase { if (auth == null) throw AuthorizationException.fromIntent(data); - tvAuthorized.setVisibility(View.VISIBLE); - final EmailProvider provider = EmailProvider.getProvider(getContext(), auth.state); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); @@ -384,6 +380,16 @@ public class FragmentOAuth extends FragmentBase { args.putString("address", etEmail.getText().toString().trim()); new SimpleTask() { + @Override + protected void onPreExecute(Bundle args) { + tvConfiguring.setVisibility(View.VISIBLE); + } + + @Override + protected void onPostExecute(Bundle args) { + tvConfiguring.setVisibility(View.GONE); + } + @Override protected Void onExecute(Context context, Bundle args) throws Throwable { String id = args.getString("id"); @@ -613,8 +619,6 @@ public class FragmentOAuth extends FragmentBase { private void showError(Throwable ex) { Log.e(ex); - pbOAuth.setVisibility(View.GONE); - if (ex instanceof IllegalArgumentException) tvError.setText(ex.getMessage()); else diff --git a/app/src/main/res/layout/fragment_oauth.xml b/app/src/main/res/layout/fragment_oauth.xml index e2b7ade3a1..88124048da 100644 --- a/app/src/main/res/layout/fragment_oauth.xml +++ b/app/src/main/res/layout/fragment_oauth.xml @@ -74,18 +74,14 @@ app:layout_constraintTop_toTopOf="@id/btnOAuth" /> + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/btnOAuth" /> + app:layout_constraintTop_toBottomOf="@id/tvConfiguring" /> Done Still to do Error + Configuring account … Export settings Import settings