Added clear log

This commit is contained in:
M66B 2019-12-11 11:56:51 +01:00
parent 0a43d19847
commit 157066ffa1
3 changed files with 30 additions and 0 deletions

View File

@ -19,6 +19,7 @@ package eu.faircode.email;
Copyright 2018-2019 by Marcel Bokhorst (M66B)
*/
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
@ -118,8 +119,32 @@ public class FragmentLogs extends FragmentBase {
item.setChecked(autoScroll);
return true;
case R.id.menu_clear:
onMenuClear();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void onMenuClear() {
Bundle args = new Bundle();
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
DB db = DB.getInstance(context);
db.log().deleteLogs(new Date().getTime());
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex);
}
}.execute(this, args, "log:clear");
}
}

View File

@ -6,4 +6,8 @@
android:checkable="true"
android:title="@string/title_auto_scroll"
app:showAsAction="never" />
<item
android:id="@+id/menu_clear"
android:title="@string/title_log_clear"
app:showAsAction="never" />
</menu>

View File

@ -991,6 +991,7 @@
<string name="title_unexpected_error">Unexpected error</string>
<string name="title_log">Log</string>
<string name="title_auto_scroll">Auto scroll</string>
<string name="title_log_clear">Clear</string>
<string name="title_debug_info">Debug info</string>
<string name="title_debug_info_remark">Please describe the problem and indicate the time of the problem:</string>
<string name="title_crash_info_remark">Please describe what you were doing when the app crashed:</string>