Merge \"Use Settings.Secure for days to retain.\" into nyc-mr1-dev
am: 584320adb8
Change-Id: Ifd3f1542b9feb2747a54f380ff7047868e563251
This commit is contained in:
@@ -18,7 +18,6 @@ package com.android.settings.deletionhelper;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -46,11 +45,9 @@ public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment
|
|||||||
OnPreferenceChangeListener, Preference.OnPreferenceClickListener {
|
OnPreferenceChangeListener, Preference.OnPreferenceClickListener {
|
||||||
public static final int DEFAULT_DAYS_TO_RETAIN = 90;
|
public static final int DEFAULT_DAYS_TO_RETAIN = 90;
|
||||||
|
|
||||||
private static final String SHARED_PREFRENCES_NAME = "automatic_storage_manager_settings";
|
|
||||||
private static final String KEY_DAYS = "days";
|
private static final String KEY_DAYS = "days";
|
||||||
private static final String KEY_DELETION_HELPER = "deletion_helper";
|
private static final String KEY_DELETION_HELPER = "deletion_helper";
|
||||||
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_DAYS_TO_RETAIN = "days_to_retain";
|
|
||||||
|
|
||||||
private DropDownPreference mDaysToRetain;
|
private DropDownPreference mDaysToRetain;
|
||||||
private Preference mDeletionHelper;
|
private Preference mDeletionHelper;
|
||||||
@@ -72,16 +69,11 @@ public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment
|
|||||||
mDeletionHelper.setOnPreferenceClickListener(this);
|
mDeletionHelper.setOnPreferenceClickListener(this);
|
||||||
|
|
||||||
mStorageManagerSwitch = (SwitchPreference) findPreference(KEY_STORAGE_MANAGER_SWITCH);
|
mStorageManagerSwitch = (SwitchPreference) findPreference(KEY_STORAGE_MANAGER_SWITCH);
|
||||||
boolean isChecked =
|
|
||||||
Settings.Secure.getInt(getContentResolver(),
|
|
||||||
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_ENABLED, 0) != 0;
|
|
||||||
mStorageManagerSwitch.setChecked(isChecked);
|
|
||||||
mStorageManagerSwitch.setOnPreferenceChangeListener(this);
|
mStorageManagerSwitch.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
SharedPreferences sharedPreferences =
|
int value = Settings.Secure.getInt(getContentResolver(),
|
||||||
getContext().getSharedPreferences(SHARED_PREFRENCES_NAME,
|
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN,
|
||||||
Context.MODE_PRIVATE);
|
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN_DEFAULT);
|
||||||
int value = sharedPreferences.getInt(KEY_DAYS_TO_RETAIN, DEFAULT_DAYS_TO_RETAIN);
|
|
||||||
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(value, stringValues)]);
|
||||||
@@ -90,7 +82,11 @@ public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
mDaysToRetain.setEnabled(mStorageManagerSwitch.isChecked());
|
boolean isChecked =
|
||||||
|
Settings.Secure.getInt(getContentResolver(),
|
||||||
|
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_ENABLED, 0) != 0;
|
||||||
|
mStorageManagerSwitch.setChecked(isChecked);
|
||||||
|
mDaysToRetain.setEnabled(isChecked);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -103,11 +99,9 @@ public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment
|
|||||||
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_ENABLED, checked ? 1 : 0);
|
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_ENABLED, checked ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
case KEY_DAYS:
|
case KEY_DAYS:
|
||||||
SharedPreferences.Editor editor =
|
Settings.Secure.putInt(getContentResolver(),
|
||||||
getContext().getSharedPreferences(SHARED_PREFRENCES_NAME,
|
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN,
|
||||||
Context.MODE_PRIVATE).edit();
|
Integer.parseInt((String) newValue));
|
||||||
editor.putInt(KEY_DAYS_TO_RETAIN, Integer.parseInt((String) newValue));
|
|
||||||
editor.apply();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user