Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<!-- SPDX-License-Identifier: LicenseRef-DIFF -->

<p align="center">
<img src="https://raw.githubusercontent.com/bniladridas/diff-android/main/docs/assets/icon-transparent.png" alt="DIFF Android icon" width="96" height="96">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/bniladridas/diff-android/main/docs/assets/diff-sign-light.png">
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/bniladridas/diff-android/main/docs/assets/diff-sign.png">
<img src="https://raw.githubusercontent.com/bniladridas/diff-android/main/docs/assets/diff-sign.png" alt="DIFF Android icon" width="96" height="96">
</picture>
</p>

# DIFF Android
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/java/com/bniladridas/diff/ui/MarkdownPreview.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ internal fun markdownBodyPreview(
.replace(markdownLinkPattern) { match ->
match.groups[1]?.value?.trim().orEmpty()
}
.replace(bareUrlPattern) { match ->
match.value.displayUrl()
}
.replaceBareUrls()
.lines()
.map { it.trim() }
.filter { it.isNotBlank() }
Expand All @@ -51,6 +49,11 @@ private fun String.cleanBadgeLabel(): String? {
return cleaned
}

internal fun String.replaceBareUrls(): String =
replace(bareUrlPattern) { match ->
match.value.displayUrl()
}

private fun String.displayUrl(): String {
val withoutScheme = removePrefix("https://").removePrefix("http://")
return withoutScheme.substringBefore('/').ifBlank { "link" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.bniladridas.diff.ui.components

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
Expand Down Expand Up @@ -52,6 +53,7 @@ import com.bniladridas.diff.model.TimelineEvent
import com.bniladridas.diff.model.WorkspaceTab
import com.bniladridas.diff.ui.formatDate
import com.bniladridas.diff.ui.markdownBodyPreview
import com.bniladridas.diff.ui.replaceBareUrls
import com.bniladridas.diff.ui.shortSha
import com.bniladridas.diff.ui.theme.BrandOrange
import com.bniladridas.diff.ui.theme.BrandOrangeSoft
Expand Down Expand Up @@ -222,20 +224,19 @@ private fun markdownBlocks(

@Composable
fun BrandMark() {
val signRes = if (isSystemInDarkTheme()) {
R.drawable.app_icon_foreground
} else {
R.drawable.diff_sign
}

Row(verticalAlignment = Alignment.CenterVertically) {
Box(
modifier = Modifier
.size(24.dp)
.background(Color(0xFF111418), RoundedCornerShape(5.dp)),
contentAlignment = Alignment.Center,
) {
Icon(
painter = painterResource(R.drawable.ic_diff_mark),
contentDescription = null,
tint = Color.Unspecified,
modifier = Modifier.size(18.dp),
)
}
Icon(
painter = painterResource(signRes),
contentDescription = null,
tint = Color.Unspecified,
modifier = Modifier.size(24.dp),
)
Spacer(Modifier.width(7.dp))
Text(
"DIFF",
Expand Down Expand Up @@ -774,7 +775,7 @@ fun CheckCard(
}
log?.let { rawLog ->
Text(
rawLog,
cleanCheckOutput(rawLog),
modifier = Modifier
.fillMaxWidth()
.background(codeSurface())
Expand Down Expand Up @@ -1231,6 +1232,7 @@ private fun cleanCheckOutput(value: String): String =
.replace("&lt;", "<")
.replace("&gt;", ">")
.replace("&amp;", "&")
.replaceBareUrls()
.lineSequence()
.map { it.trim() }
.filter { it.isNotBlank() }
Expand Down
Binary file modified app/src/main/res/drawable-nodpi/app_icon_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-nodpi/diff_sign.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions app/src/test/java/com/bniladridas/diff/ui/MarkdownPreviewTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ class MarkdownPreviewTest {
)
}

@Test
fun `shortens bare urls in log style output`() {
val body = "Downloaded from https://objects.githubusercontent.com/github-production-release-asset/example"

assertEquals(
"Downloaded from objects.githubusercontent.com",
body.replaceBareUrls(),
)
}

@Test
fun `hides html image badges behind alt labels`() {
val body = """<img src="https://img.shields.io/badge/status-ready-green" alt="Status badge">"""
Expand Down
Binary file added docs/assets/diff-sign-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/diff-sign.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/assets/icon-dark.png
Binary file not shown.
Binary file removed docs/assets/icon-transparent.png
Binary file not shown.