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

@ -59,24 +59,14 @@
android:id="@+id/tvImportHint" android:id="@+id/tvImportHint"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
android:text="@string/title_setup_import_do" android:text="@string/title_setup_import_do"
android:textAppearance="@style/TextAppearance.AppCompat.Small" 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" android:textStyle="italic"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvImportHint" /> app:layout_constraintTop_toBottomOf="@id/cbAccounts" />
<CheckBox <CheckBox
android:id="@+id/cbRules" android:id="@+id/cbRules"
@ -87,7 +77,7 @@
android:checked="true" android:checked="true"
android:text="@string/title_setup_import_contacts" android:text="@string/title_setup_import_contacts"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvImportGmail" /> app:layout_constraintTop_toBottomOf="@id/tvImportHint" />
<CheckBox <CheckBox
android:id="@+id/cbContacts" android:id="@+id/cbContacts"

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

@ -251,10 +251,6 @@
</string> </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_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_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">Password</string>
<string name="title_setup_password_chars">Password contains control or whitespace characters</string> <string name="title_setup_password_chars">Password contains control or whitespace characters</string>
<string name="title_setup_password_repeat">Repeat password</string> <string name="title_setup_password_repeat">Repeat password</string>

Loading…
Cancel
Save