Use one standard Iris resource bundle

This commit is contained in:
iris committed 2026-09-11 02:09:17 -04:00
1 parent d8bb1699a8
commit 213a0debb7
24 files changed
+177 -186

No files matched your search

+7 -19
View File
@@ -3,7 +3,7 @@ use crate::client::transcript_fold::{TranscriptItem, fold_event};
use crate::ui::{self, TranscriptScreen};
use android_view::jni::{JavaVM, objects::GlobalRef};
use event_model::SeqEvent;
use iris::android::{AndroidAppState, AndroidRsc, AndroidUiState, HasAndroidUiState};
use iris::android::{AndroidAppState, AndroidUiState};
use iris::prelude::*;
use std::{
fs, mem,
@@ -42,6 +42,7 @@ const POLL_MS: u64 = 16;
const REPORT_MAX_HEIGHT_DP: f32 = 260.0;
#[derive(AndroidUiState)]
pub struct BenchClient {
ui_state: AndroidUiState,
content: WeakWidget<WidgetPtr>,
@@ -65,15 +66,6 @@ struct ImeState {
hidden_events: u32,
}
impl HasAndroidUiState for BenchClient {
fn android_state(&self) -> &AndroidUiState {
&self.ui_state
}
fn android_state_mut(&mut self) -> &mut AndroidUiState {
&mut self.ui_state
}
}
fn placeholder<Rsc: HasEvents>(rsc: &mut Rsc, message: &str) -> StrongWidget {
wtext(message.to_string())
.color(PaintId::WHITE)
@@ -121,7 +113,7 @@ fn battery_line(samples: &[i32]) -> String {
}
impl AndroidAppState for BenchClient {
fn new(mut ui_state: AndroidUiState, rsc: &mut AndroidRsc<Self>) -> Self {
fn new(mut ui_state: AndroidUiState, rsc: &mut StdRsc<Self>) -> Self {
let content = WidgetPtr::new().add(rsc);
let loading = placeholder(rsc, "Loading fixture...");
content(rsc).set(loading);
@@ -195,19 +187,15 @@ impl AndroidAppState for BenchClient {
client
}
fn platform_ready(&mut self, _rsc: &mut AndroidRsc<Self>, vm: JavaVM, view: GlobalRef) {
fn platform_ready(&mut self, _rsc: &mut StdRsc<Self>, vm: JavaVM, view: GlobalRef) {
self.platform = Some(Arc::new(PlatformHandle::new(vm, view)));
}
fn back_pressed(&mut self, _rsc: &mut AndroidRsc<Self>) -> bool {
fn back_pressed(&mut self, _rsc: &mut StdRsc<Self>) -> bool {
false
}
fn on_insets_changed(
&mut self,
rsc: &mut AndroidRsc<Self>,
insets: iris::android::WindowInsets,
) {
fn on_insets_changed(&mut self, rsc: &mut StdRsc<Self>, insets: iris::android::WindowInsets) {
if insets.top != self.last_top_pad {
self.last_top_pad = insets.top;
let controls = bench_controls(rsc, insets.top);
@@ -255,7 +243,7 @@ impl AndroidAppState for BenchClient {
const KEYBOARD_DIAGNOSTICS_DELAY_MS: u64 = 500;
type Rsc = AndroidRsc<BenchClient>;
type Rsc = StdRsc<BenchClient>;
/// What a report says about the `iris::input`/`iris::frame` trace, from
/// the flag read at the start of what is being reported and again at the
+3 -1
View File
@@ -4,7 +4,9 @@
use android_view::jni::JNIEnv;
use android_view::jni::objects::{JClass, JObject, JString};
use android_view::jni::sys::{jlong, jobjectArray};
use std::{path::Path, ptr, sync::OnceLock};
#[cfg(feature = "transcript-screen")]
use std::path::Path;
use std::{ptr, sync::OnceLock};
/// Gated with its one reader: the tabs demo links no `client-core` and so
/// has no ring to lay out, and an ungated constant is a warning in that
+11 -17
View File
@@ -8,12 +8,15 @@ use android_view::{
register_view_class,
};
#[cfg(not(feature = "transcript-screen"))]
use iris::android::{AndroidAppState, AndroidRsc, AndroidUiState, HasAndroidUiState};
use log::LevelFilter;
use std::{
ffi::c_void,
path::{Path, PathBuf},
use iris::{
android::{AndroidAppState, AndroidUiState},
macros::AndroidUiState,
rsc::StdRsc,
};
use log::LevelFilter;
use std::ffi::c_void;
#[cfg(feature = "transcript-screen")]
use std::path::{Path, PathBuf};
/// The app's own log ring and its upload -- only where `client-core` is
/// linked, which is every build that has a server to send to. The plain
@@ -35,23 +38,14 @@ mod transcript_client;
const VIEW_CLASS: &str = "dev/iris/android/demo/IrisView";
#[cfg(not(feature = "transcript-screen"))]
#[derive(AndroidUiState)]
pub struct Client {
ui_state: AndroidUiState,
}
#[cfg(not(feature = "transcript-screen"))]
impl HasAndroidUiState for Client {
fn android_state(&self) -> &AndroidUiState {
&self.ui_state
}
fn android_state_mut(&mut self) -> &mut AndroidUiState {
&mut self.ui_state
}
}
#[cfg(not(feature = "transcript-screen"))]
impl AndroidAppState for Client {
fn new(mut ui_state: AndroidUiState, rsc: &mut AndroidRsc<Self>) -> Self {
fn new(mut ui_state: AndroidUiState, rsc: &mut StdRsc<Self>) -> Self {
// `widgets.info` is the winit example's frame-debug readout, kept
// current from `DesktopAppState::window_event` -- android-view has
// no per-frame hook to drive the equivalent from here yet, so it
@@ -60,7 +54,7 @@ impl AndroidAppState for Client {
Self { ui_state }
}
fn back_pressed(&mut self, _rsc: &mut AndroidRsc<Self>) -> bool {
fn back_pressed(&mut self, _rsc: &mut StdRsc<Self>) -> bool {
false
}
}
+11 -19
View File
@@ -5,7 +5,7 @@ use crate::client::transcript_fold::{
};
use crate::ui::{self, TranscriptScreen};
use event_model::SeqEvent;
use iris::android::{AndroidAppState, AndroidRsc, AndroidUiState, HasAndroidUiState};
use iris::android::{AndroidAppState, AndroidUiState};
use iris::prelude::*;
use std::{
sync::{
@@ -15,6 +15,7 @@ use std::{
thread,
};
#[derive(AndroidUiState)]
pub struct TranscriptClient {
ui_state: AndroidUiState,
/// The screen's own content -- everything under the fixed
@@ -29,15 +30,6 @@ pub struct TranscriptClient {
generation: Arc<AtomicU64>,
}
impl HasAndroidUiState for TranscriptClient {
fn android_state(&self) -> &AndroidUiState {
&self.ui_state
}
fn android_state_mut(&mut self) -> &mut AndroidUiState {
&mut self.ui_state
}
}
fn build_transport() -> Result<UreqTransport, String> {
crate::android::enrollment::transport()
}
@@ -51,8 +43,8 @@ fn placeholder<Rsc: HasEvents>(rsc: &mut Rsc, message: &str) -> StrongWidget {
.any()
}
fn frame_report_controls(rsc: &mut AndroidRsc<TranscriptClient>) -> WeakWidget {
type Rsc = AndroidRsc<TranscriptClient>;
fn frame_report_controls(rsc: &mut StdRsc<TranscriptClient>) -> WeakWidget {
type Rsc = StdRsc<TranscriptClient>;
let report_rect = rect(Srgba8::rgb(50, 50, 60))
.on(
CursorSense::click(),
@@ -98,7 +90,7 @@ fn frame_report_controls(rsc: &mut AndroidRsc<TranscriptClient>) -> WeakWidget {
}
impl AndroidAppState for TranscriptClient {
fn new(mut ui_state: AndroidUiState, rsc: &mut AndroidRsc<Self>) -> Self {
fn new(mut ui_state: AndroidUiState, rsc: &mut StdRsc<Self>) -> Self {
let content = WidgetPtr::new().add(rsc);
let loading = placeholder(rsc, "Loading sessions...");
content(rsc).set(loading);
@@ -121,7 +113,7 @@ impl AndroidAppState for TranscriptClient {
client
}
fn back_pressed(&mut self, _rsc: &mut AndroidRsc<Self>) -> bool {
fn back_pressed(&mut self, _rsc: &mut StdRsc<Self>) -> bool {
// No screen stack of its own -- same "let the activity finish"
// answer `iris-android-app`'s tabs `Client` already gives.
false
@@ -129,13 +121,13 @@ impl AndroidAppState for TranscriptClient {
}
impl TranscriptClient {
fn show_message(&mut self, rsc: &mut AndroidRsc<Self>, message: &str) {
fn show_message(&mut self, rsc: &mut StdRsc<Self>, message: &str) {
let widget = placeholder(rsc, message);
(self.content)(rsc).set(widget);
self.screen = None;
}
fn spawn_fetch_sessions(&mut self, rsc: &mut AndroidRsc<Self>) {
fn spawn_fetch_sessions(&mut self, rsc: &mut StdRsc<Self>) {
let redraw = rsc.tasks.redraw_handle();
let my_generation = self.generation.load(Ordering::SeqCst);
let generation = self.generation.clone();
@@ -164,7 +156,7 @@ impl TranscriptClient {
});
}
fn select_session(&mut self, rsc: &mut AndroidRsc<Self>, session_id: String) {
fn select_session(&mut self, rsc: &mut StdRsc<Self>, session_id: String) {
let my_generation = self.generation.fetch_add(1, Ordering::SeqCst) + 1;
self.items.clear();
self.session_id = Some(session_id.clone());
@@ -251,7 +243,7 @@ impl TranscriptClient {
});
}
fn rebuild_transcript(&mut self, rsc: &mut AndroidRsc<Self>) {
fn rebuild_transcript(&mut self, rsc: &mut StdRsc<Self>) {
let in_progress = self
.screen
.as_ref()
@@ -279,7 +271,7 @@ impl TranscriptClient {
self.screen = Some(screen);
}
fn apply_event(&mut self, rsc: &mut AndroidRsc<Self>, event: &SeqEvent) {
fn apply_event(&mut self, rsc: &mut StdRsc<Self>, event: &SeqEvent) {
let old_items = self.items.clone();
self.items = fold_event(&self.items, event);
match self.screen.as_mut() {