• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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 
17 package com.android.settings.deviceinfo;
18 
19 import android.content.Context;
20 import android.graphics.Color;
21 import android.support.v7.preference.Preference;
22 import android.support.v7.preference.PreferenceViewHolder;
23 import android.view.View;
24 import android.widget.ProgressBar;
25 import android.widget.TextView;
26 
27 import com.android.settings.R;
28 
29 public class StorageSummaryPreference extends Preference {
30     private int mPercent = -1;
31 
StorageSummaryPreference(Context context)32     public StorageSummaryPreference(Context context) {
33         super(context);
34 
35         setLayoutResource(R.layout.storage_summary);
36         setEnabled(false);
37     }
38 
setPercent(int percent)39     public void setPercent(int percent) {
40         mPercent = percent;
41     }
42 
43     @Override
onBindViewHolder(PreferenceViewHolder view)44     public void onBindViewHolder(PreferenceViewHolder view) {
45         final ProgressBar progress = (ProgressBar) view.findViewById(android.R.id.progress);
46         if (mPercent != -1) {
47             progress.setVisibility(View.VISIBLE);
48             progress.setProgress(mPercent);
49             progress.setScaleY(7f);
50         } else {
51             progress.setVisibility(View.GONE);
52         }
53 
54         final TextView summary = (TextView) view.findViewById(android.R.id.summary);
55         summary.setTextColor(Color.parseColor("#8a000000"));
56 
57         super.onBindViewHolder(view);
58     }
59 }
60