Skip to content

Commit 2a208e3

Browse files
authored
Merge pull request #280 from LedgerHQ/y333/fix_nbgl_streaming_review
NBGL streaming review usecase: subtitle is optional
2 parents 625d67e + 913f7fe commit 2a208e3

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ledger_device_sdk/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ledger_device_sdk"
3-
version = "1.24.2"
3+
version = "1.24.3"
44
authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"]
55
edition = "2021"
66
license.workspace = true

ledger_device_sdk/src/nbgl/nbgl_streaming_review.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ impl NbglStreamingReview {
3737
}
3838
}
3939

40-
pub fn start(&self, title: &str, subtitle: &str) -> bool {
40+
pub fn start(&self, title: &str, subtitle: Option<&str>) -> bool {
41+
crate::testing::debug_print("NbglStreamingReview::start called\n");
4142
unsafe {
4243
let title = CString::new(title).unwrap();
43-
let subtitle = CString::new(subtitle).unwrap();
44+
let subtitle = match subtitle {
45+
Some(s) => CString::new(s).unwrap(),
46+
None => CString::default(),
47+
};
4448

4549
self.ux_sync_init();
4650
match self.blind {
@@ -49,7 +53,10 @@ impl NbglStreamingReview {
4953
self.tx_type.to_c_type(false),
5054
&self.icon as *const nbgl_icon_details_t,
5155
title.as_ptr() as *const c_char,
52-
subtitle.as_ptr() as *const c_char,
56+
match subtitle.is_empty() {
57+
true => core::ptr::null(),
58+
false => subtitle.as_ptr() as *const c_char,
59+
},
5360
Some(choice_callback),
5461
);
5562
}
@@ -58,7 +65,10 @@ impl NbglStreamingReview {
5865
self.tx_type.to_c_type(false),
5966
&self.icon as *const nbgl_icon_details_t,
6067
title.as_ptr() as *const c_char,
61-
subtitle.as_ptr() as *const c_char,
68+
match subtitle.is_empty() {
69+
true => core::ptr::null(),
70+
false => subtitle.as_ptr() as *const c_char,
71+
},
6272
Some(choice_callback),
6373
);
6474
}

0 commit comments

Comments
 (0)