Explorar o código

提交人:江天明
提交内容:优化

江天明 hai 11 meses
pai
achega
11e6b300f7

+ 2 - 1
BusinessAuth/src/main/java/com/develop/auth/ui/AgeSelectDialog.kt

@@ -37,7 +37,8 @@ class AgeSelectDialog(
 
     private fun createAgeListData(): List<String> {
         val list = mutableListOf<String>()
-        list.add(0, "18")
+        list.add(0, "0")
+        list.add(1, "18")
         for (index in 20..80) {
             list.add(index.toString())
         }

+ 28 - 32
BusinessAuth/src/main/java/com/develop/auth/ui/MemberProfileFragment.kt

@@ -38,8 +38,7 @@ class MemberProfileFragment : ViewBindingFragment<FragmentMemberProfileBinding>(
     }
 
     override fun createViewBinding(
-        inflater: LayoutInflater,
-        container: ViewGroup?
+        inflater: LayoutInflater, container: ViewGroup?
     ): FragmentMemberProfileBinding {
         return FragmentMemberProfileBinding.inflate(inflater, container, false)
     }
@@ -48,10 +47,22 @@ class MemberProfileFragment : ViewBindingFragment<FragmentMemberProfileBinding>(
         queryUserInfo()
         binding.tvChooseAge.setOnClickListener {
             AgeSelectDialog(hostActivity) { index, change ->
-                selectAge = if (index == 0) {
-                    18
-                } else {
-                    index + 20
+                selectAge = when (index) {
+                    0 -> {
+                        0
+                    }
+
+                    1 -> {
+                        18
+                    }
+
+                    2 -> {
+                        20
+                    }
+
+                    else -> {
+                        index + 18
+                    }
                 }
                 binding.tvChooseAge.text = selectAge.toString()
                 binding.tvChooseAge.text_color = R.color.register_edit_color
@@ -79,29 +90,23 @@ class MemberProfileFragment : ViewBindingFragment<FragmentMemberProfileBinding>(
         binding.tvSkipForNow.setOnClickListener {
             if (binding.tvSkipForNow.text == getString(R.string.sign_out)) {
                 EventBus.getDefault().post(FinishAtyEvent())
-                FoodDataProvider
-                    .getUserDatabase()
-                    .userInfoDao()
+                FoodDataProvider.getUserDatabase().userInfoDao()
                     .deleteUserInfoByUserId(CURRENT_USER_ID)
                 MmkvUtils.save(LOGIN_TAG, false)
                 MmkvUtils.clear(API_TOKEN)
                 MmkvUtils.save(CURRENT_USER_ID_TAG, 0)
                 FoodDataProvider.getUserDatabase().userInfoDao().deleteAllUserInfo()
-                parentFragmentManager
-                    .beginTransaction()
-                    .replace(R.id.fl_container, MemberLoginFragment())
-                    .commitAllowingStateLoss()
+                parentFragmentManager.beginTransaction()
+                    .replace(R.id.fl_container, MemberLoginFragment()).commitAllowingStateLoss()
             } else {
                 navigateTo(Screens.Main.ENTRANCE_CHOSEN)
             }
 
         }
         binding.tvDestroyAccount.setOnClickListener {
-            viewModel.cancelAccount().observe(viewLifecycleOwner){
+            viewModel.cancelAccount().observe(viewLifecycleOwner) {
                 EventBus.getDefault().post(FinishAtyEvent())
-                FoodDataProvider
-                    .getUserDatabase()
-                    .userInfoDao()
+                FoodDataProvider.getUserDatabase().userInfoDao()
                     .deleteUserInfoByUserId(CURRENT_USER_ID)
                 val saveToken: String? = null
                 MmkvUtils.save(API_TOKEN, saveToken)
@@ -110,10 +115,8 @@ class MemberProfileFragment : ViewBindingFragment<FragmentMemberProfileBinding>(
                 MmkvUtils.save(RECORD_ACCOUNT, "")
                 MmkvUtils.save(RECORD_PASSWORD, "")
                 FoodDataProvider.getUserDatabase().userInfoDao().deleteAllUserInfo()
-                parentFragmentManager
-                    .beginTransaction()
-                    .replace(R.id.fl_container, MemberLoginFragment())
-                    .commitAllowingStateLoss()
+                parentFragmentManager.beginTransaction()
+                    .replace(R.id.fl_container, MemberLoginFragment()).commitAllowingStateLoss()
             }
 
         }
@@ -152,10 +155,7 @@ class MemberProfileFragment : ViewBindingFragment<FragmentMemberProfileBinding>(
     }
 
     private fun saveProfile(
-        nickname: String?,
-        age: Int,
-        sex: Int,
-        portrait: Int
+        nickname: String?, age: Int, sex: Int, portrait: Int
     ) {
         if (nickname.isNullOrEmpty()) {
             showToast("Please fill in nickname")
@@ -185,11 +185,7 @@ class MemberProfileFragment : ViewBindingFragment<FragmentMemberProfileBinding>(
 
     private fun saveDatabase(user: User) {
         val userInfo = UserInfo(
-            user.id.toLong(),
-            user.nickname.toString(),
-            user.portrait,
-            user.gender,
-            user.age
+            user.id.toLong(), user.nickname.toString(), user.portrait, user.gender, user.age
         )
         MmkvUtils.save(CURRENT_USER_ID_TAG, user.id.toLong())
         FoodDataProvider.getUserDatabase().userInfoDao().updateUserInfo(userInfo)
@@ -198,8 +194,8 @@ class MemberProfileFragment : ViewBindingFragment<FragmentMemberProfileBinding>(
     private fun queryUserInfo() {
         FoodDataProvider.getUserDatabase().runInTransaction {
             val userId = MmkvUtils.getLong(CURRENT_USER_ID_TAG)
-            val userInfo = FoodDataProvider.getUserDatabase().userInfoDao()
-                .queryUserInfoByUserId(userId)
+            val userInfo =
+                FoodDataProvider.getUserDatabase().userInfoDao().queryUserInfoByUserId(userId)
             userInfoLiveData.postValue(userInfo)
         }
     }

+ 7 - 0
BusinessAuth/src/main/java/com/develop/auth/ui/MemberRegisterFragment.kt

@@ -7,6 +7,7 @@ import androidx.fragment.app.activityViewModels
 import com.develop.auth.R
 import com.develop.auth.databinding.FragmentMemberRegisterBinding
 import com.develop.food.base.ui.ViewBindingFragment
+import com.develop.food.base.utils.isEmail
 
 class MemberRegisterFragment: ViewBindingFragment<FragmentMemberRegisterBinding>() {
 
@@ -45,6 +46,12 @@ class MemberRegisterFragment: ViewBindingFragment<FragmentMemberRegisterBinding>
             showToast(getString(R.string.please_fill_in))
             return false
         }
+
+        if (!inputEmailId.isEmail()){
+            showToast("Please input email")
+            return false
+        }
+
         if (!TextUtils.equals(inputPsd, inputPsdConfirm)) {
             showToast(getString(R.string.password_is_not_the_same))
             return false

+ 1 - 0
BusinessAuth/src/main/res/layout/fragment_member_register.xml

@@ -31,6 +31,7 @@
             android:singleLine="true"
             android:textCursorDrawable="@drawable/shape_edittext_cursor"
             android:focusable="true"
+            android:inputType="textEmailAddress"
             android:focusableInTouchMode="true"
             android:textColor="@color/register_edit_color"
             android:textColorHint="@color/register_edit_color"

+ 10 - 0
BusinessMain/src/main/java/com/develop/main/init/ui/viewmodel/HomeViewModel.kt

@@ -153,6 +153,13 @@ class HomeViewModel : ViewModel() {
             allList.addAll(recipesList)
             allList.addAll(foodList)
             result.add(CategoryModel(recipeCount + foodCount, recipeCount, foodCount))
+            val favoriteRecipesList =
+                FoodDataProvider.getUserDatabase().userInfoDao().queryFavoriteRecipes(userId)
+                    .toMutableList()
+            val favoriteRecipesIds = mutableListOf<String>()
+            favoriteRecipesList.forEach {
+                favoriteRecipesIds.add(it.favoriteRecipesId)
+            }
             when (categoryType) {
                 CategoryType.All -> {
                     allList.forEach {
@@ -163,6 +170,7 @@ class HomeViewModel : ViewModel() {
                                 it.score?.toInt() ?: 0,
                                 DataFactory.getTime(it.makeHours ?: 0, it.makeMinutes ?: 0),
                                 it.difficultyLevel ?: "",
+                                isLike = favoriteRecipesIds.contains(it.number),
                                 foodId = it.number ?: "",
                                 useNum = it.useNum?.toInt() ?: 0
                             )
@@ -179,6 +187,7 @@ class HomeViewModel : ViewModel() {
                                 it.score?.toInt() ?: 0,
                                 DataFactory.getTime(it.makeHours ?: 0, it.makeMinutes ?: 0),
                                 it.difficultyLevel ?: "",
+                                isLike = favoriteRecipesIds.contains(it.number),
                                 foodId = it.number ?: "",
                                 useNum = it.useNum?.toInt() ?: 0
                             )
@@ -195,6 +204,7 @@ class HomeViewModel : ViewModel() {
                                 it.score?.toInt() ?: 0,
                                 DataFactory.getTime(it.makeHours ?: 0, it.makeMinutes ?: 0),
                                 it.difficultyLevel ?: "",
+                                isLike = favoriteRecipesIds.contains(it.number),
                                 foodId = it.number ?: "",
                                 useNum = it.useNum?.toInt() ?: 0
                             )

+ 32 - 15
BusinessSetting/src/main/java/com/develop/setting/init/ui/AboutActivity.kt

@@ -292,27 +292,44 @@ class AboutActivity : BaseActivity<ActivityAboutBinding>() {
                 weight = true;
                 weightAlignCount = 0
 
-                var dailog = CancelConfirmDialog()
-                dailog.title = getString(R.string.change_lang_tips)
-                dailog.showCancel = false;
+                val ctx = this
+                //2023年06月29日14:16:18 处理密码弹出
+                val pwdDialog = PwdDialog()
+                pwdDialog.title = getString(com.develop.base.R.string.enter_password)
+                pwdDialog.showDialog(supportFragmentManager, "pwdDialog")
+                pwdDialog.onDialogClickListener = object : PwdDialog.OnDialogClickListener {
 
-                dailog.onDialogClickListener = object : CancelConfirmDialog.OnDialogClickListener {
-                    override fun onConfirm() {
+                    override fun onConfirm(pwd: String) {
+                        if ("12345678".equals(pwd)) {
+                            var dailog = CancelConfirmDialog()
+                            dailog.title = getString(R.string.change_lang_tips)
+                            dailog.showCancel = false;
 
-                    }
+                            dailog.onDialogClickListener = object : CancelConfirmDialog.OnDialogClickListener {
+                                override fun onConfirm() {
 
-                    override fun onCancel() {
-                    }
+                                }
 
-                }
-                if (CofarSDK.devInfo().runningStatus == DevStatus.RUNNING) {
-                    dailog.showDialog(supportFragmentManager, "confirm")
-                    return@setOnClickListener
-                } else {
+                                override fun onCancel() {
+                                }
+
+                            }
+                            if (CofarSDK.devInfo().runningStatus == DevStatus.RUNNING) {
+                                dailog.showDialog(supportFragmentManager, "confirm")
+                            } else {
 //                    CofarSDK.register(this)
+                                //进入称重标定模式
+                                CofarSDK.startWeightAlign()
+                            }
 
-                    //进入称重标定模式
-                    CofarSDK.startWeightAlign()
+                        } else {
+                            GlobalToast.showToast(getString(com.develop.base.R.string.account_password_error))
+                        }
+                    }
+
+                    override fun onCancel() {
+
+                    }
                 }
 
 

+ 40 - 44
BusinessStep/src/main/java/com/develop/step/CookEvaluateActivity.kt

@@ -8,8 +8,6 @@ import com.alibaba.android.arouter.facade.annotation.Route
 import com.alibaba.android.arouter.launcher.ARouter
 import com.blankj.utilcode.util.KeyboardUtils
 import com.develop.food.base.event.RefreshStarDataEvent
-import com.develop.food.base.ext.runOnMainThread
-import com.develop.food.base.ext.safeGlobalScope
 import com.develop.food.base.repo.CURRENT_USER_ID
 import com.develop.food.base.repo.FoodDataProvider
 import com.develop.food.base.repo.entity.UserTag
@@ -18,8 +16,6 @@ import com.develop.food.base.ui.BaseActivity
 import com.develop.food.base.utils.GlobalToast
 import com.develop.food.base.utils.ThreadUtils
 import com.develop.step.databinding.ActivityCookEvaluateBinding
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.launch
 import org.greenrobot.eventbus.EventBus
 
 @Route(path = Screens.Cook.COOK_EVALUATE)
@@ -84,46 +80,46 @@ class CookEvaluateActivity : BaseActivity<ActivityCookEvaluateBinding>() {
         }
 
 
-        safeGlobalScope.launch(Dispatchers.IO) {
-            val userTag = FoodDataProvider.getUserDatabase().userInfoDao().queryUserTag(
-                CURRENT_USER_ID, recipeNumber ?: ""
-            )
-            val recipes = FoodDataProvider.getDatabase().recipeDao().queryRecipe(recipeNumber)
-            val count1 = userTag?.starCount ?: 0
-            val count2 = recipes?.score?.toInt() ?: 0
-            starCount = if (count1 != 0) {
-                count1
-            } else if (count2 != 0) {
-                count2
-            } else {
-                0
-            }
-            runOnMainThread {
-                selectStar(starCount)
-                when (starCount) {
-                    1 -> {
-                        binding.tvGood.text = getString(R.string.bad)
-                    }
-
-                    2 -> {
-                        binding.tvGood.text = getString(R.string.imperfect)
-                    }
-
-                    3 -> {
-                        binding.tvGood.text = getString(R.string.ordinary)
-                    }
-
-                    4 -> {
-                        binding.tvGood.text = getString(R.string.good)
-                    }
-
-                    5 -> {
-                        binding.tvGood.text = getString(R.string.perfect)
-                    }
-                }
-                binding.etContent.setText(userTag?.daily)
-            }
-        }
+//        safeGlobalScope.launch(Dispatchers.IO) {
+//            val userTag = FoodDataProvider.getUserDatabase().userInfoDao().queryUserTag(
+//                CURRENT_USER_ID, recipeNumber ?: ""
+//            )
+//            val recipes = FoodDataProvider.getDatabase().recipeDao().queryRecipe(recipeNumber)
+//            val count1 = userTag?.starCount ?: 0
+//            val count2 = recipes?.score?.toInt() ?: 0
+//            starCount = if (count1 != 0) {
+//                count1
+//            } else if (count2 != 0) {
+//                count2
+//            } else {
+//                0
+//            }
+//            runOnMainThread {
+//                selectStar(starCount)
+//                when (starCount) {
+//                    1 -> {
+//                        binding.tvGood.text = getString(R.string.bad)
+//                    }
+//
+//                    2 -> {
+//                        binding.tvGood.text = getString(R.string.imperfect)
+//                    }
+//
+//                    3 -> {
+//                        binding.tvGood.text = getString(R.string.ordinary)
+//                    }
+//
+//                    4 -> {
+//                        binding.tvGood.text = getString(R.string.good)
+//                    }
+//
+//                    5 -> {
+//                        binding.tvGood.text = getString(R.string.perfect)
+//                    }
+//                }
+//                binding.etContent.setText(userTag?.daily)
+//            }
+//        }
 
         binding.tvOk.setOnClickListener {
             KeyboardUtils.hideSoftInput(this)

+ 2 - 2
BusinessStep/src/main/java/com/develop/step/details/CookDetailActivity.kt

@@ -224,14 +224,14 @@ class CookDetailActivity : BaseActivity<ActivityCookDetailBinding>() {
             binding.viewIcon.src = R.drawable.ic_detail_cook_start
             binding.viewServing.setGone()
             binding.tvServingSize.setGone()
-            //binding.tvMoreDelete.setVisible()
+            binding.tvMoreDelete.setVisible()
         } else {
             binding.tvDownload.text = getString(R.string.download).uppercase(Locale.ROOT)
             binding.viewProgress.setButtonColor(Color.parseColor("#1296db"))
             binding.viewIcon.src = R.drawable.ic_detail_cook_download
             binding.viewServing.setGone()
             binding.tvServingSize.setGone()
-            //binding.tvMoreDelete.setGone()
+            binding.tvMoreDelete.setGone()
         }
         binding.viewHide.setOnClickListener {
             hideDetail = !hideDetail

+ 23 - 19
BusinessStep/src/main/java/com/develop/step/modes/ModesDetailActivity.kt

@@ -89,6 +89,10 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
         super.onCreate(savedInstanceState)
         hasShowScreenSaver = true
         modeType = intent.extras?.getString(MODE_TYPE, ModesType.FERMENT.name) ?: ""
+        if (modeType == ModesType.TURBO.name) {
+            binding.btnStart.setGone()
+            binding.btnConfirm.setGone()
+        }
         lastModeType = modeType
         if (isNightTheme()) {
             val param = binding.ivBack.layoutParams as LinearLayout.LayoutParams
@@ -464,27 +468,27 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
 
 
     @Subscribe
-    fun onTuyaEvent(event: TuyaEvent){
+    fun onTuyaEvent(event: TuyaEvent) {
 
-        if("start" == event.type){
-            if(DevStatus.PAUSE.toInt() == CofarSDK.devInfo().status){
+        if ("start" == event.type) {
+            if (DevStatus.PAUSE.toInt() == CofarSDK.devInfo().status) {
                 CofarSDK.confirm()
                 resumeClick()
-            }else{
+            } else {
                 startClick(false)
             }
         }
 
-        if("stop" == event.type){
+        if ("stop" == event.type) {
             stopClick(false)
         }
 
-        if("pause" == event.type){
+        if ("pause" == event.type) {
             pauseClick()
         }
 
 
-        if("change_time" == event.type){
+        if ("change_time" == event.type) {
 
             ThreadUtils.runOnMainThread {
                 //当前调节时间
@@ -557,24 +561,23 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
         }
 
 
-        if("change_temp" == event.type){
+        if ("change_temp" == event.type) {
 
-            ThreadUtils.runOnMainThread ({
+            ThreadUtils.runOnMainThread({
                 updateTempUI(
                     minTemp.toFloat(),
                     maxTemp.toFloat(),
                     if (currDevInfo.status == DevStatus.STOP.toInt()) currDevInfo.targetTemp.toInt()
                     else currDevInfo.temp.toInt(),
-                    if (currDevInfo.targetTempBuffer.toInt() != -1 ) currDevInfo.targetTempBuffer.toString() else currDevInfo.targetTemp.toString(),
+                    if (currDevInfo.targetTempBuffer.toInt() != -1) currDevInfo.targetTempBuffer.toString() else currDevInfo.targetTemp.toString(),
                     isTempChange,
                     focusUpdate = true
                 )
-            },500)
+            }, 500)
 
         }
 
 
-
     }
 
 
@@ -1021,6 +1024,7 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
                                 handleRotateTimeChange(false)
                             }
                         }
+
                         CookSettingType.DIRECTION_SETTING -> {
                             motorGearDirectionClick(DirectionView.Direction.LEFT)
 
@@ -1137,7 +1141,7 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
     override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
         if (keyCode == PRESS_DOWN_KEY_CODE) {
 
-            Log.d("======","down")
+            Log.d("======", "down")
 
             //当前是turbo模式下
             if (modeType == ModesType.TURBO.name) {
@@ -1182,7 +1186,7 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
      * 物理键离开事件
      */
     override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {
-        Log.d("======","up")
+        Log.d("======", "up")
         if (modeType == ModesType.TURBO.name && event.keyCode == PRESS_DOWN_KEY_CODE) {
             //当前是turbo模式下,并且是物理键按下
             turboUpEvent()
@@ -1455,7 +1459,7 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
     /**
      * 点击开始操作
      */
-    private fun startClick(showStopTips:Boolean=true) {
+    private fun startClick(showStopTips: Boolean = true) {
         if (mRunningInstId != mSettingInstId) {
             overrideModeDialog.showDialog(supportFragmentManager, "overrideModeDialog")
         } else {
@@ -1463,8 +1467,8 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
             CofarSDK.cancel()
             CofarSDK.devInfo().runningRecipeId = null
             var startConfig = HashMap<String, Any>()
-            startConfig.put("stopTips",showStopTips)
-            CofarSDK.startWithConfig(modeType,startConfig)
+            startConfig.put("stopTips", showStopTips)
+            CofarSDK.startWithConfig(modeType, startConfig)
             whereIndex = -1
             binding.clSetTime.stopAlphaAnim()
         }
@@ -1506,7 +1510,7 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
     /**
      * 点击停止操作
      */
-    private fun stopClick(tips:Boolean = true) {
+    private fun stopClick(tips: Boolean = true) {
         userChanging = false
         //结束
         CofarSDK.stop(tips)
@@ -1639,7 +1643,7 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
      * 点击电机方向事件
      */
     private fun motorGearDirectionClick(direction: DirectionView.Direction) {
-        if (isMotorDirectionGearChange){
+        if (isMotorDirectionGearChange) {
             userChanging = true
             binding.clCookDirection.updateChangeValue(
                 getDirectionStr(direction == DirectionView.Direction.LEFT)

+ 1 - 0
app/build.gradle

@@ -117,6 +117,7 @@ android {
     buildTypes {
 
         release {
+            debuggable true
             minifyEnabled false
             productFlavors.brand034.signingConfig signingConfigs.release
             productFlavors.brand000ATuya.signingConfig signingConfigs.release

+ 1 - 1
libBase/src/main/java/com/develop/food/base/utils/AppVerUtils.kt

@@ -129,7 +129,7 @@ object AppVerUtils {
             }
             val jsonContent = FileKit.readFileToStringB(jsonFile)
             val contentData = Gson().fromJson(jsonContent, RecipeDataConfig::class.java)
-          //  contentData.resetAllCodes()
+            contentData.resetAllCodes()
             FoodDataProvider.getDatabase().runInTransaction {
                 FoodDataProvider.getDatabase().recipeDao().apply {
 

+ 9 - 1
libBase/src/main/java/com/develop/food/base/utils/GlobalExt.kt

@@ -27,6 +27,8 @@ import java.net.URI
 import java.text.DecimalFormat
 import java.text.SimpleDateFormat
 import java.util.*
+import java.util.regex.Matcher
+import java.util.regex.Pattern
 
 
 /**
@@ -284,7 +286,13 @@ fun getSN(): String {
     return serial
 }
 
-
+fun String.isEmail(): Boolean {
+    val str =
+        "^([a-zA-Z0-9_\\-.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$"
+    val p: Pattern = Pattern.compile(str)
+    val m: Matcher = p.matcher(this)
+    return m.matches()
+}
 fun setNightTheme(isNight: Boolean) {
     MmkvUtils.save("nightTheme", isNight)
 }