Update memory/storage usage

pull/185/head
M66B 4 years ago
parent f9983ead6f
commit 73296979f4

@ -67,6 +67,8 @@ import javax.net.ssl.SSLSocketFactory;
import io.requery.android.database.sqlite.SQLiteDatabase; import io.requery.android.database.sqlite.SQLiteDatabase;
public class FragmentOptionsMisc extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener { public class FragmentOptionsMisc extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private boolean resumed = false;
private SwitchCompat swExternalSearch; private SwitchCompat swExternalSearch;
private SwitchCompat swShortcuts; private SwitchCompat swShortcuts;
private SwitchCompat swFts; private SwitchCompat swFts;
@ -472,6 +474,27 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
return view; return view;
} }
@Override
public void onResume() {
super.onResume();
resumed = true;
View view = getView();
if (view != null)
view.post(new Runnable() {
@Override
public void run() {
updateUsage();
}
});
}
@Override
public void onPause() {
super.onPause();
resumed = false;
}
@Override @Override
public void onDestroyView() { public void onDestroyView() {
PreferenceManager.getDefaultSharedPreferences(getContext()).unregisterOnSharedPreferenceChangeListener(this); PreferenceManager.getDefaultSharedPreferences(getContext()).unregisterOnSharedPreferenceChangeListener(this);
@ -587,6 +610,18 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
tvMemoryClass.setText(getString(R.string.title_advanced_memory_class, tvMemoryClass.setText(getString(R.string.title_advanced_memory_class,
class_mb + " MB", Helper.humanReadableByteCount(mi.totalMem))); class_mb + " MB", Helper.humanReadableByteCount(mi.totalMem)));
tvFingerprint.setText(Helper.getFingerprint(getContext()));
grpDebug.setVisibility(swDebug.isChecked() || BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
}
private void updateUsage() {
if (!resumed)
return;
try {
Log.i("Update usage");
Runtime rt = Runtime.getRuntime(); Runtime rt = Runtime.getRuntime();
long hused = rt.totalMemory() - rt.freeMemory(); long hused = rt.totalMemory() - rt.freeMemory();
long hmax = rt.maxMemory(); long hmax = rt.maxMemory();
@ -599,9 +634,16 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
tvStorageUsage.setText(getString(R.string.title_advanced_storage_usage, tvStorageUsage.setText(getString(R.string.title_advanced_storage_usage,
Helper.humanReadableByteCount(Helper.getAvailableStorageSpace()), Helper.humanReadableByteCount(Helper.getAvailableStorageSpace()),
Helper.humanReadableByteCount(Helper.getTotalStorageSpace()))); Helper.humanReadableByteCount(Helper.getTotalStorageSpace())));
tvFingerprint.setText(Helper.getFingerprint(getContext()));
grpDebug.setVisibility(swDebug.isChecked() || BuildConfig.DEBUG ? View.VISIBLE : View.GONE); getView().postDelayed(new Runnable() {
@Override
public void run() {
updateUsage();
}
}, 2500);
} catch (Throwable ex) {
Log.e(ex);
}
} }
private void setLastCleanup(long time) { private void setLastCleanup(long time) {

Loading…
Cancel
Save