Browse Source

息屏唤醒误触

wbspool 1 year ago
parent
commit
767ed79eb8

+ 137 - 0
BusinessAirFryer/src/main/assets/config_030.json

@@ -0,0 +1,137 @@
+{
+  "workModes": [
+    {
+      "type": "ADAPTED_COOKING",
+      "name": "adapted_cooking",
+      "bg": "ic_mode_chop",
+      "icon": "ic_grid_adapted_cooking",
+      "devMode": "SOUP"
+    },
+    {
+      "type": "WIGHT",
+      "name": "wight",
+      "bg": "ic_mode_weight",
+      "icon": "ic_grid_weight",
+      "devMode": "SOUP"
+    },
+    {
+      "type": "BOIL_WATER",
+      "name": "boil_water",
+      "bg": "ic_mode_boil_water",
+      "icon": "ic_grid_boil_water",
+      "devMode": "SOUP"
+    },
+    {
+      "type": "CHOP",
+      "name": "chop",
+      "bg": "ic_mode_chop",
+      "icon": "ic_grid_chop",
+      "devMode": "SOUP"
+    },
+    {
+      "type": "SLOW_COOK",
+      "name": "slow_cook",
+      "bg": "ic_mode_slow_cook",
+      "icon": "ic_grid_slow_cook",
+      "devMode": "SOUP"
+    },
+    {
+      "type": "KNEAD_TOUGH",
+      "name": "knead_dough",
+      "bg": "ic_mode_knead_dough",
+      "icon": "ic_grid_knead_dough",
+      "devMode": "SOUP"
+    },
+    {
+      "type": "STEAM",
+      "name": "steam",
+      "bg": "ic_mode_steam",
+      "icon": "ic_grid_steam",
+      "devMode": "SOUP"
+    },
+    {
+      "type": "FOOD_PROCESSOR",
+      "name": "food_processor",
+      "bg": "ic_mode_food_processor",
+      "icon": "ic_grid_food_processor",
+      "devMode": "SOUP"
+    },
+    {
+      "type": "TURBO",
+      "name": "turbo",
+      "bg": "ic_mode_turbo",
+      "icon": "ic_grid_turbo",
+      "devMode": "SOUP"
+    },
+    {
+      "type": "AIR_FRYER",
+      "name": "air_fryer",
+       "bg": "air_fryer",
+      "icon": "air_fryer",
+      "devMode": "AIR_FRYER"
+    },
+    {
+      "type": "MEAT",
+      "name": "meat",
+      "bg": "meat",
+      "icon": "meat",
+      "devMode": "AIR_FRYER"
+    },
+    {
+      "type": "FISH",
+      "name": "fish",
+      "bg": "fish_steak",
+      "icon": "fish_steak",
+      "devMode": "AIR_FRYER"
+    },
+    {
+      "type": "BAKC",
+      "name": "bakc",
+      "bg": "bakc",
+      "icon": "bakc",
+      "devMode": "AIR_FRYER"
+    },
+    {
+      "type": "DRUMSTICKS",
+      "name": "drumsticks",
+      "bg": "drumsticks",
+      "icon": "drumsticks",
+      "devMode": "AIR_FRYER"
+    },
+    {
+      "type": "CHICKEN_WING",
+      "name": "chicken_wing",
+      "bg": "chicken_wing",
+      "icon": "chicken_wing",
+      "devMode": "AIR_FRYER"
+    },
+    {
+      "type": "VEGETABLE",
+      "name": "vegetable",
+      "bg": "vegetable",
+      "icon": "vegetable",
+      "devMode": "AIR_FRYER"
+    },
+    {
+      "type": "SHRIMP",
+      "name": "shrimp",
+      "bg": "shrimp",
+      "icon": "shrimp",
+      "devMode": "AIR_FRYER"
+    },
+    {
+      "type": "PIZZA",
+      "name": "pizza",
+      "bg": "pizza",
+      "icon": "pizza",
+      "devMode": "AIR_FRYER"
+    },
+    {
+      "type": "DEHYDRATE",
+      "name": "dehydrate",
+      "bg": "dehydrate",
+      "icon": "dehydrate",
+      "devMode": "AIR_FRYER"
+    }
+  ]
+}

+ 2 - 0
BusinessCommon/src/main/java/com/develop/common/ui/CommonBVMActivity.kt

@@ -15,6 +15,8 @@ abstract class CommonBVMActivity<VB : ViewBinding, VM : BaseViewModel> :
 
     abstract fun createViewModel(): VM
 
+
+
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
         viewModel = createViewModel()

+ 53 - 1
BusinessCommon/src/main/java/com/develop/common/ui/CommonBindingActivity.kt

@@ -1,10 +1,14 @@
 package com.develop.common.ui
 
+import android.content.BroadcastReceiver
 import android.content.Context
+import android.content.Intent
+import android.content.IntentFilter
 import android.content.res.Resources
 import android.os.Bundle
 import android.os.IBinder
 import android.os.Looper
+import android.util.Log
 import android.view.MotionEvent
 import android.view.View
 import android.view.inputmethod.InputMethodManager
@@ -13,6 +17,7 @@ import androidx.viewbinding.ViewBinding
 import com.develop.base.ext.navigateTo
 import com.develop.base.mvvm.BaseBindingActivity
 import com.develop.base.util.MMkvUtils
+import com.develop.base.util.TopResumedAtyHolder
 import com.develop.common.R
 import com.develop.common.dialog.CancelConfirmDialog
 import com.develop.common.dialog.PlainDialogView
@@ -25,13 +30,17 @@ import com.kuyuntech.cofarcooking.device.sdk.eventbus.event.DevPromptEvent
 import me.jessyan.autosize.AutoSizeCompat
 import org.greenrobot.eventbus.EventBus
 import org.greenrobot.eventbus.Subscribe
-import com.develop.base.util.TopResumedAtyHolder
+
 
 /**
  * 带业务逻辑的基类
  */
 abstract class CommonBindingActivity<T : ViewBinding> : BaseBindingActivity<T>() {
 
+
+    private var screenReceiver: BroadcastReceiver? = null
+
+
     protected var hasShowScreenSaver = false
 
     private val plainDialogView by lazy {
@@ -52,6 +61,29 @@ abstract class CommonBindingActivity<T : ViewBinding> : BaseBindingActivity<T>()
     override fun onCreate(savedInstanceState: Bundle?) {
         EventBus.getDefault().register(this)
         super.onCreate(savedInstanceState)
+
+
+        screenReceiver = object : BroadcastReceiver() {
+            override fun onReceive(context: Context, intent: Intent) {
+                val action = intent.action
+
+                if (action == Intent.ACTION_SCREEN_ON) {
+                    // 处理屏幕亮起事件
+                    Log.i("0525","ACTION_SCREEN_ON")
+                    locktime = System.currentTimeMillis()
+                } else if (action == Intent.ACTION_SCREEN_OFF) {
+                    // 处理屏幕关闭事件
+                    Log.i("0525","ACTION_SCREEN_OFF")
+                }
+            }
+        }
+
+        val intentFilter = IntentFilter().apply {
+            addAction(Intent.ACTION_SCREEN_ON)
+            addAction(Intent.ACTION_SCREEN_OFF)
+        }
+        registerReceiver(screenReceiver, intentFilter)
+
         val time = MMkvUtils.getInt(SCREENSAVER)
         if (time != 0) {
             screenSaverTime = time
@@ -76,15 +108,33 @@ abstract class CommonBindingActivity<T : ViewBinding> : BaseBindingActivity<T>()
         } else {
             stopScreenSaverCount()
         }
+        val intentFilter = IntentFilter()
+        intentFilter.addAction(Intent.ACTION_SCREEN_ON)
+        intentFilter.addAction(Intent.ACTION_SCREEN_OFF)
+        registerReceiver(screenReceiver, intentFilter)
     }
 
     override fun onPause() {
         super.onPause()
         isResume = false
         stopScreenSaverCount()
+
     }
 
+
+
+    var  lock = false
+    var locktime:Long = 0
     override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
+
+
+        if(((System.currentTimeMillis() - locktime) < 3000)){
+            return true
+        }
+
+        locktime = 0L
+        lock = false
+
         if (ev.x == 0f && ev.y == 0f) {
             return true
         }
@@ -264,5 +314,7 @@ abstract class CommonBindingActivity<T : ViewBinding> : BaseBindingActivity<T>()
         EventBus.getDefault().unregister(this)
         GlobalDevEvent.dismissDialog()
         dismissPlainDialog()
+        if(screenReceiver != null) unregisterReceiver(screenReceiver)
+
     }
 }

+ 1 - 1
BusinessCommon/src/main/java/com/develop/common/utils/ConfigUtils.kt

@@ -14,7 +14,7 @@ object ConfigUtils {
 
     fun loadConfig(): CfConfig? {
         return try {
-            val inputStream = GlobalApp().assets.open("config.json")
+            val inputStream = GlobalApp().assets.open("config_030.json")
             val size = inputStream.available()
             val buffer = ByteArray(size)
             inputStream.read(buffer)

+ 8 - 3
app/build.gradle

@@ -8,16 +8,21 @@ plugins {
 
 ext{
 
-    versionCode=230505180
-    brandCode="010A"
+    versionCode=230523141
+    brandCode="030A"
     brandVersionCode=versionCode
-    model="5037"
+    model="1039"
 }
 
 
 android {
     compileSdk 31
 
+    lintOptions {
+        checkReleaseBuilds false
+
+    }
+
     defaultConfig {
         applicationId "com.develop.foodcooking"
         minSdk 21

+ 18 - 17
app/src/main/java/com/develop/foodcooking/FoodCookingApp.kt

@@ -6,6 +6,7 @@ import android.content.Intent
 import android.net.Uri
 import android.os.PowerManager
 import android.provider.Settings
+import android.util.Log
 import com.develop.common.data_repo.FoodDataProvider
 import com.develop.common.data_repo.net.Api
 import com.develop.common.data_repo.net.converter.SerializationConverter
@@ -33,23 +34,23 @@ class FoodCookingApp : BaseApp() {
         CofarSDK.register(this)
         CofarSDK.stopNative()
 
-        val powerManager = getSystemService(POWER_SERVICE) as PowerManager
-        val wakeLock: PowerManager.WakeLock =
-            powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "motionDetection:keepAwake")
-        wakeLock.acquire()
-//        pm = getSystemService(POWER_SERVICE) as PowerManager
-//        minute = MMkvUtils.getInt("ScreenSaver")
-//        if (minute == 0) {
-//            minute = 3
-//        }
-//        Settings.System.putInt(
-//            contentResolver,
-//            Settings.System.SCREEN_OFF_TIMEOUT,
-//            (1000 * 60 * minute).toInt()
-//        )
-//        val uri: Uri = Settings.System
-//            .getUriFor(Settings.System.SCREEN_OFF_TIMEOUT)
-//        contentResolver.notifyChange(uri, null)
+//        val powerManager = getSystemService(POWER_SERVICE) as PowerManager
+//        val wakeLock: PowerManager.WakeLock =
+//            powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "motionDetection:keepAwake")
+//        wakeLock.acquire()
+        pm = getSystemService(POWER_SERVICE) as PowerManager
+        minute = MMkvUtils.getInt("ScreenSaver")
+        if (minute == 0) {
+            minute = 3
+        }
+        Settings.System.putInt(
+            contentResolver,
+            Settings.System.SCREEN_OFF_TIMEOUT,
+            (1000 * 60 * minute).toInt()
+        )
+        val uri: Uri = Settings.System
+            .getUriFor(Settings.System.SCREEN_OFF_TIMEOUT)
+        contentResolver.notifyChange(uri, null)
     }
 
     override fun createHostUrl(): String {

+ 21 - 5
build.gradle

@@ -1,14 +1,30 @@
 buildscript {
+    ext.kotlin_version = "1.5.20"
+    repositories {
+        maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
+        google()
+        mavenCentral()
+    }
     dependencies {
+        classpath "com.android.tools.build:gradle:4.2.2"
         classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10'
-        classpath "org.jetbrains.kotlin:kotlin-serialization:1.7.20"
+        classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
         classpath "com.alibaba:arouter-register:1.0.2"
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
     }
 }
-plugins {
-    id 'com.android.application' version '7.3.1' apply false
-    id 'com.android.library' version '7.3.1' apply false
-    id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
+
+allprojects {
+    repositories {
+        //google()
+//        mavenCentral()
+//        maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
+//        jcenter()
+//        maven { url 'https://www.jitpack.io' }
+    }
+}
+
+task clean(type: Delete) {
+    delete rootProject.buildDir
 }