mirror of https://github.com/M66B/FairEmail.git
Added option tolog memory usage
This commit is contained in:
parent
c062a1c8ad
commit
44413bbab0
|
@ -21,6 +21,7 @@ package eu.faircode.email;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Debug;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
@ -120,6 +121,13 @@ public class EntityLog {
|
||||||
if (!main_log)
|
if (!main_log)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
boolean main_log_memory = prefs.getBoolean("main_log_memory", false);
|
||||||
|
if (main_log_memory) {
|
||||||
|
long j = Log.getAvailableMb() - Log.getFreeMemMb();
|
||||||
|
long n = Debug.getNativeHeapSize() / 1024L / 1024L;
|
||||||
|
data = j + "/" + n + " " + data;
|
||||||
|
}
|
||||||
|
|
||||||
final EntityLog entry = new EntityLog();
|
final EntityLog entry = new EntityLog();
|
||||||
entry.time = new Date().getTime();
|
entry.time = new Date().getTime();
|
||||||
entry.type = type;
|
entry.type = type;
|
||||||
|
|
|
@ -146,6 +146,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||||
private SwitchCompat swExperiments;
|
private SwitchCompat swExperiments;
|
||||||
private TextView tvExperimentsHint;
|
private TextView tvExperimentsHint;
|
||||||
private SwitchCompat swMainLog;
|
private SwitchCompat swMainLog;
|
||||||
|
private SwitchCompat swMainLogMem;
|
||||||
private SwitchCompat swProtocol;
|
private SwitchCompat swProtocol;
|
||||||
private SwitchCompat swLogInfo;
|
private SwitchCompat swLogInfo;
|
||||||
private SwitchCompat swDebug;
|
private SwitchCompat swDebug;
|
||||||
|
@ -236,7 +237,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||||
"language", "lt_enabled", "deepl_enabled", "vt_enabled", "vt_apikey", "send_enabled", "send_host",
|
"language", "lt_enabled", "deepl_enabled", "vt_enabled", "vt_apikey", "send_enabled", "send_host",
|
||||||
"updates", "weekly", "show_changelog",
|
"updates", "weekly", "show_changelog",
|
||||||
"crash_reports", "cleanup_attachments",
|
"crash_reports", "cleanup_attachments",
|
||||||
"watchdog", "experiments", "main_log", "protocol", "log_level", "debug", "leak_canary",
|
"watchdog", "experiments", "main_log", "main_log_memory", "protocol", "log_level", "debug", "leak_canary",
|
||||||
"test1", "test2", "test3", "test4", "test5",
|
"test1", "test2", "test3", "test4", "test5",
|
||||||
"work_manager", // "external_storage",
|
"work_manager", // "external_storage",
|
||||||
"query_threads",
|
"query_threads",
|
||||||
|
@ -347,6 +348,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||||
swExperiments = view.findViewById(R.id.swExperiments);
|
swExperiments = view.findViewById(R.id.swExperiments);
|
||||||
tvExperimentsHint = view.findViewById(R.id.tvExperimentsHint);
|
tvExperimentsHint = view.findViewById(R.id.tvExperimentsHint);
|
||||||
swMainLog = view.findViewById(R.id.swMainLog);
|
swMainLog = view.findViewById(R.id.swMainLog);
|
||||||
|
swMainLogMem = view.findViewById(R.id.swMainLogMem);
|
||||||
swProtocol = view.findViewById(R.id.swProtocol);
|
swProtocol = view.findViewById(R.id.swProtocol);
|
||||||
swLogInfo = view.findViewById(R.id.swLogInfo);
|
swLogInfo = view.findViewById(R.id.swLogInfo);
|
||||||
swDebug = view.findViewById(R.id.swDebug);
|
swDebug = view.findViewById(R.id.swDebug);
|
||||||
|
@ -847,6 +849,14 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||||
prefs.edit().putBoolean("main_log", checked).apply();
|
prefs.edit().putBoolean("main_log", checked).apply();
|
||||||
|
swMainLogMem.setEnabled(checked);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
swMainLogMem.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||||
|
prefs.edit().putBoolean("main_log_memory", checked).apply();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1971,6 +1981,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||||
|
|
||||||
swWatchdog.setChecked(prefs.getBoolean("watchdog", true));
|
swWatchdog.setChecked(prefs.getBoolean("watchdog", true));
|
||||||
swMainLog.setChecked(prefs.getBoolean("main_log", true));
|
swMainLog.setChecked(prefs.getBoolean("main_log", true));
|
||||||
|
swMainLogMem.setChecked(prefs.getBoolean("main_log_memory", false));
|
||||||
|
swMainLogMem.setEnabled(swMainLog.isChecked());
|
||||||
swProtocol.setChecked(prefs.getBoolean("protocol", false));
|
swProtocol.setChecked(prefs.getBoolean("protocol", false));
|
||||||
swLogInfo.setChecked(prefs.getInt("log_level", Log.getDefaultLogLevel()) <= android.util.Log.INFO);
|
swLogInfo.setChecked(prefs.getInt("log_level", Log.getDefaultLogLevel()) <= android.util.Log.INFO);
|
||||||
swDebug.setChecked(prefs.getBoolean("debug", false));
|
swDebug.setChecked(prefs.getBoolean("debug", false));
|
||||||
|
|
|
@ -737,6 +737,18 @@
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvExperimentsHint"
|
app:layout_constraintTop_toBottomOf="@id/tvExperimentsHint"
|
||||||
app:switchPadding="12dp" />
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
|
android:id="@+id/swMainLogMem"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="12dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:text="@string/title_advanced_main_log_mem"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/swMainLog"
|
||||||
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
android:id="@+id/swProtocol"
|
android:id="@+id/swProtocol"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -747,7 +759,7 @@
|
||||||
android:text="@string/title_advanced_protocol"
|
android:text="@string/title_advanced_protocol"
|
||||||
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/swMainLog"
|
app:layout_constraintTop_toBottomOf="@id/swMainLogMem"
|
||||||
app:switchPadding="12dp" />
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
|
@ -766,6 +766,7 @@
|
||||||
<string name="title_advanced_app">App settings</string>
|
<string name="title_advanced_app">App settings</string>
|
||||||
<string name="title_advanced_more">More options</string>
|
<string name="title_advanced_more">More options</string>
|
||||||
<string name="title_advanced_main_log">Main logging</string>
|
<string name="title_advanced_main_log">Main logging</string>
|
||||||
|
<string name="title_advanced_main_log_mem">Log memory usage</string>
|
||||||
<string name="title_advanced_protocol">Protocol logging</string>
|
<string name="title_advanced_protocol">Protocol logging</string>
|
||||||
<string name="title_advanced_log_info">Debug logging</string>
|
<string name="title_advanced_log_info">Debug logging</string>
|
||||||
<string name="title_advanced_debug">Debug mode</string>
|
<string name="title_advanced_debug">Debug mode</string>
|
||||||
|
|
Loading…
Reference in New Issue