2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.settings;
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;
25 public class ProgressCategory extends ProgressCategoryBase {
27 private boolean mProgress = false;
28 private Preference mNoDeviceFoundPreference;
30 public ProgressCategory(Context context, AttributeSet attrs) {
31 super(context, attrs);
32 setLayoutResource(R.layout.preference_progress_category);
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);
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);
47 if (mNoDeviceFoundPreference != null) {
48 removePreference(mNoDeviceFoundPreference);
52 if (mNoDeviceFoundPreference == null) {
53 mNoDeviceFoundPreference = new Preference(getContext());
54 mNoDeviceFoundPreference.setSummary(R.string.bluetooth_no_devices_found);
56 addPreference(mNoDeviceFoundPreference);
62 public void setProgress(boolean progressOn) {
63 mProgress = progressOn;