剩余模块:生产退料

This commit is contained in:
2025-05-26 16:57:56 +08:00
parent b1d8dec263
commit eb2c8d2d7a
161 changed files with 18754 additions and 6607 deletions

View File

@@ -0,0 +1,38 @@
{
"version": "1",
"env": {
"compilerVersion": "4.63.2025042307-alpha"
},
"files": {
"utssdk/app-android/TransparentActivity.uts": {
"md5": "d41530560fe13e9934cc3b1fb73c9890"
},
"utssdk/app-android/callbacks.uts": {
"md5": "348b1166fafde03d77d31c708ffeca5f"
},
"utssdk/app-android/constant.uts": {
"md5": "9e03e42b19d59d8ed16f3df814dbba74"
},
"utssdk/app-android/index.uts": {
"md5": "d3752bb6c002b2da6377f0e8a215f91a"
},
"utssdk/interface.uts": {
"md5": "ff87bca6142d3990b5057f452ea3f2b4"
},
"utssdk/unierror.uts": {
"md5": "d41d8cd98f00b204e9800998ecf8427e"
},
"package.json": {
"md5": "3cdbb2337594f0c0315d1fa20a739617"
},
"utssdk/app-android/AndroidManifest.xml": {
"md5": "80263498d2ad55cb954e347c7c933e65"
},
"utssdk/app-android/config.json": {
"md5": "d903d6c89479ad424282bba97dff94ef"
},
"utssdk/app-android/res/values/notification_progress_styles.xml": {
"md5": "6fa2d7ac4d16a31ee5251cfb34bacd41"
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
.multi-line-omit[data-v-401afd0e]{word-break:break-all;text-overflow:ellipsis;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}.one-line-omit[data-v-401afd0e]{width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.content[data-v-401afd0e]{display:flex;flex-direction:column;align-items:center;justify-content:center}.inputsty[data-v-401afd0e]{border:1px solid #000000;margin-top:50vh}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
body{background:transparent}.flex-center{display:flex;justify-content:center;align-items:center}.mask{position:fixed;left:0;top:0;right:0;bottom:0;background-color:rgba(0,0,0,.65)}.botton-radius{border-bottom-left-radius:.9375rem;border-bottom-right-radius:.9375rem}.content{position:relative;top:0;width:18.75rem;background-color:#fff;box-sizing:border-box;padding:0 1.5625rem;font-family:Source Han Sans CN}.text{display:block;line-height:200px;text-align:center;color:#fff}.content-top{position:absolute;top:-6.09375rem;left:0;width:18.75rem;height:8.4375rem}.content-top-text{font-size:1.40625rem;font-weight:700;color:#f8f8fa;position:absolute;top:3.75rem;left:1.5625rem;z-index:1}.content-header{height:2.1875rem}.title{font-size:1.03125rem;font-weight:700;color:#3da7ff;display:flex;align-items:center}.content-body-version{color:#fff;font-size:12px;margin-left:5px;padding:2px 6px;border-radius:4px;display:flex;background:#50aefd}.footer{height:4.6875rem;display:flex;align-items:center;justify-content:space-around}.box-des-scroll{box-sizing:border-box;height:6.25rem;text-align:left}.box-des{font-size:.8125rem;color:#000;line-height:1.5625rem}.progress-box{width:100%}.progress{width:90%;height:1.25rem}.close-img{width:2.1875rem;height:2.1875rem;z-index:1000;position:absolute;bottom:-3.75rem;left:calc(50% - 1.09375rem)}.content-button{text-align:center;flex:1;font-size:.9375rem;font-weight:400;color:#fff;border-radius:1.25rem;margin:0 .5625rem;height:2.5rem;line-height:2.5rem;background:linear-gradient(to right,#1785ff,#3da7ff)}.flex-column{display:flex;flex-direction:column;align-items:center}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
package="uts.sdk.modules.utsProgressNotification">
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<application>
<activity android:name="uts.sdk.modules.utsProgressNotification.TransparentActivity"
android:theme="@style/DCNotificationProgressTranslucentTheme" android:hardwareAccelerated="true"
android:screenOrientation="user" android:exported="true">
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,3 @@
{
"minSdkVersion": "19"
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="DCNotificationProgressTranslucentTheme">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
</resources>

View File

@@ -0,0 +1,255 @@
@file:Suppress("UNCHECKED_CAST", "USELESS_CAST", "INAPPLICABLE_JVM_NAME", "UNUSED_ANONYMOUS_PARAMETER", "NAME_SHADOWING", "UNNECESSARY_NOT_NULL_ASSERTION")
package uts.sdk.modules.utsProgressNotification
import android.app.Activity
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.view.View
import android.view.WindowManager
import io.dcloud.uniapp.*
import io.dcloud.uniapp.extapi.*
import io.dcloud.uts.*
import io.dcloud.uts.Map
import io.dcloud.uts.Set
import io.dcloud.uts.UTSAndroid
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import uts.sdk.modules.utsProgressNotification.R
open class CreateNotificationProgressOptions (
open var title: String? = null,
@JsonNotNull
open var content: String,
@JsonNotNull
open var progress: Number,
open var onClick: (() -> Unit)? = null,
) : UTSObject()
open class FinishNotificationProgressOptions (
open var title: String? = null,
@JsonNotNull
open var content: String,
open var onClick: () -> Unit,
) : UTSObject()
val ACTION_DOWNLOAD_FINISH = "ACTION_DOWNLOAD_FINISH"
val ACTION_DOWNLOAD_PROGRESS = "ACTION_DOWNLOAD_PROGRESS"
@JvmField
var globalNotificationProgressCallBack: (() -> Unit)? = fun(){}
@JvmField
var globalNotificationProgressFinishCallBack: (() -> Unit)? = fun(){}
fun setGlobalNotificationProgressCallBack(callBack: (() -> Unit)?): Unit {
globalNotificationProgressCallBack = callBack
}
fun getGlobalNotificationProgressCallBack(): (() -> Unit)? {
return globalNotificationProgressCallBack
}
fun setGlobalNotificationProgressFinishCallBack(callBack: (() -> Unit)?): Unit {
globalNotificationProgressFinishCallBack = callBack
}
fun getGlobalNotificationProgressFinishCallBack(): (() -> Unit)? {
return globalNotificationProgressFinishCallBack
}
open class TransparentActivity : Activity {
constructor() : super() {}
@Suppress("DEPRECATION")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
this.fullScreen(this)
val action = this.getIntent().getAction()
if (action == ACTION_DOWNLOAD_FINISH) {
setTimeout(fun(){
getGlobalNotificationProgressFinishCallBack()?.invoke()
setGlobalNotificationProgressFinishCallBack(fun(){})
}
, 100)
this.overridePendingTransition(0, 0)
}
if (action == ACTION_DOWNLOAD_PROGRESS) {
setTimeout(fun(){
getGlobalNotificationProgressCallBack()?.invoke()
setGlobalNotificationProgressCallBack(fun(){})
}
, 100)
this.overridePendingTransition(0, 0)
}
setTimeout(fun(){
this.finish()
}
, 20)
}
@Suppress("DEPRECATION")
private fun fullScreen(activity: Activity) {
if (Build.VERSION.SDK_INT >= 19) {
if (Build.VERSION.SDK_INT >= 21) {
val window = activity.getWindow()
val decorView = window.getDecorView()
val option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
decorView.setSystemUiVisibility(option)
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.setStatusBarColor(Color.TRANSPARENT)
} else {
val window = activity.getWindow()
val attributes = window.getAttributes()
val flagTranslucentStatus = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
attributes.flags = attributes.flags or flagTranslucentStatus
window.setAttributes(attributes)
}
}
}
}
val DOWNLOAD_PROGRESS_NOTIFICATION_ID: Int = 7890
val DC_DOWNLOAD_CHANNEL_ID = "下载文件"
val DC_DOWNLOAD_CHANNEL_NAME = "用于显示现在进度的渠道"
var notificationBuilder: Notification.Builder? = null
var timeId: Number = -1
var histroyProgress: Number = 0
var isProgress = false
fun createNotificationProgress(options: CreateNotificationProgressOptions): Unit {
val content = options.content
val progress = options.progress
val onClick = options.onClick
if (progress == 100) {
clearTimeout(timeId)
val context = UTSAndroid.getAppContext() as Context
realCreateNotificationProgress(options.title ?: getAppName(context), content, progress, onClick)
reset()
return
}
histroyProgress = progress
if (timeId != -1) {
return
}
val context = UTSAndroid.getAppContext() as Context
if (!isProgress) {
realCreateNotificationProgress(options.title ?: getAppName(context), content, histroyProgress, onClick)
isProgress = true
} else {
timeId = setTimeout(fun(){
realCreateNotificationProgress(options.title ?: getAppName(context), content, histroyProgress, onClick)
timeId = -1
}
, 1000)
}
}
fun cancelNotificationProgress(): Unit {
val context = UTSAndroid.getAppContext() as Context
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.cancel(DOWNLOAD_PROGRESS_NOTIFICATION_ID)
reset()
}
fun realCreateNotificationProgress(title: String, content: String, progress: Number, cb: (() -> Unit)?): Unit {
setGlobalNotificationProgressCallBack(cb)
val context = UTSAndroid.getAppContext() as Context
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
createDownloadChannel(notificationManager)
val builder = createNotificationBuilder(context)
builder.setProgress(100, progress.toInt(), false)
builder.setContentTitle(title)
builder.setContentText(content)
builder.setContentIntent(createPendingIntent(context, ACTION_DOWNLOAD_PROGRESS))
notificationManager.notify(DOWNLOAD_PROGRESS_NOTIFICATION_ID, builder.build())
}
fun finishNotificationProgress(options: FinishNotificationProgressOptions) {
setGlobalNotificationProgressFinishCallBack(options.onClick)
val context = UTSAndroid.getAppContext() as Context
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
createDownloadChannel(notificationManager)
val builder = createNotificationBuilder(context)
builder.setProgress(0, 0, false)
builder.setContentTitle(options.title ?: getAppName(context))
builder.setContentText(options.content)
builder.setAutoCancel(true)
builder.setContentIntent(createPendingIntent(context, ACTION_DOWNLOAD_FINISH))
notificationManager.notify(DOWNLOAD_PROGRESS_NOTIFICATION_ID, builder.build())
reset()
}
fun reset() {
isProgress = false
notificationBuilder = null
histroyProgress = 0
if (timeId != -1) {
clearTimeout(timeId)
timeId = -1
}
}
fun createPendingIntent(context: Context, action: String): PendingIntent {
val intent = Intent(action)
intent.setComponent(ComponentName(context.getPackageName(), "uts.sdk.modules.utsProgressNotification.TransparentActivity"))
var flags = PendingIntent.FLAG_UPDATE_CURRENT
if (Build.VERSION.SDK_INT >= 23) {
flags = PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
}
return PendingIntent.getActivity(context, DOWNLOAD_PROGRESS_NOTIFICATION_ID, intent, flags)
}
fun createDownloadChannel(notificationManager: NotificationManager) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(DC_DOWNLOAD_CHANNEL_ID, DC_DOWNLOAD_CHANNEL_NAME, NotificationManager.IMPORTANCE_LOW)
notificationManager.createNotificationChannel(channel)
}
}
@Suppress("DEPRECATION")
fun createNotificationBuilder(context: Context): Notification.Builder {
if (notificationBuilder == null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notificationBuilder = Notification.Builder(context, DC_DOWNLOAD_CHANNEL_ID)
} else {
notificationBuilder = Notification.Builder(context)
}
notificationBuilder!!.setSmallIcon(context.getApplicationInfo().icon)
notificationBuilder!!.setOngoing(true)
notificationBuilder!!.setSound(null)
}
return notificationBuilder!!
}
@Suppress("DEPRECATION")
fun getAppName(context: Context): String {
var appName = ""
try {
val packageManager = context.getPackageManager()
val applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0)
appName = packageManager.getApplicationLabel(applicationInfo) as String
}
catch (e: Exception) {
e.printStackTrace()
}
return appName
}
open class CreateNotificationProgressOptionsJSONObject : UTSJSONObject() {
open var title: String? = null
open lateinit var content: String
open lateinit var progress: Number
open var onClick: UTSCallback? = null
}
open class FinishNotificationProgressOptionsJSONObject : UTSJSONObject() {
open var title: String? = null
open lateinit var content: String
open lateinit var onClick: UTSCallback
}
open class TransparentActivityByJs : TransparentActivity {
constructor() : super() {}
open fun onCreateByJs(savedInstanceState: Bundle?) {
return this.onCreate(savedInstanceState)
}
}
fun createNotificationProgressByJs(options: CreateNotificationProgressOptionsJSONObject): Unit {
return createNotificationProgress(CreateNotificationProgressOptions(title = options.title, content = options.content, progress = options.progress, onClick = fun(): Unit {
options.onClick?.invoke()
}
))
}
fun cancelNotificationProgressByJs(): Unit {
return cancelNotificationProgress()
}
fun finishNotificationProgressByJs(options: FinishNotificationProgressOptionsJSONObject) {
return finishNotificationProgress(FinishNotificationProgressOptions(title = options.title, content = options.content, onClick = fun(): Unit {
options.onClick()
}
))
}