Support displaying favorite notes
This commit is contained in:
1 parent
7672a82260
commit
652d6a2f28
5 files changed
+32
-17
No files matched your search
@@ -251,8 +251,8 @@ object EhEngine {
|
||||
formBody {
|
||||
add("favcat", catStr)
|
||||
add("favnote", note ?: "")
|
||||
// submit=Add+to+Favorites is not necessary, just use submit=Apply+Changes all the time
|
||||
add("submit", "Apply Changes")
|
||||
// apply=Add+to+Favorites is not necessary, just use apply=Apply+Changes all the time
|
||||
add("apply", "Apply Changes")
|
||||
add("update", "1")
|
||||
}
|
||||
}.executeAndParsingWith { }
|
||||
|
||||
@@ -19,4 +19,5 @@ interface AbstractGalleryInfo {
|
||||
var simpleLanguage: String?
|
||||
var favoriteSlot: Int
|
||||
var favoriteName: String?
|
||||
var favoriteNote: String?
|
||||
}
|
||||
@@ -77,4 +77,6 @@ open class BaseGalleryInfo(
|
||||
@Ignore
|
||||
override var favoriteName: String? = null,
|
||||
|
||||
@Ignore
|
||||
override var favoriteNote: String? = null,
|
||||
) : GalleryInfo
|
||||
@@ -26,8 +26,10 @@ import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.produceState
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.text.font.FontStyle
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -80,13 +82,13 @@ fun GalleryInfoListItem(
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
)
|
||||
ProvideTextStyle(MaterialTheme.typography.labelLarge) {
|
||||
if (!isInFavScene) {
|
||||
info.uploader?.let {
|
||||
Text(
|
||||
text = info.uploader ?: if (info.disowned) "(DISOWNED)" else "",
|
||||
text = it,
|
||||
modifier = Modifier.constrainAs(uploaderRef) {
|
||||
start.linkTo(parent.start)
|
||||
bottom.linkTo(ratingRef.top)
|
||||
},
|
||||
}.alpha(if (info.disowned) 0.5f else 1f),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
@@ -114,7 +116,7 @@ fun GalleryInfoListItem(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.constrainAs(iconsRef) {
|
||||
end.linkTo(parent.end)
|
||||
bottom.linkTo(if (showFav) favRef.top else postedRef.top)
|
||||
bottom.linkTo(postedRef.top)
|
||||
},
|
||||
) {
|
||||
val download by produceState(false, info.gid) {
|
||||
@@ -141,9 +143,15 @@ fun GalleryInfoListItem(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.constrainAs(favRef) {
|
||||
end.linkTo(parent.end)
|
||||
bottom.linkTo(postedRef.top)
|
||||
bottom.linkTo(iconsRef.top)
|
||||
},
|
||||
) {
|
||||
if (isInFavScene) {
|
||||
Text(
|
||||
text = info.favoriteNote.orEmpty(),
|
||||
fontStyle = FontStyle.Italic,
|
||||
)
|
||||
}
|
||||
if (showFav) {
|
||||
Icon(
|
||||
Icons.Default.Favorite,
|
||||
|
||||
@@ -36,6 +36,7 @@ pub struct BaseGalleryInfo {
|
||||
simpleLanguage: Option<String>,
|
||||
favoriteSlot: i32,
|
||||
favoriteName: Option<String>,
|
||||
favoriteNote: Option<String>,
|
||||
}
|
||||
|
||||
fn to_category_i32(category: &str) -> i32 {
|
||||
@@ -104,8 +105,7 @@ fn parse_uploader_and_pages(str: &str) -> (Option<String>, bool, i32) {
|
||||
fn parse_thumb_resolution(str: &str) -> (i32, i32) {
|
||||
let reg = regex!(r"height:(\d+)px;width:(\d+)px");
|
||||
match reg.captures(str) {
|
||||
None => panic!("regex err{}", str),
|
||||
//None => (0, 0),
|
||||
None => (0, 0),
|
||||
Some(grp) => (grp[1].parse().unwrap(), grp[2].parse().unwrap()),
|
||||
}
|
||||
}
|
||||
@@ -153,15 +153,15 @@ pub fn parseGalleryInfo(env: JNIEnv, _class: JClass, input: JString) -> jobject
|
||||
},
|
||||
Some(cn) => cn.inner_text(parser),
|
||||
};
|
||||
let (posted, favoriteName) = match dom
|
||||
.get_element_by_id(format!("posted_{gid}").as_str())?
|
||||
.get(parser)
|
||||
{
|
||||
let (posted, favoriteName) = match dom.get_element_by_id(format!("posted_{gid}").as_str()) {
|
||||
None => ("".to_string(), None),
|
||||
Some(node) => (
|
||||
node.inner_text(parser).trim().to_string(),
|
||||
get_node_attr(node, "title").map(str::to_string),
|
||||
),
|
||||
Some(e) => {
|
||||
let node = e.get(parser)?;
|
||||
(
|
||||
node.inner_text(parser).trim().to_string(),
|
||||
get_node_attr(node, "title").map(str::to_string),
|
||||
)
|
||||
}
|
||||
};
|
||||
let ir = dom
|
||||
.get_first_element_by_class_name("ir")?
|
||||
@@ -174,6 +174,9 @@ pub fn parseGalleryInfo(env: JNIEnv, _class: JClass, input: JString) -> jobject
|
||||
None => (None, false, 0),
|
||||
Some(node) => parse_uploader_and_pages(&node.get(parser)?.inner_html(parser)),
|
||||
};
|
||||
let favoriteNote = dom
|
||||
.get_element_by_id(format!("favnote_{gid}").as_str())
|
||||
.map(|e| e.get(parser).unwrap().inner_text(parser).to_string());
|
||||
Some(BaseGalleryInfo {
|
||||
gid,
|
||||
token,
|
||||
@@ -193,6 +196,7 @@ pub fn parseGalleryInfo(env: JNIEnv, _class: JClass, input: JString) -> jobject
|
||||
simpleLanguage: None,
|
||||
favoriteSlot: if favoriteName.is_some() { 0 } else { -2 },
|
||||
favoriteName,
|
||||
favoriteNote,
|
||||
})
|
||||
})
|
||||
.unwrap()
|
||||
|
||||
Reference in new issue
Block a user