Merge "Add the automatic storage manager settings." into nyc-mr1-dev
am: 699efba106
* commit '699efba10667eb18bd28de02aebb549257baf53e':
Add the automatic storage manager settings.
Change-Id: I7518c8784a43ee522ebc3ff06097c474b24d2725
This commit is contained in:
@@ -1031,4 +1031,18 @@
|
||||
<item>Red</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Automatic storage management settings. The amount of days for the automatic storage manager
|
||||
to retain. These are shown in a list dialog. [CHAR LIMIT=70] -->
|
||||
<string-array name="automatic_storage_management_days">
|
||||
<item>Over 30 days old</item>
|
||||
<item>Over 60 days old</item>
|
||||
<item>Over 90 days old</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="automatic_storage_management_days_values" translatable="false">
|
||||
<item>30</item>
|
||||
<item>60</item>
|
||||
<item>90</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
@@ -40,4 +40,7 @@
|
||||
|
||||
<!-- Whether none security option is hide or not (country specific). -->
|
||||
<bool name="config_hide_none_security_option">false</bool>
|
||||
|
||||
<!--Whether the storage manager exists. -->
|
||||
<bool name="config_has_storage_manager">false</bool>
|
||||
</resources>
|
||||
|
@@ -7602,4 +7602,13 @@
|
||||
<!-- Button label for the dialog prompt for clearing data in deletion helper. [CHAR LIMIT=40] -->
|
||||
<string name="deletion_helper_clear_dialog_remove">Remove</string>
|
||||
|
||||
<!-- Used as title on the automatic storage manager settings. [CHAR LIMIT=60] -->
|
||||
<string name="automatic_storage_manager_settings">Storage manager</string>
|
||||
|
||||
<!-- Used as wall of text to describe the feature. [CHAR LIMIT=NONE] -->
|
||||
<string name="automatic_storage_manager_text">To help free up storage space, storage manager removes backed up photos and videos from your device.</string>
|
||||
|
||||
<!-- Dropdown preference title for dropdown describing how many days of data to retain.-->
|
||||
<string name="automatic_storage_manager_days_title">Remove photos & videos</string>
|
||||
|
||||
</resources>
|
||||
|
35
res/xml/automatic_storage_management_settings.xml
Normal file
35
res/xml/automatic_storage_management_settings.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2016 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:title="@string/automatic_storage_manager_settings" >
|
||||
|
||||
<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"/>
|
||||
|
||||
<com.android.settings.fuelgauge.WallOfTextPreference
|
||||
android:key="disclaimer"
|
||||
android:summary="@string/automatic_storage_manager_text"
|
||||
android:persistent="false"
|
||||
android:selectable="false"
|
||||
settings:allowDividerAbove="true" />
|
||||
|
||||
</PreferenceScreen>
|
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.deletionhelper;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Switch;
|
||||
import android.support.v7.preference.DropDownPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
import com.android.settings.widget.SwitchBar.OnSwitchChangeListener;
|
||||
|
||||
/**
|
||||
* AutomaticStorageManagerSettings is the Settings screen for configuration and management of the
|
||||
* automatic storage manager.
|
||||
*/
|
||||
public class AutomaticStorageManagerSettings extends SettingsPreferenceFragment implements
|
||||
OnSwitchChangeListener, OnPreferenceChangeListener {
|
||||
private static final String KEY_DAYS = "days";
|
||||
|
||||
private SwitchBar mSwitchBar;
|
||||
private DropDownPreference mDaysToRetain;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.automatic_storage_management_settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
Activity activity = getActivity();
|
||||
mSwitchBar = ((SettingsActivity) activity).getSwitchBar();
|
||||
mSwitchBar.show();
|
||||
mSwitchBar.addOnSwitchChangeListener(this);
|
||||
// TODO: Initialize the switch bar position based on if the storage manager is active.
|
||||
|
||||
mDaysToRetain = (DropDownPreference) findPreference(KEY_DAYS);
|
||||
mDaysToRetain.setOnPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
// TODO: Initialize the switch bar position based on if the storage manager is active.
|
||||
maybeShowDayDropdown(mSwitchBar.isChecked());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSwitchChanged(Switch switchView, boolean isChecked) {
|
||||
// TODO: Flip a setting which controls if the storage manager should run.
|
||||
maybeShowDayDropdown(isChecked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
// TODO: Configure a setting which controls how many days of data the storage manager
|
||||
// should retain.
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMetricsCategory() {
|
||||
return MetricsEvent.STORAGE_MANAGER_SETTINGS;
|
||||
}
|
||||
|
||||
private void maybeShowDayDropdown(boolean shouldShow) {
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
if (shouldShow) {
|
||||
screen.addPreference(mDaysToRetain);
|
||||
} else {
|
||||
screen.removePreference(mDaysToRetain);
|
||||
}
|
||||
}
|
||||
}
|
@@ -59,6 +59,7 @@ import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.applications.ManageApplications;
|
||||
import com.android.settings.deletionhelper.DeletionHelperFragment;
|
||||
import com.android.settings.deletionhelper.AutomaticStorageManagerSettings;
|
||||
import com.android.settings.deviceinfo.StorageSettings.MountTask;
|
||||
import com.android.settingslib.deviceinfo.StorageMeasurement;
|
||||
import com.android.settingslib.deviceinfo.StorageMeasurement.MeasurementDetails;
|
||||
@@ -117,6 +118,7 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
||||
private int mItemPoolIndex;
|
||||
|
||||
private Preference mExplore;
|
||||
private Preference mAutomaticStorageManagement;
|
||||
|
||||
private boolean mNeedsUpdate;
|
||||
|
||||
@@ -164,6 +166,7 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
||||
mCurrentUser = mUserManager.getUserInfo(UserHandle.myUserId());
|
||||
|
||||
mExplore = buildAction(R.string.storage_menu_explore);
|
||||
mAutomaticStorageManagement = buildAction(R.string.storage_settings);
|
||||
|
||||
mNeedsUpdate = true;
|
||||
|
||||
@@ -190,6 +193,9 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
||||
|
||||
screen.removeAll();
|
||||
|
||||
if (getResources().getBoolean(R.bool.config_has_storage_manager)) {
|
||||
addPreference(screen, mAutomaticStorageManagement);
|
||||
}
|
||||
addPreference(screen, mSummary);
|
||||
|
||||
List<UserInfo> allUsers = mUserManager.getUsers();
|
||||
@@ -475,6 +481,11 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
||||
case R.string.storage_menu_explore: {
|
||||
intent = mSharedVolume.buildBrowseIntent();
|
||||
} break;
|
||||
case R.string.storage_settings: {
|
||||
startFragment(this, AutomaticStorageManagerSettings.class.getCanonicalName(),
|
||||
R.string.automatic_storage_manager_settings, 0, null);
|
||||
return true;
|
||||
}
|
||||
case 0: {
|
||||
UserInfoFragment.show(this, pref.getTitle(), pref.getSummary());
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user