diff --git a/app/src/main/java/eu/faircode/email/CloudSync.java b/app/src/main/java/eu/faircode/email/CloudSync.java
index cdc91eac47..b4877266bb 100644
--- a/app/src/main/java/eu/faircode/email/CloudSync.java
+++ b/app/src/main/java/eu/faircode/email/CloudSync.java
@@ -21,6 +21,7 @@ package eu.faircode.email;
import android.content.Context;
import android.content.SharedPreferences;
+import android.os.OperationCanceledException;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Pair;
@@ -652,6 +653,8 @@ public class CloudSync {
JSONObject jerror = new JSONObject(detail);
if (status == HttpsURLConnection.HTTP_FORBIDDEN)
throw new SecurityException(jerror.optString("error"));
+ else if (status == HttpsURLConnection.HTTP_PAYMENT_REQUIRED)
+ throw new OperationCanceledException(jerror.optString("error"));
else
throw new IOException(error + " " + jerror);
}
diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsBackup.java b/app/src/main/java/eu/faircode/email/FragmentOptionsBackup.java
index 0d076f0fd2..348172a424 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptionsBackup.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptionsBackup.java
@@ -37,6 +37,7 @@ import android.graphics.Typeface;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
+import android.os.OperationCanceledException;
import android.text.Editable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
@@ -119,6 +120,7 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
private TextInputLayout tilPassword;
private Button btnLogin;
private TextView tvLogin;
+ private Button btnActivate;
private CheckBox cbSend;
private CheckBox cbReceive;
private ImageButton ibSync;
@@ -161,6 +163,7 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
tilPassword = view.findViewById(R.id.tilPassword);
btnLogin = view.findViewById(R.id.btnLogin);
tvLogin = view.findViewById(R.id.tvLogin);
+ btnActivate = view.findViewById(R.id.btnActivate);
cbSend = view.findViewById(R.id.cbSend);
cbReceive = view.findViewById(R.id.cbReceive);
ibSync = view.findViewById(R.id.ibSync);
@@ -209,6 +212,13 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
}
});
+ btnActivate.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ // TODO
+ }
+ });
+
ibSync.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -246,6 +256,7 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
!TextUtils.isEmpty(BuildConfig.CLOUD_URI)
? View.VISIBLE : View.GONE);
Helper.linkPro(tvCloudPro);
+ btnActivate.setVisibility(View.GONE);
cbSend.setChecked(prefs.getBoolean("cloud_send", true));
cbReceive.setChecked(prefs.getBoolean("cloud_receive", false));
@@ -1555,6 +1566,7 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
@Override
protected void onExecuted(Bundle args, Void data) {
+ btnActivate.setVisibility(View.GONE);
view.post(new Runnable() {
@Override
public void run() {
@@ -1565,6 +1577,7 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
@Override
protected void onException(Bundle args, Throwable ex) {
+ btnActivate.setVisibility(ex instanceof OperationCanceledException ? View.VISIBLE : View.GONE);
if (ex instanceof SecurityException) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext())
.setIcon(R.drawable.twotone_warning_24)
@@ -1574,7 +1587,7 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
if (!TextUtils.isEmpty(message))
builder.setMessage(message);
builder.show();
- } else
+ } else if (!(ex instanceof OperationCanceledException))
Log.unexpectedError(getParentFragmentManager(), ex);
}
}.execute(FragmentOptionsBackup.this, args, "cloud");
diff --git a/app/src/main/res/drawable/twotone_redeem_24.xml b/app/src/main/res/drawable/twotone_redeem_24.xml
new file mode 100644
index 0000000000..445c356d2a
--- /dev/null
+++ b/app/src/main/res/drawable/twotone_redeem_24.xml
@@ -0,0 +1,15 @@
+
+
+
+
diff --git a/app/src/main/res/layout/fragment_options_backup.xml b/app/src/main/res/layout/fragment_options_backup.xml
index 632b7f61a8..6ea7fb5a84 100644
--- a/app/src/main/res/layout/fragment_options_backup.xml
+++ b/app/src/main/res/layout/fragment_options_backup.xml
@@ -324,6 +324,24 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnLogin" />
+
+
+ app:layout_constraintTop_toBottomOf="@id/btnActivate" />
Logging in for the first time will automatically create an account
You can change the password by wiping the data and logging in again
Invalid username or password
+ Activate
Only enabled accounts and identities will be synchronized.
Folder properties will not be synchronized.