Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e3bca2f authored by Lais Andrade's avatar Lais Andrade Committed by Android (Google) Code Review
Browse files

Merge "[Catalyst] Migrate touch and media vibration switch preferences" into main

parents 27534bc4 c76e8a0b
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -65,16 +65,17 @@

    <PreferenceCategory
        android:key="vibration_category_haptics"
        android:title="@string/accessibility_interactive_haptics_category_title">
        android:title="@string/accessibility_interactive_haptics_category_title"
        android:persistent="false">

        <SwitchPreferenceCompat
            android:key="vibration_preference_touch"
            android:key="haptic_feedback_intensity"
            android:title="@string/accessibility_touch_vibration_title"
            app:keywords="@string/keywords_touch_vibration"
            app:controller="com.android.settings.accessibility.HapticFeedbackTogglePreferenceController" />

        <SwitchPreferenceCompat
            android:key="vibration_preference_media"
            android:key="media_vibration_intensity"
            android:title="@string/accessibility_media_vibration_title"
            app:keywords="@string/keywords_media_vibration"
            app:controller="com.android.settings.accessibility.MediaVibrationTogglePreferenceController" />
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.Context;
import com.android.settings.accessibility.HapticFeedbackIntensityPreferenceController.HapticFeedbackVibrationPreferenceConfig;

/** Preference controller for haptic feedback with only a toggle for on/off states. */
// LINT.IfChange
public class HapticFeedbackTogglePreferenceController extends VibrationTogglePreferenceController {

    public HapticFeedbackTogglePreferenceController(Context context, String preferenceKey) {
@@ -32,3 +33,4 @@ public class HapticFeedbackTogglePreferenceController extends VibrationTogglePre
        return AVAILABLE;
    }
}
// LINT.ThenChange(TouchVibrationIntensitySwitchPreference.java)
+47 −0
Original line number Diff line number Diff line

/*
 * Copyright (C) 2025 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.accessibility

import android.content.Context
import android.os.VibrationAttributes
import android.provider.Settings
import com.android.settings.R
import com.android.settingslib.metadata.PreferenceAvailabilityProvider

/** Accessibility settings for media vibration. */
// LINT.IfChange
class MediaVibrationIntensitySwitchPreference :
    VibrationIntensitySwitchPreference(
        key = KEY,
        vibrationUsage = VibrationAttributes.USAGE_MEDIA,
        title = R.string.accessibility_media_vibration_title,
    ), PreferenceAvailabilityProvider {
    override val keywords: Int
        get() = R.string.keywords_media_vibration

    override fun isAvailable(context: Context) = context.isMediaVibrationPreferenceSupported()

    companion object {
        const val KEY = Settings.System.MEDIA_VIBRATION_INTENSITY
    }
}

/** Returns true is media vibration preference is supported by this device. */
private fun Context.isMediaVibrationPreferenceSupported(): Boolean =
    resources.getBoolean(R.bool.config_media_vibration_supported)

// LINT.ThenChange(MediaVibrationTogglePreferenceController.java)
+3 −1
Original line number Diff line number Diff line
@@ -18,10 +18,11 @@ package com.android.settings.accessibility;

import android.content.Context;

import com.android.settings.accessibility.MediaVibrationIntensityPreferenceController.MediaVibrationPreferenceConfig;
import com.android.settings.R;
import com.android.settings.accessibility.MediaVibrationIntensityPreferenceController.MediaVibrationPreferenceConfig;

/** Preference controller for alarm vibration with only a toggle for on/off states. */
// LINT.IfChange
public class MediaVibrationTogglePreferenceController extends VibrationTogglePreferenceController {

    public MediaVibrationTogglePreferenceController(Context context, String preferenceKey) {
@@ -34,3 +35,4 @@ public class MediaVibrationTogglePreferenceController extends VibrationTogglePre
                AVAILABLE : UNSUPPORTED_ON_DEVICE;
    }
}
// LINT.ThenChange(MediaVibrationIntensitySwitchPreference.java)
+37 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.accessibility

import android.os.VibrationAttributes
import android.provider.Settings
import com.android.settings.R

/** Accessibility settings for touch haptic feedback. */
// LINT.IfChange
class TouchVibrationIntensitySwitchPreference :
    VibrationIntensitySwitchPreference(
        key = KEY,
        vibrationUsage = VibrationAttributes.USAGE_TOUCH,
        title = R.string.accessibility_touch_vibration_title,
    ) {
    override val keywords: Int
        get() = R.string.keywords_touch_vibration

    companion object {
        const val KEY = Settings.System.HAPTIC_FEEDBACK_INTENSITY
    }
}
// LINT.ThenChange(HapticFeedbackTogglePreferenceController.java)
Loading