Add switch to enable downloads backup.
Bug: 30503075 Change-Id: I011d88d16ab8677b63b73e059f0edf823cc82389
This commit is contained in:
@@ -7764,4 +7764,10 @@
|
|||||||
<!-- Dropdown preference title for dropdown describing how many days of downloads to retain.-->
|
<!-- Dropdown preference title for dropdown describing how many days of downloads to retain.-->
|
||||||
<string name="automatic_storage_manager_downloads_days_title">Remove downloads</string>
|
<string name="automatic_storage_manager_downloads_days_title">Remove downloads</string>
|
||||||
|
|
||||||
|
<!-- Preference title for downloads backup toggle. [CHAR LIMIT=60]-->
|
||||||
|
<string name="downloads_backup_preference_title">Downloads backup</string>
|
||||||
|
|
||||||
|
<!-- Used as wall of text to describe the feature. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="downloads_backup_text"></string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -27,6 +27,10 @@
|
|||||||
android:title="@string/automatic_storage_manager_preference_title"
|
android:title="@string/automatic_storage_manager_preference_title"
|
||||||
android:summary="@string/automatic_storage_manager_text"/>
|
android:summary="@string/automatic_storage_manager_text"/>
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="downloads_backup_active"
|
||||||
|
android:title="@string/downloads_backup_preference_title"
|
||||||
|
android:summary="@string/downloads_backup_text"/>
|
||||||
|
|
||||||
<com.android.settings.fuelgauge.WallOfTextPreference
|
<com.android.settings.fuelgauge.WallOfTextPreference
|
||||||
android:key="freed_bytes"
|
android:key="freed_bytes"
|
||||||
|
@@ -55,6 +55,7 @@ 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_BACKUP_SWITCH = "downloads_backup_active";
|
||||||
private static final String KEY_DOWNLOADS_DAYS = "downloads_days";
|
private static final String KEY_DOWNLOADS_DAYS = "downloads_days";
|
||||||
|
|
||||||
private DropDownPreference mDaysToRetain;
|
private DropDownPreference mDaysToRetain;
|
||||||
@@ -62,6 +63,7 @@ public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment
|
|||||||
private Preference mFreedBytes;
|
private Preference mFreedBytes;
|
||||||
private Preference mDeletionHelper;
|
private Preference mDeletionHelper;
|
||||||
private SwitchPreference mStorageManagerSwitch;
|
private SwitchPreference mStorageManagerSwitch;
|
||||||
|
private SwitchPreference mDownloadsBackupSwitch;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -86,6 +88,9 @@ public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment
|
|||||||
mStorageManagerSwitch = (SwitchPreference) findPreference(KEY_STORAGE_MANAGER_SWITCH);
|
mStorageManagerSwitch = (SwitchPreference) findPreference(KEY_STORAGE_MANAGER_SWITCH);
|
||||||
mStorageManagerSwitch.setOnPreferenceChangeListener(this);
|
mStorageManagerSwitch.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
mDownloadsBackupSwitch = (SwitchPreference) findPreference(KEY_DOWNLOADS_BACKUP_SWITCH);
|
||||||
|
mDownloadsBackupSwitch.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
ContentResolver cr = getContentResolver();
|
ContentResolver cr = getContentResolver();
|
||||||
int photosDaysToRetain = 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,
|
||||||
@@ -120,23 +125,34 @@ public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
boolean isChecked =
|
boolean isStorageManagerChecked =
|
||||||
Settings.Secure.getInt(getContentResolver(),
|
Settings.Secure.getInt(getContentResolver(),
|
||||||
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_ENABLED, 0) != 0;
|
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_ENABLED, 0) != 0;
|
||||||
mStorageManagerSwitch.setChecked(isChecked);
|
mStorageManagerSwitch.setChecked(isStorageManagerChecked);
|
||||||
mDaysToRetain.setEnabled(isChecked);
|
mDaysToRetain.setEnabled(isStorageManagerChecked);
|
||||||
|
|
||||||
|
boolean isDownloadsBackupChecked =
|
||||||
|
Settings.Secure.getInt(getContentResolver(),
|
||||||
|
Settings.Secure.DOWNLOADS_BACKUP_ENABLED, 0) != 0;
|
||||||
|
mDownloadsBackupSwitch.setChecked(isDownloadsBackupChecked);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
switch (preference.getKey()) {
|
switch (preference.getKey()) {
|
||||||
case KEY_STORAGE_MANAGER_SWITCH:
|
case KEY_STORAGE_MANAGER_SWITCH:
|
||||||
boolean checked = (boolean) newValue;
|
boolean storageManagerChecked = (boolean) newValue;
|
||||||
MetricsLogger.action(getContext(), MetricsEvent.ACTION_TOGGLE_STORAGE_MANAGER,
|
MetricsLogger.action(getContext(), MetricsEvent.ACTION_TOGGLE_STORAGE_MANAGER,
|
||||||
checked);
|
storageManagerChecked);
|
||||||
mDaysToRetain.setEnabled(checked);
|
mDaysToRetain.setEnabled(storageManagerChecked);
|
||||||
Settings.Secure.putInt(getContentResolver(),
|
Settings.Secure.putInt(getContentResolver(),
|
||||||
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_ENABLED, checked ? 1 : 0);
|
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_ENABLED,
|
||||||
|
storageManagerChecked ? 1 : 0);
|
||||||
|
break;
|
||||||
|
case KEY_DOWNLOADS_BACKUP_SWITCH:
|
||||||
|
boolean downloadsBackupChecked = (boolean) newValue;
|
||||||
|
Settings.Secure.putInt(getContentResolver(),
|
||||||
|
Settings.Secure.DOWNLOADS_BACKUP_ENABLED, downloadsBackupChecked ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
case KEY_DAYS:
|
case KEY_DAYS:
|
||||||
Settings.Secure.putInt(getContentResolver(),
|
Settings.Secure.putInt(getContentResolver(),
|
||||||
|
Reference in New Issue
Block a user