1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! # Termux GUI Rust Bindings
//!
//! This library provides Rust bindings for Termux:GUI, allowing you to create
//! native Android GUI applications using Rust in the Termux environment.
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use termux_gui::{Activity, Result};
//!
//! fn main() -> Result<()> {
//! // Create an activity (dialog mode)
//! let mut activity = Activity::new(true)?;
//!
//! // Create a layout
//! let layout = activity.create_linear_layout(None)?;
//!
//! // Add a title
//! let mut title = activity.create_text_view("Hello Termux!", Some(layout.id()))?;
//! title.set_text_size(&mut activity, 24)?;
//!
//! // Add a button
//! let button = activity.create_button("Click Me", Some(layout.id()))?;
//!
//! // Event loop
//! use std::io::Read;
//! let mut buf = [0u8; 1024];
//! loop {
//! let n = activity.event_stream().read(&mut buf)?;
//! if n > 0 {
//! let event: serde_json::Value = serde_json::from_slice(&buf[..n])?;
//! if event["type"] == "UserLeave" {
//! break;
//! }
//! }
//! }
//!
//! activity.finish()?;
//! Ok(())
//! }
//! ```
//!
//! ## Architecture
//!
//! - **Connection**: Low-level socket communication with Termux GUI service
//! - **Activity**: Represents a GUI window (dialog or full-screen)
//! - **View**: Base view type with common operations
//! - **Components**: UI widgets (TextView, Button, EditText, etc.)
//!
//! ## Features
//!
//! - Object-oriented API design
//! - Type-safe error handling with `thiserror`
//! - Zero-cost abstractions using lifetimes
//! - All Termux GUI components supported
// Re-exports for convenience
pub use Connection;
pub use Activity;
pub use ;
pub use ;
// Re-export all components
pub use ;