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