pub const ACTION_FOCUS: i32 = 1;
pub const ACTION_CLEAR_FOCUS: i32 = 2;
pub const ACTION_SELECT: i32 = 4;
pub const ACTION_CLICK: i32 = 16;
pub const ACTION_ACCESSIBILITY_FOCUS: i32 = 64;
pub const ACTION_CLEAR_ACCESSIBILITY_FOCUS: i32 = 128;
pub const ACTION_SCROLL_FORWARD: i32 = 4096;
pub const ACTION_SCROLL_BACKWARD: i32 = 8192;
pub const ACTION_EXPAND: i32 = 262144;
pub const ACTION_COLLAPSE: i32 = 524288;
pub const ACTION_SET_TEXT: i32 = 2097152;
pub const FOCUS_INPUT: i32 = 1;
pub const FOCUS_ACCESSIBILITY: i32 = 2;
pub const RANGE_TYPE_FLOAT: i32 = 1;
pub const CHECKED_STATE_FALSE: i32 = 0;
pub const CHECKED_STATE_TRUE: i32 = 1;
pub const CHECKED_STATE_PARTIAL: i32 = 2;
pub const CONTENT_CHANGE_TYPE_UNDEFINED: i32 = 0;
pub const CONTENT_CHANGE_TYPE_SUBTREE: i32 = 1;
pub const CONTENT_CHANGE_TYPE_TEXT: i32 = 2;
pub const CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION: i32 = 4;
pub const ACCESSIBILITY_LIVE_REGION_NONE: i32 = 0;
pub const ACCESSIBILITY_LIVE_REGION_POLITE: i32 = 1;
pub const DEFAULT_CLASS_NAME: &str = "android.view.View";
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct RangeInfo {
pub range_type: i32,
pub min: f32,
pub max: f32,
pub current: f32,
}
#[derive(Clone, Debug, PartialEq)]
pub struct NodeInfo {
pub children: Vec<i32>,
pub labeled_by: Vec<i32>,
pub class_name: Option<String>,
pub unique_id: Option<String>,
pub view_id_resource_name: Option<String>,
pub enabled: bool,
pub screen_reader_focusable: bool,
pub focusable: bool,
pub accessibility_focused: bool,
pub focused: bool,
pub bounds_in_screen: Option<(i32, i32, i32, i32)>,
pub text: Option<String>,
pub content_description: Option<String>,
pub actions: Vec<i32>,
pub clickable: bool,
pub checkable: bool,
pub checked: i32,
pub scrollable: bool,
pub selected: bool,
pub editable: bool,
pub range_info: Option<RangeInfo>,
pub text_selection: Option<(i32, i32)>,
pub live_region: i32,
}
impl Default for NodeInfo {
fn default() -> Self {
Self::new()
}
}
impl NodeInfo {
pub fn new() -> Self {
Self {
children: Vec::new(),
labeled_by: Vec::new(),
class_name: None,
unique_id: None,
view_id_resource_name: None,
enabled: false,
screen_reader_focusable: false,
focusable: false,
accessibility_focused: false,
focused: false,
bounds_in_screen: None,
text: None,
content_description: None,
actions: Vec::new(),
clickable: false,
checkable: false,
checked: CHECKED_STATE_FALSE,
scrollable: false,
selected: false,
editable: false,
range_info: None,
text_selection: None,
live_region: ACCESSIBILITY_LIVE_REGION_NONE,
}
}
pub fn add_action(&mut self, action: i32) {
if !self.actions.contains(&action) {
self.actions.push(action);
}
}
pub fn has_action(&self, action: i32) -> bool {
self.actions.contains(&action)
}
pub fn action_mask(&self) -> i32 {
self.actions.iter().fold(0, |mask, action| mask | action)
}
}