1/* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.tv.settings.device.storage; 18 19import com.android.tv.settings.R; 20import com.android.tv.settings.dialog.old.Action; 21 22import android.content.Context; 23import android.content.Intent; 24import android.content.res.Resources; 25import android.graphics.drawable.ShapeDrawable; 26import android.graphics.drawable.shapes.RectShape; 27 28public enum StorageItem { 29 AVAILABLE(R.string.storage_available, R.color.storage_avail, 30 R.drawable.storage_indicator_available), 31 APPS(R.string.storage_apps_usage, R.color.storage_apps_usage, 32 R.drawable.storage_indicator_apps), 33 PICTURES_VIDEO(R.string.storage_dcim_usage, R.color.storage_dcim, 34 R.drawable.storage_indicator_dcim), 35 AUDIO(R.string.storage_music_usage, R.color.storage_music, R.drawable.storage_indicator_music), 36 DOWNLOADS(R.string.storage_downloads_usage, R.color.storage_downloads, 37 R.drawable.storage_indicator_downloads), 38 CACHED_DATA(R.string.storage_media_cache_usage, R.color.storage_cache, 39 R.drawable.storage_indicator_cache), 40 MISC(R.string.storage_media_misc_usage, R.color.storage_misc, 41 R.drawable.storage_indicator_misc); 42 43 private final int mTitleResource; 44 private final int mColorResource; 45 private final int mIndicatorResource; 46 47 private StorageItem(int titleResource, int colorResource, int indicatorResource) { 48 mTitleResource = titleResource; 49 mColorResource = colorResource; 50 mIndicatorResource = indicatorResource; 51 } 52 53 public int getColor(Resources resources) { 54 return resources.getColor(mColorResource); 55 } 56 57 Action toAction(Resources resources, String description) { 58 return new Action.Builder() 59 .key(name()) 60 .title(resources.getString(mTitleResource)) 61 .description(description) 62 .drawableResource(mIndicatorResource) 63 .infoOnly(true) 64 .build(); 65 } 66} 67