Settings: Add a preference controller for Volume steps settings

* Enable volume steps pref by default
This commit is contained in:
Joey
2024-06-05 15:46:44 +09:00
parent f7df878d2f
commit f401bbc5ad
5 changed files with 45 additions and 6 deletions

View File

@@ -67,4 +67,7 @@
<!-- Whether to show double tap ambient settings -->
<bool name="config_supports_double_tap_ambient" translatable="false">false</bool>
<!-- Whether to show volume steps settings -->
<bool name="config_supports_volume_steps" translatable="false">true</bool>
</resources>

View File

@@ -116,8 +116,9 @@
android:key="volume_steps"
android:title="@string/volume_steps_title"
android:summary="@string/volume_steps_summary"
android:fragment="com.android.settings.sound.VolumeSteps"
android:order="-135"/>
android:fragment="com.android.settings.sound.VolumeStepsSettings"
android:order="-135"
settings:controller="com.android.settings.sound.VolumeStepsPreferenceController"/>
<!-- TODO(b/174964721): make this a PrimarySwitchPreference -->
<!-- Interruptions -->

View File

@@ -199,7 +199,7 @@ import com.android.settings.security.SecurityAdvancedSettings;
import com.android.settings.security.SecuritySettings;
import com.android.settings.shortcut.CreateShortcut;
import com.android.settings.sound.MediaControlsSettings;
import com.android.settings.sound.VolumeSteps;
import com.android.settings.sound.VolumeStepsSettings;
import com.android.settings.support.SupportDashboardActivity;
import com.android.settings.system.ResetDashboardFragment;
import com.android.settings.system.SystemDashboardFragment;
@@ -428,7 +428,7 @@ public class SettingsGateway {
ToggleScreenMagnificationPreferenceFragment.class.getName(),
FlashNotificationsPreferenceFragment.class.getName(),
PrivateDnsSettings.class.getName(),
VolumeSteps.class.getName(),
VolumeStepsSettings.class.getName(),
};
public static final String[] SETTINGS_FOR_RESTRICTED = {

View File

@@ -0,0 +1,35 @@
/*
* Copyright (C) 2019-2024 The Evolution X 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.sound;
import android.content.Context;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
public class VolumeStepsPreferenceController extends BasePreferenceController {
public VolumeStepsPreferenceController(Context context, String key) {
super(context, key);
}
@Override
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(R.bool.config_supports_volume_steps)
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
}

View File

@@ -37,10 +37,10 @@ import org.evolution.settings.preferences.CustomSeekBarPreference;
* volume steps settings under sound
*/
@SearchIndexable
public class VolumeSteps extends SettingsPreferenceFragment implements
public class VolumeStepsSettings extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener {
private static final String TAG = "VolumeSteps";
private static final String TAG = "VolumeStepsSettings";
@Override
public void onCreate(Bundle savedInstanceState) {