Import improvements

pull/206/head
M66B 3 years ago
parent cf9db50a09
commit 543ebe08ae

@ -42,6 +42,7 @@ import android.os.Build;
import android.os.Bundle;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.util.Pair;
import android.view.LayoutInflater;
@ -782,6 +783,8 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
Log.w(ex);
}
final int colorWarning = Helper.resolveColor(this, R.attr.colorWarning);
View dview = LayoutInflater.from(this).inflate(R.layout.dialog_import_progress, null);
TextView tvLog = dview.findViewById(R.id.tvLog);
tvLog.setText(null);
@ -935,6 +938,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
SpannableStringBuilder ssb = new SpannableStringBuilder();
ssb.append(context.getString(R.string.title_importing_wizard));
ssb.setSpan(new StyleSpan(Typeface.BOLD), 0, ssb.length(), 0);
ssb.setSpan(new ForegroundColorSpan(colorWarning), 0, ssb.length(), 0);
postProgress(ssb);
EntityLog.log(context, "Run wizard account=" + account.name +
"id=" + account.id);
@ -1224,27 +1228,27 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
ServiceSynchronize.eval(context, "import");
Log.i("Imported data");
postProgress(context.getString(R.string.title_setup_imported), null);
SpannableStringBuilder ssb = new SpannableStringBuilder();
ssb.append(context.getString(R.string.title_setup_imported));
ssb.setSpan(new StyleSpan(Typeface.BOLD), 0, ssb.length(), 0);
postProgress(ssb, null);
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
if (ex.getCause() instanceof BadPaddingException) {
onProgress(getString(R.string.title_setup_password_invalid), null);
onProgress("\n" + ex.toString(), null);
} else if (ex instanceof IOException && ex.getCause() instanceof IllegalBlockSizeException) {
onProgress(getString(R.string.title_setup_import_invalid), null);
onProgress("\n" + ex.toString(), null);
} else if (ex instanceof IllegalArgumentException ||
ex instanceof IOException ||
ex instanceof JSONException ||
ex instanceof SecurityException) {
onProgress(ex.toString(), null);
} else {
dialog.dismiss();
Log.unexpectedError(getSupportFragmentManager(), ex);
SpannableStringBuilder ssb = new SpannableStringBuilder();
if (ex.getCause() instanceof BadPaddingException)
ssb.append(getString(R.string.title_setup_password_invalid));
else if (ex instanceof IOException && ex.getCause() instanceof IllegalBlockSizeException)
ssb.append(getString(R.string.title_setup_import_invalid));
if (ssb.length() > 0) {
ssb.setSpan(new StyleSpan(Typeface.BOLD), 0, ssb.length(), 0);
ssb.setSpan(new ForegroundColorSpan(colorWarning), 0, ssb.length(), 0);
ssb.append("\n\n");
}
ssb.append(ex.toString());
onProgress(ssb, null);
}
}.execute(this, args, "setup:import");
}

@ -59,24 +59,14 @@
android:id="@+id/tvImportHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="6dp"
android:text="@string/title_setup_import_do"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?attr/colorWarning"
android:textStyle="italic"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbAccounts" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvImportGmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="@string/title_setup_import_gmail"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvImportHint" />
app:layout_constraintTop_toBottomOf="@id/cbAccounts" />
<CheckBox
android:id="@+id/cbRules"
@ -87,7 +77,7 @@
android:checked="true"
android:text="@string/title_setup_import_contacts"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvImportGmail" />
app:layout_constraintTop_toBottomOf="@id/tvImportHint" />
<CheckBox
android:id="@+id/cbContacts"

@ -28,6 +28,7 @@
android:layout_marginTop="24dp"
android:text="Log"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textIsSelectable="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvCaption" />

@ -251,10 +251,6 @@
</string>
<string name="title_setup_export_do">The export file will contain all settings and data, but no messages and no images referenced in signatures</string>
<string name="title_setup_import_do">Imported accounts will be added without overwriting any existing ones</string>
<string name="title_setup_import_gmail">
Since Android 8.0 Oreo, Gmail accounts can no longer be imported, as each account must be selected to grant access to the account.
You can easily reconfigure Gmail accounts with the quick setup wizard.
</string>
<string name="title_setup_password">Password</string>
<string name="title_setup_password_chars">Password contains control or whitespace characters</string>
<string name="title_setup_password_repeat">Repeat password</string>

Loading…
Cancel
Save