Extends SeekBarPreference to add labels and callbacks
Adds title, left and right labels to the SeekBarPreference. Also adds a listener for the seek stop event. Bug: 146004827 Test: make RunSettingsRoboTests ROBOTEST_FILTER=GestureNavigationSeekBarPreferenceTest Change-Id: I0ecca4e92cfc52abb8bb975b710f72f75ed5b50d
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.gestures;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
import androidx.core.content.res.TypedArrayUtils;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.widget.SeekBarPreference;
|
||||
|
||||
/** A slider preference that is used to set the back gesture's sensitivity **/
|
||||
public class GestureNavigationSeekBarPreference extends SeekBarPreference {
|
||||
|
||||
private OnPreferenceChangeListener mStopListener;
|
||||
|
||||
public GestureNavigationSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
|
||||
int defStyleRes) {
|
||||
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
setLayoutResource(R.layout.preference_gesture_navigation_slider);
|
||||
}
|
||||
|
||||
public GestureNavigationSeekBarPreference(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, TypedArrayUtils.getAttr(context,
|
||||
androidx.preference.R.attr.seekBarPreferenceStyle,
|
||||
com.android.internal.R.attr.seekBarPreferenceStyle), 0);
|
||||
}
|
||||
|
||||
public void setOnPreferenceChangeStopListener(OnPreferenceChangeListener listener) {
|
||||
mStopListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
super.onStopTrackingTouch(seekBar);
|
||||
|
||||
if (mStopListener != null) {
|
||||
mStopListener.onPreferenceChange(this, seekBar.getProgress());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user