|
@@ -1,14 +1,12 @@
|
|
package com.ys.imageProcess
|
|
package com.ys.imageProcess
|
|
|
|
|
|
-import android.content.ContentValues
|
|
|
|
|
|
+import android.app.AlertDialog
|
|
import android.content.ContentValues.*
|
|
import android.content.ContentValues.*
|
|
import android.content.Context
|
|
import android.content.Context
|
|
-import android.graphics.BitmapFactory
|
|
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
import android.util.Log
|
|
import android.util.Log
|
|
import androidx.activity.ComponentActivity
|
|
import androidx.activity.ComponentActivity
|
|
import androidx.activity.compose.setContent
|
|
import androidx.activity.compose.setContent
|
|
-import androidx.compose.animation.core.withInfiniteAnimationFrameNanos
|
|
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
import androidx.compose.material3.MaterialTheme
|
|
import androidx.compose.material3.MaterialTheme
|
|
import androidx.compose.material3.Surface
|
|
import androidx.compose.material3.Surface
|
|
@@ -16,20 +14,30 @@ import androidx.compose.runtime.Composable
|
|
import androidx.compose.ui.Modifier
|
|
import androidx.compose.ui.Modifier
|
|
import androidx.compose.ui.platform.LocalContext
|
|
import androidx.compose.ui.platform.LocalContext
|
|
import androidx.compose.ui.tooling.preview.Preview
|
|
import androidx.compose.ui.tooling.preview.Preview
|
|
|
|
+import androidx.core.app.ActivityCompat
|
|
|
|
+import androidx.core.app.ActivityCompat.finishAffinity
|
|
import androidx.navigation.compose.rememberNavController
|
|
import androidx.navigation.compose.rememberNavController
|
|
|
|
+import com.ys.imageProcess.access.UsagePermission
|
|
import com.ys.imageProcess.ui.navigation.IPNavHost
|
|
import com.ys.imageProcess.ui.navigation.IPNavHost
|
|
import com.ys.imageProcess.ui.theme.ImageProcTheme
|
|
import com.ys.imageProcess.ui.theme.ImageProcTheme
|
|
-import com.ys.imageProcess.cv.Process
|
|
|
|
import com.ys.imageProcess.data.IPFile
|
|
import com.ys.imageProcess.data.IPFile
|
|
import com.ys.imageProcess.ocr.OCRModelLoader
|
|
import com.ys.imageProcess.ocr.OCRModelLoader
|
|
-import kotlin.math.log
|
|
|
|
|
|
+import kotlin.system.exitProcess
|
|
|
|
|
|
class MainActivity : ComponentActivity() {
|
|
class MainActivity : ComponentActivity() {
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
super.onCreate(savedInstanceState)
|
|
|
|
+ val valid = UsagePermission.checkDatePermissionLocal()
|
|
setContent {
|
|
setContent {
|
|
- IPApp(context = this)
|
|
|
|
|
|
+ if (valid) {
|
|
|
|
+ IPApp(context = this)
|
|
|
|
+ } else {
|
|
|
|
+ showAlertDialog(this) {
|
|
|
|
+ finishAffinity(this)
|
|
|
|
+ exitProcess(0) // 确保完全退出
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
IPFile.config(this)
|
|
IPFile.config(this)
|
|
@@ -61,6 +69,36 @@ fun IPApp(
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+private fun showAlertDialog(context: Context, exit: (() -> Unit)? = null) {
|
|
|
|
+ // 创建一个新的 AlertDialog.Builder 实例
|
|
|
|
+ val builder = AlertDialog.Builder(context)
|
|
|
|
+
|
|
|
|
+ // 设置对话框的标题
|
|
|
|
+ builder.setTitle("提示")
|
|
|
|
+
|
|
|
|
+ // 设置对话框的消息
|
|
|
|
+ builder.setMessage("应用已过期请更新。")
|
|
|
|
+
|
|
|
|
+ // 添加确定按钮
|
|
|
|
+ builder.setPositiveButton("确定") { dialog, which ->
|
|
|
|
+ // 点击确定按钮时的操作
|
|
|
|
+ dialog.dismiss() // 关闭对话框
|
|
|
|
+ if (exit != null) {
|
|
|
|
+ exit()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // // 添加取消按钮
|
|
|
|
+ // builder.setNegativeButton("取消") { dialog, which ->
|
|
|
|
+ // // 点击取消按钮时的操作
|
|
|
|
+ // dialog.cancel() // 关闭对话框
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // 创建并显示对话框
|
|
|
|
+ val alertDialog = builder.create()
|
|
|
|
+ alertDialog.show()
|
|
|
|
+}
|
|
|
|
+
|
|
@Preview(showBackground = true, showSystemUi = true, device = "id:pixel_tablet")
|
|
@Preview(showBackground = true, showSystemUi = true, device = "id:pixel_tablet")
|
|
@Composable
|
|
@Composable
|
|
fun ChildrenAppPreview() {
|
|
fun ChildrenAppPreview() {
|