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

Commit 5aa8cbf3 authored by Jacky Wang's avatar Jacky Wang
Browse files

[Catalyst] Move getPreferenceSummary out of PreferenceMetadata

PreferenceMetadata.getPreferenceSummary is implementation detail.

Bug: 388167106
Flag: EXEMPT refactor
Test: atest
Change-Id: If6726f0b4420eafa7107e6bf2710163faf4b72ff
parent d33d3f8d
Loading
Loading
Loading
Loading
+0 −13
Original line number Diff line number Diff line
@@ -150,19 +150,6 @@ interface PreferenceMetadata {
            else -> null
        }

    /**
     * Returns the preference summary.
     *
     * Implement [PreferenceSummaryProvider] interface if summary content is generated dynamically
     * (e.g. summary is provided per preference value).
     */
    fun getPreferenceSummary(context: Context): CharSequence? =
        when {
            summary != 0 -> context.getText(summary)
            this is PreferenceSummaryProvider -> getSummary(context)
            else -> null
        }

    /**
     * Returns the preference icon.
     *
+27 −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.settingslib.metadata

import android.content.Context

/** Returns the preference summary. */
fun PreferenceMetadata.getPreferenceSummary(context: Context): CharSequence? =
    when {
        summary != 0 -> context.getText(summary)
        this is PreferenceSummaryProvider -> getSummary(context)
        else -> null
    }
+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import com.android.settingslib.metadata.IntRangeValuePreference
import com.android.settingslib.metadata.PreferenceAvailabilityProvider
import com.android.settingslib.metadata.PreferenceMetadata
import com.android.settingslib.metadata.PreferenceScreenMetadata
import com.android.settingslib.metadata.getPreferenceSummary

/** Binding of preference widget and preference metadata. */
interface PreferenceBinding {