Add text to the Manage Settings page to show freed storage.
Bug: 29643106 Change-Id: Id05dc70e36a690e27cab67fecf921257ed7baf15
This commit is contained in:
@@ -7681,4 +7681,7 @@
|
||||
<string name="oem_unlock_enable_disabled_summary_connectivity">Connect to the Internet first</string>
|
||||
<!-- setting enable OEM unlock Checkbox's summary to explain this Checkbox is disabled because this setting is unavailable on sim-locked devices. [CHAR_LIMIT=60] -->
|
||||
<string name="oem_unlock_enable_disabled_summary_sim_locked_device">Unavailable on carrier-locked devices</string>
|
||||
|
||||
<string name="automatic_storage_manager_freed_bytes"><xliff:g id="size" example="3.25MB">%1$s</xliff:g> total made available\n\nLast ran on <xliff:g id="date" example="Jan 12">%2$s</xliff:g></string>
|
||||
|
||||
</resources>
|
||||
|
@@ -27,12 +27,21 @@
|
||||
android:title="@string/automatic_storage_manager_preference_title"
|
||||
android:summary="@string/automatic_storage_manager_text"/>
|
||||
|
||||
|
||||
<com.android.settings.fuelgauge.WallOfTextPreference
|
||||
android:key="freed_bytes"
|
||||
android:persistent="false"
|
||||
android:selectable="false"
|
||||
settings:allowDividerAbove="false"
|
||||
settings:allowDividerBelow="true" />
|
||||
|
||||
<DropDownPreference
|
||||
android:key="days"
|
||||
android:summary="%s"
|
||||
android:title="@string/automatic_storage_manager_days_title"
|
||||
android:entries="@array/automatic_storage_management_days"
|
||||
android:entryValues="@array/automatic_storage_management_days_values"/>
|
||||
android:entryValues="@array/automatic_storage_management_days_values"
|
||||
settings:allowDividerAbove="true" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
@@ -17,12 +17,15 @@
|
||||
package com.android.settings.deletionhelper;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.os.storage.StorageManager;
|
||||
import android.provider.Settings;
|
||||
import android.text.format.DateUtils;
|
||||
import android.text.format.Formatter;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Switch;
|
||||
@@ -49,9 +52,11 @@ public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment
|
||||
|
||||
private static final String KEY_DAYS = "days";
|
||||
private static final String KEY_DELETION_HELPER = "deletion_helper";
|
||||
private static final String KEY_FREED = "freed_bytes";
|
||||
private static final String KEY_STORAGE_MANAGER_SWITCH = "storage_manager_active";
|
||||
|
||||
private DropDownPreference mDaysToRetain;
|
||||
private Preference mFreedBytes;
|
||||
private Preference mDeletionHelper;
|
||||
private SwitchPreference mStorageManagerSwitch;
|
||||
|
||||
@@ -67,18 +72,37 @@ public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment
|
||||
mDaysToRetain = (DropDownPreference) findPreference(KEY_DAYS);
|
||||
mDaysToRetain.setOnPreferenceChangeListener(this);
|
||||
|
||||
mFreedBytes = findPreference(KEY_FREED);
|
||||
|
||||
mDeletionHelper = findPreference(KEY_DELETION_HELPER);
|
||||
mDeletionHelper.setOnPreferenceClickListener(this);
|
||||
|
||||
mStorageManagerSwitch = (SwitchPreference) findPreference(KEY_STORAGE_MANAGER_SWITCH);
|
||||
mStorageManagerSwitch.setOnPreferenceChangeListener(this);
|
||||
|
||||
int value = Settings.Secure.getInt(getContentResolver(),
|
||||
ContentResolver cr = getContentResolver();
|
||||
int value = Settings.Secure.getInt(cr,
|
||||
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN,
|
||||
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN_DEFAULT);
|
||||
String[] stringValues =
|
||||
getResources().getStringArray(R.array.automatic_storage_management_days_values);
|
||||
mDaysToRetain.setValue(stringValues[daysValueToIndex(value, stringValues)]);
|
||||
|
||||
long freedBytes = Settings.Secure.getLong(cr,
|
||||
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_BYTES_CLEARED,
|
||||
0);
|
||||
long lastRunMillis = Settings.Secure.getLong(cr,
|
||||
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_LAST_RUN,
|
||||
0);
|
||||
if (freedBytes == 0 || lastRunMillis == 0) {
|
||||
mFreedBytes.setVisible(false);
|
||||
} else {
|
||||
Activity activity = getActivity();
|
||||
mFreedBytes.setSummary(activity.getString(
|
||||
R.string.automatic_storage_manager_freed_bytes,
|
||||
Formatter.formatFileSize(activity, freedBytes),
|
||||
DateUtils.formatDateTime(activity, lastRunMillis, DateUtils.FORMAT_SHOW_DATE)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user