Some progress

This commit is contained in:
w1nst0n 2021-08-19 23:54:13 +02:00
commit db39b38dc0
No known key found for this signature in database
GPG key ID: 34D27465928A0A1D
6 changed files with 420 additions and 20 deletions

343
Cargo.lock generated
View file

@ -27,6 +27,18 @@ version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9fe5e32de01730eb1f6b7f5b51c17e03e2325bf40a74f754f04f130043affff"
[[package]]
name = "adler"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "adler32"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234"
[[package]]
name = "ahash"
version = "0.4.7"
@ -55,6 +67,12 @@ dependencies = [
"num-traits",
]
[[package]]
name = "arrayref"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544"
[[package]]
name = "arrayvec"
version = "0.5.2"
@ -76,6 +94,12 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "base64"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
[[package]]
name = "bit-set"
version = "0.5.2"
@ -359,6 +383,15 @@ dependencies = [
"objc",
]
[[package]]
name = "crc32fast"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a"
dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "crossbeam-channel"
version = "0.5.1"
@ -449,6 +482,25 @@ dependencies = [
"syn",
]
[[package]]
name = "data-url"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d33fe99ccedd6e84bc035f1931bb2e6be79739d6242bd895e7311c886c50dc9c"
dependencies = [
"matches",
]
[[package]]
name = "deflate"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73770f8e1fe7d64df17ca66ad28994a0a623ea497fa69486e14984e715c5d174"
dependencies = [
"adler32",
"byteorder",
]
[[package]]
name = "derivative"
version = "2.2.0"
@ -580,6 +632,24 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d"
[[package]]
name = "flate2"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0"
dependencies = [
"cfg-if 1.0.0",
"crc32fast",
"libc",
"miniz_oxide 0.4.4",
]
[[package]]
name = "float-cmp"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75224bec9bfe1a65e2d34132933f2de7fe79900c96a0174307554244ece8150e"
[[package]]
name = "float-ord"
version = "0.2.0"
@ -617,6 +687,18 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "fontdb"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccfec742e7db963305c1d8fde9edef949b47b01e1664dae127489928633fbea8"
dependencies = [
"log",
"memmap2 0.1.0",
"ttf-parser 0.9.0",
"uuid",
]
[[package]]
name = "foreign-types"
version = "0.3.2"
@ -1185,6 +1267,8 @@ dependencies = [
"iced_native",
"log",
"raw-window-handle",
"resvg",
"usvg",
"wgpu",
"wgpu_glyph",
]
@ -1277,6 +1361,12 @@ dependencies = [
"libc",
]
[[package]]
name = "jpeg-decoder"
version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "229d53d58899083193af11e15917b5640cd40b29ff475a1fe4ef725deb02d0f2"
[[package]]
name = "js-sys"
version = "0.3.46"
@ -1306,6 +1396,15 @@ dependencies = [
"libloading 0.6.7",
]
[[package]]
name = "kurbo"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16cb54cd28cb3d2e964d9444ca185676a94fd9b7cce5f02b22c717947ed8e9a2"
dependencies = [
"arrayvec",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
@ -1442,6 +1541,25 @@ dependencies = [
"objc",
]
[[package]]
name = "miniz_oxide"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "791daaae1ed6889560f8c4359194f56648355540573244a5448a83ba1ecc7435"
dependencies = [
"adler32",
]
[[package]]
name = "miniz_oxide"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b"
dependencies = [
"adler",
"autocfg",
]
[[package]]
name = "mio"
version = "0.6.23"
@ -1774,6 +1892,12 @@ dependencies = [
"indexmap",
]
[[package]]
name = "pico-args"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28b9b4df73455c861d7cbf8be42f01d3b373ed7f02e378d55fa84eafc6f638b1"
[[package]]
name = "pin-project-lite"
version = "0.2.7"
@ -1792,6 +1916,18 @@ version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
[[package]]
name = "png"
version = "0.16.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c3287920cb847dee3de33d301c463fba14dda99db24214ddf93f83d3021f4c6"
dependencies = [
"bitflags",
"crc32fast",
"deflate",
"miniz_oxide 0.3.7",
]
[[package]]
name = "ppv-lite86"
version = "0.2.10"
@ -1917,6 +2053,12 @@ dependencies = [
"num_cpus",
]
[[package]]
name = "rctree"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be9e29cb19c8fe84169fcb07f8f11e66bc9e6e0280efd4715c54818296f8a4a8"
[[package]]
name = "redox_syscall"
version = "0.2.10"
@ -1936,6 +2078,40 @@ dependencies = [
"redox_syscall",
]
[[package]]
name = "resvg"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6989baba2fe2d85b0daaea5e897ba842c42bd7bff59cb0c5fb099bdcead70421"
dependencies = [
"jpeg-decoder",
"log",
"pico-args",
"png",
"rgb",
"svgfilters",
"tiny-skia",
"usvg",
]
[[package]]
name = "rgb"
version = "0.8.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fddb3b23626145d1776addfc307e1a1851f60ef6ca64f376bcb889697144cf0"
dependencies = [
"bytemuck",
]
[[package]]
name = "roxmltree"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbf7d7b1ea646d380d0e8153158063a6da7efe30ddbf3184042848e3f8a6f671"
dependencies = [
"xmlparser",
]
[[package]]
name = "rustc-hash"
version = "1.1.0"
@ -1961,12 +2137,37 @@ dependencies = [
"owned_ttf_parser 0.6.0",
]
[[package]]
name = "rustybuzz"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ab463a295d00f3692e0974a0bfd83c7a9bcd119e27e07c2beecdb1b44a09d10"
dependencies = [
"bitflags",
"bytemuck",
"smallvec",
"ttf-parser 0.9.0",
"unicode-bidi-mirroring",
"unicode-ccc",
"unicode-general-category",
"unicode-script",
]
[[package]]
name = "ryu"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
[[package]]
name = "safe_arch"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1ff3d6d9696af502cc3110dacce942840fb06ff4514cad92236ecc455f2ce05"
dependencies = [
"bytemuck",
]
[[package]]
name = "same-file"
version = "1.0.6"
@ -2058,6 +2259,21 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "simplecss"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a11be7c62927d9427e9f40f3444d5499d868648e2edbc4e2116de69e7ec0e89d"
dependencies = [
"log",
]
[[package]]
name = "siphasher"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac"
[[package]]
name = "slab"
version = "0.4.4"
@ -2176,6 +2392,26 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fb1df15f412ee2e9dfc1c504260fa695c1c3f10fe9f4a6ee2d2184d7d6450e2"
[[package]]
name = "svgfilters"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3016b3217b82ea3bb7cd3b773030222c6acca46c52ef4e64b4e716bd4b25090e"
dependencies = [
"float-cmp",
"rgb",
]
[[package]]
name = "svgtypes"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c536faaff1a10837cfe373142583f6e27d81e96beba339147e77b67c9f260ff"
dependencies = [
"float-cmp",
"siphasher",
]
[[package]]
name = "syn"
version = "1.0.65"
@ -2213,6 +2449,19 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7572415bd688d401c52f6e36f4c8e805b9ae1622619303b9fa835d531db0acae"
[[package]]
name = "tiny-skia"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a428f0f1f63fa531b4a820f68b97270a4e90469c97162f0b01e3d6872c68e5ba"
dependencies = [
"arrayref",
"arrayvec",
"bytemuck",
"png",
"wide",
]
[[package]]
name = "tinyvec"
version = "1.3.1"
@ -2275,6 +2524,12 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e5d7cd7ab3e47dda6e56542f4bbf3824c15234958c6e1bd6aaa347e93499fdc"
[[package]]
name = "ttf-parser"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62ddb402ac6c2af6f7a2844243887631c4e94b51585b229fcfddb43958cd55ca"
[[package]]
name = "ttf-parser"
version = "0.12.3"
@ -2304,6 +2559,24 @@ version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "246f4c42e67e7a4e3c6106ff716a5d067d4132a642840b242e357e468a2a0085"
[[package]]
name = "unicode-bidi-mirroring"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56d12260fb92d52f9008be7e4bca09f584780eb2266dc8fecc6a192bec561694"
[[package]]
name = "unicode-ccc"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc2520efa644f8268dce4dcd3050eaa7fc044fca03961e9998ac7e2e92b77cf1"
[[package]]
name = "unicode-general-category"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f9af028e052a610d99e066b33304625dea9613170a2563314490a4e6ec5cf7f"
[[package]]
name = "unicode-normalization"
version = "0.1.19"
@ -2313,12 +2586,24 @@ dependencies = [
"tinyvec",
]
[[package]]
name = "unicode-script"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "098ec66172ce21cd55f8bcc786ee209dd20e04eff70acfca30cb79924d173ae9"
[[package]]
name = "unicode-segmentation"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
[[package]]
name = "unicode-vo"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94"
[[package]]
name = "unicode-xid"
version = "0.2.2"
@ -2337,6 +2622,42 @@ dependencies = [
"percent-encoding",
]
[[package]]
name = "usvg"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05a7ff57fca79848360bd2c00072a8029543cf554fe49c4d0af247271434702e"
dependencies = [
"base64",
"data-url",
"flate2",
"fontdb",
"kurbo",
"log",
"memmap2 0.1.0",
"pico-args",
"rctree",
"roxmltree",
"rustybuzz",
"simplecss",
"siphasher",
"svgtypes",
"ttf-parser 0.9.0",
"unicode-bidi",
"unicode-script",
"unicode-vo",
"xmlwriter",
]
[[package]]
name = "uuid"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
dependencies = [
"getrandom",
]
[[package]]
name = "version_check"
version = "0.9.3"
@ -2580,6 +2901,16 @@ dependencies = [
"wgpu",
]
[[package]]
name = "wide"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46bbe7c604a27ca0b05c5503221e76da628225b568e6f1280b42dbad3b72d89b"
dependencies = [
"bytemuck",
"safe_arch",
]
[[package]]
name = "winapi"
version = "0.2.8"
@ -2745,3 +3076,15 @@ name = "xml-rs"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3"
[[package]]
name = "xmlparser"
version = "0.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "114ba2b24d2167ef6d67d7d04c8cc86522b87f490025f39f0303b7db5bf5e3d8"
[[package]]
name = "xmlwriter"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9"

View file

@ -5,6 +5,6 @@ authors = ["w1nst0n"]
edition = "2018"
[dependencies]
iced = "^0.3"
iced = { version = "^0.3", features = ["svg"] }
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"

1
assets/trash.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-trash-2"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line></svg>

After

Width:  |  Height:  |  Size: 448 B

View file

@ -21,3 +21,24 @@ pub fn list_phone_packages() -> String {
}
pub async fn uninstall_package(package: String) -> String {
let output = Command::new("adb")
.arg("shell")
.arg("pm")
.arg("uninstall")
.arg("--user")
.arg("0")
.arg(package)
.output()
.expect("adb command failed");
if !output.status.success() {
let error = String::from_utf8(output.stderr).unwrap();
println!("[DEBUG] {:?}", error);
error
} else {
let adb_return = String::from_utf8(output.stdout).unwrap();
println!("[DEBUG] - Uninstall: {:?}", adb_return);
adb_return
}
}

View file

@ -150,7 +150,7 @@ impl scrollable::StyleSheet for Scrollable {
}
}
/*pub enum InstallButton {
pub enum InstallButton {
Enabled,
Disabled,
}
@ -171,4 +171,4 @@ impl button::StyleSheet for InstallButton {
Self::Enabled | Self::Disabled => button::Style { ..self.active() },
}
}
} */
}

View file

@ -3,11 +3,11 @@ use crate::core::uad_lists::{ UadLists, PackageState };
use iced::{
scrollable, Align, Column, Command, Container, Element, Space,
Length, Row, Scrollable, Text, text_input, TextInput,
PickList, pick_list,
Length, Row, Scrollable, Text, text_input, TextInput, Svg,
PickList, pick_list, Button, button, HorizontalAlignment,
};
use crate::core::sync::list_phone_packages;
use crate::core::sync::{ list_phone_packages, uninstall_package };
#[derive(Default, Debug, Clone)]
pub struct List {
@ -34,7 +34,9 @@ pub enum Message {
ListInputChanged(String),
LoadPackages,
ListSelected(UadLists),
PackageStateSelected(PackageState)
PackageStateSelected(PackageState),
List(usize, RowMessage),
NoEvent,
}
@ -46,7 +48,7 @@ impl List {
}
Message::LoadPackages => {
self.packages = test();
self.packages = list_phone_packages();
self.p_row = Vec::new();
for p_name in self.packages.lines() {
let package_row = PackageRow::new(
@ -69,7 +71,11 @@ impl List {
Message::PackageStateSelected(package_state) => {
self.selected_package_state = Some(package_state);
Command::none()
}
},
Message::List(i, row_message) => self.p_row[i]
.update(row_message)
.map(move |row_message| Message::List(i, row_message)),
Message::NoEvent => Command::none(),
}
}
pub fn view(&mut self) -> Element<Message> {
@ -125,8 +131,8 @@ impl List {
let test = self.p_row
.iter_mut()
.enumerate()
.fold(Column::new().spacing(5), |col, (_, p)| {
col.push(p.view())
.fold(Column::new().spacing(5), |col, (i, p)| {
col.push(p.view().map(move |msg| Message::List(i, msg)))
});
let packages_scrollable = Scrollable::new(&mut self.package_scrollable_state)
@ -156,11 +162,16 @@ pub struct PackageRow {
pub name: String,
pub state: String,
pub advice: String,
remove_restore_btn_state: button::State,
}
#[derive(Clone, Debug)]
pub enum RowMessage {
NoEvent,
RemovePressed(PackageRow),
RestorePressed(PackageRow),
Uninstall(String)
}
impl PackageRow {
@ -168,27 +179,56 @@ impl PackageRow {
name: &str,
state: &str,
advice: &str,
) -> Self {
Self {
name: name.to_string(),
state: "Installed".to_string(),
advice: advice.to_string(),
remove_restore_btn_state: button::State::default(),
}
}
/* pub fn update(&mut self, message: RowMessage) -> Command<RowMessage> {
pub fn update(&mut self, message: RowMessage) -> Command<RowMessage> {
match message {
RowMessage::RemovePressed(package) => Command::perform(
uninstall_package(package.name),
RowMessage::Uninstall
),
RowMessage::RestorePressed(package) => Command::none(),
RowMessage::NoEvent => Command::none(),
RowMessage::Uninstall(_) => Command::none(),
}
}*/
}
pub fn view(&mut self) -> Element<Message> {
pub fn view(&mut self) -> Element<RowMessage> {
let package = self.clone();
let add_svg_path = format!("{}/assets/trash.svg", env!("CARGO_MANIFEST_DIR"));
let content = Row::new()
.align_items(Align::Center)
.push(Text::new(&self.name).width(Length::FillPortion(6)))
.push(Text::new(&self.state).width(Length::FillPortion(3)))
.push(Text::new(&self.advice).width(Length::FillPortion(3)));
.push(Text::new(&self.advice).width(Length::FillPortion(3)))
.push(if self.state == "Installed" {
Button::new(
&mut self.remove_restore_btn_state,
Svg::from_path(add_svg_path)
.width(Length::Fill)
.height(Length::Fill),
)
.on_press(RowMessage::RemovePressed(package))
.style(style::PrimaryButton::Enabled)
} else {
Button::new(
&mut self.remove_restore_btn_state,
Text::new("Restore")
.width(Length::Fill)
.horizontal_alignment(HorizontalAlignment::Center),
)
.on_press(RowMessage::RestorePressed(package))
.style(style::PrimaryButton::Enabled)
});
let p_row = Container::new(content)
.padding(10)
@ -198,9 +238,4 @@ impl PackageRow {
}
}
pub fn test() -> String {
list_phone_packages()
}