feat: 图片水印设置
This commit is contained in:
parent
e8a83b1ac1
commit
1024a6d33f
|
|
@ -2,7 +2,7 @@ package com.huanchengfly.tieba.post.components
|
|||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.util.Log
|
||||
import com.huanchengfly.tieba.post.App
|
||||
import com.huanchengfly.tieba.post.api.BOUNDARY
|
||||
import com.huanchengfly.tieba.post.api.booleanToString
|
||||
import com.huanchengfly.tieba.post.api.models.UploadPictureResultBean
|
||||
|
|
@ -14,6 +14,7 @@ import com.huanchengfly.tieba.post.api.retrofit.exception.getErrorCode
|
|||
import com.huanchengfly.tieba.post.api.retrofit.exception.getErrorMessage
|
||||
import com.huanchengfly.tieba.post.utils.ImageUtil
|
||||
import com.huanchengfly.tieba.post.utils.MD5Util
|
||||
import com.huanchengfly.tieba.post.utils.appPreferences
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
|
@ -40,9 +41,9 @@ class ImageUploader(
|
|||
const val IMAGE_MAX_SIZE = 5242880
|
||||
const val ORIGIN_IMAGE_MAX_SIZE = 10485760
|
||||
|
||||
const val PIC_WATER_TYPE_NO = 0
|
||||
const val PIC_WATER_TYPE_USER_NAME = 1
|
||||
const val PIC_WATER_TYPE_FORUM_NAME = 2
|
||||
const val PIC_WATER_TYPE_NO = "0"
|
||||
const val PIC_WATER_TYPE_USER_NAME = "1"
|
||||
const val PIC_WATER_TYPE_FORUM_NAME = "2"
|
||||
}
|
||||
|
||||
fun uploadImages(
|
||||
|
|
@ -117,7 +118,8 @@ class ImageUploader(
|
|||
val fileMd5 = MD5Util.toMd5(file)
|
||||
val isMultipleChunkSize = fileLength % chunkSize == 0L
|
||||
val totalChunkNum = fileLength / chunkSize + if (isMultipleChunkSize) 0 else 1
|
||||
Log.i("ImageUploader", "fileLength=$fileLength, totalChunkNum=$totalChunkNum")
|
||||
val picWatermarkType =
|
||||
App.INSTANCE.appPreferences.picWatermarkType ?: PIC_WATER_TYPE_FORUM_NAME
|
||||
val requestBodies = (0 until totalChunkNum).map { chunk ->
|
||||
val isFinish = chunk == totalChunkNum - 1
|
||||
val curChunkSize = if (isFinish) {
|
||||
|
|
@ -145,7 +147,7 @@ class ImageUploader(
|
|||
addFormDataPart("height", "$height")
|
||||
addFormDataPart("isFinish", isFinish.booleanToString())
|
||||
addFormDataPart("is_bjh", "0")
|
||||
addFormDataPart("pic_water_type", "2")
|
||||
addFormDataPart("pic_water_type", picWatermarkType)
|
||||
addFormDataPart("resourceId", "$fileMd5$chunkSize")
|
||||
addFormDataPart("saveOrigin", isOriginImage.booleanToString())
|
||||
addFormDataPart("size", "$fileLength")
|
||||
|
|
|
|||
|
|
@ -318,7 +318,6 @@ fun ReplyPage(
|
|||
.filter { it > 0 }
|
||||
.distinctUntilChanged()
|
||||
.collect {
|
||||
Log.i("ReplyPage", "imeVisibleHeight: $it")
|
||||
context.appPreferences.imeHeight = it
|
||||
value = it
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ import androidx.compose.foundation.layout.fillMaxSize
|
|||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.BrandingWatermark
|
||||
import androidx.compose.material.icons.outlined.CalendarViewDay
|
||||
import androidx.compose.material.icons.outlined.ExitToApp
|
||||
import androidx.compose.material.icons.outlined.Extension
|
||||
import androidx.compose.material.icons.outlined.PhotoSizeSelectActual
|
||||
import androidx.compose.material.icons.outlined.SecurityUpdateWarning
|
||||
import androidx.compose.material.icons.outlined.StarOutline
|
||||
|
|
@ -21,13 +21,10 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.res.vectorResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.huanchengfly.tieba.post.R
|
||||
import com.huanchengfly.tieba.post.activities.PluginManageActivity
|
||||
import com.huanchengfly.tieba.post.dataStore
|
||||
import com.huanchengfly.tieba.post.goToActivity
|
||||
import com.huanchengfly.tieba.post.ui.common.prefs.PrefsScreen
|
||||
import com.huanchengfly.tieba.post.ui.common.prefs.widgets.ListPref
|
||||
import com.huanchengfly.tieba.post.ui.common.prefs.widgets.SwitchPref
|
||||
import com.huanchengfly.tieba.post.ui.common.prefs.widgets.TextPref
|
||||
import com.huanchengfly.tieba.post.ui.page.settings.LeadingIcon
|
||||
import com.huanchengfly.tieba.post.ui.widgets.compose.AvatarIcon
|
||||
import com.huanchengfly.tieba.post.ui.widgets.compose.BackNavigationIcon
|
||||
|
|
@ -62,23 +59,6 @@ fun HabitSettingsPage(
|
|||
.padding(paddingValues)
|
||||
.fillMaxSize(),
|
||||
) {
|
||||
prefsItem {
|
||||
TextPref(
|
||||
title = stringResource(id = R.string.title_plugin_manage),
|
||||
onClick = {
|
||||
context.goToActivity<PluginManageActivity>()
|
||||
},
|
||||
leadingIcon = {
|
||||
LeadingIcon {
|
||||
AvatarIcon(
|
||||
icon = Icons.Outlined.Extension,
|
||||
size = Sizes.Small,
|
||||
contentDescription = null,
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
prefsItem {
|
||||
ListPref(
|
||||
key = "image_load_type",
|
||||
|
|
@ -102,6 +82,28 @@ fun HabitSettingsPage(
|
|||
},
|
||||
)
|
||||
}
|
||||
prefsItem {
|
||||
ListPref(
|
||||
key = "pic_watermark_type",
|
||||
title = stringResource(id = R.string.title_settings_image_watermark),
|
||||
entries = mapOf(
|
||||
"0" to stringResource(id = R.string.title_image_watermark_none),
|
||||
"1" to stringResource(id = R.string.title_image_watermark_user_name),
|
||||
"2" to stringResource(id = R.string.title_image_watermark_forum_name)
|
||||
),
|
||||
useSelectedAsSummary = true,
|
||||
defaultValue = "2",
|
||||
leadingIcon = {
|
||||
LeadingIcon {
|
||||
AvatarIcon(
|
||||
icon = Icons.Outlined.BrandingWatermark,
|
||||
size = Sizes.Small,
|
||||
contentDescription = null,
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
prefsItem {
|
||||
ListPref(
|
||||
key = "default_sort_type",
|
||||
|
|
|
|||
|
|
@ -142,6 +142,11 @@ open class AppPreferencesUtils private constructor(ctx: Context) {
|
|||
key = "oksign_use_official_oksign"
|
||||
)
|
||||
|
||||
var picWatermarkType by DataStoreDelegates.string(
|
||||
defaultValue = "2",
|
||||
key = "pic_watermark_type",
|
||||
)
|
||||
|
||||
var postOrReplyWarning by DataStoreDelegates.boolean(defaultValue = true)
|
||||
|
||||
var radius by DataStoreDelegates.int(defaultValue = 8)
|
||||
|
|
|
|||
|
|
@ -691,4 +691,8 @@
|
|||
<string name="toast_upload_image_failed">上传图片失败 %s</string>
|
||||
<string name="origin_image">原图</string>
|
||||
<string name="desc_remove_image">删除图片</string>
|
||||
<string name="title_settings_image_watermark">图片添加水印</string>
|
||||
<string name="title_image_watermark_none">无水印</string>
|
||||
<string name="title_image_watermark_user_name">显示用户名</string>
|
||||
<string name="title_image_watermark_forum_name">显示吧名</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Reference in New Issue