Skip to content

Commit ec5adf6

Browse files
committed
fix: 修复高图缩放限制过小
1 parent 89b6b3e commit ec5adf6

4 files changed

Lines changed: 13 additions & 11 deletions

File tree

app/src/main/java/com/github/zly2006/zhihu/markdown/RenderMarkdown.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ import com.github.zly2006.zhihu.navigation.Video
6767
import com.github.zly2006.zhihu.navigation.resolveContent
6868
import com.github.zly2006.zhihu.theme.ThemeManager
6969
import com.github.zly2006.zhihu.ui.PREFERENCE_NAME
70-
import com.github.zly2006.zhihu.ui.components.OpenImageDislog
70+
import com.github.zly2006.zhihu.ui.components.OpenImageDialog
7171
import com.github.zly2006.zhihu.ui.subscreens.PREF_FONT_SIZE
7272
import com.github.zly2006.zhihu.ui.subscreens.PREF_LINE_HEIGHT
7373
import com.github.zly2006.zhihu.util.luoTianYiUrlLauncher
@@ -103,7 +103,7 @@ fun RenderImage(
103103
.pointerInput(Unit) {
104104
detectTapGestures(
105105
onTap = {
106-
val dialog = OpenImageDislog(context, httpClient, data.url)
106+
val dialog = OpenImageDialog(context, httpClient, data.url)
107107
dialog.show()
108108
},
109109
onLongPress = { offset ->
@@ -126,7 +126,7 @@ fun RenderImage(
126126
text = { Text("查看图片") },
127127
onClick = {
128128
expanded = false
129-
val dialog = OpenImageDislog(context, httpClient, data.url)
129+
val dialog = OpenImageDialog(context, httpClient, data.url)
130130
dialog.show()
131131
},
132132
)
@@ -210,7 +210,7 @@ fun RenderMarkdown(
210210
html: String,
211211
modifier: Modifier = Modifier,
212212
scrollState: ScrollState = rememberScrollState(),
213-
selectable: Boolean = false,
213+
selectable: Boolean = true,
214214
enableScroll: Boolean = true,
215215
header: (@Composable () -> Unit)? = null,
216216
footer: (@Composable () -> Unit)? = null,
@@ -235,7 +235,7 @@ fun RenderMarkdown(
235235
imageContent = ::RenderImage,
236236
scrollState = scrollState,
237237
enableScroll = enableScroll,
238-
onLinkClick = { url ->
238+
onLinkClick = { url: String ->
239239
resolveContent(url)?.let { navigator.onNavigate(it) }
240240
?: luoTianYiUrlLauncher(context, url.toUri())
241241
},

app/src/main/java/com/github/zly2006/zhihu/ui/CommentScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ import com.github.zly2006.zhihu.navigation.DummyLocalNavigator
116116
import com.github.zly2006.zhihu.navigation.LocalNavigator
117117
import com.github.zly2006.zhihu.navigation.NavDestination
118118
import com.github.zly2006.zhihu.navigation.Person
119-
import com.github.zly2006.zhihu.ui.components.OpenImageDislog
119+
import com.github.zly2006.zhihu.ui.components.OpenImageDialog
120120
import com.github.zly2006.zhihu.util.createEmojiInlineContent
121121
import com.github.zly2006.zhihu.util.dfsSimple
122122
import com.github.zly2006.zhihu.util.fuckHonorService
@@ -351,7 +351,7 @@ private fun ClickableImageWithMenu(
351351
return
352352
}
353353
when (action) {
354-
CommentImageMenuAction.Open -> OpenImageDislog(context, httpClient, imageUrl).show()
354+
CommentImageMenuAction.Open -> OpenImageDialog(context, httpClient, imageUrl).show()
355355
CommentImageMenuAction.OpenInBrowser -> luoTianYiUrlLauncher(context, imageUrl.toUri())
356356
CommentImageMenuAction.Save -> {
357357
coroutineScope.launch {

app/src/main/java/com/github/zly2006/zhihu/ui/PeopleScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ import com.github.zly2006.zhihu.navigation.Person
7777
import com.github.zly2006.zhihu.navigation.Pin
7878
import com.github.zly2006.zhihu.navigation.Question
7979
import com.github.zly2006.zhihu.ui.components.FeedCard
80-
import com.github.zly2006.zhihu.ui.components.OpenImageDislog
80+
import com.github.zly2006.zhihu.ui.components.OpenImageDialog
8181
import com.github.zly2006.zhihu.ui.components.PaginatedList
8282
import com.github.zly2006.zhihu.ui.components.ProgressIndicatorFooter
8383
import com.github.zly2006.zhihu.util.signFetchRequest
@@ -1342,7 +1342,7 @@ private fun UserInfoHeader(
13421342
.size(80.dp)
13431343
.clip(CircleShape)
13441344
.clickable {
1345-
OpenImageDislog(
1345+
OpenImageDialog(
13461346
context,
13471347
AccountData.httpClient(context),
13481348
profile.avatar.substringBefore("_") + ".jpg",

app/src/main/java/com/github/zly2006/zhihu/ui/components/WebviewComp.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ import kotlinx.serialization.json.jsonPrimitive
106106
import org.jsoup.Jsoup
107107
import org.jsoup.nodes.Document
108108
import org.jsoup.nodes.Element
109+
import kotlin.math.max
109110

110111
// HTML 点击事件监听器接口
111112
fun interface HtmlClickListener {
@@ -395,7 +396,7 @@ class CustomWebView : WebView {
395396
}
396397

397398
fun openImage(httpClient: HttpClient, url: String) {
398-
OpenImageDislog(context, httpClient, url).show()
399+
OpenImageDialog(context, httpClient, url).show()
399400
}
400401

401402
fun loadZhihu(
@@ -501,7 +502,7 @@ class CustomWebView : WebView {
501502
}
502503
}
503504

504-
class OpenImageDislog(
505+
class OpenImageDialog(
505506
context: Context,
506507
private val httpClient: HttpClient,
507508
private val url: String,
@@ -525,6 +526,7 @@ class OpenImageDislog(
525526
val bitmap = BitmapFactory.decodeStream(it)
526527
withContext(Dispatchers.Main) {
527528
photoView.setImageBitmap(bitmap)
529+
photoView.maximumScale = max(photoView.maximumScale, bitmap.height.toFloat() / bitmap.width)
528530
}
529531
}
530532
}

0 commit comments

Comments
 (0)