Skip to content

Commit

Permalink
update 文案和日志调整;微盘图片重试;图片压缩率调整
Browse files Browse the repository at this point in the history
  • Loading branch information
gallonyin committed May 24, 2023
1 parent 4eac366 commit ac8b450
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ class SettingsAdvanceActivity : AppCompatActivity() {
val text = builder.editText.text
if (text != null) {
dialog.dismiss()
Constant.weworkMP = text.toString().trim()
val username = text.toString().trim()
Constant.weworkMP = if (username.endsWith("@app")) username else "$username@app"
} else {
ToastUtils.showLong("请勿为空!")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,10 @@ object WeworkOperationImpl {
message: WeworkMessageBean,
titleList: List<String>,
objectName: String,
extraText: String? = null
extraText: String? = null,
maxRetryCount: Int? = null
): Boolean {
val retryCount = maxRetryCount ?: 2
val startTime = System.currentTimeMillis()
goHomeTab("工作台")
val node = AccessibilityUtil.scrollAndFindByText(WeworkController.weworkService, getRoot(), "微盘", exact = true)
Expand Down Expand Up @@ -443,21 +445,33 @@ object WeworkOperationImpl {
return true
} else {
LogUtils.e("微盘文件转发失败: $objectName")
if (retryCount > 0) {
return pushMicroDiskImage(message, titleList, objectName, extraText, retryCount - 1)
}
uploadCommandResult(message, ExecCallbackBean.ERROR_RELAY, "微盘文件转发失败: $objectName", startTime, listOf(), titleList)
return false
}
} else {
LogUtils.e("微盘未搜索到相关图片: $objectName")
if (retryCount > 0) {
return pushMicroDiskImage(message, titleList, objectName, extraText, retryCount - 1)
}
uploadCommandResult(message, ExecCallbackBean.ERROR_TARGET, "微盘未搜索到相关图片: $objectName", startTime, listOf(), titleList)
return false
}
} else {
LogUtils.e("未找到微盘内搜索")
if (retryCount > 0) {
return pushMicroDiskImage(message, titleList, objectName, extraText, retryCount - 1)
}
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "未找到微盘内搜索", startTime, listOf(), titleList)
return false
}
} else {
LogUtils.e("未找到微盘")
if (retryCount > 0) {
return pushMicroDiskImage(message, titleList, objectName, extraText, retryCount - 1)
}
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "未找到微盘", startTime, listOf(), titleList)
return false
}
Expand Down Expand Up @@ -533,8 +547,7 @@ object WeworkOperationImpl {
receivedContent: String,
originalContent: String,
fileUrl: String,
extraText: String? = null,
maxRetryCount: Int? = null
extraText: String? = null
): Boolean {
val startTime = System.currentTimeMillis()
if (IWWAPIUtil.sendMicroProgram(fileUrl, originalContent, objectName, receivedContent)) {
Expand Down Expand Up @@ -630,7 +643,7 @@ object WeworkOperationImpl {
extraText: String? = null,
maxRetryCount: Int? = null
): Boolean {
val retryCount = maxRetryCount ?: 1
val retryCount = maxRetryCount ?: 2
val startTime = System.currentTimeMillis()
if (!PermissionUtils.isGrantedDrawOverlays()) {
LogUtils.e("未打开悬浮窗权限")
Expand Down Expand Up @@ -781,8 +794,7 @@ object WeworkOperationImpl {
receivedContent: String,
originalContent: String,
fileUrl: String,
extraText: String? = null,
maxRetryCount: Int? = null
extraText: String? = null
): Boolean {
val startTime = System.currentTimeMillis()
if (IWWAPIUtil.sendLink(fileUrl, originalContent, objectName, receivedContent)) {
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/org/yameida/worktool/utils/IWWAPIUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.tencent.wework.api.model.WWMediaLink
import com.tencent.wework.api.model.WWMediaMiniProgram
import org.yameida.worktool.Constant
import org.yameida.worktool.R
import org.yameida.worktool.service.log
import java.io.ByteArrayOutputStream
import java.io.File
import java.text.SimpleDateFormat
Expand Down Expand Up @@ -52,9 +53,10 @@ object IWWAPIUtil {
miniProgram.path = webpageUrl
miniProgram.title = title

log("小程序: ${miniProgram.appId} ${miniProgram.username} ${miniProgram.title}")
val bitmap = (Utils.getApp().getDrawable(R.mipmap.ic_launcher) as BitmapDrawable).bitmap
val stream = ByteArrayOutputStream()
bitmap.compress(Bitmap.CompressFormat.JPEG, 0, stream)
bitmap.compress(Bitmap.CompressFormat.JPEG, 75, stream)
miniProgram.hdImageData = stream.toByteArray()
if (imageUrl != null) {
LogUtils.i("下载开始 $imageUrl")
Expand All @@ -73,7 +75,7 @@ object IWWAPIUtil {
LogUtils.i("文件存储本地成功 $filePath")
val bitmap = ImageUtils.bytes2Bitmap(File(filePath).readBytes())
val stream = ByteArrayOutputStream()
bitmap.compress(Bitmap.CompressFormat.JPEG, 0, stream)
bitmap.compress(Bitmap.CompressFormat.JPEG, 75, stream)
miniProgram.hdImageData = stream.toByteArray()
} else {
LogUtils.e("文件存储本地失败 $filePath")
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_settings_advance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="企微绑定的小程序UserName"
android:text="应用绑的小程序原始Id(gh_xxx)"
android:textColor="@color/color_999999"
android:textSize="@dimen/setting_end_font_size" />

Expand Down

0 comments on commit ac8b450

Please sign in to comment.