OSDN Git Service

am 57c88834: (-s ours) am 9fe36302: (-s ours) am 9cb97c44: Merge "DO NOT MERGE Fix...
[android-x86/packages-apps-Settings.git] / src / com / android / settings / ProgressCategory.java
1 /*
2  * Copyright (C) 2008 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;
18
19 import android.content.Context;
20 import android.preference.Preference;
21 import android.util.AttributeSet;
22 import android.view.View;
23 import android.widget.TextView;
24
25 public class ProgressCategory extends ProgressCategoryBase {
26
27     private boolean mProgress = false;
28     private Preference mNoDeviceFoundPreference;
29
30     public ProgressCategory(Context context, AttributeSet attrs) {
31         super(context, attrs);
32         setLayoutResource(R.layout.preference_progress_category);
33     }
34     
35     @Override
36     public void onBindView(View view) {
37         super.onBindView(view);
38         final TextView textView = (TextView) view.findViewById(R.id.scanning_text);
39         final View progressBar = view.findViewById(R.id.scanning_progress);
40
41         textView.setText(mProgress ? R.string.progress_scanning : R.string.progress_tap_to_pair);
42         boolean noDeviceFound = getPreferenceCount() == 0;
43         textView.setVisibility(noDeviceFound ? View.INVISIBLE : View.VISIBLE);
44         progressBar.setVisibility(mProgress ? View.VISIBLE : View.INVISIBLE);
45
46         if (mProgress) {
47             if (mNoDeviceFoundPreference != null) {
48                 removePreference(mNoDeviceFoundPreference);
49             }
50         } else {
51             if (noDeviceFound) {
52                 if (mNoDeviceFoundPreference == null) {
53                     mNoDeviceFoundPreference = new Preference(getContext());
54                     mNoDeviceFoundPreference.setSummary(R.string.bluetooth_no_devices_found);
55                 }
56                 addPreference(mNoDeviceFoundPreference);
57             }
58         }
59     }
60
61     @Override
62     public void setProgress(boolean progressOn) {
63         mProgress = progressOn;
64         notifyChanged();
65     }
66 }
67