Add a dropdown for changing the days of retained downloads.
Bug: 30304998 Change-Id: I3113d58313a4badff55f79988abd7612d3bb4da5
This commit is contained in:
@@ -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>
|
<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>
|
</resources>
|
||||||
|
@@ -43,6 +43,14 @@
|
|||||||
android:entryValues="@array/automatic_storage_management_days_values"
|
android:entryValues="@array/automatic_storage_management_days_values"
|
||||||
settings:allowDividerAbove="true" />
|
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>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
|
@@ -55,8 +55,10 @@ public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment
|
|||||||
private static final String KEY_DELETION_HELPER = "deletion_helper";
|
private static final String KEY_DELETION_HELPER = "deletion_helper";
|
||||||
private static final String KEY_FREED = "freed_bytes";
|
private static final String KEY_FREED = "freed_bytes";
|
||||||
private static final String KEY_STORAGE_MANAGER_SWITCH = "storage_manager_active";
|
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 mDaysToRetain;
|
||||||
|
private DropDownPreference mDownloadsDaysToRetain;
|
||||||
private Preference mFreedBytes;
|
private Preference mFreedBytes;
|
||||||
private Preference mDeletionHelper;
|
private Preference mDeletionHelper;
|
||||||
private SwitchPreference mStorageManagerSwitch;
|
private SwitchPreference mStorageManagerSwitch;
|
||||||
@@ -73,6 +75,9 @@ public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment
|
|||||||
mDaysToRetain = (DropDownPreference) findPreference(KEY_DAYS);
|
mDaysToRetain = (DropDownPreference) findPreference(KEY_DAYS);
|
||||||
mDaysToRetain.setOnPreferenceChangeListener(this);
|
mDaysToRetain.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
mDownloadsDaysToRetain = (DropDownPreference) findPreference(KEY_DOWNLOADS_DAYS);
|
||||||
|
mDownloadsDaysToRetain.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
mFreedBytes = findPreference(KEY_FREED);
|
mFreedBytes = findPreference(KEY_FREED);
|
||||||
|
|
||||||
mDeletionHelper = findPreference(KEY_DELETION_HELPER);
|
mDeletionHelper = findPreference(KEY_DELETION_HELPER);
|
||||||
@@ -82,12 +87,18 @@ public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment
|
|||||||
mStorageManagerSwitch.setOnPreferenceChangeListener(this);
|
mStorageManagerSwitch.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
ContentResolver cr = getContentResolver();
|
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,
|
||||||
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN_DEFAULT);
|
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN_DEFAULT);
|
||||||
String[] stringValues =
|
String[] stringValues =
|
||||||
getResources().getStringArray(R.array.automatic_storage_management_days_values);
|
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,
|
long freedBytes = Settings.Secure.getLong(cr,
|
||||||
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_BYTES_CLEARED,
|
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_BYTES_CLEARED,
|
||||||
@@ -132,6 +143,11 @@ public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment
|
|||||||
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN,
|
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN,
|
||||||
Integer.parseInt((String) newValue));
|
Integer.parseInt((String) newValue));
|
||||||
break;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user