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

Commit 11cd2d97 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[Catalyst] Add PreferenceMetadata.tags" into main

parents 63554b30 e8279c01
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -93,6 +93,8 @@ message PreferenceProto {
  optional PermissionsProto read_permissions = 17;
  // The required permissions to write preference value.
  optional PermissionsProto write_permissions = 18;
  // Tag constants associated with the preference.
  repeated string tags = 19;

  // Target of an Intent
  message ActionTarget {
+1 −0
Original line number Diff line number Diff line
@@ -412,6 +412,7 @@ fun PreferenceMetadata.toProto(
        }
        metadata.intent(context)?.let { actionTarget = it.toActionTarget(context) }
        screenMetadata.getLaunchIntent(context, metadata)?.let { launchIntent = it.toProto() }
        for (tag in metadata.tags(context)) addTags(tag)
    }
    persistent = metadata.isPersistent(context)
    if (persistent) {
+15 −1
Original line number Diff line number Diff line
@@ -89,10 +89,24 @@ interface PreferenceMetadata {
    /**
     * Return the extras Bundle object associated with this preference.
     *
     * It is used to provide more information for metadata.
     * It is used to provide more *internal* information for metadata. External app is not expected
     * to use this information as it could be changed in future. Consider [tags] for external usage.
     */
    fun extras(context: Context): Bundle? = null

    /**
     * Returns the tags associated with this preference.
     *
     * Unlike [extras], tags are exposed for external usage. The returned tag list must be constants
     * and **append only**. Do not edit/delete existing tag strings as it can cause backward
     * compatibility issue.
     *
     * Use cases:
     * - identify a specific preference
     * - identify a group of preferences related to network settings
     */
    fun tags(context: Context): Array<String> = arrayOf()

    /**
     * Returns if preference is indexable, default value is `true`.
     *