Implement Android Room UI and customizable palette
android-ci / android-arm64 (push) Successful in 17m10s
android-ci / android-arm64 (push) Successful in 17m10s
This commit is contained in:
1 parent
057bfae87c
commit
87265a3e75
26 files changed
+825
-135
No files matched your search
@@ -11,6 +11,7 @@ pub struct Snapshot {
|
||||
pub audio_input_starts:u64,pub audio_output_starts:u64,
|
||||
pub connections:Arc<ConnectionsSnapshot>,pub tabs:Vec<Tab>,pub tree:Vec<Entry>,pub bookmarks:Vec<Entry>,pub contacts:Vec<Entry>,
|
||||
pub detail:Detail,pub actions:Vec<Action>,pub voice:Option<Voice>,pub profile_form:Option<Form>,pub dialog:Option<Form>,
|
||||
pub room:Room,
|
||||
pub last_error:Option<crate::services::ServiceError>,pub settings_completed:u64,
|
||||
pub status:String,pub error:String,pub loading:bool,pub destination:Destination,
|
||||
pub settings:SettingsSnapshot,pub settings_view:ViewState,pub chat:ChatPresentation,
|
||||
@@ -22,7 +23,7 @@ pub struct Snapshot {
|
||||
pub insets:crate::platform::lifecycle::Insets,pub text_scale:f32,pub reduced_motion:bool,pub high_contrast:bool,
|
||||
}
|
||||
impl Default for Snapshot {
|
||||
fn default()->Self{Self{revision:0,ready:false,last_error:None,settings_completed:0,audio_input_active:false,audio_output_active:false,audio_input_starts:0,audio_output_starts:0,bootstrap:BootstrapState::Loading,root:None,catalog:Catalog::default(),connections:Arc::default(),tabs:vec![],tree:vec![],bookmarks:vec![],contacts:vec![],detail:Detail::default(),actions:vec![],voice:None,profile_form:None,dialog:None,status:String::new(),error:String::new(),loading:true,destination:Destination::Servers,settings:SettingsSnapshot::default(),settings_view:ViewState::default(),chat:ChatPresentation::default(),streams:vec![],#[cfg(feature="webrtc")]frames:vec![],theme:None,theme_revision:0,theme_fonts:vec![],insets:Default::default(),text_scale:1.,reduced_motion:false,high_contrast:false}}
|
||||
fn default()->Self{Self{revision:0,ready:false,last_error:None,settings_completed:0,audio_input_active:false,audio_output_active:false,audio_input_starts:0,audio_output_starts:0,bootstrap:BootstrapState::Loading,root:None,catalog:Catalog::default(),connections:Arc::default(),tabs:vec![],tree:vec![],bookmarks:vec![],contacts:vec![],detail:Detail::default(),actions:vec![],voice:None,room:Room::default(),profile_form:None,dialog:None,status:String::new(),error:String::new(),loading:true,destination:Destination::Servers,settings:SettingsSnapshot::default(),settings_view:ViewState::default(),chat:ChatPresentation::default(),streams:vec![],#[cfg(feature="webrtc")]frames:vec![],theme:None,theme_revision:0,theme_fonts:vec![],insets:Default::default(),text_scale:1.,reduced_motion:false,high_contrast:false}}
|
||||
}
|
||||
pub struct AppState {
|
||||
pub snapshot:Snapshot,pub selected:Option<Target>,pub expanded:HashSet<(String,u64)>,pub folder:Option<String>,
|
||||
@@ -64,7 +65,8 @@ impl AppState {
|
||||
.and_then(|connection|connection.server.as_ref())
|
||||
.and_then(|server|server["channels"].as_array().and_then(|channels|channels.iter().find(|channel|channel["id"].as_u64()==server["own_channel_id"].as_u64())))
|
||||
.and_then(|channel|channel["name"].as_str()) {
|
||||
voice.status=format!("{}: {channel}",c.text("ui.channel"));
|
||||
voice.title=channel.into();
|
||||
voice.status=c.text(if voice.transmitting{"native.room.speaking"}else if voice.deafened{"native.room.sound_off"}else if voice.muted{"native.room.listening"}else{"native.room.microphone_on"});
|
||||
}
|
||||
}
|
||||
self.snapshot.actions=actions(&Target::application(),&[Operation::NewConnection,Operation::BookmarkCreate,Operation::BookmarkFolderCreate,Operation::ContactAdd,Operation::OpenLogs],&c);
|
||||
@@ -74,8 +76,38 @@ impl AppState {
|
||||
for bookmark in prefs["savedServers"].as_array().into_iter().flatten(){if bookmark["folder"].as_str()!=self.folder.as_deref(){continue}if let Some(id)=bookmark["id"].as_str(){let target=Target{entity:Entity::Bookmark(id.into()),name:bookmark["name"].as_str().unwrap_or_default().into(),..Target::application()};let mut e=entry(target.clone(),format!("bookmark:{id}"),0);e.subtitle=bookmark["address"].as_str().unwrap_or_default().into();e.actions=actions(&target,&[Operation::BookmarkConnect,Operation::BookmarkEdit,Operation::BookmarkRename,Operation::BookmarkDuplicate,Operation::BookmarkMove,Operation::BookmarkPasswordSet,Operation::BookmarkPasswordReveal,Operation::BookmarkPasswordClear,Operation::BookmarkDelete],&c);self.snapshot.bookmarks.push(e);}}
|
||||
self.snapshot.contacts.clear();for contact in prefs["contacts"].as_array().into_iter().flatten(){if let Some(uid)=contact["uid"].as_str(){let target=Target{entity:Entity::Contact(uid.into()),name:contact["alias"].as_str().filter(|s|!s.is_empty()).or_else(||contact["name"].as_str()).unwrap_or(uid).into(),..Target::application()};let mut e=entry(target.clone(),format!("contact:{uid}"),0);e.subtitle=uid.into();e.actions=actions(&target,&[Operation::ContactChat,Operation::ContactRename,Operation::ContactIgnore,Operation::ContactUnignore,Operation::ContactRemove],&c);self.snapshot.contacts.push(e);}}
|
||||
if self.detail_target.as_ref().is_some_and(|t|ctx.require_target(t).is_err()){self.detail_target=None;self.snapshot.detail=Detail::default();}
|
||||
#[cfg(target_os="android")]
|
||||
if self.snapshot.destination!=Destination::Settings {
|
||||
super::settings_actions::cancel_palette_preview(ctx)?;
|
||||
if self.snapshot.settings_view.page()==crate::ui::settings::Page::Palette {self.snapshot.settings_view.pages.clear();}
|
||||
}
|
||||
self.snapshot.settings=super::settings_actions::project(ctx,&self.snapshot.settings_view)?;
|
||||
self.snapshot.chat=super::chat_actions::project(ctx).await?;
|
||||
#[cfg(target_os="android")]
|
||||
{
|
||||
self.snapshot.room=Room::default();
|
||||
if let Some(connection)=viewed.filter(|connection|connection.is_connected()) {
|
||||
if let Some(server)=connection.server.as_ref() {
|
||||
if let Some(channel_id)=server["own_channel_id"].as_u64().filter(|id|*id>0) {
|
||||
let room=&mut self.snapshot.room;
|
||||
room.server=server["server"]["name"].as_str().unwrap_or(&connection.address).into();
|
||||
room.title=server["channels"].as_array().into_iter().flatten().find(|channel|channel["id"].as_u64()==Some(channel_id)).and_then(|channel|channel["name"].as_str()).unwrap_or_default().into();
|
||||
room.target=Some(Target{session:Some(connection.key.clone()),entity:Entity::Channel{id:channel_id},name:room.title.clone(),own_channel_id:Some(channel_id)});
|
||||
for client in server["clients"].as_array().into_iter().flatten().filter(|client|client["channel_id"].as_u64()==Some(channel_id)) {
|
||||
let (Some(id),Some(uid))=(client["id"].as_u64().and_then(|id|u16::try_from(id).ok()),client["uid"].as_str()) else {continue};
|
||||
let target=Target{session:Some(connection.key.clone()),entity:Entity::Client{id,uid:uid.into(),channel_id},name:client["nickname"].as_str().unwrap_or_default().into(),own_channel_id:Some(channel_id)};
|
||||
let mut participant=entry(target.clone(),format!("client:{id}:{uid}"),0);
|
||||
participant.muted=client["input_muted"]==true;
|
||||
participant.talking=if client["id"]==server["own_client_id"] {connection.audio.transmitting && ctx.microphone_enabled(&connection.key)} else {connection.talking.contains(&id)};
|
||||
participant.subtitle=c.text(if participant.talking{"native.room.speaking"}else if participant.muted{"native.room.microphone_off"}else{"native.room.listening"});
|
||||
participant.actions=actions(&target,&[Operation::ClientVolume,Operation::ClientPrivateChat,Operation::ClientInfo,Operation::ClientConnectionInfo,Operation::ClientPoke,Operation::ClientWhisperAdd,Operation::ClientMove,Operation::ClientKickChannel,Operation::ClientKickServer,Operation::ClientBan,Operation::ClientCommander,Operation::ClientServerGroupAdd,Operation::ClientServerGroupRemove,Operation::ClientChannelGroupSet,Operation::ClientPermissions,Operation::ClientChannelPermissionSet,Operation::ClientChannelPermissionRemove,Operation::ClientAvatarChoose,Operation::ClientAvatarDelete,Operation::TalkGrant,Operation::TalkRevoke,Operation::ContactAdd],&c);
|
||||
room.participants.push(participant);
|
||||
}
|
||||
room.chat_id=self.snapshot.chat.tabs.iter().find(|tab|tab.target.session==connection.key && matches!(tab.target.target,crate::ui::chat::ChatTarget::Channel(id) if id==channel_id)).map(|tab|format!("{}\u{1f}{}\u{1f}{:?}\u{1f}{}",tab.target.scope.base.identity,tab.target.scope.base.server,tab.target.scope.kind,tab.target.scope.key)).unwrap_or_default();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
self.snapshot.streams=super::stream_actions::project(ctx).await?;
|
||||
#[cfg(feature="webrtc")] {self.snapshot.frames=super::stream_actions::frame_sources(ctx).await;}
|
||||
self.snapshot.connections=connections;self.snapshot.loading=false;self.snapshot.bootstrap=BootstrapState::Ready;Ok(())
|
||||
|
||||
Reference in new issue
Block a user