wbspool 1 рік тому
батько
коміт
7aed4f1019

+ 1 - 0
BusinessAirFryer/.gitignore

@@ -0,0 +1 @@
+/build

+ 21 - 0
BusinessAirFryer/build.gradle

@@ -0,0 +1,21 @@
+plugins {
+    id 'kotlin-kapt'
+    id 'org.jetbrains.kotlin.android'
+}
+
+apply from: '../common.gradle'
+
+android{
+    sourceSets {
+        main {
+            jniLibs.srcDirs = ['libs']
+        }
+    }
+}
+
+dependencies {
+    api project(path: ':libBase')
+    api project(path: ':libThirdPart')
+    kapt 'com.alibaba:arouter-compiler:1.5.2'
+    kapt  "androidx.room:room-compiler:2.4.2"
+}

+ 0 - 0
BusinessAirFryer/consumer-rules.pro


+ 21 - 0
BusinessAirFryer/proguard-rules.pro

@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile

+ 24 - 0
BusinessAirFryer/src/androidTest/java/com/develop/airfryer/ExampleInstrumentedTest.kt

@@ -0,0 +1,24 @@
+package com.develop.airfryer
+
+import androidx.test.platform.app.InstrumentationRegistry
+import androidx.test.ext.junit.runners.AndroidJUnit4
+
+import org.junit.Test
+import org.junit.runner.RunWith
+
+import org.junit.Assert.*
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+@RunWith(AndroidJUnit4::class)
+class ExampleInstrumentedTest {
+    @Test
+    fun useAppContext() {
+        // Context of the app under test.
+        val appContext = InstrumentationRegistry.getInstrumentation().targetContext
+        assertEquals("com.develop.airfryer.test", appContext.packageName)
+    }
+}

+ 4 - 0
BusinessAirFryer/src/main/AndroidManifest.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.develop.airfryer">
+
+</manifest>

+ 120 - 0
BusinessAirFryer/src/main/assets/config.json

@@ -0,0 +1,120 @@
+{
+  "soupWorkModes": [
+    {
+      "type": "ADAPTED_COOKING",
+      "name": "adapted_cooking",
+      "bg": "",
+      "icon": "ic_grid_adapted_cooking"
+    },
+    {
+      "type": "WIGHT",
+      "name": "wight",
+      "bg": "",
+      "icon": "ic_grid_weight"
+    },
+    {
+      "type": "BOIL_WATER",
+      "name": "boil_water",
+      "bg": "",
+      "icon": "ic_grid_boil_water"
+    },
+    {
+      "type": "CHOP",
+      "name": "chop",
+      "bg": "",
+      "icon": "ic_grid_chop"
+    },
+    {
+      "type": "SLOW_COOK",
+      "name": "slow_cook",
+      "bg": "",
+      "icon": "ic_grid_slow_cook"
+    },
+    {
+      "type": "KNEAD_TOUGH",
+      "name": "knead_dough",
+      "bg": "",
+      "icon": "ic_grid_knead_dough"
+    },
+    {
+      "type": "STEAM",
+      "name": "steam",
+      "bg": "",
+      "icon": "ic_grid_steam"
+    },
+    {
+      "type": "FOOD_PROCESSOR",
+      "name": "food_processor",
+      "bg": "",
+      "icon": "ic_grid_food_processor"
+    },
+    {
+      "type": "TURBO",
+      "name": "turbo",
+      "bg": "",
+      "icon": "ic_grid_turbo"
+    }
+  ],
+  "airFryerWorkModes": [
+    {
+      "type": "AIR_FRYER",
+      "name": "air_fryer",
+       "bg": "air_fryer",
+      "icon": "air_fryer"
+    },
+    {
+      "type": "MEAT",
+      "name": "meat",
+      "bg": "meat",
+      "icon": "meat"
+    },
+    {
+      "type": "FISH",
+      "name": "fish",
+      "bg": "fish",
+      "icon": "fish"
+    },
+    {
+      "type": "BAKC",
+      "name": "bakc",
+      "bg": "bakc",
+      "icon": "bakc"
+    },
+    {
+      "type": "DRUMSTICKS",
+      "name": "drumsticks",
+      "bg": "drumsticks",
+      "icon": "drumsticks"
+    },
+    {
+      "type": "CHICKEN_WING",
+      "name": "chicken_wing",
+      "bg": "chicken_wing",
+      "icon": "chicken_wing"
+    },
+    {
+      "type": "VEGETABLE",
+      "name": "vegetable",
+      "bg": "vegetable",
+      "icon": "vegetable"
+    },
+    {
+      "type": "SHRIMP",
+      "name": "shrimp",
+      "bg": "shrimp",
+      "icon": "shrimp"
+    },
+    {
+      "type": "PIZZA",
+      "name": "pizza",
+      "bg": "pizza",
+      "icon": "pizza"
+    },
+    {
+      "type": "DEHYDRATE",
+      "name": "dehydrate",
+      "bg": "dehydrate",
+      "icon": "dehydrate"
+    }
+  ]
+}

+ 67 - 0
BusinessAirFryer/src/main/java/com/develop/airfryer/ui/DevModeView.kt

@@ -0,0 +1,67 @@
+package com.develop.airfryer.ui
+
+import android.content.Context
+import android.util.AttributeSet
+import android.view.LayoutInflater
+import android.view.View
+import androidx.constraintlayout.widget.ConstraintLayout
+import com.develop.airfryer.databinding.DevModeViewBinding
+import com.kuyuntech.cofarcooking.device.sdk.constant.core.DevModes
+import com.kuyuntech.cofarcooking.device.sdk.eventbus.event.DevCommonEvent
+import com.kuyuntech.cofarcooking.device.sdk.util.core.CofarSDK
+import org.greenrobot.eventbus.Subscribe
+
+class DevModeView(context: Context, attrs: AttributeSet) : ConstraintLayout(context, attrs){
+
+   private var mode = CofarSDK.devInfo().devMode;
+
+   private val binding: DevModeViewBinding
+
+   init {
+      binding = DevModeViewBinding.inflate(LayoutInflater.from(context), this, true)
+       setupClickListener()
+       CofarSDK.register(this)
+       updateUI()
+   }
+
+    override fun onDetachedFromWindow() {
+        super.onDetachedFromWindow()
+        CofarSDK.unregister(this);
+    }
+
+    @Subscribe
+    fun onDevModeChange(event: DevCommonEvent){
+            mode = CofarSDK.devInfo().devMode;
+            updateUI();
+    }
+
+    private fun updateUI(){
+        //判断模式
+        if(mode == DevModes.AIR_FRYER){
+            binding.dfbAtive.visibility = View.GONE;
+            binding.dfbUnactive.visibility = View.VISIBLE;
+            binding.kqzgActive.visibility = View.VISIBLE;
+            binding.kqzgUnactive.visibility = View.GONE;
+        }else{
+            binding.dfbAtive.visibility = View.VISIBLE;
+            binding.dfbUnactive.visibility = View.GONE;
+            binding.kqzgActive.visibility = View.GONE;
+            binding.kqzgUnactive.visibility = View.VISIBLE;
+        }
+    }
+
+   private fun setupClickListener(){
+
+
+      setOnClickListener {
+          CofarSDK.changeDevMode(if (mode ==DevModes.SOUP) DevModes.AIR_FRYER else DevModes.SOUP)
+
+      }
+
+   }
+
+
+
+
+
+}

+ 3 - 0
BusinessAirFryer/src/main/java/com/develop/airfryer/viewmodel/WorkMode.kt

@@ -0,0 +1,3 @@
+package com.develop.airfryer.viewmodel
+
+data class WorkMode(val name: String?, val type: String, val icon: String?,val bg: String?)

BIN
BusinessAirFryer/src/main/res/drawable/dfb.png


BIN
BusinessAirFryer/src/main/res/drawable/dfb_active.png


BIN
BusinessAirFryer/src/main/res/drawable/kqzg.png


BIN
BusinessAirFryer/src/main/res/drawable/kqzg_active.png


BIN
BusinessAirFryer/src/main/res/drawable/test.png


+ 90 - 0
BusinessAirFryer/src/main/res/layout/dev_mode_view.xml

@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
+
+
+
+        <androidx.cardview.widget.CardView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            app:cardCornerRadius="@dimen/convert_30px"
+            app:cardElevation="@dimen/convert_8px"
+            app:cardUseCompatPadding="true"
+            app:cardPreventCornerOverlap="false"
+            app:cardBackgroundColor="#ffffff"
+            >
+
+
+
+                <LinearLayout
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content">
+
+                        <LinearLayout
+                            android:gravity="center"
+                            android:id="@+id/dfb_ative"
+                            android:layout_width="@dimen/convert_80px"
+                            android:layout_height="@dimen/convert_60px"
+                            android:background="#EE8F08"
+                            >
+                                <ImageView
+                                    android:layout_width="@dimen/convert_40px"
+                                    android:layout_height="@dimen/convert_40px"
+                                    android:src="@drawable/dfb_active"
+                                    />
+                        </LinearLayout>
+
+                        <LinearLayout
+                            android:gravity="center"
+                            android:id="@+id/dfb_unactive"
+                            android:visibility="gone"
+                            android:layout_width="@dimen/convert_80px"
+                            android:layout_height="@dimen/convert_60px"
+                            android:background="#ffffff"
+                            >
+                                <ImageView
+                                    android:layout_width="@dimen/convert_40px"
+                                    android:layout_height="@dimen/convert_40px"
+                                    android:src="@drawable/dfb"
+                                    />
+                        </LinearLayout>
+
+
+                        <LinearLayout
+                            android:gravity="center"
+                            android:id="@+id/kqzg_unactive"
+                            android:layout_width="@dimen/convert_80px"
+                            android:layout_height="@dimen/convert_60px"
+                            android:background="#ffffff" >
+                                <ImageView
+                                    android:layout_width="@dimen/convert_40px"
+                                    android:layout_height="@dimen/convert_40px"
+                                    android:src="@drawable/kqzg"
+                                    />
+                        </LinearLayout>
+
+                        <LinearLayout
+                            android:gravity="center"
+                            android:visibility="gone"
+                            android:id="@+id/kqzg_active"
+                            android:layout_width="@dimen/convert_80px"
+                            android:layout_height="@dimen/convert_60px"
+                            android:background="#EE8F08" >
+                                <ImageView
+                                    android:layout_width="@dimen/convert_40px"
+                                    android:layout_height="@dimen/convert_40px"
+                                    android:src="@drawable/kqzg_active"
+                                    />
+                        </LinearLayout>
+
+                </LinearLayout>
+
+        </androidx.cardview.widget.CardView>
+
+
+
+
+
+</LinearLayout>

+ 17 - 0
BusinessAirFryer/src/test/java/com/develop/airfryer/ExampleUnitTest.kt

@@ -0,0 +1,17 @@
+package com.develop.airfryer
+
+import org.junit.Test
+
+import org.junit.Assert.*
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+class ExampleUnitTest {
+    @Test
+    fun addition_isCorrect() {
+        assertEquals(4, 2 + 2)
+    }
+}

+ 1 - 0
BusinessCommon/build.gradle

@@ -16,5 +16,6 @@ android{
 
 dependencies {
     api project(path: ':libBase')
+    api project(path:':BusinessAirFryer')
     kapt  "androidx.room:room-compiler:2.4.2"
 }

+ 16 - 0
BusinessCommon/src/main/res/layout/home_function_top_bar_view.xml

@@ -4,6 +4,7 @@
     android:layout_height="@dimen/convert_88px">
 
 
+
     <RelativeLayout
         android:id="@+id/mode_layout"
         android:layout_width="@dimen/convert_314px"
@@ -17,6 +18,7 @@
             android:layout_centerVertical="true"
             android:layout_marginStart="@dimen/convert_40px" />
 
+
         <androidx.appcompat.widget.AppCompatTextView
             android:id="@+id/function_name"
             android:layout_width="wrap_content"
@@ -26,6 +28,10 @@
             android:layout_toEndOf="@id/iv_function"
             android:textColor="@color/color_fff"
             android:textSize="@dimen/convert_36px" />
+
+
+
+
     </RelativeLayout>
 
     <LinearLayout
@@ -84,6 +90,7 @@
 
     <androidx.appcompat.widget.AppCompatTextView
         android:id="@+id/tv_title"
+        android:visibility="gone"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_centerVertical="true"
@@ -91,4 +98,13 @@
         android:layout_toEndOf="@id/mode_layout"
         android:textColor="@color/color_1A1A1A"
         android:textSize="@dimen/convert_30px" />
+
+    <com.develop.airfryer.ui.DevModeView
+        android:layout_centerVertical="true"
+        android:layout_toStartOf="@id/user_layout"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginEnd="@dimen/convert_24px"
+        />
+
 </RelativeLayout>

+ 15 - 0
BusinessCommon/src/main/res/values/strings.xml

@@ -233,4 +233,19 @@ Nanfang plus client is an online information platform developed and operated by
     <string name="account_or_pwd_error">Incorrect account number or password</string>
     <string name="login_faild">Incorrect account number or password</string>
 
+
+    <!-- 空炸模式 -->
+    <string name="air_fryer">AIR FRYER</string>
+    <string name="meat">MEAT</string>
+    <string name="fish">FISH</string>
+    <string name="bakc">BAKC</string>
+    <string name="drumsticks">DRUMSTICKS</string>
+    <string name="chicken_wing">CHICKEN WING</string>
+    <string name="vegetable">VEGETABLE</string>
+    <string name="shrimp">SHRIMP</string>
+    <string name="pizza">PIZZA</string>
+    <string name="dehydrate">DEHYDRATE</string>
+    <string name="confirm_change_dev_mode">Confirm change dev mode ?</string>
+
+
 </resources>

+ 52 - 7
BusinessMain/src/main/java/com/develop/main/ui/ModesFragment.kt

@@ -1,5 +1,7 @@
 package com.develop.main.ui
 
+import android.content.Context
+import android.content.res.AssetManager
 import android.os.Bundle
 import android.view.LayoutInflater
 import android.view.ViewGroup
@@ -7,6 +9,7 @@ import android.widget.ImageView
 import androidx.appcompat.widget.AppCompatTextView
 import androidx.recyclerview.widget.LinearSnapHelper
 import androidx.recyclerview.widget.RecyclerView
+import com.develop.airfryer.viewmodel.WorkMode
 import com.develop.base.ext.load
 import com.develop.base.ext.navigateTo
 import com.develop.base.ext.resId2Dimension
@@ -24,8 +27,12 @@ import com.develop.main.databinding.FragmentModesBinding
 import com.develop.main.viewmodel.HomeViewModel
 import com.drake.brv.utils.linear
 import com.drake.brv.utils.setup
+import com.kuyuntech.cofarcooking.device.sdk.constant.core.DevModes
 import com.kuyuntech.cofarcooking.device.sdk.constant.core.DevStatus
 import com.kuyuntech.cofarcooking.device.sdk.util.core.CofarSDK
+import org.json.JSONObject
+import java.io.IOException
+import java.nio.charset.Charset
 import kotlin.math.abs
 
 /**
@@ -53,18 +60,56 @@ class ModesFragment : CommonBVMFragment<FragmentModesBinding, HomeViewModel>() {
         initView()
     }
 
+
+    fun loadJSONFromAsset(context: Context, fileName: String): JSONObject? {
+        return try {
+            val inputStream = context.assets.open(fileName)
+            val size = inputStream.available()
+            val buffer = ByteArray(size)
+            inputStream.read(buffer)
+            inputStream.close()
+
+            val jsonString = String(buffer, Charset.defaultCharset())
+            JSONObject(jsonString)
+        } catch (ex: IOException) {
+            ex.printStackTrace()
+            null
+        }
+    }
+
+
+
+
+
+
+
+
     private fun initView() {
+
+        val configJson = this.context?.let { loadJSONFromAsset(it, "config.json") }
+        val workModes = configJson?.getJSONArray( if (CofarSDK.devInfo().devMode == DevModes.SOUP)  "soupWorkModes" else "airFryerWorkModes");
+        var modes = ArrayList<WorkMode>();
+        val len = workModes?.length();
+        for (i in 0 until len!!) {
+            val element = workModes.getJSONObject(i)
+            // 处理数组元素,例如打印它们
+            var model = WorkMode(name = element.getString("name"), icon = element.getString("icon"), bg = element.getString("bg"), type = element.getString("type"))
+            modes.add(model)
+        }
+
         modeTypeList = DataFactory.modesTypeList
         binding.galleryRecycle.apply {
             linear(RecyclerView.HORIZONTAL)
             setup {
-                addType<ModelsModel>(R.layout.item_mode_card_view)
+                addType<WorkMode>(R.layout.item_mode_card_view)
                 onBind {
-                    val model = getModel<ModelsModel>()
-                    findView<ImageView>(R.id.iv_icon).load(model.resId)
-                    findView<AppCompatTextView>(R.id.tv_mode_name).updateText(
-                        model.modeName
-                    )
+                    val model = getModel<WorkMode>()
+                    findView<ImageView>(R.id.iv_icon).load(resources.getIdentifier(model.icon,"drawable","com.develop.foodcooking"))
+                    model.name?.let { it1 ->
+                        findView<AppCompatTextView>(R.id.tv_mode_name).updateText(
+                            resources.getString(resources.getIdentifier(it1,"string","com.develop.foodcooking"))
+                        )
+                    }
                 }
                 R.id.card_view.onClick {
 
@@ -85,7 +130,7 @@ class ModesFragment : CommonBVMFragment<FragmentModesBinding, HomeViewModel>() {
                         with(bundle)
                     }
                 }
-            }.models = DataFactory.genGalleryModesList(resources)
+            }.models = modes
             // 让item居中显示
             val snapHelper = LinearSnapHelper()
             // 绑定到 mRecyclerView

BIN
libThirdPart/libs/cofar-cooking-device-sdk-0.0.1-SNAPSHOT.jar


+ 1 - 0
settings.gradle

@@ -7,3 +7,4 @@ include ':BusinessAuth'
 include ':BusinessSetting'
 include ':BusinessMain'
 include ':BusinessStep'
+include ':BusinessAirFryer'