Refactor: env of keyboard mode

This commit is contained in:
asur4s 2022-09-03 21:49:58 -04:00
parent abf79ba61d
commit 925a9e43cb
3 changed files with 15 additions and 4 deletions

View File

@ -711,3 +711,14 @@ pub fn make_fd_flutter(id: i32, entries: &Vec<FileEntry>, only_count: bool) -> S
m.insert("total_size".into(), json!(n as f64));
serde_json::to_string(&m).unwrap_or("".into())
}
pub fn get_keyboard_mode() -> String {
return std::env::var("KEYBOARD_MODE")
.unwrap_or(String::from("legacy"))
.to_lowercase();
}
pub fn save_keyboard_mode(value: String) {
std::env::set_var("KEYBOARD_MODE", value);
}

View File

@ -1,3 +1,4 @@
use crate::common::{get_keyboard_mode, save_keyboard_mode};
use std::{
collections::HashMap,
ops::{Deref, DerefMut},

View File

@ -7,6 +7,7 @@ use crate::client::{
QualityStatus, KEY_MAP, SERVER_KEYBOARD_ENABLED,
};
use crate::{client::Data, client::Interface};
use crate::common::{get_keyboard_mode, save_keyboard_mode};
use async_trait::async_trait;
use hbb_common::config::{Config, LocalConfig, PeerConfig};
@ -58,13 +59,11 @@ impl<T: InvokeUi> Session<T> {
}
pub fn get_keyboard_mode(&self) -> String {
return std::env::var("KEYBOARD_MODE")
.unwrap_or(String::from("legacy"))
.to_lowercase();
return get_keyboard_mode();
}
pub fn save_keyboard_mode(&self, value: String) {
std::env::set_var("KEYBOARD_MODE", value);
save_keyboard_mode(value);
}
pub fn save_view_style(&mut self, value: String) {