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

Commit 27aa5f9d authored by PETER LIANG's avatar PETER LIANG Committed by Android (Google) Code Review
Browse files

Merge "Logging for the feature "Text and reading options" in Android T." into tm-dev

parents 36639869 fcce62aa
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -41,7 +41,8 @@
            android:icon="@drawable/ic_adaptive_font_download"
            android:key="text_reading_options"
            android:persistent="false"
            android:title="@string/accessibility_text_reading_options_title" />
            android:title="@string/accessibility_text_reading_options_title"
            settings:controller="com.android.settings.accessibility.TextReadingFragmentForA11ySettingsController"/>

        <Preference
            android:fragment="com.android.settings.accessibility.ColorAndMotionFragment"
+2 −1
Original line number Diff line number Diff line
@@ -26,7 +26,8 @@
        android:key="text_reading_options"
        android:persistent="false"
        android:title="@string/accessibility_text_reading_options_title"
        settings:keywords="text_reading_options" />
        settings:keywords="text_reading_options"
        settings:controller="com.android.settings.accessibility.TextReadingFragmentForSuwController"/>

    <Preference
        android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragmentForSetupWizard"
+2 −1
Original line number Diff line number Diff line
@@ -72,7 +72,8 @@
            android:fragment="com.android.settings.accessibility.TextReadingPreferenceFragment"
            android:key="text_reading_options"
            android:persistent="false"
            android:title="@string/accessibility_text_reading_options_title" />
            android:title="@string/accessibility_text_reading_options_title"
            settings:controller="com.android.settings.accessibility.TextReadingFragmentForDisplaySettingsController"/>
    </PreferenceCategory>

    <PreferenceCategory
+54 −0
Original line number Diff line number Diff line
@@ -16,6 +16,16 @@

package com.android.settings.accessibility;

import static com.android.settings.accessibility.TextReadingPreferenceFragment.BOLD_TEXT_KEY;
import static com.android.settings.accessibility.TextReadingPreferenceFragment.DISPLAY_SIZE_KEY;
import static com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint.ACCESSIBILITY_SETTINGS;
import static com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint.DISPLAY_SETTINGS;
import static com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint.SUW_ANYTHING_ELSE;
import static com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint.SUW_VISION_SETTINGS;
import static com.android.settings.accessibility.TextReadingPreferenceFragment.FONT_SIZE_KEY;
import static com.android.settings.accessibility.TextReadingPreferenceFragment.HIGH_TEXT_CONTRAST_KEY;
import static com.android.settings.accessibility.TextReadingPreferenceFragment.RESET_KEY;

import android.content.ComponentName;

import com.android.settings.core.instrumentation.SettingsStatsLog;
@@ -58,4 +68,48 @@ public final class AccessibilityStatsLogUtils {
                                .ACCESSIBILITY_PRIVACY_WARNING_STATUS_SERVICE_DISABLED,
                        durationMills);
    }

    /**
     * Converts to the key name for logging.
     *
     * @param prefKey the preference key
     * @return the int value which maps to the key name
     */
    static int convertToItemKeyName(String prefKey) {
        switch (prefKey) {
            case FONT_SIZE_KEY:
                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__NAME__TEXT_READING_FONT_SIZE;
            case DISPLAY_SIZE_KEY:
                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__NAME__TEXT_READING_DISPLAY_SIZE;
            case BOLD_TEXT_KEY:
                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__NAME__TEXT_READING_BOLD_TEXT;
            case HIGH_TEXT_CONTRAST_KEY:
                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__NAME__TEXT_READING_HIGH_CONTRAST_TEXT;
            case RESET_KEY:
                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__NAME__TEXT_READING_RESET;
            default:
                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__NAME__TEXT_READING_UNKNOWN_ITEM;
        }
    }

    /**
     * Converts to the entry point for logging.
     *
     * @param entryPoint the entry point
     * @return the int value which maps to the entry point
     */
    static int convertToEntryPoint(int entryPoint) {
        switch (entryPoint) {
            case SUW_VISION_SETTINGS:
                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__ENTRY_POINT__TEXT_READING_SUW_VISION_SETTINGS;
            case SUW_ANYTHING_ELSE:
                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__ENTRY_POINT__TEXT_READING_SUW_ANYTHING_ELSE;
            case DISPLAY_SETTINGS:
                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__ENTRY_POINT__TEXT_READING_DISPLAY_SETTINGS;
            case ACCESSIBILITY_SETTINGS:
                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__ENTRY_POINT__TEXT_READING_ACCESSIBILITY_SETTINGS;
            default:
                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__ENTRY_POINT__TEXT_READING_UNKNOWN_ENTRY;
        }
    }
}
+20 −0
Original line number Diff line number Diff line
@@ -21,7 +21,9 @@ import android.graphics.fonts.FontStyle;
import android.provider.Settings;

import com.android.settings.R;
import com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint;
import com.android.settings.core.TogglePreferenceController;
import com.android.settings.core.instrumentation.SettingsStatsLog;

/** PreferenceController for displaying all text in bold. */
public class FontWeightAdjustmentPreferenceController extends TogglePreferenceController implements
@@ -29,6 +31,9 @@ public class FontWeightAdjustmentPreferenceController extends TogglePreferenceCo
    static final int BOLD_TEXT_ADJUSTMENT =
            FontStyle.FONT_WEIGHT_BOLD - FontStyle.FONT_WEIGHT_NORMAL;

    @EntryPoint
    private int mEntryPoint;

    public FontWeightAdjustmentPreferenceController(Context context, String preferenceKey) {
        super(context, preferenceKey);
    }
@@ -46,6 +51,12 @@ public class FontWeightAdjustmentPreferenceController extends TogglePreferenceCo

    @Override
    public boolean setChecked(boolean isChecked) {
        SettingsStatsLog.write(
                SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED,
                AccessibilityStatsLogUtils.convertToItemKeyName(getPreferenceKey()),
                isChecked ? 1 : 0,
                AccessibilityStatsLogUtils.convertToEntryPoint(mEntryPoint));

        return Settings.Secure.putInt(mContext.getContentResolver(),
                Settings.Secure.FONT_WEIGHT_ADJUSTMENT, (isChecked ? BOLD_TEXT_ADJUSTMENT : 0));
    }
@@ -59,4 +70,13 @@ public class FontWeightAdjustmentPreferenceController extends TogglePreferenceCo
    public void resetState() {
        setChecked(false);
    }

    /**
     * The entry point is used for logging.
     *
     * @param entryPoint from which settings page
     */
    void setEntryPoint(@EntryPoint int entryPoint) {
        mEntryPoint = entryPoint;
    }
}
Loading