android_manifest/activity.rs
1use crate::VarOrBool;
2
3use super::attribute_list::{AttributeList, VerticalBar};
4use super::intent_filter::IntentFilter;
5use super::layout::Layout;
6use super::meta_data::MetaData;
7use super::resources::{
8 DrawableResource, MipmapOrDrawableResource, Resource, StringResourceOrString, StyleResource,
9};
10use super::ui_options::UiOptions;
11use serde::{Deserialize, Serialize};
12
13/// Declares an activity (an [`Activity`] subclass) that implements part of the
14/// application's visual user interface.
15///
16/// All activities must be represented by `<activity>` elements in the manifest file. Any
17/// that are not declared there will not be seen by the system and will never be run.
18///
19/// ## XML Syntax
20/// ```xml
21/// <activity android:allowEmbedded=["true" | "false"]
22/// android:allowTaskReparenting=["true" | "false"]
23/// android:alwaysRetainTaskState=["true" | "false"]
24/// android:autoRemoveFromRecents=["true" | "false"]
25/// android:banner="drawable resource"
26/// android:clearTaskOnLaunch=["true" | "false"]
27/// android:colorMode=["hdr" | "wideColorGamut"]
28/// android:configChanges=["mcc", "mnc", "locale",
29/// "touchscreen", "keyboard", "keyboardHidden",
30/// "navigation", "screenLayout", "fontScale",
31/// "uiMode", "orientation", "density",
32/// "screenSize", "smallestScreenSize"]
33/// android:directBootAware=["true" | "false"]
34/// android:documentLaunchMode=["intoExisting" | "always" |
35/// "none" | "never"]
36/// android:enabled=["true" | "false"]
37/// android:excludeFromRecents=["true" | "false"]
38/// android:exported=["true" | "false"]
39/// android:finishOnTaskLaunch=["true" | "false"]
40/// android:hardwareAccelerated=["true" | "false"]
41/// android:icon="drawable resource"
42/// android:immersive=["true" | "false"]
43/// android:label="string resource"
44/// android:launchMode=["standard" | "singleTop"|
45/// "singleTask" | "singleInstance"]
46/// android:lockTaskMode=["normal" | "never" |
47/// "if_whitelisted" | "always"]
48/// android:maxRecents="integer"
49/// android:maxAspectRatio="float"
50/// android:multiprocess=["true" | "false"]
51/// android:name="string"
52/// android:noHistory=["true" | "false"]
53/// android:parentActivityName="string"
54/// android:persistableMode=["persistRootOnly" |
55/// "persistAcrossReboots" | "persistNever"]
56/// android:permission="string"
57/// android:process="string"
58/// android:relinquishTaskIdentity=["true" | "false"]
59/// android:resizeableActivity=["true" | "false"]
60/// android:screenOrientation=["unspecified" | "behind" |
61/// "landscape" | "portrait" |
62/// "reverseLandscape" | "reversePortrait" |
63/// "sensorLandscape" | "sensorPortrait" |
64/// "userLandscape" | "userPortrait" |
65/// "sensor" | "fullSensor"|"nosensor" |
66/// "user" | "fullUser" | "locked"]
67/// android:showForAllUsers=["true" | "false"]
68/// android:stateNotNeeded=["true" | "false"]
69/// android:supportsPictureInPicture=["true" | "false"]
70/// android:taskAffinity="string"
71/// android:theme="resource or theme"
72/// android:uiOptions=["none" | "splitActionBarWhenNarrow"]
73/// android:windowSoftInputMode=["stateUnspecified",
74/// "stateUnchanged", "stateHidden",
75/// "stateAlwaysHidden", "stateVisible",
76/// "stateAlwaysVisible", "adjustUnspecified",
77/// "adjustResize", "adjustPan"]
78/// tools:replace="string"
79/// tools:remove="string"
80/// tools:node=["merge" | "replace" | "removeAll" | "merge-only" | "strict"]
81/// tools:ignore="string"
82/// tools:targetApi="string"
83/// tools:selector="string"
84/// tools:strict="string" >
85/// ...
86/// </activity>
87/// ```
88///
89/// ## Contained in
90/// * [`<application>`]
91///
92/// ## Can contain
93/// * [`<intent-filter>`]
94/// * [`<meta-data>`]
95/// * [`<layout>`]
96///
97/// ## Introduced in
98/// API Level 1 for all attributes except for [`noHistory`] and [`windowSoftInputMode`],
99/// which were added in API Level 3.
100///
101/// [`Activity`]: https://developer.android.com/reference/android/app/Activity
102/// [`<application>`]: crate::Application
103/// [`<intent-filter>`]: crate::IntentFilter
104/// [`<meta-data>`]: crate::MetaData
105/// [`<layout>`]: crate::Layout
106/// [`noHistory`]: crate::Activity#structfield.no_history
107/// [`windowSoftInputMode`]: crate::Activity#structfield.window_soft_input_mode
108#[derive(
109 Debug, Deserialize, Serialize, XmlSerialize, XmlDeserialize, PartialEq, Default, Clone,
110)]
111pub struct Activity {
112 /// Indicate that the activity can be launched as the embedded child of another
113 /// activity. Particularly in the case where the child lives in a container such
114 /// as a Display owned by another activity. For example, activities that are used
115 /// for Wear custom notifications must declare this so Wear can display the
116 /// activity in it's context stream, which resides in another process. The default
117 /// value of this attribute is "`false`".
118 #[xml(attribute = true, prefix = "android", rename = "allowEmbedded")]
119 pub allow_embedded: Option<VarOrBool>,
120 /// Whether or not the activity can move from the task that started it to the task it
121 /// has an affinity for when that task is next brought to the front — "`true`" if
122 /// it can move, and "`false`" if it must remain with the task where it started.
123 ///
124 /// If this attribute is not set, the value set by the corresponding
125 /// [`allowTaskReparenting`] attribute of the [`<application>`] element
126 /// applies to the activity. The default value is "`false`".
127 ///
128 /// Normally when an activity is started, it's associated with the task of the
129 /// activity that started it and it stays there for its entire lifetime. You can use
130 /// this attribute to force it to be re-parented to the task it has an affinity for
131 /// when its current task is no longer displayed. Typically, it's used to cause the
132 /// activities of an application to move to the main task associated with that
133 /// application.
134 ///
135 /// For example, if an e-mail message contains a link to a web page, clicking the link
136 /// brings up an activity that can display the page. That activity is defined by the
137 /// browser application, but is launched as part of the e-mail task. If it's
138 /// reparented to the browser task, it will be shown when the browser next comes to
139 /// the front, and will be absent when the e-mail task again comes forward.
140 ///
141 /// The affinity of an activity is defined by the [`taskAffinity`] attribute. The
142 /// affinity of a task is determined by reading the affinity of its root activity.
143 /// Therefore, by definition, a root activity is always in a task with the same
144 /// affinity. Since activities with "`singleTask`" or "`singleInstance`" launch
145 /// modes can only be at the root of a task, re-parenting is limited to the
146 /// "`standard`" and "`singleTop`" modes. (See also the [`launchMode`] attribute.)
147 ///
148 /// [`allowTaskReparenting`]: crate::Application#structfield.allow_task_reparenting
149 /// [`<application>`]: crate::Application
150 /// [`taskAffinity`]: crate::Activity#structfield.task_affinity
151 /// [`launchMode`]: crate::Activity#structfield.launch_mode
152 #[xml(attribute = true, prefix = "android", rename = "allowTaskReparenting")]
153 pub allow_task_reparenting: Option<VarOrBool>,
154 /// Whether or not the state of the task that the activity is in will always be
155 /// maintained by the system — "`true`" if it will be, and "`false`" if the system
156 /// is allowed to reset the task to its initial state in certain situations. The
157 /// default value is "`false`". This attribute is meaningful only for the root
158 /// activity of a task; it's ignored for all other activities.
159 ///
160 /// Normally, the system clears a task (removes all activities from the stack above
161 /// the root activity) in certain situations when the user re-selects that task
162 /// from the home screen. Typically, this is done if the user hasn't visited the
163 /// task for a certain amount of time, such as 30 minutes.
164 ///
165 /// However, when this attribute is "`true`", users will always return to the task in
166 /// its last state, regardless of how they get there. This is useful, for example, in
167 /// an application like the web browser where there is a lot of state (such as
168 /// multiple open tabs) that users would not like to lose.
169 #[xml(attribute = true, prefix = "android", rename = "alwaysRetainTaskState")]
170 pub always_retain_task_state: Option<VarOrBool>,
171 /// Whether or not tasks launched by activities with this attribute remains in the
172 /// [`overview screen`] until the last activity in the task is completed. If true, the
173 /// task is automatically removed from the `overview screen.` This overrides the
174 /// caller's use of [`FLAG_ACTIVITY_RETAIN_IN_RECENTS`]. It must be a boolean value,
175 /// either "`true`" or "`false`".
176 ///
177 /// [`overview screen`]: https://developer.android.com/guide/components/activities/recents
178 /// [`FLAG_ACTIVITY_RETAIN_IN_RECENTS`]: https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_RETAIN_IN_RECENTS
179 #[xml(attribute = true, prefix = "android", rename = "autoRemoveFromRecents")]
180 pub auto_remove_from_recents: Option<VarOrBool>,
181 /// A [`drawable resource`] providing an extended graphical banner for its associated
182 /// item. Use with the `<activity>` tag to supply a default banner for a specific
183 /// activity, or with the [`<application>`] tag to supply a banner for all
184 /// application activities.
185 ///
186 /// The system uses the banner to represent an app in the Android TV home screen.
187 /// Since the banner is displayed only in the home screen, it should only be
188 /// specified by applications with an activity that handles the
189 /// [`CATEGORY_LEANBACK_LAUNCHER`] intent.
190 ///
191 /// This attribute must be set as a reference to a drawable resource containing the
192 /// image (for example "`@drawable/banner`"). There is no default banner.
193 ///
194 /// See [`Provide a home screen banner`] in Get Started with TV Apps for more
195 /// information.
196 ///
197 /// [`drawable resource`]: https://developer.android.com/guide/topics/resources/drawable-resource
198 /// [`<application>`]: crate::Application
199 /// [`CATEGORY_LEANBACK_LAUNCHER`]: https://developer.android.com/reference/android/content/Intent#CATEGORY_LEANBACK_LAUNCHER
200 /// [`Provide a home screen banner`]: https://developer.android.com/training/tv/start/start#banner
201 #[xml(attribute = true, prefix = "android")]
202 pub banner: Option<Resource<DrawableResource>>,
203 /// Whether or not all activities will be removed from the task, except for the root
204 /// activity, whenever it is re-launched from the home screen — "`true`" if the
205 /// task is always stripped down to its root activity, and "`false`" if not. The
206 /// default value is "`false`". This attribute is meaningful only for activities
207 /// that start a new task (the root activity); it's ignored for all other
208 /// activities in the task.
209 ///
210 /// When the value is "`true`", every time users start the task again, they are
211 /// brought to its root activity regardless of what they were last doing in the
212 /// task and regardless of whether they used the Back or Home button to leave it.
213 /// When the value is "`false`", the task may be cleared of activities in some
214 /// situations (see the [`alwaysRetainTaskState`] attribute), but not always.
215 ///
216 /// Suppose, for example, that someone launches activity P from the home screen, and
217 /// from there goes to activity Q. The user next presses Home, and then returns to
218 /// activity P. Normally, the user would see activity Q, since that is what they were
219 /// last doing in P's task. However, if P set this flag to "`true`", all of the
220 /// activities on top of it (Q in this case) would be removed when the user launched
221 /// activity P from the home screen. So the user would see only P when returning to
222 /// the task.
223 ///
224 /// If this attribute and [`allowTaskReparenting`] are both "`true`", any activities
225 /// that can be re-parented are moved to the task they share an affinity with; the
226 /// remaining activities are then dropped, as described above.
227 ///
228 /// This attribute is ignored if [`FLAG_ACTIVITY_RESET_TASK_IF_NEEDED`] is not set.
229 ///
230 /// [`alwaysRetainTaskState`]: crate::Activity#structfield.always_retain_task_state
231 /// [`allowTaskReparenting`]: crate::Activity#structfield.allow_task_reparenting
232 /// [`FLAG_ACTIVITY_RESET_TASK_IF_NEEDED`]: https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
233 #[xml(attribute = true, prefix = "android", rename = "clearTaskOnLaunch")]
234 pub clear_task_on_launch: Option<VarOrBool>,
235 /// Requests the activity to be displayed in wide color gamut mode on compatible
236 /// devices. In wide color gamut mode, a window can render outside of the [`SRGB`]
237 /// gamut to display more vibrant colors. If the device doesn't support wide color
238 /// gamut rendering, this attribute has no effect. For more information about
239 /// rendering in wide color mode, see [`Enhancing Graphics with Wide Color Content`].
240 ///
241 /// [`Enhancing Graphics with Wide Color Content`]: https://developer.android.com/training/wide-color-gamut
242 /// [`SRGB`]: https://developer.android.com/reference/android/graphics/ColorSpace.Named#SRGB
243 #[xml(attribute = true, prefix = "android", rename = "colorMode")]
244 pub color_mode: Option<ColorMode>,
245 /// Lists configuration changes that the activity will handle itself. When a
246 /// configuration change occurs at runtime, the activity is shut down and
247 /// restarted by default, but declaring a configuration with this
248 /// attribute will prevent the activity from being restarted. Instead, the
249 /// activity remains running and its [`onConfigurationChanged()`] method is
250 /// called.
251 ///
252 /// Any or all of the following strings are valid values for this attribute. Multiple
253 /// values are separated by '`|`' — for example: "`locale|navigation|orientation`".
254 ///
255 /// ## Note
256 /// Using this attribute should be avoided and used only as a last resort. Please read
257 /// [`Handling Runtime Changes`] for more information about how to properly handle a
258 /// restart due to a configuration change.
259 ///
260 /// [`Handling Runtime Changes`]: https://developer.android.com/guide/topics/resources/runtime-changes
261 /// [`onConfigurationChanged()`]: https://developer.android.com/reference/android/app/Activity#onConfigurationChanged(android.content.res.Configuration)
262 #[xml(
263 attribute = true,
264 prefix = "android",
265 rename = "configChanges",
266 skip_serializing_if = "check_config_changes",
267 default = "default_config_changes"
268 )]
269 #[serde(default, skip_serializing_if = "AttributeList::is_empty")]
270 pub config_changes: AttributeList<VerticalBar, ConfigChanges>,
271 /// Whether or not the activity is direct-boot aware; that is, whether or not it can
272 /// run before the user unlocks the device.
273 ///
274 /// The default value is "`false`".
275 ///
276 /// ## Note
277 /// During [`Direct Boot`], an activity in your application can only access the data
278 /// that is stored in device protected storage.
279 ///
280 /// [`Direct Boot`]: https://developer.android.com/training/articles/direct-boot
281 #[xml(attribute = true, prefix = "android", rename = "directBootAware")]
282 pub direct_boot_aware: Option<VarOrBool>,
283 /// Specifies how a new instance of an activity should be added to a task
284 /// each time it is launched. This attribute permits the user to have
285 /// multiple documents from the same application appear in the [`overview
286 /// screen`].
287 ///
288 /// ## Note
289 /// For values other than "`none`" and "`never`" the activity must be defined with
290 /// `launchMode`="`standard`". If this attribute is not specified,
291 /// `documentLaunchMode`="`none`" is used.
292 ///
293 /// [`overview screen`]: https://developer.android.com/guide/components/activities/recents
294 #[xml(attribute = true, prefix = "android", rename = "documentLaunchMode")]
295 pub document_launch_mode: Option<DocumentLaunchMode>,
296 /// Whether or not the activity can be instantiated by the system — "`true`" if it can
297 /// be, and "`false`" if not.
298 ///
299 /// The default value is "`true`".
300 ///
301 /// The [`<application>`] element has its own [`enabled`] attribute that applies to
302 /// all application components, including activities. The [`<application>`] and
303 /// `<activity>` attributes must both be "`true`" (as they both are by default)
304 /// for the system to be able to instantiate the activity. If either is "`false`",
305 /// it cannot be instantiated.
306 ///
307 /// [`<application>`]: crate::Application
308 /// [`enabled`]: crate::Application#structfield.enabled
309 #[xml(attribute = true, prefix = "android")]
310 pub enabled: Option<VarOrBool>,
311 /// Whether or not the task initiated by this activity should be excluded
312 /// from the list of recently used applications, the [`overview screen`].
313 /// That is, when this activity is the root activity of a new task, this
314 /// attribute determines whether the task should not appear in the list of
315 /// recent apps. Set "`true`" if the task should be excluded from the
316 /// list; set "`false`" if it should be included.
317 ///
318 /// The default value is "`false`".
319 ///
320 /// [`overview screen`]: https://developer.android.com/guide/components/activities/recents
321 #[xml(attribute = true, prefix = "android", rename = "excludeFromRecents")]
322 pub exclude_from_recents: Option<VarOrBool>,
323 /// This element sets whether the activity can be launched by components of other
324 /// applications — "`true`" if it can be, and "`false`" if not. If "`false`", the
325 /// activity can be launched only by components of the same application or
326 /// applications with the same user ID.
327 ///
328 /// If you are using intent filters, you should not set this element "`false`". If you
329 /// do so, and an app tries to call the activity, system throws an
330 /// [`ActivityNotFoundException`]. Instead, you should prevent other apps
331 /// from calling the activity by not setting intent filters for it.
332 ///
333 /// If you do not have intent filters, the default value for this element is
334 /// "false". If you set the element "true", the activity is accessible to
335 /// any app that knows its exact class name, but does not resolve when
336 /// the system tries to match an implicit intent.
337 ///
338 /// This attribute is not the only way to limit an activity's exposure to other
339 /// applications. You can also use a permission to limit the external entities
340 /// that can invoke the activity (see the [`permission`] attribute).
341 ///
342 /// [`ActivityNotFoundException`]: https://developer.android.com/reference/android/content/ActivityNotFoundException
343 /// [`permission`]: crate::Activity#structfield.permission
344 #[xml(attribute = true, prefix = "android")]
345 pub exported: Option<VarOrBool>,
346 /// Whether or not an existing instance of the activity should be shut down (finished)
347 /// whenever the user again launches its task (chooses the task on the home
348 /// screen) — "`true`" if it should be shut down, and "`false`" if not.
349 ///
350 /// The default value is "`false`".
351 ///
352 /// If this attribute and [`allowTaskReparenting`] are both "`true`", this attribute
353 /// trumps the other. The affinity of the activity is ignored. The activity is not
354 /// re-parented, but destroyed.
355 ///
356 /// [`allowTaskReparenting`]: https://developer.android.com/guide/topics/manifest/activity-element#reparent
357 #[xml(attribute = true, prefix = "android", rename = "finishOnTaskLaunch")]
358 pub finish_on_task_launch: Option<VarOrBool>,
359 /// Whether or not hardware-accelerated rendering should be enabled for this Activity
360 /// — "`true`" if it should be enabled, and "`false`" if not.
361 ///
362 /// The default value is "`false`".
363 ///
364 /// Starting from Android 3.0, a hardware-accelerated OpenGL renderer is available to
365 /// applications, to improve performance for many common 2D graphics operations.
366 /// When the hardware-accelerated renderer is enabled, most operations in Canvas,
367 /// Paint, Xfermode, ColorFilter, Shader, and Camera are accelerated.This results in
368 /// smoother animations, smoother scrolling, and improved responsiveness overall, even
369 /// for applications that do not explicitly make use the framework's OpenGL libraries.
370 /// Because of the increased resources required to enable hardware acceleration, your
371 /// app will consume more RAM.
372 ///
373 /// Note that not all of the OpenGL 2D operations are accelerated. If you enable the
374 /// hardware-accelerated renderer, test your application to ensure that it can
375 /// make use of the renderer without errors.
376 #[xml(attribute = true, prefix = "android", rename = "hardwareAccelerated")]
377 pub hardware_accelerated: Option<VarOrBool>,
378 /// An icon representing the activity. The icon is displayed to users when a
379 /// representation of the activity is required on-screen. For example,
380 /// icons for activities that initiate tasks are displayed in the launcher
381 /// window. The icon is often accompanied by a label (see the
382 /// [`android:label`] attribute).
383 ///
384 /// This attribute must be set as a reference to a drawable resource containing the
385 /// image definition. If it is not set, the icon specified for the application as
386 /// a whole is used instead (see the [`<application>`] element's
387 /// [`icon`](crate::Application#structfield.icon) attribute).
388 ///
389 /// The activity's icon — whether set here or by the [`<application>`] element — is
390 /// also the default icon for all the activity's intent filters (see the
391 /// [`<intent-filter>`] element's [`icon`](crate::IntentFilter#structfield.icon)
392 /// attribute).
393 ///
394 /// [`android:label`]: crate::Activity#structfield.label
395 /// [`<application>`]: crate::Application
396 /// [`<intent-filter>`]: crate::IntentFilter
397 #[xml(attribute = true, prefix = "android")]
398 pub icon: Option<MipmapOrDrawableResource>,
399 /// Sets the immersive mode setting for the current activity. If the
400 /// `android:immersive` attribute is set to true in the app's manifest entry
401 /// for this activity, the [`ActivityInfo.flags`] member always has its
402 /// [`FLAG_IMMERSIVE`] bit set, even if the immersive mode is changed at
403 /// runtime using the [`setImmersive()`] method.
404 ///
405 /// [`ActivityInfo.flags`]: https://developer.android.com/reference/android/content/pm/ActivityInfo#flags
406 /// [`FLAG_IMMERSIVE`]: https://developer.android.com/reference/android/content/pm/ActivityInfo#FLAG_IMMERSIVE
407 /// [`setImmersive()`]: https://developer.android.com/reference/android/app/Activity#setImmersive(boolean)
408 #[xml(attribute = true, prefix = "android")]
409 pub immersive: Option<VarOrBool>,
410 /// A user-readable label for the activity. The label is displayed on-screen when the
411 /// activity must be represented to the user. It's often displayed along with the
412 /// activity icon. If this attribute is not set, the label set for the application
413 /// as a whole is used instead (see the [`<application>`] element's
414 /// [`label`](crate::Application#structfield.label) attribute).
415 ///
416 /// The activity's label — whether set here or by the [`<application>`] element — is
417 /// also the default label for all the activity's intent filters (see the
418 /// [`<intent-filter>`] element's [`label`](crate::IntentFilter#structfield.label)
419 /// attribute).
420 ///
421 /// The label should be set as a reference to a string resource, so that it can be
422 /// localized like other strings in the user interface. However, as a convenience
423 /// while you're developing the application, it can also be set as a raw string.
424 ///
425 /// [`<application>`]: crate::Application
426 /// [`<intent-filter>`]: crate::IntentFilter
427 #[xml(attribute = true, prefix = "android")]
428 pub label: Option<StringResourceOrString>,
429 /// An instruction on how the activity should be launched. There are four modes that
430 /// work in conjunction with activity flags (`FLAG_ACTIVITY_*` constants) in
431 /// [`Intent`] objects to determine what should happen when the activity is called
432 /// upon to handle an intent.
433 ///
434 /// The default mode is `"standard"`.
435 ///
436 /// [`Intent`]: https://developer.android.com/reference/android/content/Intent
437 #[xml(attribute = true, prefix = "android", rename = "launchMode")]
438 pub launch_mode: Option<LaunchMode>,
439 /// Determines how the system presents this activity when the device is running in
440 /// [`lock task mode`].
441 ///
442 /// Android can run tasks in an immersive, kiosk-like fashion called lock task mode.
443 /// When the system runs in lock task mode, device users typically can’t see
444 /// notifications, access non-allowlisted apps, or return to the home screen
445 /// (unless the Home app is allowlisted). Only apps that have been allowlisted by
446 /// a device policy controller (DPC) can run when the system is in lock task mode.
447 /// System and [`privileged apps`], however, can run in lock task mode without
448 /// being allowlisted.
449 ///
450 /// This attribute was introduced in API Level 23.
451 ///
452 /// [`lock task mode`]: https://developer.android.com/work/dpc/dedicated-devices/lock-task-mode
453 /// [`privileged apps`]: https://source.android.com/devices/tech/config/perms-allowlist
454 #[xml(attribute = true, prefix = "android", rename = "lockTaskMode")]
455 pub lock_task_mode: Option<LockTaskMode>,
456 /// The maximum number of tasks rooted at this activity in the [`overview screen`].
457 /// When this number of entries is reached, the system removes the least-recently
458 /// used instance from the overview screen. Valid values are 1 through 50 (25 on
459 /// low memory devices); zero is invalid. This must be an integer value, such as
460 /// 50.
461 ///
462 /// The default value is 16.
463 ///
464 /// [`overview screen`]: https://developer.android.com/guide/components/activities/recents
465 #[xml(attribute = true, prefix = "android", rename = "maxRecents")]
466 pub max_recents: Option<u32>,
467 /// The maximum aspect ratio the activity supports. If the app runs on a device with a
468 /// wider aspect ratio, the system automatically letterboxes the app, leaving
469 /// portions of the screen unused so the app can run at its specified maximum
470 /// aspect ratio. Maximum aspect ratio is expressed as the decimal form of the
471 /// quotient of the device's longer dimension divided by its shorter dimension.
472 /// For example, if the maximum aspect ratio is 7:3, set the value of this
473 /// attribute to 2.33. On non-wearable devices, the value of this attribute needs
474 /// to be 1.33 or greater. On wearable devices, it must be 1.0 or greater.
475 /// Otherwise, the system ignores the set value.
476 ///
477 /// ## Note
478 /// This attribute is ignored if the activity has [`resizeableActivity`] set to true,
479 /// since that means your activity supports any size.
480 ///
481 /// For more information about this attribute, see [`Supporting Multiple Screens`].
482 ///
483 /// [`Supporting Multiple Screens`]: https://developer.android.com/guide/practices/screens_support
484 /// [`resizeableActivity`]: crate::Activity#structfield.resizeable_activity
485 #[xml(attribute = true, prefix = "android", rename = "maxAspectRatio")]
486 pub max_aspect_ratio: Option<f32>,
487 /// Whether an instance of the activity can be launched into the process of the
488 /// component that started it — "`true`" if it can be, and "`false`" if not.
489 ///
490 /// The default value is "`false`".
491 ///
492 /// Normally, a new instance of an activity is launched into the process of the
493 /// application that defined it, so all instances of the activity run in the same
494 /// process. However, if this flag is set to "`true`", instances of the activity
495 /// can run in multiple processes, allowing the system to create instances
496 /// wherever they are used (provided permissions allow it), something that is
497 /// almost never necessary or desirable.
498 #[xml(attribute = true, prefix = "android")]
499 pub multiprocess: Option<VarOrBool>,
500 /// The name of the class that implements the activity, a subclass of [`Activity`].
501 /// The attribute value should be a fully qualified class name (such as, "`com.
502 /// example.project.ExtracurricularActivity`"). However, as a shorthand, if the
503 /// first character of the name is a period (for example, "`.
504 /// ExtracurricularActivity`"), it is appended to the package name specified in
505 /// the [`<manifest>`] element.
506 ///
507 /// Once you publish your application, you [`should not change this name`] (unless
508 /// you've set [`android:exported`]="`false`").
509 ///
510 /// There is no default. The name must be specified.
511 ///
512 /// [`Activity`]: https://developer.android.com/reference/android/app/Activity
513 /// [`<manifest>`]: crate::AndroidManifest
514 /// [`should not change this name`]: https://android-developers.googleblog.com/2011/06/things-that-cannot-change.html
515 /// [`android:exported`]: crate::Activity#structfield.exported
516 #[xml(attribute = true, prefix = "android")]
517 pub name: String,
518 /// Whether or not the activity should be removed from the activity stack and finished
519 /// (its [`finish()`] method called) when the user navigates away from it and it's
520 /// no longer visible on screen — "`true`" if it should be finished, and "`false`"
521 /// if not.
522 ///
523 /// The default value is "`false`".
524 ///
525 /// A value of "`true`" means that the activity will not leave a historical
526 /// trace. It will not remain in the activity stack for the task, so the
527 /// user will not be able to return to it. In this case,
528 /// [`onActivityResult()`] is never called if you start another activity for a
529 /// result from this activity.
530 ///
531 /// This attribute was introduced in API Level 3.
532 ///
533 /// [`finish()`]: https://developer.android.com/reference/android/app/Activity#finish()
534 /// [`onActivityResult()`]: https://developer.android.com/reference/android/app/Activity#onActivityResult(int,%20int,%20android.content.Intent)
535 #[xml(attribute = true, prefix = "android", rename = "noHistory")]
536 pub no_history: Option<VarOrBool>,
537 /// The class name of the logical parent of the activity. The name here must match the
538 /// class name given to the corresponding `<activity>` element's [`android:name`]
539 /// attribute.
540 ///
541 /// The system reads this attribute to determine which activity should be started when
542 /// the user presses the Up button in the action bar. The system can also use this
543 /// information to synthesize a back stack of activities with
544 /// [`TaskStackBuilder`].
545 ///
546 /// To support API levels 4 - 16, you can also declare the parent activity
547 /// with a `<meta-data>` element that specifies a value for
548 /// `"android.support.PARENT_ACTIVITY"`.
549 ///
550 /// For more information about declaring the parent activity to support Up navigation,
551 /// read [`Providing Up Navigation`].
552 ///
553 /// This attribute was introduced in API Level 16.
554 ///
555 /// ## XML Examples
556 /// To support API levels 4 - 16:
557 /// ```xml
558 /// <activity android:name="com.example.app.ChildActivity"
559 /// android:label="@string/title_child_activity"
560 /// android:parentActivityName="com.example.app.MainActivity" >
561 /// <!-- Parent activity meta-data to support API level 4+ -->
562 /// <meta-data android:name="android.support.PARENT_ACTIVITY"
563 /// android:value="com.example.app.MainActivity" />
564 /// </activity>
565 /// ```
566 ///
567 /// [`android:name`]: crate::Activity#structfield.name
568 /// [`TaskStackBuilder`]: https://developer.android.com/reference/android/app/TaskStackBuilder
569 /// [`Providing Up Navigation`]: https://developer.android.com/guide/navigation
570 #[xml(attribute = true, prefix = "android", rename = "parentActivityName")]
571 pub parent_activity_name: Option<String>,
572 /// Defines how an instance of an activity is preserved within a containing task
573 /// across device restarts.
574 ///
575 /// If the root activity of a task sets this attribute's value to `persistRootOnly`,
576 /// then only the root activity is preserved. Otherwise, the activities that are
577 /// higher up the task's [`back stack`] are examined; any of these activities that
578 /// set this attribute's value to `persistAcrossReboots` are preserved.
579 ///
580 /// This attribute was introduced in API level 21.
581 ///
582 /// [`back stack`]: https://developer.android.com/guide/components/activities/tasks-and-back-stack
583 #[xml(attribute = true, prefix = "android", rename = "persistableMode")]
584 pub persistable_mode: Option<PersistableMode>,
585 /// The name of a permission that clients must have to launch the activity or
586 /// otherwise get it to respond to an intent. If a caller of [`startActivity()`]
587 /// or [`startActivityForResult()`] has not been granted the specified permission,
588 /// its intent will not be delivered to the activity.
589 ///
590 /// If this attribute is not set, the permission set by the [`<application>`]
591 /// element's [`permission`] attribute applies to the activity. If neither
592 /// attribute is set, the activity is not protected by a permission.
593 ///
594 /// For more information on permissions, see the [`Permissions`] section in the
595 /// introduction and another document, [`Security and Permissions`].
596 ///
597 /// [`startActivity()`]: https://developer.android.com/reference/android/content/Context#startActivity(android.content.Intent)
598 /// [`startActivityForResult()`]: https://developer.android.com/reference/android/app/Activity#startActivityForResult(android.content.Intent,%20int)
599 /// [`<application>`]: crate::Application
600 /// [`permission`]: crate::Application#structfield.permission
601 /// [`Permissions`]: https://developer.android.com/guide/topics/manifest/manifest-intro#perms
602 /// [`Security and Permissions`]: https://developer.android.com/training/articles/security-tips
603 #[xml(attribute = true, prefix = "android")]
604 pub permission: Option<String>,
605 /// The name of the process in which the activity should run. Normally, all components
606 /// of an application run in a default process name created for the application
607 /// and you do not need to use this attribute. But if necessary, you can override
608 /// the default process name with this attribute, allowing you to spread your app
609 /// components across multiple processes.
610 ///
611 /// If the name assigned to this attribute begins with a colon (':'), a new process,
612 /// private to the application, is created when it's needed and the activity runs
613 /// in that process. If the process name begins with a lowercase character, the
614 /// activity will run in a global process of that name, provided that it has
615 /// permission to do so. This allows components in different applications to share
616 /// a process, reducing resource usage.
617 ///
618 /// The [`<application>`] element's [`process`] attribute can set a different default
619 /// process name for all components.
620 ///
621 /// [`<application>`]: crate::Application
622 /// [`process`]: crate::Application#structfield.process
623 #[xml(attribute = true, prefix = "android")]
624 pub process: Option<String>,
625 /// Whether or not the activity relinquishes its task identifiers to an activity above
626 /// it in the task stack. A task whose root activity has this attribute set to
627 /// "`true`" replaces the base Intent with that of the next activity in the task.
628 /// If the next activity also has this attribute set to "`true`" then it will
629 /// yield the base Intent to any activity that it launches in the same task. This
630 /// continues for each activity until an activity is encountered which has this
631 /// attribute set to "`false`".
632 ///
633 /// The default value is "`false`".
634 ///
635 /// This attribute set to "`true`" also permits the activity's use of the
636 /// [`ActivityManager.TaskDescription`] to change labels, colors and icons in the
637 /// [`overview screen`].
638 ///
639 /// [`ActivityManager.TaskDescription`]: https://developer.android.com/reference/android/app/ActivityManager.TaskDescription
640 /// [`overview screen`]: https://developer.android.com/guide/components/activities/recents
641 #[xml(
642 attribute = true,
643 prefix = "android",
644 rename = "relinquishTaskIdentity"
645 )]
646 pub relinquish_task_identity: Option<VarOrBool>,
647 /// Specifies whether the app supports [`multi-window display`]. You can set
648 /// this attribute in either the `<activity>` or [`<application>`] element.
649 ///
650 /// If you set this attribute to true, the user can launch the activity in
651 /// split-screen and freeform modes. If you set the attribute to false, the
652 /// activity does not support multi-window mode. If this value is false,
653 /// and the user attempts to launch the activity in multi-window mode, the
654 /// activity takes over the full screen.
655 ///
656 /// If your app targets API level 24 or higher, but you do not specify a value for
657 /// this attribute, the attribute's value defaults to true.
658 ///
659 /// This attribute was added in API level 24.
660 ///
661 /// ## Note
662 /// A task's root activity value is applied to all additional activities launched
663 /// in the task. That is, if the root activity of a task is resizable then the system
664 /// treats all other activities in the task as resizable. If the root activity is not
665 /// resizable, the other activities in the task are not resizable.
666 ///
667 /// [`multi-window display`]: https://developer.android.com/guide/topics/ui/multi-window
668 /// [`<application>`]: crate::Application
669 #[xml(attribute = true, prefix = "android", rename = "resizeableActivity")]
670 pub resizeable_activity: Option<VarOrBool>,
671 /// The orientation of the activity's display on the device. The system ignores this
672 /// attribute if the activity is running in [`multi-window mode`].
673 ///
674 /// ## Note
675 /// When you declare one of the landscape or portrait values, it is considered a hard
676 /// requirement for the orientation in which the activity runs. As such, the value
677 /// you declare enables filtering by services such as Google Play so your
678 /// application is available only to devices that support the orientation required
679 /// by your activities. For example, if you declare either `"landscape"`,
680 /// `"reverseLandscape"`, or `"sensorLandscape"`, then your application will be
681 /// available only to devices that support landscape orientation. However, you
682 /// should also explicitly declare that your application requires either portrait
683 /// or landscape orientation with the [`<uses-feature>`] element.
684 ///
685 /// ```xml
686 /// <uses-feature android:name="android.hardware.screen.portrait"/>.
687 /// ```
688 ///
689 /// This is purely a filtering behavior provided by Google Play (and other services
690 /// that support it) and the platform itself does not control whether your app can
691 /// be installed when a device supports only certain orientations.
692 ///
693 /// [`multi-window mode`]: https://developer.android.com/guide/topics/ui/multi-window
694 /// [`<uses-feature>`]: crate::UsesFeature
695 #[xml(attribute = true, prefix = "android", rename = "screenOrientation")]
696 pub screen_orientation: Option<ScreenOrientation>,
697 /// Whether or not the activity is shown when the device's current user is
698 /// different than the user who launched the activity. You can set this
699 /// attribute to a literal value — "`true`" or "`false`" — or you can set the
700 /// attribute to a resource or theme attribute that contains a boolean
701 /// value.
702 ///
703 /// This attribute was added in API level 23.
704 #[xml(attribute = true, prefix = "android", rename = "showForAllUsers")]
705 pub show_for_all_users: Option<VarOrBool>,
706 /// Whether or not the activity can be killed and successfully restarted without
707 /// having saved its state — "`true`" if it can be restarted without reference to
708 /// its previous state, and "`false`" if its previous state is required. The
709 /// default value is "`false`".
710 ///
711 /// Normally, before an activity is temporarily shut down to save resources, its
712 /// [`onSaveInstanceState()`] method is called. This method stores the current
713 /// state of the activity in a [`Bundle`] object, which is then passed to
714 /// [`onCreate()`] when the activity is restarted. If this attribute is set to
715 /// "`true`", `onSaveInstanceState()` may not be called and `onCreate()`
716 /// will be passed null instead of the Bundle — just as it was when the
717 /// activity started for the first time.
718 ///
719 /// A "`true`" setting ensures that the activity can be restarted in the absence of
720 /// retained state. For example, the activity that displays the home screen uses
721 /// this setting to make sure that it does not get removed if it crashes for some
722 /// reason.
723 ///
724 /// [`onSaveInstanceState()`]: https://developer.android.com/reference/android/app/Activity#onSaveInstanceState(android.os.Bundle)
725 /// [`Bundle`]: https://developer.android.com/reference/android/os/Bundle
726 /// [`onCreate()`]: https://developer.android.com/reference/android/app/Activity#onCreate(android.os.Bundle)
727 #[xml(attribute = true, prefix = "android", rename = "stateNotNeeded")]
728 pub state_not_needed: Option<VarOrBool>,
729 /// Specifies whether the activity supports [`Picture-in-Picture`] display.
730 ///
731 /// This attribute was added in API level 24.
732 ///
733 /// [`Picture-in-Picture`]: https://developer.android.com/guide/topics/ui/picture-in-picture
734 #[xml(
735 attribute = true,
736 prefix = "android",
737 rename = "supportsPictureInPicture"
738 )]
739 pub supports_picture_in_picture: Option<VarOrBool>,
740 /// The task that the activity has an affinity for. Activities with the same affinity
741 /// conceptually belong to the same task (to the same `"application"` from the
742 /// user's perspective). The affinity of a task is determined by the affinity of
743 /// its root activity.
744 ///
745 /// The affinity determines two things — the task that the activity is re-parented to
746 /// (see the [`allowTaskReparenting`] attribute) and the task that will house
747 /// the activity when it is launched with the [`FLAG_ACTIVITY_NEW_TASK`] flag.
748 ///
749 /// By default, all activities in an application have the same affinity. You can set
750 /// this attribute to group them differently, and even place activities defined in
751 /// different applications within the same task. To specify that the activity does
752 /// not have an affinity for any task, set it to an empty string.
753 ///
754 /// If this attribute is not set, the activity inherits the affinity set for the
755 /// application (see the [`<application>`] element's [`taskAffinity`] attribute). The
756 /// name of the default affinity for an application is the package name set by the
757 /// [`<manifest>`] element.
758 ///
759 /// [`allowTaskReparenting`]: crate::Activity#structfield.allow_task_reparenting
760 /// [`FLAG_ACTIVITY_NEW_TASK`]: https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_NEW_TASK
761 /// [`<application>`]: crate::Application
762 /// [`taskAffinity`]: crate::Application#structfield.task_affinity
763 /// [`<manifest>`]: crate::AndroidManifest
764 #[xml(attribute = true, prefix = "android", rename = "taskAffinity")]
765 pub task_affinity: Option<String>,
766 /// A reference to a style resource defining an overall theme for the activity. This
767 /// automatically sets the activity's context to use this theme (see
768 /// [`setTheme()`] and may also cause "starting" animations prior to the
769 /// activity being launched (to better match what the activity actually looks
770 /// like).
771 ///
772 /// If this attribute is not set, the activity inherits the theme set for the
773 /// application as a whole — from the [`<application>`] element's [`theme`]
774 /// attribute. If that attribute is also not set, the default system theme is
775 /// used.
776 ///
777 /// For more information, see the [`Styles and Themes`] developer guide.
778 ///
779 /// [`setTheme()`]: https://developer.android.com/reference/android/content/Context#setTheme(int)
780 /// [`<application>`]: crate::Application
781 /// [`theme`]: crate::Application#structfield.theme
782 /// [`Styles and Themes`]: https://developer.android.com/guide/topics/ui/look-and-feel/themes
783 #[xml(attribute = true, prefix = "android")]
784 pub theme: Option<Resource<StyleResource>>,
785 /// Extra options for an activity's UI.
786 ///
787 /// For more information about the app bar, see the [`Adding the App Bar`] training
788 /// class.
789 ///
790 /// This attribute was added in API level 14.
791 ///
792 /// [`Adding the App Bar`]: https://developer.android.com/training/appbar
793 #[xml(attribute = true, prefix = "android", rename = "uiOptions")]
794 pub ui_options: Option<UiOptions>,
795 /// How the main window of the activity interacts with the window containing the
796 /// on-screen soft keyboard. The setting for this attribute affects two things:
797 ///
798 /// * The state of the soft keyboard — whether it is hidden or visible — when the
799 /// activity becomes the focus of user attention.
800 /// * The adjustment made to the activity's main window — whether it is resized
801 /// smaller to make room for the soft keyboard or whether its contents pan to make
802 /// the current focus visible when part of the window is covered by the soft
803 /// keyboard.
804 ///
805 /// The setting must be one of the values listed in the following table, or a
806 /// combination of one "`state...`" value plus one "`adjust...`" value.
807 /// Setting multiple values in either group — multiple "`state...`" values,
808 /// for example — has undefined results. Individual values are separated
809 /// by a vertical bar (`|`).
810 ///
811 /// ## XML Examples
812 /// ```xml
813 /// <activity android:windowSoftInputMode="stateVisible|adjustResize" ... >
814 /// ```
815 ///
816 /// Values set here (other than "`stateUnspecified`" and "`adjustUnspecified`")
817 /// override values set in the theme.
818 #[xml(
819 attribute = true,
820 prefix = "android",
821 rename = "windowSoftInputMode",
822 skip_serializing_if = "check_window_soft_input_mode",
823 default = "default_window_soft_input_mode"
824 )]
825 #[serde(default, skip_serializing_if = "AttributeList::is_empty")]
826 pub window_soft_input_mode: AttributeList<VerticalBar, WindowSoftInputMode>,
827 /// A `<layout>` tag.
828 pub layout: Option<Layout>,
829 /// List of `<intent-filter>` tags.
830 #[xml(rename = "intent-filter")]
831 #[serde(default, skip_serializing_if = "Vec::is_empty")]
832 pub intent_filter: Vec<IntentFilter>,
833 /// List of `<meta-data>` tags.
834 #[xml(rename = "meta-data")]
835 #[serde(default, skip_serializing_if = "Vec::is_empty")]
836 pub meta_data: Vec<MetaData>,
837 /// Specifies which attributes from lower priority manifest files should be replaced
838 /// by attributes from this manifest. This is a comma-separated list of attribute
839 /// names.
840 ///
841 /// For example: `tools:replace="android:theme,android:exported"`
842 ///
843 /// Reference: [Merge manifest files - tools:replace](https://developer.android.com/studio/build/manage-manifests#merge-manifests)
844 #[xml(attribute = true, prefix = "tools")]
845 pub replace: Option<String>,
846 /// Specifies which attributes or child elements from lower priority manifest files
847 /// should be removed entirely.
848 ///
849 /// For example: `tools:remove="android:configChanges"`
850 ///
851 /// Reference: [Merge manifest files - tools:remove](https://developer.android.com/studio/build/manage-manifests#merge-manifests)
852 #[xml(attribute = true, prefix = "tools")]
853 pub remove: Option<String>,
854 /// Specifies the merge strategy for this element. Can be "merge", "replace",
855 /// "removeAll", "merge-only", or "strict".
856 ///
857 /// For example: `tools:node="replace"`
858 ///
859 /// Reference: [Merge manifest files - tools:node](https://developer.android.com/studio/build/manage-manifests#merge-manifests)
860 #[xml(attribute = true, prefix = "tools")]
861 pub node: Option<String>,
862 /// This attribute accepts a comma-separated list of lint issue IDs that you'd like
863 /// the tools to ignore on this element or any of its descendants.
864 ///
865 /// For example: `tools:ignore="UnusedAttribute"`
866 ///
867 /// Reference: [Tools Attributes - tools:ignore](https://developer.android.com/studio/write/tool-attributes#tools-ignore)
868 #[xml(attribute = true, prefix = "tools")]
869 pub ignore: Option<String>,
870 /// This attribute works the same as the @TargetApi annotation in Java code. It lets
871 /// you specify the API level (either as an integer or as a code name) that supports
872 /// this element.
873 ///
874 /// For example: `tools:targetApi="14"`
875 ///
876 /// Reference: [Tools Attributes - tools:targetApi](https://developer.android.com/studio/write/tool-attributes#toolstargetapi)
877 #[xml(attribute = true, prefix = "tools", rename = "targetApi")]
878 pub target_api: Option<String>,
879 /// Specifies library package names to apply the merge rule to.
880 ///
881 /// For example: `tools:selector="com.example.lib1"`
882 ///
883 /// Reference: [Merge manifest files - tools:selector](https://developer.android.com/studio/build/manage-manifests#marker_selector)
884 #[xml(attribute = true, prefix = "tools")]
885 pub selector: Option<String>,
886 /// Generate a build failure if attributes don't exactly match.
887 ///
888 /// For example: `tools:strict="android:screenOrientation"`
889 ///
890 /// Reference: [Merge manifest files - tools:strict](https://developer.android.com/studio/build/manage-manifests#attribute_markers)
891 #[xml(attribute = true, prefix = "tools")]
892 pub strict: Option<String>,
893}
894
895fn default_config_changes() -> AttributeList<VerticalBar, ConfigChanges> {
896 AttributeList::default()
897}
898
899fn default_window_soft_input_mode() -> AttributeList<VerticalBar, WindowSoftInputMode> {
900 AttributeList::default()
901}
902
903impl Activity {
904 fn check_config_changes(&self, value: &AttributeList<VerticalBar, ConfigChanges>) -> bool {
905 value.is_empty()
906 }
907
908 fn check_window_soft_input_mode(
909 &self,
910 value: &AttributeList<VerticalBar, WindowSoftInputMode>,
911 ) -> bool {
912 value.is_empty()
913 }
914}
915
916/// Requests the activity to be displayed in wide color gamut mode on compatible
917/// devices.
918#[derive(Debug, Deserialize, Serialize, XmlSerialize, XmlDeserialize, PartialEq, Eq, Clone)]
919#[serde(rename_all = "camelCase")]
920#[derive(Default)]
921pub enum ColorMode {
922 /// Indicating that the activity should use a high dynamic range if the presentation
923 /// display supports it.
924 #[xml(rename = "hdr")]
925 #[default]
926 Hdr,
927 /// Indicating that the activity should use a wide color gamut if the presentation
928 /// display supports it. To render wide color gamut content, your app must load a
929 /// wide color bitmap, that is a bitmap with a color profile containing a color
930 /// space wider than sRGB.
931 #[xml(rename = "wideColorGamut")]
932 WideColorGamut,
933}
934
935/// Lists configuration changes that the `activity` will handle itself.
936#[derive(Debug, Deserialize, Serialize, XmlSerialize, XmlDeserialize, PartialEq, Eq, Clone)]
937#[serde(rename_all = "camelCase")]
938#[derive(Default)]
939pub enum ConfigChanges {
940 /// The display density has changed — the user might have specified a different
941 /// display scale, or a different display might now be active. Added in API level
942 /// 24.
943 #[xml(rename = "density")]
944 #[default]
945 Density,
946 /// The font scaling factor has changed — the user has selected a new global font
947 /// size.
948 #[xml(rename = "fontScale")]
949 FontScale,
950 /// The keyboard type has changed — for example, the user has plugged in an external
951 /// keyboard.
952 #[xml(rename = "keyboard")]
953 Keyboard,
954 /// The keyboard accessibility has changed — for example, the user hasrevealed the
955 /// hardware keyboard.
956 #[xml(rename = "keyboardHidden")]
957 KeyboardHidden,
958 /// The layout direction has changed — for example, changing from left-to-right (LTR)
959 /// to right-to-left (RTL). Added in API level 17.
960 #[xml(rename = "layoutDirection")]
961 LayoutDirection,
962 /// The locale has changed — the user has selected a new language that text should be
963 /// displayed in.
964 #[xml(rename = "locale")]
965 Locale,
966 /// The IMSI mobile country code (MCC) has changed — a SIM has been detected and
967 /// updated the MCC.
968 #[xml(rename = "mcc")]
969 Mcc,
970 /// The IMSI mobile network code (MNC) has changed — a SIM has been detected and
971 /// updated the MNC.
972 #[xml(rename = "mnc")]
973 Mnc,
974 /// The navigation type (trackball/dpad) has changed. (This should never
975 /// normally happen.)
976 #[xml(rename = "navigation")]
977 Navigation,
978 /// The screen orientation has changed — the user has rotated the device.
979 ///
980 /// ## Note
981 /// If your application targets Android 3.2 (API level 13) or higher, then you should
982 /// also declare the "`screenSize`" and "`screenLayout`" configurations, because
983 /// they might also change when a device switches between portrait and landscape
984 /// orientations.
985 #[xml(rename = "orientation")]
986 Orientation,
987 /// The screen layout has changed — a different display might now be active.
988 #[xml(rename = "screenLayout")]
989 ScreenLayout,
990 /// The current available screen size has changed. This represents a change in the
991 /// currently available size, relative to the current aspect ratio, so will change
992 /// when the user switches between landscape and portrait. Added in API level 13.
993 #[xml(rename = "screenSize")]
994 ScreenSize,
995 /// The physical screen size has changed. This represents a change in size regardless
996 /// of orientation, so will only change when the actual physical screen size has
997 /// changed such as switching to an external display. A change to this
998 /// configuration corresponds to a change in the [`smallestWidth configuration`].
999 /// Added in API level 13
1000 ///
1001 /// [`smallestWidth configuration`]: https://developer.android.com/guide/topics/resources/providing-resources#SmallestScreenWidthQualifier
1002 #[xml(rename = "smallestScreenSize")]
1003 SmallestScreenSize,
1004 /// The touchscreen has changed. (This should never normally happen.)
1005 #[xml(rename = "touchscreen")]
1006 Touchscreen,
1007 /// The user interface mode has changed — the user has placed the device into a desk
1008 /// or car dock, or the night mode has changed. For more information about the
1009 /// different UI modes, see [`UiModeManager`]. Added in API level 8.
1010 ///
1011 /// [`UiModeManager`]: https://developer.android.com/reference/android/app/UiModeManager
1012 #[xml(rename = "uiMode")]
1013 UiMode,
1014}
1015
1016/// Four values which produce the following effects when the user opens a document with
1017/// the application
1018#[derive(Debug, Deserialize, Serialize, XmlSerialize, XmlDeserialize, PartialEq, Eq, Clone)]
1019#[serde(rename_all = "camelCase")]
1020#[derive(Default)]
1021pub enum DocumentLaunchMode {
1022 /// The system searches for a task whose base intent's `ComponentName` and data URI
1023 /// match those of the launching intent. If the system finds such a task, the
1024 /// system clears the task, and restarts with the root activity receiving a call
1025 /// to [`onNewIntent(android.content.Intent)`]. If the system does not find such a
1026 /// task, the system creates a new task.
1027 ///
1028 /// [`onNewIntent(android.content.Intent)`]: https://developer.android.com/reference/android/app/Activity#onNewIntent(android.content.Intent)
1029 #[xml(rename = "intoExisting")]
1030 IntoExisting,
1031 /// The activity creates a new task for the document, even if the document is already
1032 /// opened. This is the same as setting both the [`FLAG_ACTIVITY_NEW_DOCUMENT`]
1033 /// and [`FLAG_ACTIVITY_MULTIPLE_TASK`] flags.
1034 ///
1035 /// [`FLAG_ACTIVITY_NEW_DOCUMENT`]: https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_NEW_DOCUMENT
1036 /// [`FLAG_ACTIVITY_MULTIPLE_TASK`]: https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_MULTIPLE_TASK
1037 #[xml(rename = "always")]
1038 Always,
1039 /// The activity does not create a new task for the activity. This is the default
1040 /// value, which creates a new task only when [`FLAG_ACTIVITY_NEW_TASK`]
1041 /// is set. The overview screen treats the activity as it would by
1042 /// default: it displays a single task for the app, which resumes from
1043 /// whatever activity the user last invoked.
1044 ///
1045 /// [`FLAG_ACTIVITY_NEW_TASK`]: https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_NEW_TASK
1046 #[xml(rename = "none")]
1047 #[default]
1048 None,
1049 /// This activity is not launched into a new document even if the Intent contains
1050 /// [`FLAG_ACTIVITY_NEW_DOCUMENT`]. Setting this overrides the behavior of the
1051 /// [`FLAG_ACTIVITY_NEW_DOCUMENT`] and [`FLAG_ACTIVITY_MULTIPLE_TASK`] flags, if
1052 /// either of these are set in the activity, and the overview screen displays a
1053 /// single task for the app, which resumes from whatever activity the user last
1054 /// invoked.
1055 ///
1056 /// [`FLAG_ACTIVITY_NEW_DOCUMENT`]: https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_NEW_DOCUMENT
1057 /// [`FLAG_ACTIVITY_MULTIPLE_TASK`]: https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_MULTIPLE_TASK
1058 #[xml(rename = "never")]
1059 Never,
1060}
1061
1062/// An instruction on how the activity should be launched.
1063///
1064/// As shown in the enum variant description, the modes fall into two main groups, with
1065/// `"standard"` and `"singleTop"`activities on one side, and "singleTask"
1066/// and "singleInstance" activities on the other. An activity with the
1067/// `"standard"` or "singleTop" launch mode can be instantiated multiple
1068/// times. The instances can belong to any task and can be located
1069/// anywhere in the activity stack. Typically, they're launched into the
1070/// task that called [`startActivity()`] (unless the Intent object contains a
1071/// [`FLAG_ACTIVITY_NEW_TASK`] instruction, in which case a different task is
1072/// chosen — see the [`taskAffinity`] attribute).
1073///
1074/// In contrast, `"singleTask"` and `"singleInstance"` activities can only begin a
1075/// task. They are always at the root of the activity stack. Moreover, the
1076/// device can hold only one instance of the activity at a time — only one
1077/// such task.
1078///
1079/// The `"standard"` and `"singleTop"` modes differ from each other in just one
1080/// respect: Every time there's a new intent for a `"standard"` activity, a new
1081/// instance of the class is created to respond to that intent. Each instance
1082/// handles a single intent. Similarly, a new instance of a `"singleTop"` activity
1083/// may also be created to handle a new intent. However, if the target task
1084/// already has an existing instance of the activity at the top of its stack, that
1085/// instance will receive the new intent (in an [`onNewIntent()`] call); a new
1086/// instance is not created. In other circumstances — for example, if an existing
1087/// instance of the `"singleTop"` activity is in the target task, but not at
1088/// the top of the stack, or if it's at the top of a stack, but not in
1089/// the target task — a new instance would be created and pushed on the
1090/// stack.
1091///
1092/// Similarly, if you [`navigate up`] to an activity on the current stack, the behavior is
1093/// determined by the parent activity's launch mode. If the parent activity has
1094/// launch mode `singleTop` (or the `up` intent contains [`FLAG_ACTIVITY_CLEAR_TOP`]),
1095/// the parent is brought to the top of the stack, and its state is preserved. The
1096/// navigation intent is received by the parent activity's [`onNewIntent()`] method.
1097/// If the parent activity has launch mode standard (and the up intent does not
1098/// contain [`FLAG_ACTIVITY_CLEAR_TOP`]), the current activity and its parent
1099/// are both popped off the stack, and a new instance of the parent activity
1100/// is created to receive the navigation intent.
1101///
1102/// The "singleTask" and "singleInstance" modes also differ from each other in only
1103/// one respect: A "singleTask" activity allows other activities to be part of its
1104/// task. It's always at the root of its task, but other activities (necessarily
1105/// "standard" and "singleTop" activities) can be launched into that task. A
1106/// "singleInstance" activity, on the other hand, permits no other activities to be
1107/// part of its task. It's the only activity in the task. If it starts another
1108/// activity, that activity is assigned to a different task — as if
1109/// FLAG_ACTIVITY_NEW_TASK was in the intent.
1110///
1111/// As shown in the enum variant description, `standard` is the default mode and is
1112/// appropriate for most types of activities. `SingleTop` is also a common and useful
1113/// launch mode for many types of activities. The other modes — `singleTask` and
1114/// `singleInstance` — are `not appropriate for most applications`, since they result in
1115/// an interaction model that is likely to be unfamiliar to users and is very different
1116/// from most other applications.
1117///
1118/// Regardless of the launch mode that you choose, make sure to test the usability of the
1119/// activity during launch and when navigating back to it from other activities and tasks
1120/// using the Back button.
1121///
1122/// For more information on launch modes and their interaction with Intent flags, see the
1123/// [`Tasks and Back Stack`] document.
1124///
1125/// [`startActivity()`]: https://developer.android.com/reference/android/content/Context#startActivity(android.content.Intent)
1126/// [`FLAG_ACTIVITY_NEW_TASK`]: https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_NEW_TASK
1127/// [`taskAffinity`]: crate::Activity#structfield.task_affinity
1128/// [`onNewIntent()`]: https://developer.android.com/reference/android/app/Activity#onNewIntent(android.content.Intent)
1129/// [`navigate up`]: https://developer.android.com/guide/navigation
1130/// [`FLAG_ACTIVITY_CLEAR_TOP`]: https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_CLEAR_TOP
1131/// [`Tasks and Back Stack`]: https://developer.android.com/guide/components/activities/tasks-and-back-stack
1132#[derive(Debug, Deserialize, Serialize, XmlSerialize, XmlDeserialize, PartialEq, Eq, Clone)]
1133#[serde(rename_all = "camelCase")]
1134#[derive(Default)]
1135pub enum LaunchMode {
1136 /// Default. The system always creates a new instance of the activity in the target
1137 /// task and routes the intent to it.
1138 ///
1139 /// Use Cases: Normal launches for most activities
1140 ///
1141 /// Multiple Instances?: Yes
1142 #[xml(rename = "standard")]
1143 #[default]
1144 Standard,
1145 /// If an instance of the activity already exists at the top of the target task, the
1146 /// system routes the intent to that instance through a call to
1147 /// its [`onNewIntent()`] method, rather than creating a new instance of the
1148 /// activity.
1149 ///
1150 /// Use Cases: Normal launches for most activities
1151 ///
1152 /// Multiple Instances?: Conditionally
1153 ///
1154 /// [`onNewIntent()`]: https://developer.android.com/reference/android/app/Activity#onNewIntent(android.content.Intent)
1155 #[xml(rename = "singleTop")]
1156 SingleTop,
1157 /// The system creates the activity at the root of a new task and routes the intent to
1158 /// it. However, if an instance of the activity already exists, the system routes
1159 /// the intent to existing instance through a call to its [`onNewIntent()`]
1160 /// method, rather than creating a new one.
1161 ///
1162 /// Use Cases: Specialized launches (not recommended for general use)
1163 ///
1164 /// Multiple Instances?: No
1165 ///
1166 /// [`onNewIntent()`]: https://developer.android.com/reference/android/app/Activity#onNewIntent(android.content.Intent)
1167 #[xml(rename = "singleTask")]
1168 SingleTask,
1169 /// Same as "`singleTask`", except that the system doesn't launch any other activities
1170 /// into the task holding the instance. The activity is always the single and only
1171 /// member of its task.
1172 ///
1173 /// Use Cases: Specialized launches (not recommended for general use)
1174 ///
1175 /// Multiple Instances?: No
1176 #[xml(rename = "singleInstance")]
1177 SingleInstance,
1178}
1179
1180/// This value indicates how tasks rooted at this activity will behave in lockTask mode.
1181/// The value can be any one of the following [`R.attr.lockTaskMode`] string values:
1182///
1183/// [`R.attr.lockTaskMode`]: https://developer.android.com/reference/android/R.attr#lockTaskMode
1184#[derive(Debug, Deserialize, Serialize, XmlSerialize, XmlDeserialize, PartialEq, Eq, Clone)]
1185#[serde(rename_all = "camelCase")]
1186#[derive(Default)]
1187pub enum LockTaskMode {
1188 /// `Default value`. This is the default value. Tasks don't launch into lock task mode
1189 /// but can be placed there by calling [`startLockTask()`].
1190 ///
1191 /// [`startLockTask()`]: https://developer.android.com/reference/android/app/Activity#startLockTask()
1192 #[xml(rename = "normal")]
1193 #[default]
1194 Normal,
1195 /// Tasks don't launch into lockTask mode, and the device user can't pin these tasks
1196 /// from the overview screen.
1197 ///
1198 /// ## Note
1199 /// This mode is only available to system and privileged applications.
1200 /// Non-privileged apps with this value are treated as `normal`.
1201 #[xml(rename = "never")]
1202 Never,
1203 /// If the DPC authorizes this package using
1204 /// [`DevicePolicyManager.setLockTaskPackages()`], then this mode is identical to
1205 /// always, except that the activity needs to call [`stopLockTask()`] before being
1206 /// able to finish if it is the last locked task. If the DPC does not authorize
1207 /// this package then this mode is identical to normal.
1208 ///
1209 /// [`DevicePolicyManager.setLockTaskPackages()`]: https://developer.android.com/reference/android/app/admin/DevicePolicyManager#setLockTaskPackages(android.content.ComponentName,%20java.lang.String[])
1210 /// [`stopLockTask()`]: https://developer.android.com/reference/android/app/Activity#stopLockTask()
1211 #[serde(rename = "if_whitelisted")]
1212 #[xml(rename = "if_whitelisted")]
1213 IfWhitelisted,
1214 /// Tasks rooted at this activity always launch into lock task mode. If the
1215 /// system is already in lock task mode when this task is launched then the
1216 /// new task are launched on top of the current task. Tasks launched in
1217 /// this mode can exit lock task mode by calling [`finish()`].
1218 ///
1219 /// ## Note
1220 /// This mode is only available to system and privileged
1221 /// applications. Non-privileged apps with this value are treated as `normal`.
1222 ///
1223 /// [`finish()`]: https://developer.android.com/reference/android/app/Activity#finish()
1224 #[xml(rename = "always")]
1225 Always,
1226}
1227
1228/// Defines how an instance of an activity is preserved within a containing task
1229/// across device restarts.
1230#[derive(Debug, Deserialize, Serialize, XmlSerialize, XmlDeserialize, PartialEq, Eq, Clone)]
1231#[serde(rename_all = "camelCase")]
1232#[derive(Default)]
1233pub enum PersistableMode {
1234 /// `Default value`. When the system restarts, the activity task is preserved, but
1235 /// only the root activity's launching intent is used.
1236 ///
1237 /// When your app's launching intent loads your app's root activity, the activity
1238 /// doesn't receive a [`PersistableBundle`] object. Therefore,
1239 /// don't use [`onSaveInstanceState()`] to preserve the state of your app's
1240 /// root activity across a device restart.
1241 ///
1242 /// ## Note
1243 /// This attribute value affects your app's behavior only if it's set on your app's
1244 /// root activity.
1245 ///
1246 /// [`PersistableBundle`]: https://developer.android.com/reference/android/os/PersistableBundle
1247 /// [`onSaveInstanceState()`]: https://developer.android.com/reference/android/app/Activity#onSaveInstanceState(android.os.Bundle,%20android.os.PersistableBundle)
1248 #[xml(rename = "persistRootOnly")]
1249 #[default]
1250 PersistRootOnly,
1251 /// This activity's state is preserved, along with the state of each activity higher
1252 /// up the [`back stack`] that has its own persistableMode attribute set to
1253 /// persistAcrossReboots. If an activity doesn't have a persistableMode attribute
1254 /// that is set to persistAcrossReboots, or if it's launched using the
1255 /// [`Intent.FLAG_ACTIVITY_NEW_DOCUMENT`] flag, then that activity, along with all
1256 /// activities higher up the back stack, aren't preserved.
1257 ///
1258 /// When an intent loads an activity whose persistableMode attribute is set to
1259 /// `persistAcrossReboots` in your app, the activity receives a
1260 /// [`PersistableBundle`] object in its [`onCreate()`] method. Therefore, you can
1261 /// use [`onSaveInstanceState()`] to preserve the state of an activity across a
1262 /// device restart as long as its persistableMode attribute is set to
1263 /// `persistAcrossReboots`.
1264 ///
1265 /// ## Note
1266 /// This attribute value affects your app's behavior even if it's
1267 /// set on an activity other than your app's root activity
1268 ///
1269 /// [`back stack`]: https://developer.android.com/guide/components/activities/tasks-and-back-stack
1270 /// [`Intent.FLAG_ACTIVITY_NEW_DOCUMENT`]: https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_NEW_DOCUMENT
1271 /// [`PersistableBundle`]: https://developer.android.com/reference/android/os/PersistableBundle
1272 /// [`onCreate()`]: https://developer.android.com/reference/android/app/Activity#onCreate(android.os.Bundle,%20android.os.PersistableBundle)
1273 /// [`onSaveInstanceState()`]: https://developer.android.com/reference/android/app/Activity#onSaveInstanceState(android.os.Bundle,%20android.os.PersistableBundle)
1274 #[xml(rename = "persistAcrossReboots")]
1275 PersistAcrossReboots,
1276 /// The activity's state isn't preserved.
1277 ///
1278 /// ## Note
1279 /// This attribute value affects your app's behavior only if it's
1280 /// set on your app's root activity.
1281 #[xml(rename = "persistNever")]
1282 PersistNever,
1283}
1284
1285/// The orientation of the activity's display on the device.
1286#[derive(Debug, Deserialize, Serialize, XmlSerialize, XmlDeserialize, PartialEq, Eq, Clone)]
1287#[serde(rename_all = "camelCase")]
1288#[derive(Default)]
1289pub enum ScreenOrientation {
1290 /// `The default value`. The system chooses the orientation. The policy it uses, and
1291 /// therefore the choices made in specific contexts, may differ from device to
1292 /// device.
1293 #[xml(rename = "unspecified")]
1294 #[default]
1295 Unspecified,
1296 /// The same orientation as the activity that's immediately beneath it in the activity
1297 /// stack.
1298 #[xml(rename = "behind")]
1299 Behind,
1300 /// Landscape orientation (the display is wider than it is tall).
1301 #[xml(rename = "landscape")]
1302 Landscape,
1303 /// Portrait orientation (the display is taller than it is wide).
1304 #[xml(rename = "portrait")]
1305 Portrait,
1306 /// Landscape orientation in the opposite direction from normal landscape.
1307 ///
1308 /// Added in API level 9.
1309 #[xml(rename = "reverseLandscape")]
1310 ReverseLandscape,
1311 /// Portrait orientation in the opposite direction from normal portrait.
1312 ///
1313 /// Added in API level 9.
1314 #[xml(rename = "reversePortrait")]
1315 ReversePortrait,
1316 /// Landscape orientation, but can be either normal or reverse landscape based on the
1317 /// device sensor. The sensor is used even if the user has locked sensor-based
1318 /// rotation.
1319 ///
1320 /// Added in API level 9.
1321 #[xml(rename = "sensorLandscape")]
1322 SensorLandscape,
1323 /// Portrait orientation, but can be either normal or reverse portrait based on the
1324 /// device sensor. The sensor is used even if the user has locked sensor-based
1325 /// rotation.
1326 ///
1327 /// Added in API level 9.
1328 #[xml(rename = "sensorPortrait")]
1329 SensorPortrait,
1330 /// Landscape orientation, but can be either normal or reverse landscape based on the
1331 /// device sensor and the user's preference.
1332 ///
1333 /// Added in API level 18.
1334 #[xml(rename = "userLandscape")]
1335 UserLandscape,
1336 /// Portrait orientation, but can be either normal or reverse portrait based on the
1337 /// device sensor and the user's preference.
1338 ///
1339 /// Added in API level 18.
1340 #[xml(rename = "userPortrait")]
1341 UserPortrait,
1342 /// The orientation is determined by the device orientation sensor. The orientation of
1343 /// the display depends on how the user is holding the device; it changes when the
1344 /// user rotates the device. Some devices, though, will not rotate to all four
1345 /// possible orientations, by default. To allow all four orientations, use
1346 /// "`fullSensor`" The sensor is used even if the user locked sensor-based rotation.
1347 #[xml(rename = "sensor")]
1348 Sensor,
1349 /// The orientation is determined by the device orientation sensor for any of the 4
1350 /// orientations. This is similar to "`sensor`" except this allows any of the 4
1351 /// possible screen orientations, regardless of what the device will normally do
1352 /// (for example, some devices won't normally use reverse portrait or reverse
1353 /// landscape, but this enables those).
1354 ///
1355 /// Added in API level 9.
1356 #[xml(rename = "fullSensor")]
1357 FullSensor,
1358 /// The orientation is determined without reference to a physical orientation sensor.
1359 /// The sensor is ignored, so the display will not rotate based on how the user
1360 /// moves the device.
1361 #[xml(rename = "nosensor")]
1362 Nosensor,
1363 /// The user's current preferred orientation.
1364 #[xml(rename = "user")]
1365 User,
1366 /// If the user has locked sensor-based rotation, this behaves the same as user,
1367 /// otherwise it behaves the same as `fullSensor` and allows any of the 4 possible
1368 /// screen orientations.
1369 ///
1370 /// Added in API level 18.
1371 #[xml(rename = "fullUser")]
1372 FullUser,
1373 /// Locks the orientation to its current rotation, whatever that is.
1374 ///
1375 /// Added in API level 18.
1376 #[xml(rename = "locked")]
1377 Locked,
1378}
1379
1380/// How the main window of the activity interacts with the window containing the on-screen
1381/// soft keyboard.
1382#[derive(Debug, Deserialize, Serialize, XmlSerialize, XmlDeserialize, PartialEq, Eq, Clone)]
1383#[serde(rename_all = "camelCase")]
1384#[derive(Default)]
1385pub enum WindowSoftInputMode {
1386 /// The state of the soft keyboard (whether it is hidden or visible) is not
1387 /// specified. The system will choose an appropriate state or rely on the
1388 /// setting in the theme. This is the default setting for the behavior
1389 /// of the soft keyboard.
1390 #[xml(rename = "stateUnspecified")]
1391 #[default]
1392 StateUnspecified,
1393 /// The soft keyboard is kept in whatever state it was last in, whether
1394 /// visible or hidden, when the activity comes to the fore.
1395 #[xml(rename = "stateUnchanged")]
1396 StateUnchanged,
1397 /// The soft keyboard is hidden when the user chooses the activity — that
1398 /// is, when the user affirmatively navigates forward to the activity,
1399 /// rather than backs into it because of leaving another activity.
1400 #[xml(rename = "stateHidden")]
1401 StateHidden,
1402 /// The soft keyboard is always hidden when the activity's main window has
1403 /// input focus.
1404 #[xml(rename = "stateAlwaysHidden")]
1405 StateAlwaysHidden,
1406 /// The soft keyboard is made visible when the user chooses the activity —
1407 /// that is, when the user affirmatively navigates forward to the activity,
1408 /// rather than backs into it because of leaving another activity.
1409 #[xml(rename = "stateVisible")]
1410 StateVisible,
1411 /// The soft keyboard is visible when the window receives input focus.
1412 #[xml(rename = "stateAlwaysVisible")]
1413 StateAlwaysVisible,
1414 /// It is unspecified whether the activity's main window resizes to make
1415 /// room for the soft keyboard, or whether the contents of the window pan to
1416 /// make the current focus visible on-screen. The system will
1417 /// automatically select one of these modes depending on whether the content
1418 /// of the window has any layout views that can scroll their contents.
1419 /// If there is such a view, the window will be resized, on the assumption
1420 /// that scrolling can make all of the window's contents visible within a
1421 /// smaller area.
1422 ///
1423 /// This is the default setting for the behavior of the main window.
1424 #[xml(rename = "adjustUnspecified")]
1425 AdjustUnspecified,
1426 /// The activity's main window is always resized to make room for the soft
1427 /// keyboard on screen.
1428 #[xml(rename = "adjustResize")]
1429 AdjustResize,
1430 /// The activity's main window is not resized to make room for the soft
1431 /// keyboard. Rather, the contents of the window are automatically panned so
1432 /// that the current focus is never obscured by the keyboard and users can
1433 /// always see what they are typing. This is generally less desirable
1434 /// than resizing, because the user may need to close the soft keyboard to
1435 /// get at and interact with obscured parts of the window.
1436 #[xml(rename = "adjustPan")]
1437 AdjustPan,
1438}