Add storage dashborad page.
Refactor shared dashboard page display logic between storage and system page. Bug: 31800690 Test: RunSettingsRoboTests Change-Id: I7eb86f590b79ab871bdb383fb2f5326790beb193
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.deviceinfo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceController;
|
||||
|
||||
public class ManageStoragePreferenceController extends PreferenceController {
|
||||
|
||||
public static final String KEY_MANAGE_STORAGE = "pref_manage_storage";
|
||||
|
||||
public ManageStoragePreferenceController(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
if (!isAvailable()) {
|
||||
removePreference(screen, KEY_MANAGE_STORAGE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a preference should be available on screen.
|
||||
*/
|
||||
private boolean isAvailable() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_storage_manager_settings_enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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.deviceinfo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
|
||||
public class StorageDashboardFragment extends DashboardFragment {
|
||||
|
||||
private static final String TAG = "StorageDashboardFrag";
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return STORAGE_CATEGORY_FRAGMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
addPreferenceController(new ManageStoragePreferenceController(context));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
super.onCreatePreferences(savedInstanceState, rootKey);
|
||||
refreshAllPreferences();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCategoriesChanged() {
|
||||
refreshAllPreferences();
|
||||
}
|
||||
|
||||
private void refreshAllPreferences() {
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
if (screen != null) {
|
||||
screen.removeAll();
|
||||
}
|
||||
addPreferencesFromResource(R.xml.storage_dashboard_fragment);
|
||||
|
||||
getPreferenceController(ManageStoragePreferenceController.class)
|
||||
.displayPreference(getPreferenceScreen());
|
||||
|
||||
displayTilesAsPreference(TAG, getPreferenceScreen(),
|
||||
mDashboardFeatureProvider.getTilesForStorageCategory());
|
||||
}
|
||||
}
|
||||
@@ -27,29 +27,27 @@ import android.util.Log;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.PreferenceController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static android.content.Context.CARRIER_CONFIG_SERVICE;
|
||||
|
||||
public class SystemUpdatePreferenceController {
|
||||
public class SystemUpdatePreferenceController extends PreferenceController {
|
||||
|
||||
private static final String TAG = "SysUpdatePrefContr";
|
||||
|
||||
static final String KEY_SYSTEM_UPDATE_SETTINGS = "system_update_settings";
|
||||
static final String KEY_UPDATE_SETTING = "additional_system_update_settings";
|
||||
|
||||
private final Context mContext;
|
||||
private final UserManager mUm;
|
||||
|
||||
public SystemUpdatePreferenceController(Context context, UserManager um) {
|
||||
mContext = context;
|
||||
super(context);
|
||||
mUm = um;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays preference in this controller.
|
||||
*/
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
if (isAvailable(mContext, KEY_SYSTEM_UPDATE_SETTINGS)) {
|
||||
Utils.updatePreferenceToSpecificActivityOrRemove(mContext, screen,
|
||||
@@ -79,12 +77,7 @@ public class SystemUpdatePreferenceController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles preference tree click
|
||||
*
|
||||
* @param preference the preference being clicked
|
||||
* @return true if click is handled
|
||||
*/
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (KEY_SYSTEM_UPDATE_SETTINGS.equals(preference.getKey())) {
|
||||
CarrierConfigManager configManager =
|
||||
@@ -113,16 +106,6 @@ public class SystemUpdatePreferenceController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes preference from screen.
|
||||
*/
|
||||
private void removePreference(PreferenceScreen screen, String key) {
|
||||
Preference pref = screen.findPreference(key);
|
||||
if (pref != null) {
|
||||
screen.removePreference(pref);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger client initiated action (send intent) on system update
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user