mirror of https://github.com/M66B/FairEmail.git
Added folder repair button
This commit is contained in:
parent
064f3e0c0c
commit
a41a264099
|
@ -125,6 +125,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
private SwitchCompat swLogInfo;
|
||||
private SwitchCompat swDebug;
|
||||
|
||||
private Button btnRepair;
|
||||
private TextView tvRoomQueryThreads;
|
||||
private SeekBar sbRoomQueryThreads;
|
||||
private ImageButton ibRoom;
|
||||
|
@ -246,6 +247,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
swLogInfo = view.findViewById(R.id.swLogInfo);
|
||||
swDebug = view.findViewById(R.id.swDebug);
|
||||
|
||||
btnRepair = view.findViewById(R.id.btnRepair);
|
||||
tvRoomQueryThreads = view.findViewById(R.id.tvRoomQueryThreads);
|
||||
sbRoomQueryThreads = view.findViewById(R.id.sbRoomQueryThreads);
|
||||
ibRoom = view.findViewById(R.id.ibRoom);
|
||||
|
@ -1144,6 +1146,62 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
swLogInfo.setChecked(prefs.getInt("log_level", Log.getDefaultLogLevel()) <= android.util.Log.INFO);
|
||||
swDebug.setChecked(prefs.getBoolean("debug", false));
|
||||
|
||||
btnRepair.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
new SimpleTask<Void>() {
|
||||
@Override
|
||||
protected void onPostExecute(Bundle args) {
|
||||
ToastEx.makeText(v.getContext(), R.string.title_completed, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void onExecute(Context context, Bundle args) throws Throwable {
|
||||
DB db = DB.getInstance(context);
|
||||
|
||||
List<EntityAccount> accounts = db.account().getAccounts();
|
||||
if (accounts == null)
|
||||
return null;
|
||||
|
||||
for (EntityAccount account : accounts) {
|
||||
if (account.protocol != EntityAccount.TYPE_IMAP)
|
||||
continue;
|
||||
|
||||
List<EntityFolder> folders = db.folder().getFolders(account.id, false, false);
|
||||
if (folders == null)
|
||||
continue;
|
||||
|
||||
EntityFolder inbox = db.folder().getFolderByType(account.id, EntityFolder.INBOX);
|
||||
for (EntityFolder folder : folders) {
|
||||
if (inbox == null && "inbox".equalsIgnoreCase(folder.name))
|
||||
folder.type = EntityFolder.INBOX;
|
||||
|
||||
if (!EntityFolder.USER.equals(folder.type) &&
|
||||
!EntityFolder.SYSTEM.equals(folder.type)) {
|
||||
EntityLog.log(context, "Repairing " + account.name + ":" + folder.type);
|
||||
folder.setProperties();
|
||||
folder.setSpecials(account);
|
||||
db.folder().updateFolder(folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, Void data) {
|
||||
ServiceSynchronize.reload(v.getContext(), null, true, "repair");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||
}
|
||||
}.execute(FragmentOptionsMisc.this, new Bundle(), "repair");
|
||||
}
|
||||
});
|
||||
|
||||
int query_threads = prefs.getInt("query_threads", DB.DEFAULT_QUERY_THREADS);
|
||||
tvRoomQueryThreads.setText(getString(R.string.title_advanced_room_query_threads, NF.format(query_threads)));
|
||||
sbRoomQueryThreads.setProgress(query_threads);
|
||||
|
|
|
@ -610,6 +610,18 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnRepair"
|
||||
style="?android:attr/buttonStyleSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:drawableEnd="@drawable/twotone_bug_report_24"
|
||||
android:drawablePadding="6dp"
|
||||
android:text="@string/title_advanced_repair"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvCaptionDebug" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvRoomQueryThreads"
|
||||
android:layout_width="0dp"
|
||||
|
@ -620,7 +632,7 @@
|
|||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvCaptionDebug" />
|
||||
app:layout_constraintTop_toBottomOf="@id/btnRepair" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/sbRoomQueryThreads"
|
||||
|
|
|
@ -646,6 +646,7 @@
|
|||
<string name="title_advanced_protocol">Protocol logging</string>
|
||||
<string name="title_advanced_log_info">Debug logging</string>
|
||||
<string name="title_advanced_debug">Debug mode</string>
|
||||
<string name="title_advanced_repair" translatable="false">Repair</string>
|
||||
<string name="title_advanced_room_query_threads" translatable="false">ROOM query threads: %1$s</string>
|
||||
<string name="title_advanced_wal" translatable="false">WAL</string>
|
||||
<string name="title_advanced_checkpoints" translatable="false">Checkpoints</string>
|
||||
|
|
Loading…
Reference in New Issue