-
-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(feed): parse favicon for feed's site (#471)
- Loading branch information
Showing
7 changed files
with
67 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
app/src/main/java/me/ash/reader/infrastructure/rss/Favicon.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package me.ash.reader.infrastructure.rss | ||
|
||
data class Favicon( | ||
val url: String? = null, | ||
val icons: List<Icon>? = null | ||
) { | ||
data class Icon( | ||
val url: String?, | ||
val width: Int?, | ||
val height: Int?, | ||
val format: String?, | ||
val bytes: Long?, | ||
val error: String?, | ||
val sha1sum: String?, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,57 @@ | ||
package me.ash.reader.ui.component | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import me.ash.reader.ui.component.base.RYAsyncImage | ||
|
||
@Composable | ||
fun FeedIcon( | ||
feedName: String, | ||
iconUrl: String?, | ||
size: Dp = 20.dp, | ||
) { | ||
Row( | ||
modifier = Modifier | ||
.size(20.dp) | ||
.clip(CircleShape) | ||
.background(MaterialTheme.colorScheme.outline.copy(alpha = 0.2f)) | ||
) {} | ||
if (iconUrl == null) { | ||
Box( | ||
modifier = Modifier | ||
.size(20.dp) | ||
.clip(CircleShape) | ||
.background(MaterialTheme.colorScheme.primary), | ||
contentAlignment = Alignment.Center, | ||
) { | ||
Text( | ||
text = feedName.ifEmpty { " " }.first().toString(), | ||
fontWeight = FontWeight.Bold, | ||
color = MaterialTheme.colorScheme.onPrimary, | ||
fontSize = 10.sp, | ||
) | ||
} | ||
} else { | ||
RYAsyncImage( | ||
modifier = Modifier | ||
.size(size) | ||
.clip(CircleShape), | ||
contentDescription = feedName, | ||
data = iconUrl, | ||
placeholder = null, | ||
) | ||
} | ||
} | ||
|
||
// val url by remember { | ||
// mutableStateOf( | ||
// "https://ui-avatars.com/api/?length=1&background=random&name=${ | ||
// URLEncoder.encode( | ||
// feedName, | ||
// Charsets.UTF_8.toString() | ||
// ) | ||
// }" | ||
// ) | ||
// } | ||
// | ||
// AsyncImage( | ||
// modifier = Modifier | ||
// .size(size) | ||
// .clip(CircleShape), | ||
// contentDescription = feedName, | ||
// data = url, | ||
// placeholder = null, | ||
// ) | ||
@Preview | ||
@Composable | ||
fun FeedIconPrev(){ | ||
FeedIcon("AFF", null) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters