android_manifest/uses_configuration.rs
1use serde::{Deserialize, Serialize};
2
3use crate::VarOrBool;
4
5/// Indicates what hardware and software features the application requires.
6///
7/// For example, an application might specify that it requires a physical keyboard or a
8/// particular navigation device, like a trackball. The specification is used to avoid
9/// installing the application on devices where it will not work.
10///
11/// ## Note
12/// `Most apps should not use this manifest tag` . You should always support input with
13/// a directional pad (d-pad) in order to assist sight-impaired users and support devices
14/// that provide d-pad input in addition to or instead of touch. information about how to
15/// support d-pad input in your app, read [`Enabling Focus Navigation`]. If your app
16/// absolutely cannot function without a touchscreen, then instead use the
17/// [`<uses-feature>`] tag to declare the required touchscreen type, ranging from
18/// `"android.hardware.faketouch"` for basic touch-style events to more advanced touch
19/// types such as `"android.hardware.touchscreen.multitouch.jazzhand"` for distinct input
20/// from multiple fingers.
21///
22/// ## XML Syntax
23/// ```xml
24/// <uses-configuration android:reqFiveWayNav=["true" | "false"]
25/// android:reqHardKeyboard=["true" | "false"]
26/// android:reqKeyboardType=["undefined" | "nokeys" | "qwerty" | "twelvekey"]
27/// android:reqNavigation=["undefined" | "nonav" | "dpad" | "trackball" | "wheel"]
28/// android:reqTouchScreen=["undefined" | "notouch" | "stylus" | "finger"] />
29/// ```
30///
31/// ## Contained in
32/// * [`<manifest>`]
33///
34/// ## Introduced in
35/// API Level 3
36///
37/// [`Enabling Focus Navigation`]: https://developer.android.com/guide/topics/ui/accessibility/apps#focus-nav
38/// [`<uses-feature>`]: crate::UsesFeature
39/// [`<manifest>`]: crate::AndroidManifest
40#[derive(
41 Debug, Deserialize, Serialize, YaSerialize, YaDeserialize, PartialEq, Eq, Default, Clone,
42)]
43pub struct UsesConfiguration {
44 /// Whether or not the application requires a five-way navigation control — `"true"`
45 /// if it does, and `"false"` if not. A five-way control is one that can move the
46 /// selection up, down, right, or left, and also provides a way of invoking the
47 /// current selection. It could be a D-pad (directional pad), trackball, or other
48 /// device.
49 ///
50 /// If an application requires a directional control, but not a control of
51 /// a particular type, it can set this attribute to "true" and ignore the
52 /// [`reqNavigation`] attribute. However, if it requires a particular type
53 /// of directional control, it can ignore this attribute and set
54 /// `reqNavigation` instead.
55 ///
56 /// [`reqNavigation`]: crate::UsesConfiguration#structfield.req_navigation
57 #[yaserde(attribute, prefix = "android", rename = "reqFiveWayNav")]
58 pub req_five_way_nav: Option<VarOrBool>,
59 /// Whether or not the application requires a hardware keyboard — `"true"` if it does,
60 /// and `"false"` if not.
61 #[yaserde(attribute, prefix = "android", rename = "reqHardKeyboard")]
62 pub req_hard_keyboard: Option<VarOrBool>,
63 /// The type of keyboard the application requires, if any at all. This attribute does
64 /// not distinguish between hardware and software keyboards. If a hardware
65 /// keyboard of a certain type is required, specify the type here and also set the
66 /// reqHardKeyboard attribute to `"true"`.
67 #[yaserde(attribute, prefix = "android", rename = "reqKeyboardType")]
68 pub req_keyboard_type: Option<ReqKeyboardType>,
69 /// The navigation device required by the application, if any.
70 ///
71 /// If an application requires a navigational control, but the exact type of
72 /// control doesn't matter, it can set the [`reqFiveWayNav`] attribute to "true"
73 /// rather than set this one.
74 ///
75 /// [`reqFiveWayNav`]: crate::UsesConfiguration#structfield.req_five_way_nav
76 #[yaserde(attribute, prefix = "android", rename = "reqNavigation")]
77 pub req_navigation: Option<ReqNavigation>,
78 /// The type of touch screen the application requires, if any at all.
79 #[yaserde(attribute, prefix = "android", rename = "reqTouchScreen")]
80 pub req_touch_screen: Option<ReqTouchScreen>,
81}
82
83/// The type of keyboard the application requires, if any at all.
84#[derive(Debug, Deserialize, Serialize, YaSerialize, YaDeserialize, PartialEq, Eq, Clone)]
85#[serde(rename_all = "camelCase")]
86#[derive(Default)]
87pub enum ReqKeyboardType {
88 /// The application does not require a keyboard. (A keyboard requirement is
89 /// not defined.) This is the default value.
90 #[yaserde(rename = "undefined")]
91 #[default]
92 Undefined,
93 /// The application does not require a keyboard.
94 #[yaserde(rename = "nokeys")]
95 Nokeys,
96 /// The application requires a standard QWERTY keyboard.
97 #[yaserde(rename = "qwerty")]
98 Qwerty,
99 /// The application requires a twelve-key keypad, like those on most phones
100 /// — with keys for the digits from 0 through 9 plus star (*) and pound (#)
101 /// keys.
102 #[yaserde(rename = "twelvekey")]
103 Twelvekey,
104}
105
106/// The navigation device required by the application, if any.
107#[derive(Debug, Deserialize, Serialize, YaSerialize, YaDeserialize, PartialEq, Eq, Clone)]
108#[serde(rename_all = "camelCase")]
109#[derive(Default)]
110pub enum ReqNavigation {
111 /// The application does not require any type of navigation control. (The
112 /// navigation requirement is not defined.) This is the default value.
113 #[yaserde(rename = "undefined")]
114 #[default]
115 Undefined,
116 /// The application does not require a navigation control.
117 #[yaserde(rename = "nonav")]
118 Nonav,
119 /// The application requires a D-pad (directional pad) for navigation.
120 #[yaserde(rename = "dpad")]
121 Dpad,
122 /// The application requires a trackball for navigation.
123 #[yaserde(rename = "trackball")]
124 Trackball,
125 /// The application requires a navigation wheel.
126 #[yaserde(rename = "wheel")]
127 Wheel,
128}
129
130/// The type of touch screen the application requires, if any at all.
131#[derive(Debug, Deserialize, Serialize, YaSerialize, YaDeserialize, PartialEq, Eq, Clone)]
132#[serde(rename_all = "camelCase")]
133#[derive(Default)]
134pub enum ReqTouchScreen {
135 /// The application doesn't require a touch screen. (The touch screen
136 /// requirement is undefined.) This is the default value.
137 #[yaserde(rename = "undefined")]
138 #[default]
139 Undefined,
140 /// The application doesn't require a touch screen.
141 #[yaserde(rename = "notouch")]
142 Notouch,
143 /// The application requires a touch screen that's operated with a stylus.
144 #[yaserde(rename = "stylus")]
145 Stylus,
146 /// The application requires a touch screen that can be operated with a
147 /// finger.
148 ///
149 /// ## Node
150 /// If some type of touch input is required for your app, you should
151 /// instead use the [`<uses-feature>`] tag to declare the required touchscreen
152 /// type, beginning with `"android.hardware.faketouch"` for basic touch-style
153 /// events.
154 ///
155 /// [`<uses-feature>`]: crate::UsesFeature
156 #[yaserde(rename = "finger")]
157 Finger,
158}