Add a dropdown for changing the days of retained downloads.

Bug: 30304998
Change-Id: I3113d58313a4badff55f79988abd7612d3bb4da5
This commit is contained in:
Daniel Nishi
2016-07-22 14:02:52 -07:00
parent c74d8368e7
commit 4a184d4360
3 changed files with 29 additions and 2 deletions

View File

@@ -7741,4 +7741,7 @@
<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>
<!-- Dropdown preference title for dropdown describing how many days of downloads to retain.-->
<string name="automatic_storage_manager_downloads_days_title">Remove downloads</string>
</resources>

View File

@@ -43,6 +43,14 @@
android:entryValues="@array/automatic_storage_management_days_values"
settings:allowDividerAbove="true" />
<DropDownPreference
android:key="downloads_days"
android:summary="%s"
android:title="@string/automatic_storage_manager_downloads_days_title"
android:entries="@array/automatic_storage_management_days"
android:entryValues="@array/automatic_storage_management_days_values"
settings:allowDividerAbove="true" />
</PreferenceCategory>
<PreferenceCategory

View File

@@ -55,8 +55,10 @@ public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment
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 static final String KEY_DOWNLOADS_DAYS = "downloads_days";
private DropDownPreference mDaysToRetain;
private DropDownPreference mDownloadsDaysToRetain;
private Preference mFreedBytes;
private Preference mDeletionHelper;
private SwitchPreference mStorageManagerSwitch;
@@ -73,6 +75,9 @@ public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment
mDaysToRetain = (DropDownPreference) findPreference(KEY_DAYS);
mDaysToRetain.setOnPreferenceChangeListener(this);
mDownloadsDaysToRetain = (DropDownPreference) findPreference(KEY_DOWNLOADS_DAYS);
mDownloadsDaysToRetain.setOnPreferenceChangeListener(this);
mFreedBytes = findPreference(KEY_FREED);
mDeletionHelper = findPreference(KEY_DELETION_HELPER);
@@ -82,12 +87,18 @@ public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment
mStorageManagerSwitch.setOnPreferenceChangeListener(this);
ContentResolver cr = getContentResolver();
int value = Settings.Secure.getInt(cr,
int photosDaysToRetain = 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)]);
mDaysToRetain.setValue(stringValues[daysValueToIndex(photosDaysToRetain, stringValues)]);
int downloadsDaysToRetain = Settings.Secure.getInt(cr,
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_DOWNLOADS_DAYS_TO_RETAIN,
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN_DEFAULT);
mDownloadsDaysToRetain.setValue(stringValues[daysValueToIndex(downloadsDaysToRetain,
stringValues)]);
long freedBytes = Settings.Secure.getLong(cr,
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_BYTES_CLEARED,
@@ -132,6 +143,11 @@ public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN,
Integer.parseInt((String) newValue));
break;
case KEY_DOWNLOADS_DAYS:
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_DOWNLOADS_DAYS_TO_RETAIN,
Integer.parseInt((String) newValue));
break;
}
return true;
}