Merge pull request #9298 from Ebola16/AClearLog
Android: Clear Log file
This commit is contained in:
commit
ea2ec64ab4
|
@ -39,8 +39,13 @@ import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.SingleChoiceVie
|
|||
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.SliderViewHolder;
|
||||
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.SubmenuViewHolder;
|
||||
import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
|
||||
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
|
||||
import org.dolphinemu.dolphinemu.utils.FileBrowserHelper;
|
||||
import org.dolphinemu.dolphinemu.utils.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.security.InvalidParameterException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
@ -339,6 +344,22 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
|||
mView.onSettingChanged();
|
||||
}
|
||||
|
||||
public static void clearLog()
|
||||
{
|
||||
// Don't delete the log in case it is being monitored by another app.
|
||||
File log = new File(DirectoryInitialization.getUserDirectory() + "/Logs/dolphin.log");
|
||||
|
||||
try
|
||||
{
|
||||
RandomAccessFile raf = new RandomAccessFile(log, "rw");
|
||||
raf.setLength(0);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Log.error("[SettingsAdapter] Failed to clear log file: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void handleMenuTag(MenuTag menuTag, int value)
|
||||
{
|
||||
if (menuTag != null)
|
||||
|
|
|
@ -638,6 +638,8 @@ public final class SettingsFragmentPresenter
|
|||
() -> mView.getAdapter().setAllLogTypes(true)));
|
||||
sl.add(new RunRunnable(R.string.log_disable_all, 0, R.string.log_disable_all_confirmation, 0,
|
||||
() -> mView.getAdapter().setAllLogTypes(false)));
|
||||
sl.add(new RunRunnable(R.string.log_clear, 0, R.string.log_clear_confirmation, 0,
|
||||
SettingsAdapter::clearLog));
|
||||
|
||||
sl.add(new HeaderSetting(R.string.log_types, 0));
|
||||
for (Map.Entry<String, String> entry : LOG_TYPE_NAMES.entrySet())
|
||||
|
|
|
@ -283,6 +283,8 @@
|
|||
<string name="log_enable_all_confirmation">Are you sure you want to enable all log types?</string>
|
||||
<string name="log_disable_all">Disable all Log Types</string>
|
||||
<string name="log_disable_all_confirmation">Are you sure you want to disable all log types?</string>
|
||||
<string name="log_clear">Clear Log file</string>
|
||||
<string name="log_clear_confirmation">Are you sure you want to clear the log file?</string>
|
||||
<string name="log_types">Log Types</string>
|
||||
|
||||
<!-- Debug -->
|
||||
|
|
Loading…
Reference in New Issue