|
|
@ -1332,74 +1332,74 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|
|
|
btnRepair.setOnClickListener(new View.OnClickListener() {
|
|
|
|
btnRepair.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
public void onClick(View v) {
|
|
|
|
new AlertDialog.Builder(view.getContext())
|
|
|
|
if (BuildConfig.DEBUG)
|
|
|
|
.setIcon(R.drawable.twotone_bug_report_24)
|
|
|
|
new AlertDialog.Builder(view.getContext())
|
|
|
|
.setTitle(R.string.title_advanced_repair)
|
|
|
|
.setIcon(R.drawable.twotone_bug_report_24)
|
|
|
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
|
.setTitle(R.string.title_advanced_repair)
|
|
|
|
@Override
|
|
|
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
@Override
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
@Override
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
protected void onPostExecute(Bundle args) {
|
|
|
|
@Override
|
|
|
|
prefs.edit().remove("debug").apply();
|
|
|
|
protected void onPostExecute(Bundle args) {
|
|
|
|
}
|
|
|
|
prefs.edit().remove("debug").apply();
|
|
|
|
|
|
|
|
}
|
|
|
|
@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) {
|
|
|
|
@Override
|
|
|
|
if (account.protocol != EntityAccount.TYPE_IMAP)
|
|
|
|
protected Void onExecute(Context context, Bundle args) throws Throwable {
|
|
|
|
continue;
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
|
|
|
|
|
|
|
List<EntityFolder> folders = db.folder().getFolders(account.id, false, false);
|
|
|
|
List<EntityAccount> accounts = db.account().getAccounts();
|
|
|
|
if (folders == null)
|
|
|
|
if (accounts == null)
|
|
|
|
continue;
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
EntityFolder inbox = db.folder().getFolderByType(account.id, EntityFolder.INBOX);
|
|
|
|
for (EntityAccount account : accounts) {
|
|
|
|
for (EntityFolder folder : folders) {
|
|
|
|
if (account.protocol != EntityAccount.TYPE_IMAP)
|
|
|
|
if (inbox == null && "inbox".equalsIgnoreCase(folder.name))
|
|
|
|
continue;
|
|
|
|
folder.type = EntityFolder.INBOX;
|
|
|
|
|
|
|
|
|
|
|
|
List<EntityFolder> folders = db.folder().getFolders(account.id, false, false);
|
|
|
|
if (!EntityFolder.USER.equals(folder.type) &&
|
|
|
|
if (folders == null)
|
|
|
|
!EntityFolder.SYSTEM.equals(folder.type)) {
|
|
|
|
continue;
|
|
|
|
EntityLog.log(context, "Repairing " + account.name + ":" + folder.type);
|
|
|
|
|
|
|
|
folder.setProperties();
|
|
|
|
EntityFolder inbox = db.folder().getFolderByType(account.id, EntityFolder.INBOX);
|
|
|
|
folder.setSpecials(account);
|
|
|
|
for (EntityFolder folder : folders) {
|
|
|
|
db.folder().updateFolder(folder);
|
|
|
|
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;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onExecuted(Bundle args, Void data) {
|
|
|
|
protected void onExecuted(Bundle args, Void data) {
|
|
|
|
ToastEx.makeText(v.getContext(), R.string.title_completed, Toast.LENGTH_LONG).show();
|
|
|
|
ToastEx.makeText(v.getContext(), R.string.title_completed, Toast.LENGTH_LONG).show();
|
|
|
|
ServiceSynchronize.reload(v.getContext(), null, true, "repair");
|
|
|
|
ServiceSynchronize.reload(v.getContext(), null, true, "repair");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
Log.unexpectedError(getParentFragmentManager(), ex);
|
|
|
|
Log.unexpectedError(getParentFragmentManager(), ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.execute(FragmentOptionsMisc.this, new Bundle(), "repair");
|
|
|
|
}.execute(FragmentOptionsMisc.this, new Bundle(), "repair");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
|
|
|
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
// Do nothing
|
|
|
|
// Do nothing
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.show();
|
|
|
|
.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
btnDaily.setOnClickListener(new View.OnClickListener() {
|
|
|
|
btnDaily.setOnClickListener(new View.OnClickListener() {
|
|
|
|