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

Commit 441a16a0 authored by Chun-Ku Lin's avatar Chun-Ku Lin
Browse files

Create PreferenceControllers and xml that will be used by

AccessibilityActivity detail screen

Bug: 406052931
Test: atest com.android.settings.accessibility
Flag: EXEMPT no actual usage yet

Change-Id: If82b88ed93d094a14d815dfe0d5856652be07952
parent 2f618e74
Loading
Loading
Loading
Loading
+81 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ 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.
  -->

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <com.android.settingslib.widget.TopIntroPreference
        android:key="top_intro"
        app:controller="com.android.settings.accessibility.detail.a11yactivity.TopIntroPreferenceController"
        app:searchable="false"
        tools:title="Top intro title" />

    <com.android.settingslib.widget.IllustrationPreference
        android:key="animated_image"
        app:controller="com.android.settings.accessibility.detail.a11yactivity.AccessibilityActivityIllustrationPreferenceController"
        app:searchable="false" />

    <com.android.settingslib.widget.ButtonPreference
        android:key="launch_preference"
        app:buttonPreferenceSize="extra"
        app:buttonPreferenceType="tonal"
        app:controller="com.android.settings.accessibility.detail.a11yactivity.LaunchAccessibilityActivityPreferenceController"
        tools:title="Open XXX" />

    <PreferenceCategory
        android:key="general_categories"
        android:title="@string/accessibility_screen_option"
        app:searchable="false">

        <com.android.settings.accessibility.ShortcutPreference
            android:key="shortcut_preference_key"
            android:persistent="false"
            app:controller="com.android.settings.accessibility.detail.a11yactivity.ShortcutPreferenceController"
            tools:title="Sound Amplifier shortcuts" />

        <Preference
            android:iconSpaceReserved="false"
            android:key="accessibility_activity_settings"
            android:persistent="false"
            android:title="@string/accessibility_menu_item_settings"
            app:controller="com.android.settings.accessibility.detail.a11yactivity.SettingsPreferenceController"
            app:searchable="false" />

        <Preference
            android:iconSpaceReserved="false"
            android:key="accessibility_activity_app_info"
            android:persistent="false"
            android:title="@string/application_info_label"
            app:controller="com.android.settings.accessibility.shared.LaunchAppInfoPreferenceController"
            app:searchable="false" />

    </PreferenceCategory>

    <com.android.settings.accessibility.AccessibilityFooterPreference
        android:key="html_footer_info"
        tools:title="html footer"
        app:controller="com.android.settings.accessibility.detail.a11yactivity.AccessibilityActivityHtmlFooterPreferenceController"
        app:searchable="false" />

    <com.android.settings.accessibility.AccessibilityFooterPreference
        android:key="footer_info"
        tools:title="footer"
        app:controller="com.android.settings.accessibility.detail.a11yactivity.AccessibilityActivityFooterPreferenceController"
        app:searchable="false" />

</PreferenceScreen>
+8 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ public class AccessibilityFooterPreferenceController extends BasePreferenceContr

    @Override
    public int getAvailabilityStatus() {
        return AVAILABLE;
        return AVAILABLE_UNSEARCHABLE;
    }

    @Override
@@ -140,5 +140,12 @@ public class AccessibilityFooterPreferenceController extends BasePreferenceContr

        // Grouping subcomponents to make more accessible.
        footerPreference.setSelectable(false);

        if (TextUtils.isEmpty(footerPreference.getTitle())
                && TextUtils.isEmpty(footerPreference.getSummary())) {
            footerPreference.setVisible(false);
        } else {
            footerPreference.setVisible(true);
        }
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -44,7 +44,8 @@ public final class AccessibilityStatsLogUtils {
     * @param componentName component name of the service
     * @param enabled       {@code true} if the service is enabled
     */
    static void logAccessibilityServiceEnabled(ComponentName componentName, boolean enabled) {
    public static void logAccessibilityServiceEnabled(
            ComponentName componentName, boolean enabled) {
        SettingsStatsLog.write(SettingsStatsLog.ACCESSIBILITY_SERVICE_REPORTED,
                componentName.flattenToString(), convertToLoggingServiceEnabled(enabled));
    }
+9 −2
Original line number Diff line number Diff line
@@ -42,14 +42,21 @@ open class HtmlFooterPreferenceController(context: Context, prefKey: String) :
     * getter.
     */
    override fun setSummary(summary: CharSequence) {
        val htmlDescription: CharSequence =
        setSummary(summary, isHtml = true)
    }

    protected fun setSummary(summary: CharSequence, isHtml: Boolean) {
        val description: CharSequence = if (isHtml) {
            Html.fromHtml(
                summary.toString(),
                Html.FROM_HTML_MODE_COMPACT,
                /* imageGetter= */ null,
                /* tagHandler= */ null,
            )
        super.setSummary(htmlDescription)
        } else {
            summary
        }
        super.setSummary(description)
    }
}

+2 −1
Original line number Diff line number Diff line
@@ -39,7 +39,8 @@ open class IllustrationPreferenceController(context: Context, prefKey: String) :
        this.contentDescription = contentDescription
    }

    override fun getAvailabilityStatus(): Int = AVAILABLE_UNSEARCHABLE
    override fun getAvailabilityStatus(): Int =
        if (imageUri != null) AVAILABLE_UNSEARCHABLE else CONDITIONALLY_UNAVAILABLE

    override fun displayPreference(screen: PreferenceScreen?) {
        super.displayPreference(screen)
Loading