Add first pass at a new Storage screen.
This patch begins setting up the structure for the screen. The functionality for populating the data in the preferences is coming in a later patch. Bug: 33199077 Test: Settings Robo Tests Change-Id: I9ebad9d3896501e31ac715704ca986eceb36877d
This commit is contained in:
@@ -17,15 +17,24 @@
|
||||
package com.android.settings.deviceinfo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.storage.StorageManager;
|
||||
import android.os.storage.VolumeInfo;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceController;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.deviceinfo.storage.StorageItemPreferenceController;
|
||||
import com.android.settings.deviceinfo.storage.StorageSummaryDonutPreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.widget.FooterPreference;
|
||||
import com.android.settingslib.drawer.CategoryKey;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -33,9 +42,53 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class StorageDashboardFragment extends DashboardFragment {
|
||||
|
||||
private static final String TAG = "StorageDashboardFrag";
|
||||
|
||||
private VolumeInfo mVolume;
|
||||
private long mTotalSize;
|
||||
|
||||
private StorageSummaryDonutPreferenceController mSummaryController;
|
||||
|
||||
private boolean isVolumeValid() {
|
||||
return (mVolume != null) && (mVolume.getType() == VolumeInfo.TYPE_PRIVATE)
|
||||
&& mVolume.isMountedReadable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
final Context context = getActivity();
|
||||
|
||||
// Initialize the storage sizes that we can quickly calc.
|
||||
StorageManager sm = context.getSystemService(StorageManager.class);
|
||||
mVolume = sm.findVolumeById(VolumeInfo.ID_PRIVATE_INTERNAL);
|
||||
if (!isVolumeValid()) {
|
||||
getActivity().finish();
|
||||
return;
|
||||
}
|
||||
|
||||
final long sharedDataSize = mVolume.getPath().getTotalSpace();
|
||||
mTotalSize = sm.getPrimaryStorageSize();
|
||||
long systemSize = mTotalSize - sharedDataSize;
|
||||
|
||||
if (mTotalSize <= 0) {
|
||||
mTotalSize = sharedDataSize;
|
||||
systemSize = 0;
|
||||
}
|
||||
|
||||
final long usedBytes = mTotalSize - mVolume.getPath().getFreeSpace();
|
||||
mSummaryController.updateBytes(usedBytes, mTotalSize);
|
||||
|
||||
// Initialize the footer preference to go to the smart storage management.
|
||||
final FooterPreference pref = mFooterPreferenceMixin.createFooterPreference();
|
||||
pref.setTitle(R.string.storage_menu_manage);
|
||||
pref.setFragment("com.android.settings.deletionhelper.AutomaticStorageManagerSettings");
|
||||
pref.setIcon(R.drawable.ic_settings_storage);
|
||||
pref.setEnabled(true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.SETTINGS_STORAGE_CATEGORY;
|
||||
@@ -59,10 +112,25 @@ public class StorageDashboardFragment extends DashboardFragment {
|
||||
@Override
|
||||
protected List<PreferenceController> getPreferenceControllers(Context context) {
|
||||
final List<PreferenceController> controllers = new ArrayList<>();
|
||||
mSummaryController = new StorageSummaryDonutPreferenceController(context);
|
||||
controllers.add(mSummaryController);
|
||||
controllers.add(new ManageStoragePreferenceController(context));
|
||||
controllers.add(new StorageItemPreferenceController(context, "pref_photos_videos"));
|
||||
controllers.add(new StorageItemPreferenceController(context, "pref_music_audio"));
|
||||
controllers.add(new StorageItemPreferenceController(context, "pref_games"));
|
||||
controllers.add(new StorageItemPreferenceController(context, "pref_other_apps"));
|
||||
controllers.add(new StorageItemPreferenceController(context, "pref_system"));
|
||||
controllers.add(new StorageItemPreferenceController(context, "pref_files"));
|
||||
return controllers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View root = super.onCreateView(inflater, container, savedInstanceState);
|
||||
// TODO: Add loader to load the storage sizes for the StorageItemPreferenceControllers.
|
||||
return root;
|
||||
}
|
||||
/**
|
||||
* For Search.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user