Home | History | Annotate | Download | only in preferences
      1 /*
      2  * Copyright (C) 2011 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.browser.preferences;
     18 
     19 import android.content.Context;
     20 import android.preference.SeekBarPreference;
     21 import android.text.TextUtils;
     22 import android.util.AttributeSet;
     23 import android.view.View;
     24 import android.widget.SeekBar;
     25 import android.widget.TextView;
     26 
     27 import com.android.browser.R;
     28 
     29 public class SeekBarSummaryPreference extends SeekBarPreference {
     30 
     31     CharSequence mSummary;
     32     TextView mSummaryView;
     33 
     34     public SeekBarSummaryPreference(
     35             Context context, AttributeSet attrs, int defStyle) {
     36         super(context, attrs, defStyle);
     37         init();
     38     }
     39 
     40     public SeekBarSummaryPreference(Context context, AttributeSet attrs) {
     41         super(context, attrs);
     42         init();
     43     }
     44 
     45     public SeekBarSummaryPreference(Context context) {
     46         super(context);
     47         init();
     48     }
     49 
     50     void init() {
     51         setWidgetLayoutResource(R.layout.font_size_widget);
     52     }
     53 
     54     @Override
     55     public void setSummary(CharSequence summary) {
     56         mSummary = summary;
     57         if (mSummaryView != null) {
     58             mSummaryView.setText(mSummary);
     59         }
     60     }
     61 
     62     @Override
     63     public CharSequence getSummary() {
     64         return null;
     65     }
     66 
     67     @Override
     68     protected void onBindView(View view) {
     69         super.onBindView(view);
     70         mSummaryView = (TextView) view.findViewById(R.id.text);
     71         if (TextUtils.isEmpty(mSummary)) {
     72             mSummaryView.setVisibility(View.GONE);
     73         } else {
     74             mSummaryView.setVisibility(View.VISIBLE);
     75             mSummaryView.setText(mSummary);
     76         }
     77     }
     78 
     79     @Override
     80     public void onStartTrackingTouch(SeekBar seekBar) {
     81         // Intentionally blank - prevent super.onStartTrackingTouch from running
     82     }
     83 
     84     @Override
     85     public void onStopTrackingTouch(SeekBar seekBar) {
     86         // Intentionally blank - prevent onStopTrackingTouch from running
     87     }
     88 
     89 }
     90