android_manifest/
permission_group.rs

1use super::resources::{
2    MipmapOrDrawableResource, Resource, StringResource, StringResourceOrString,
3};
4use serde::{Deserialize, Serialize};
5
6/// Declares a name for a logical grouping of related permissions.
7///
8/// Individual permission join the group through the permissionGroup attribute of the
9/// [`<permission>`] element. Members of a group are presented together in
10/// the user interface.
11///
12/// Note that this element does not declare a permission itself, only a category in which
13/// permissions can be placed. See the [`<permission>`] element for element for
14/// information on declaring permissions and assigning them to groups.
15///
16/// ## XML Syntax
17/// ```xml
18/// <permission-group android:description="string resource"
19///                   android:icon="drawable resource"
20///                   android:label="string resource"
21///                   android:name="string" />
22/// ```
23///
24/// ## Contained in
25/// * [`<manifest>`]
26///
27/// ## Introduced in
28/// API Level 1
29///
30/// [`<manifest>`]: crate::AndroidManifest
31/// [`<permission>`]: crate::Permission
32#[derive(
33    Debug, Deserialize, Serialize, YaSerialize, YaDeserialize, PartialEq, Eq, Default, Clone,
34)]
35pub struct PermissionGroup {
36    /// User-readable text that describes the group. The text should be longer and more
37    /// explanatory than the label. This attribute must be set as a reference to a
38    /// string resource. Unlike the label attribute, it cannot be a raw string.
39    #[yaserde(attribute, prefix = "android")]
40    pub description: Option<Resource<StringResource>>,
41    /// An icon representing the permission. This attribute must be set as a reference to
42    /// a drawable resource containing the image definition.
43    #[yaserde(attribute, prefix = "android")]
44    pub icon: Option<MipmapOrDrawableResource>,
45    /// A user-readable name for the group. As a convenience, the label can be directly
46    /// set as a raw string while you're developing the application. However, when the
47    /// application is ready to be published, it should be set as a reference to a
48    /// string resource, so that it can be localized like other strings in the user
49    /// interface.
50    #[yaserde(attribute, prefix = "android")]
51    pub label: Option<StringResourceOrString>,
52    /// The name of the group. This is the name that can be assigned to a
53    /// [`<permission>`] element's [`<permissionGroup>`] attribute.
54    ///
55    /// [`<permission>`]: crate::Permission
56    /// [`<permissionGroup>`]: crate::Permission#structfield.permission_group
57    #[yaserde(attribute, prefix = "android")]
58    pub name: Option<String>,
59}