• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 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.graphics.drawable.Drawable;
21 import android.util.AttributeSet;
22 import android.view.View;
23 import android.widget.ImageView;
24 import android.widget.SeekBar;
25 
26 /**
27  * Based on frameworks/base/core/java/android/preference/SeekBarDialogPreference.java
28  * except uses support lib preferences.
29  */
30 public class SeekBarDialogPreference extends CustomDialogPreference {
31     private final Drawable mMyIcon;
32 
SeekBarDialogPreference(Context context, AttributeSet attrs)33     public SeekBarDialogPreference(Context context, AttributeSet attrs) {
34         super(context, attrs);
35         setDialogLayoutResource(R.layout.preference_dialog_seekbar_material);
36 
37         createActionButtons();
38 
39         // Steal the XML dialogIcon attribute's value
40         mMyIcon = getDialogIcon();
41 
42         setDialogIcon(null);
43     }
44 
SeekBarDialogPreference(Context context)45     public SeekBarDialogPreference(Context context) {
46         this(context, null);
47     }
48 
49     // Allow subclasses to override the action buttons
createActionButtons()50     public void createActionButtons() {
51         setPositiveButtonText(android.R.string.ok);
52         setNegativeButtonText(android.R.string.cancel);
53     }
54 
55     @Override
onBindDialogView(View view)56     protected void onBindDialogView(View view) {
57         super.onBindDialogView(view);
58 
59         final ImageView iconView = (ImageView) view.findViewById(android.R.id.icon);
60         if (mMyIcon != null) {
61             iconView.setImageDrawable(mMyIcon);
62         } else {
63             iconView.setVisibility(View.GONE);
64         }
65     }
66 
getSeekBar(View dialogView)67     protected static SeekBar getSeekBar(View dialogView) {
68         return (SeekBar) dialogView.findViewById(R.id.seekbar);
69     }
70 }
71