165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane/*
265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * Copyright (C) 2014 The Android Open Source Project
365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane *
465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * Licensed under the Apache License, Version 2.0 (the "License");
565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * you may not use this file except in compliance with the License.
665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * You may obtain a copy of the License at
765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane *
865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane *      http://www.apache.org/licenses/LICENSE-2.0
965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane *
1065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * Unless required by applicable law or agreed to in writing, software
1165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * distributed under the License is distributed on an "AS IS" BASIS,
1265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * See the License for the specific language governing permissions and
1465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * limitations under the License.
1565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane */
1665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane
1765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lanepackage com.android.tv.settings.device.storage;
1865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane
1965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport com.android.tv.settings.R;
2065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport com.android.tv.settings.dialog.old.Action;
2165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane
2265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport android.content.Context;
2365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport android.content.Intent;
2465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport android.content.res.Resources;
2565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport android.graphics.drawable.ShapeDrawable;
2665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport android.graphics.drawable.shapes.RectShape;
2765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane
2865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lanepublic enum StorageItem {
2965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane    AVAILABLE(R.string.storage_available, R.color.storage_avail,
3065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane            R.drawable.storage_indicator_available),
3165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane    APPS(R.string.storage_apps_usage, R.color.storage_apps_usage,
3265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane            R.drawable.storage_indicator_apps),
3365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane    PICTURES_VIDEO(R.string.storage_dcim_usage, R.color.storage_dcim,
3465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane            R.drawable.storage_indicator_dcim),
3565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane    AUDIO(R.string.storage_music_usage, R.color.storage_music, R.drawable.storage_indicator_music),
3665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane    DOWNLOADS(R.string.storage_downloads_usage, R.color.storage_downloads,
3765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane            R.drawable.storage_indicator_downloads),
3865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane    CACHED_DATA(R.string.storage_media_cache_usage, R.color.storage_cache,
3965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane            R.drawable.storage_indicator_cache),
4065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane    MISC(R.string.storage_media_misc_usage, R.color.storage_misc,
4165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane            R.drawable.storage_indicator_misc);
4265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane
4365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane    private final int mTitleResource;
4465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane    private final int mColorResource;
4565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane    private final int mIndicatorResource;
4665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane
4765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane    private StorageItem(int titleResource, int colorResource, int indicatorResource) {
4865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane        mTitleResource = titleResource;
4965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane        mColorResource = colorResource;
5065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane        mIndicatorResource = indicatorResource;
5165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane    }
5265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane
5365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane    public int getColor(Resources resources) {
5465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane        return resources.getColor(mColorResource);
5565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane    }
5665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane
5765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane    Action toAction(Resources resources, String description) {
5865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane        return new Action.Builder()
5965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane                .key(name())
6065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane                .title(resources.getString(mTitleResource))
6165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane                .description(description)
6265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane                .drawableResource(mIndicatorResource)
6365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane                .infoOnly(true)
6465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane                .build();
6565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane    }
6665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane}
67