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

Commit 7cb31203 authored by Zekan Qian's avatar Zekan Qian Committed by Android (Google) Code Review
Browse files

Merge "Fix typo: marco -> macro"

parents 2a9aa054 f2cdc564
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ import com.android.settingslib.spa.gallery.preference.PreferencePageModel.Compan
import com.android.settingslib.spa.gallery.preference.PreferencePageModel.Companion.logMsg
import com.android.settingslib.spa.widget.preference.Preference
import com.android.settingslib.spa.widget.preference.PreferenceModel
import com.android.settingslib.spa.widget.preference.SimplePreferenceMarco
import com.android.settingslib.spa.widget.preference.SimplePreferenceMacro
import com.android.settingslib.spa.widget.scaffold.RegularScaffold
import com.android.settingslib.spa.widget.ui.SettingsIcon

@@ -74,18 +74,18 @@ object PreferencePageProvider : SettingsPageProvider {
        entryList.add(
            createEntry(EntryEnum.SIMPLE_PREFERENCE)
                .setIsAllowSearch(true)
                .setMarco {
                    logMsg("create marco for ${EntryEnum.SIMPLE_PREFERENCE}")
                    SimplePreferenceMarco(title = SIMPLE_PREFERENCE_TITLE)
                .setMacro {
                    logMsg("create macro for ${EntryEnum.SIMPLE_PREFERENCE}")
                    SimplePreferenceMacro(title = SIMPLE_PREFERENCE_TITLE)
                }
                .build()
        )
        entryList.add(
            createEntry(EntryEnum.SUMMARY_PREFERENCE)
                .setIsAllowSearch(true)
                .setMarco {
                    logMsg("create marco for ${EntryEnum.SUMMARY_PREFERENCE}")
                    SimplePreferenceMarco(
                .setMacro {
                    logMsg("create macro for ${EntryEnum.SUMMARY_PREFERENCE}")
                    SimplePreferenceMacro(
                        title = SIMPLE_PREFERENCE_TITLE,
                        summary = SIMPLE_PREFERENCE_SUMMARY,
                        searchKeywords = SIMPLE_PREFERENCE_KEYWORDS,
@@ -96,9 +96,9 @@ object PreferencePageProvider : SettingsPageProvider {
        entryList.add(
            createEntry(EntryEnum.DISABLED_PREFERENCE)
                .setIsAllowSearch(true)
                .setMarco {
                    logMsg("create marco for ${EntryEnum.DISABLED_PREFERENCE}")
                    SimplePreferenceMarco(
                .setMacro {
                    logMsg("create macro for ${EntryEnum.DISABLED_PREFERENCE}")
                    SimplePreferenceMacro(
                        title = DISABLE_PREFERENCE_TITLE,
                        summary = DISABLE_PREFERENCE_SUMMARY,
                        disabled = true,
@@ -167,9 +167,9 @@ object PreferencePageProvider : SettingsPageProvider {
    fun buildInjectEntry(): SettingsEntryBuilder {
        return SettingsEntryBuilder.createInject(owner = owner)
            .setIsAllowSearch(true)
            .setMarco {
                logMsg("create marco for INJECT entry")
                SimplePreferenceMarco(
            .setMacro {
                logMsg("create macro for INJECT entry")
                SimplePreferenceMacro(
                    title = PAGE_TITLE,
                    clickRoute = SettingsPageProviderEnum.PREFERENCE.name
                )
+2 −3
Original line number Diff line number Diff line
@@ -19,11 +19,10 @@ package com.android.settingslib.spa.framework.common
import androidx.compose.runtime.Composable

/**
 * Defines interface of a entry marco, which contains all entry functions to support different
 * Defines interface of a entry macro, which contains entry functions to support different
 * scenarios, such as browsing (UiLayout), search, etc.
 * SPA team will rebuild some entry marcos, in order to make the entry creation easier.
 */
interface EntryMarco {
interface EntryMacro {
    @Composable
    fun UiLayout() {}
    fun getSearchData(): EntrySearchData? = null
+3 −3
Original line number Diff line number Diff line
@@ -185,11 +185,11 @@ class SettingsEntryBuilder(private val name: String, private val owner: Settings
        return this
    }

    fun setMarco(fn: (arguments: Bundle?) -> EntryMarco): SettingsEntryBuilder {
    fun setMacro(fn: (arguments: Bundle?) -> EntryMacro): SettingsEntryBuilder {
        setSearchDataFn { fn(it).getSearchData() }
        setUiLayoutFn {
            val marco = remember { fn(it) }
            marco.UiLayout()
            val macro = remember { fn(it) }
            macro.UiLayout()
        }
        return this
    }
+8 −8
Original line number Diff line number Diff line
@@ -22,34 +22,34 @@ import androidx.compose.runtime.State
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import com.android.settingslib.spa.framework.common.EntryMarco
import com.android.settingslib.spa.framework.common.EntryMacro
import com.android.settingslib.spa.framework.common.EntrySearchData
import com.android.settingslib.spa.framework.compose.navigator
import com.android.settingslib.spa.framework.compose.stateOf
import com.android.settingslib.spa.widget.ui.createSettingsIcon

data class SimplePreferenceMarco(
data class SimplePreferenceMacro(
    val title: String,
    val summary: String? = null,
    val icon: ImageVector? = null,
    val disabled: Boolean = false,
    val clickRoute: String? = null,
    val searchKeywords: List<String> = emptyList(),
) : EntryMarco {
) : EntryMacro {
    @Composable
    override fun UiLayout() {
        Preference(model = object : PreferenceModel {
            override val title: String = this@SimplePreferenceMarco.title
            override val summary = stateOf(this@SimplePreferenceMarco.summary ?: "")
            override val icon = createSettingsIcon(this@SimplePreferenceMarco.icon)
            override val enabled = stateOf(!this@SimplePreferenceMarco.disabled)
            override val title: String = this@SimplePreferenceMacro.title
            override val summary = stateOf(this@SimplePreferenceMacro.summary ?: "")
            override val icon = createSettingsIcon(this@SimplePreferenceMacro.icon)
            override val enabled = stateOf(!this@SimplePreferenceMacro.disabled)
            override val onClick = navigator(clickRoute)
        })
    }

    override fun getSearchData(): EntrySearchData {
        return EntrySearchData(
            title = this@SimplePreferenceMarco.title,
            title = this@SimplePreferenceMacro.title,
            keyword = searchKeywords
        )
    }