Skip to content

Commit 2f5a44f

Browse files
committed
TEMP
1 parent 3bd3d92 commit 2f5a44f

File tree

16 files changed

+258
-141
lines changed

16 files changed

+258
-141
lines changed

Cargo.lock

Lines changed: 165 additions & 81 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ fluent-syntax = "0.12.0"
2929
futures-util = "0.3.31"
3030
hex = "0.4.3"
3131
image = { version = "0.25.9", default-features = false }
32+
# inputbox = "0.0.1"
33+
inputbox = { git = "https://github.com/Mivik/inputbox.git", rev = "c20e7a9" }
3234
lru = "0.16.3"
3335
lyon = "1.0.16"
3436
nalgebra = "0.34.1"

phira/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ image = { workspace = true, default-features = false, features = [
3939
"rayon",
4040
"webp",
4141
] }
42+
inputbox = { workspace = true }
4243
logos = "0.16.1"
4344
lru = { workspace = true }
4445
lyon = { workspace = true }

phira/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use tracing::{error, info};
4242

4343
#[cfg(target_os = "android")]
4444
use jni::{
45-
objects::{JClass, JString},
45+
objects::{JClass, JObject, JString},
4646
sys::jint,
4747
JNIEnv,
4848
};
@@ -346,6 +346,12 @@ fn string_from_java(env: &mut JNIEnv, s: JString) -> String {
346346
env.get_string(&s).unwrap().to_str().unwrap().to_owned()
347347
}
348348

349+
#[cfg(target_os = "android")]
350+
#[no_mangle]
351+
pub extern "C" fn Java_quad_1native_QuadNative_initializeContext2(mut env: JNIEnv, _: JClass, context: JObject) {
352+
inputbox::backend::Android::set_android_context(&mut env, &context).unwrap();
353+
}
354+
349355
#[cfg(target_os = "android")]
350356
#[no_mangle]
351357
pub extern "C" fn Java_quad_1native_QuadNative_prprActivityOnPause(_env: JNIEnv, _: JClass) {

phira/src/login.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ use crate::{
88
scene::{check_read_tos_and_policy, dispatch_tos_task, JUST_ACCEPTED_TOS},
99
};
1010
use anyhow::Result;
11+
use inputbox::{InputBox, InputMode};
1112
use macroquad::prelude::*;
1213
use once_cell::sync::Lazy;
1314
use prpr::{
1415
core::BOLD_FONT,
1516
ext::{semi_black, semi_white, RectExt},
16-
scene::{request_input, request_password, return_input, show_error, show_message, take_input},
17+
scene::{request_input, return_input, show_error, show_message, take_input},
1718
task::Task,
1819
ui::{DRectButton, Dialog, Ui},
1920
};
@@ -147,23 +148,23 @@ impl Login {
147148
return true;
148149
}
149150
if self.input_email.touch(touch, t) {
150-
request_input("email", &self.t_email);
151+
request_input("email", InputBox::new().default_text(&self.t_email));
151152
return true;
152153
}
153154
if self.input_pwd.touch(touch, t) {
154-
request_password("pwd", &self.t_pwd);
155+
request_input("pwd", InputBox::new().default_text(&self.t_pwd).mode(InputMode::Password));
155156
return true;
156157
}
157158
if self.input_reg_email.touch(touch, t) {
158-
request_input("reg_email", &self.t_reg_email);
159+
request_input("reg_email", InputBox::new().default_text(&self.t_reg_email));
159160
return true;
160161
}
161162
if self.input_reg_name.touch(touch, t) {
162-
request_input("reg_name", &self.t_reg_name);
163+
request_input("reg_name", InputBox::new().default_text(&self.t_reg_name));
163164
return true;
164165
}
165166
if self.input_reg_pwd.touch(touch, t) {
166-
request_password("reg_pwd", &self.t_reg_pwd);
167+
request_input("reg_pwd", InputBox::new().default_text(&self.t_reg_pwd).mode(InputMode::Password));
167168
return true;
168169
}
169170
if self.btn_to_reg.touch(touch, t) || self.btn_to_login.touch(touch, t) {

phira/src/mp/panel.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::{
55
scene::{Downloading, SongScene, RECORD_ID},
66
};
77
use anyhow::{anyhow, Context, Result};
8+
use inputbox::InputBox;
89
use macroquad::prelude::*;
910
use phira_mp_client::Client;
1011
use phira_mp_common::{RoomId, RoomState};
@@ -302,7 +303,7 @@ impl MPPanel {
302303
}
303304
if let Some(state) = client.blocking_state() {
304305
if self.chat_btn.touch(touch, t) {
305-
request_input("chat", &self.chat_text);
306+
request_input("chat", InputBox::new().default_text(&self.chat_text));
306307
return true;
307308
}
308309
if self.chat_send_btn.touch(touch, t) {
@@ -362,11 +363,11 @@ impl MPPanel {
362363
}
363364
} else {
364365
if self.create_room_btn.touch(touch, t) {
365-
request_input("room_id", "");
366+
request_input("room_id", InputBox::new());
366367
return true;
367368
}
368369
if self.join_room_btn.touch(touch, t) {
369-
request_input("join_room", "");
370+
request_input("join_room", InputBox::new());
370371
return true;
371372
}
372373
if self.disconnect_btn.touch(touch, t) {

phira/src/page/favorites.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use crate::{
1414
};
1515
use anyhow::Result;
1616
use chrono::{DateTime, Utc};
17+
use inputbox::InputBox;
1718
use macroquad::prelude::*;
1819
use prpr::{
1920
core::Tweenable,
@@ -418,11 +419,11 @@ impl Page for FavoritesPage {
418419
}
419420

420421
if self.create_btn.touch(touch, t) {
421-
request_input("fav_create", "");
422+
request_input("fav_create", InputBox::new());
422423
return Ok(true);
423424
}
424425
if self.import_btn.touch(touch, t) {
425-
request_input("fav_import", "");
426+
request_input("fav_import", InputBox::new());
426427
return Ok(true);
427428
}
428429

@@ -660,10 +661,10 @@ impl Page for FavoritesPage {
660661
if self.edit_menu.changed() {
661662
match self.edit_options[self.edit_menu.selected()] {
662663
"rename" => {
663-
request_input("fav_rename", &data.collections[index].name);
664+
request_input("fav_rename", InputBox::new().default_text(&data.collections[index].name));
664665
}
665666
"set-description" => {
666-
request_input("fav_description", &data.collections[index].description);
667+
request_input("fav_description", InputBox::new().default_text(&data.collections[index].description));
667668
}
668669
"set-cover" => {
669670
if data.collections[index].id.is_none() {
@@ -701,7 +702,7 @@ impl Page for FavoritesPage {
701702
self.rebuild_folders();
702703
}
703704
"batch-import" => {
704-
request_input("fav_batch_import", "");
705+
request_input("fav_batch_import", InputBox::new());
705706
}
706707
_ => {}
707708
}

phira/src/page/library.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use crate::{
1515
tags::TagsDialog,
1616
};
1717
use anyhow::{anyhow, Result};
18+
use inputbox::InputBox;
1819
use macroquad::prelude::*;
1920
use prpr::{
2021
ext::{poll_future, semi_black, JoinToString, LocalTask, RectExt, SafeTexture, ScaleType},
@@ -492,7 +493,7 @@ impl Page for LibraryPage {
492493
return Ok(true);
493494
}
494495
if !self.search_clr_btn.contains(touch.position) && self.search_btn.touch(touch, t) {
495-
request_input("search", &self.search_str);
496+
request_input("search", InputBox::new().default_text(&self.search_str));
496497
return Ok(true);
497498
}
498499
}
@@ -505,7 +506,7 @@ impl Page for LibraryPage {
505506
return Ok(true);
506507
}
507508
if !self.search_clr_btn.contains(touch.position) && self.search_btn.touch(touch, t) {
508-
request_input("search", &self.search_str);
509+
request_input("search", InputBox::new().default_text(&self.search_str));
509510
return Ok(true);
510511
}
511512
if self.filter_btn.touch(touch, t) {
@@ -693,7 +694,7 @@ impl Page for LibraryPage {
693694
todo!()
694695
}
695696
1 => {
696-
request_input("new_fav", "");
697+
request_input("new_fav", InputBox::new());
697698
}
698699
2 => {
699700
confirm_dialog(ttl!("del-confirm"), tl!("multi-delete-confirm", "count" => selected.len()), self.delete_multi.clone());

phira/src/page/settings.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use crate::{
1111
};
1212
use anyhow::Result;
1313
use bytesize::ByteSize;
14+
use inputbox::InputBox;
1415
use macroquad::prelude::*;
1516
use prpr::{
1617
core::BOLD_FONT,
@@ -391,7 +392,7 @@ impl GeneralList {
391392
return Ok(Some(true));
392393
}
393394
if self.mp_addr_btn.touch(touch, t) {
394-
request_input("mp_addr", &config.mp_address);
395+
request_input("mp_addr", InputBox::new().default_text(&config.mp_address));
395396
return Ok(Some(true));
396397
}
397398
#[cfg(not(target_env = "ohos"))]
@@ -408,7 +409,7 @@ impl GeneralList {
408409
return Ok(Some(true));
409410
}
410411
if self.anys_gateway_btn.touch(touch, t) {
411-
request_input("anys_gateway", &data.anys_gateway);
412+
request_input("anys_gateway", InputBox::new().default_text(&data.anys_gateway));
412413
return Ok(Some(true));
413414
}
414415
Ok(None)

phira/src/scene/song.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use base64::{engine::general_purpose::STANDARD, Engine};
2626
use chrono::{DateTime, Utc};
2727
use core::f32;
2828
use futures_util::StreamExt;
29+
use inputbox::InputBox;
2930
use macroquad::prelude::*;
3031
use phira_mp_common::{ClientCommand, CompactPos, JudgeEvent, TouchFrame};
3132
use prpr::{
@@ -1854,7 +1855,7 @@ impl Scene for SongScene {
18541855
}));
18551856
}
18561857
"review-deny" => {
1857-
request_input("deny-reason", "");
1858+
request_input("deny-reason", InputBox::new());
18581859
}
18591860
"review-del" => {
18601861
confirm_delete(self.chart_should_delete.clone());
@@ -1892,10 +1893,10 @@ impl Scene for SongScene {
18921893
}));
18931894
}
18941895
"stabilize-comment" => {
1895-
request_input("stabilize-comment", "");
1896+
request_input("stabilize-comment", InputBox::new());
18961897
}
18971898
"stabilize-deny" => {
1898-
request_input("stabilize-deny-reason", "");
1899+
request_input("stabilize-deny-reason", InputBox::new());
18991900
}
19001901
_ => {}
19011902
}

0 commit comments

Comments
 (0)