-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DescriptionText composable, remove playlist preview dependency on…
… external HTTP calls
- Loading branch information
1 parent
0c2afe9
commit 8049fa5
Showing
12 changed files
with
148 additions
and
83 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
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
46 changes: 46 additions & 0 deletions
46
app/src/main/java/org/schabi/newpipe/compose/common/DescriptionText.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,46 @@ | ||
package org.schabi.newpipe.compose.common | ||
|
||
import androidx.compose.material3.LocalTextStyle | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.text.AnnotatedString | ||
import androidx.compose.ui.text.ParagraphStyle | ||
import androidx.compose.ui.text.SpanStyle | ||
import androidx.compose.ui.text.TextLayoutResult | ||
import androidx.compose.ui.text.TextLinkStyles | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.fromHtml | ||
import androidx.compose.ui.text.style.TextDecoration | ||
import androidx.compose.ui.text.style.TextOverflow | ||
import org.schabi.newpipe.extractor.stream.Description | ||
|
||
@Composable | ||
fun DescriptionText( | ||
description: Description, | ||
modifier: Modifier = Modifier, | ||
overflow: TextOverflow = TextOverflow.Clip, | ||
maxLines: Int = Int.MAX_VALUE, | ||
onTextLayout: (TextLayoutResult) -> Unit = {}, | ||
style: TextStyle = LocalTextStyle.current | ||
) { | ||
// TODO: Handle links and hashtags, Markdown. | ||
val parsedDescription = remember(description) { | ||
if (description.type == Description.HTML) { | ||
val styles = TextLinkStyles(SpanStyle(textDecoration = TextDecoration.Underline)) | ||
AnnotatedString.fromHtml(description.content, styles) | ||
} else { | ||
AnnotatedString(description.content, ParagraphStyle()) | ||
} | ||
} | ||
|
||
Text( | ||
modifier = modifier, | ||
text = parsedDescription, | ||
maxLines = maxLines, | ||
style = style, | ||
overflow = overflow, | ||
onTextLayout = onTextLayout | ||
) | ||
} |
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
22 changes: 22 additions & 0 deletions
22
app/src/main/java/org/schabi/newpipe/compose/playlist/PlaylistInfo.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,22 @@ | ||
package org.schabi.newpipe.compose.playlist | ||
|
||
import androidx.compose.runtime.Immutable | ||
import org.schabi.newpipe.extractor.Image | ||
import org.schabi.newpipe.extractor.Page | ||
import org.schabi.newpipe.extractor.stream.Description | ||
import org.schabi.newpipe.extractor.stream.StreamInfoItem | ||
|
||
@Immutable | ||
class PlaylistInfo( | ||
val id: String, | ||
val serviceId: Int, | ||
val url: String, | ||
val name: String, | ||
val description: Description, | ||
val relatedItems: List<StreamInfoItem>, | ||
val streamCount: Long, | ||
val uploaderUrl: String?, | ||
val uploaderName: String?, | ||
val uploaderAvatars: List<Image>, | ||
val nextPage: Page? | ||
) |
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
Oops, something went wrong.