comparison app/src/main/java/com/five_ten_sg/connectbot/util/VolumePreference.java @ 438:d29cce60f393

migrate from Eclipse to Android Studio
author Carl Byington <carl@five-ten-sg.com>
date Thu, 03 Dec 2015 11:23:55 -0800
parents src/com/five_ten_sg/connectbot/util/VolumePreference.java@0ce5cc452d02
children
comparison
equal deleted inserted replaced
437:208b31032318 438:d29cce60f393
1 /*
2 * ConnectBot: simple, powerful, open-source SSH client for Android
3 * Copyright 2007 Kenny Root, Jeffrey Sharkey
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package com.five_ten_sg.connectbot.util;
19
20 import android.content.Context;
21 import android.preference.DialogPreference;
22 import android.util.AttributeSet;
23 import android.view.View;
24 import android.widget.SeekBar;
25 import android.widget.SeekBar.OnSeekBarChangeListener;
26
27 /**
28 * @author kenny
29 *
30 */
31 public class VolumePreference extends DialogPreference implements OnSeekBarChangeListener {
32 /**
33 * @param context
34 * @param attrs
35 */
36 public VolumePreference(Context context, AttributeSet attrs) {
37 super(context, attrs);
38 setupLayout(context, attrs);
39 }
40
41 public VolumePreference(Context context, AttributeSet attrs, int defStyle) {
42 super(context, attrs, defStyle);
43 setupLayout(context, attrs);
44 }
45
46 private void setupLayout(Context context, AttributeSet attrs) {
47 setPersistent(true);
48 }
49
50 @Override
51 protected View onCreateDialogView() {
52 SeekBar sb = new SeekBar(getContext());
53 sb.setMax(100);
54 sb.setProgress((int)(getPersistedFloat(
55 PreferenceConstants.DEFAULT_BELL_VOLUME) * 100));
56 sb.setPadding(10, 10, 10, 10);
57 sb.setOnSeekBarChangeListener(this);
58 return sb;
59 }
60
61 public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
62 persistFloat(progress / 100f);
63 }
64
65 public void onStartTrackingTouch(SeekBar seekBar) { }
66
67 public void onStopTrackingTouch(SeekBar seekBar) { }
68 }