Refactor GestureNavigationSeekBarPreference

- Make GestureNavigationSeekBarPreference more flexible to configure

Fixes: 146462894
Test: adb shell am start -a android.settings.ASSIST_GESTURE_SETTINGS
      adb shell am start -a com.android.settings.GESTURE_NAVIGATION_SETTINGS

Change-Id: Ibc7ed8456fe4a42f12f0d436f53756df268acfbe
This commit is contained in:
Raff Tsai
2019-12-20 13:29:10 +08:00
parent 4e561fb9cb
commit 00c79aecd1
6 changed files with 52 additions and 17 deletions

View File

@@ -1,59 +0,0 @@
/*
* 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());
}
}
}

View File

@@ -25,6 +25,7 @@ import android.view.WindowManager;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.LabeledSeekBarPreference;
import com.android.settingslib.search.SearchIndexable;
/**
@@ -108,7 +109,7 @@ public class GestureNavigationSettingsFragment extends DashboardFragment {
}
private void initSeekBarPreference(final String key) {
final GestureNavigationSeekBarPreference pref = getPreferenceScreen().findPreference(key);
final LabeledSeekBarPreference pref = getPreferenceScreen().findPreference(key);
pref.setContinuousUpdates(true);
final String settingsKey = key == LEFT_EDGE_SEEKBAR_KEY