Procházet zdrojové kódy

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

江天明 před 10 měsíci
rodič
revize
277f4aa0eb

+ 17 - 0
BusinessAuth/src/main/java/com/develop/auth/ui/MemberForgotFragment.kt

@@ -1,11 +1,15 @@
 package com.develop.auth.ui
 
+import android.text.InputFilter
 import android.view.LayoutInflater
 import android.view.ViewGroup
+import android.widget.EditText
 import androidx.fragment.app.activityViewModels
 import com.develop.auth.R
 import com.develop.auth.databinding.FragmentMemberForgotBinding
 import com.develop.food.base.ui.ViewBindingFragment
+import java.util.regex.Matcher
+import java.util.regex.Pattern
 
 class MemberForgotFragment: ViewBindingFragment<FragmentMemberForgotBinding>() {
 
@@ -67,6 +71,19 @@ class MemberForgotFragment: ViewBindingFragment<FragmentMemberForgotBinding>() {
                 }
             }
         }
+        setEditTextInhibitInputSpeChat(binding.etPassword)
+    }
+
+
+    private fun setEditTextInhibitInputSpeChat(editText: EditText) {
+        val filter =
+            InputFilter { source, start, end, dest, dstart, dend ->
+                val speChat = "[-©®™℅¡¿¥£°^¢€%&-+()~`|•√π÷׶∆`~!@#$%^=|':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?\"'_\\\\]"
+                val pattern: Pattern = Pattern.compile(speChat)
+                val matcher: Matcher = pattern.matcher(source.toString())
+                if (matcher.find()) "" else null
+            }
+        editText.filters = arrayOf(filter)
     }
 
 }

+ 17 - 0
BusinessAuth/src/main/java/com/develop/auth/ui/MemberLoginFragment.kt

@@ -1,8 +1,10 @@
 package com.develop.auth.ui
 
+import android.text.InputFilter
 import android.util.Log
 import android.view.LayoutInflater
 import android.view.ViewGroup
+import android.widget.EditText
 import androidx.fragment.app.activityViewModels
 import com.blankj.utilcode.util.KeyboardUtils
 import com.develop.auth.R
@@ -14,6 +16,9 @@ import com.develop.food.base.router.navigateTo
 import com.develop.food.base.ui.ViewBindingFragment
 import com.develop.food.base.utils.MmkvUtils
 import com.develop.food.base.utils.dimenRes
+import java.util.regex.Matcher
+import java.util.regex.Pattern
+
 
 class MemberLoginFragment : ViewBindingFragment<FragmentMemberLoginBinding>(), KeyboardUtils.OnSoftInputChangedListener {
 
@@ -70,8 +75,20 @@ class MemberLoginFragment : ViewBindingFragment<FragmentMemberLoginBinding>(), K
             binding.etPassword.setText(savePassword)
         }
        // KeyboardUtils.registerSoftInputChangedListener(requireActivity(), this)
+        setEditTextInhibitInputSpeChat(binding.etPassword)
     }
 
+
+    private fun setEditTextInhibitInputSpeChat(editText: EditText) {
+        val filter =
+            InputFilter { source, start, end, dest, dstart, dend ->
+                val speChat = "[-©®™℅¡¿¥£°^¢€%&-+()~`|•√π÷׶∆`~!@#$%^=|':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?\"'_\\\\]"
+                val pattern: Pattern = Pattern.compile(speChat)
+                val matcher: Matcher = pattern.matcher(source.toString())
+                if (matcher.find()) "" else null
+            }
+        editText.filters = arrayOf(filter)
+    }
     override fun onSoftInputChanged(height: Int) {
         val flRoot = (activity as? MemberAuthActivity)?.getRootView() ?: return
         if (height == 0) {

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

@@ -1,13 +1,17 @@
 package com.develop.auth.ui
 
+import android.text.InputFilter
 import android.text.TextUtils
 import android.view.LayoutInflater
 import android.view.ViewGroup
+import android.widget.EditText
 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
+import java.util.regex.Matcher
+import java.util.regex.Pattern
 
 class MemberRegisterFragment: ViewBindingFragment<FragmentMemberRegisterBinding>() {
 
@@ -36,6 +40,20 @@ class MemberRegisterFragment: ViewBindingFragment<FragmentMemberRegisterBinding>
                 .replace(R.id.fl_container, MemberLoginFragment())
                 .commitAllowingStateLoss()
         }
+        setEditTextInhibitInputSpeChat(binding.etPassword)
+        setEditTextInhibitInputSpeChat(binding.etPasswordAgain)
+    }
+
+
+    private fun setEditTextInhibitInputSpeChat(editText: EditText) {
+        val filter =
+            InputFilter { source, start, end, dest, dstart, dend ->
+                val speChat = "[-©®™℅¡¿¥£°^¢€%&-+()~`|•√π÷׶∆`~!@#$%^=|':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?\"'_\\\\]"
+                val pattern: Pattern = Pattern.compile(speChat)
+                val matcher: Matcher = pattern.matcher(source.toString())
+                if (matcher.find()) "" else null
+            }
+        editText.filters = arrayOf(filter)
     }
 
     private fun checkInputs(): Boolean {

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

@@ -94,7 +94,6 @@
             android:textColorHint="@color/register_edit_color"
             android:textSize="@dimen/convert_45px"
             android:singleLine="true"
-            android:digits="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
             android:background="@drawable/bg_edit_input"
             android:layout_marginTop="@dimen/convert_45px"
             android:layout_gravity="center_horizontal"

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

@@ -52,7 +52,6 @@
             android:textColor="@color/register_edit_color"
             android:textColorHint="@color/register_edit_color"
             android:singleLine="true"
-            android:digits="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
             android:inputType="textPassword"
             android:background="@drawable/bg_edit_input"
             android:layout_marginTop="@dimen/convert_47px"
@@ -72,7 +71,6 @@
             android:hint="@string/enter_password_again"
             android:textSize="@dimen/convert_45px"
             android:singleLine="true"
-            android:digits="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
             android:background="@drawable/bg_edit_input"
             android:layout_marginTop="@dimen/convert_47px"
             android:layout_gravity="center_horizontal"

+ 27 - 17
BusinessSetting/src/main/java/com/develop/setting/init/ui/RestoreActivity.kt

@@ -6,9 +6,11 @@ import android.os.PowerManager
 import android.view.LayoutInflater
 import com.alibaba.android.arouter.facade.annotation.Route
 import com.develop.food.base.manager.wifi.WifiHelp
+import com.develop.food.base.repo.CURRENT_USER_ID
 import com.develop.food.base.repo.FoodDataProvider
 import com.develop.food.base.router.Screens
 import com.develop.food.base.ui.BaseActivity
+import com.develop.food.base.utils.ThreadUtils
 import com.develop.food.base.widgets.CancelConfirmDialog
 import com.develop.setting.R
 import com.develop.setting.databinding.ActivityRestoreBinding
@@ -34,25 +36,33 @@ class RestoreActivity : BaseActivity<ActivityRestoreBinding>() {
 
             dailog.onDialogClickListener = object:CancelConfirmDialog.OnDialogClickListener {
                 override fun onConfirm() {
-                    FoodDataProvider.deleteAll()
-                    WifiHelp.Build(this@RestoreActivity).build().removeAllWifi()
-                    var cacheDirectory = getCacheDir();
-                    var applicationDirectory =  File(cacheDirectory.getParent());
-                    if (applicationDirectory.exists()) {
-
-                        var files = applicationDirectory.listFiles();
-
-                        for (file in files) {
-
-                            if (!file.name.equals("lib")) {
-                                com.blankj.utilcode.util.FileUtils.delete(file)
+                    ThreadUtils.runOnWorkThread({
+                        FoodDataProvider.deleteAll()
+                        val cacheDirectory = cacheDir
+                        WifiHelp.Build(this@RestoreActivity).build().removeAllWifi()
+                        FoodDataProvider.getUserDatabase().userInfoDao().apply {
+                            removeAllOnlineRecipe(CURRENT_USER_ID)
+                            removeAllFavouriteRecipe(CURRENT_USER_ID)
+                            removeAllHistoryRecipe(CURRENT_USER_ID)
+                        }
+                        FoodDataProvider.getUserDatabase().devConfigDao().apply {
+                            removeAllDevVersion()
+                        }
+                        val applicationDirectory = cacheDirectory.parent?.let { File(it) }
+                        if (applicationDirectory?.exists() == true) {
+
+                            val files = applicationDirectory.listFiles() ?: emptyArray()
+                            for (file in files) {
+                                if (!file.name.equals("lib")) {
+                                    com.blankj.utilcode.util.FileUtils.delete(file)
+                                }
                             }
-
                         }
-
-                    }
-                    val pm = getSystemService(Context.POWER_SERVICE) as PowerManager
-                    pm.reboot("")
+                        runOnUiThread {
+                            val pm = getSystemService(Context.POWER_SERVICE) as PowerManager
+                            pm.reboot("")
+                        }
+                    })
                 }
 
                 override fun onCancel() {

+ 4 - 4
libBase/src/main/java/com/develop/food/base/repo/db/dao/DevConfigDao.kt

@@ -1,10 +1,6 @@
 package com.develop.food.base.repo.db.dao
 
-import androidx.lifecycle.LiveData
 import androidx.room.*
-import com.develop.food.base.repo.entity.DevAccessory
-import com.develop.food.base.repo.entity.DevHotTag
-import com.develop.food.base.repo.entity.DevPortrait
 import com.develop.food.base.repo.entity.DevVersion
 
 @Dao
@@ -17,4 +13,8 @@ interface DevConfigDao {
     @Insert(onConflict = OnConflictStrategy.REPLACE)
     fun saveDevVersion(devVersion: DevVersion)
 
+
+    @Query("Delete from cc_dev_version")
+    fun removeAllDevVersion()
+
 }

+ 12 - 0
libBase/src/main/java/com/develop/food/base/repo/db/dao/UserInfoDao.kt

@@ -72,4 +72,16 @@ interface UserInfoDao {
     @Query("delete  from user_history_recipes where userId =:userId")
     fun deleteAllHistoryRecipes(userId: Long)
 
+
+    @Query("Delete from user_online_recipes where userId = :userId")
+    fun removeAllOnlineRecipe(userId: Long)
+
+
+    @Query("Delete from user_history_recipes where userId = :userId")
+    fun removeAllHistoryRecipe(userId: Long)
+
+
+    @Query("Delete from user_favorite_recipes where userId = :userId")
+    fun removeAllFavouriteRecipe(userId: Long)
+
 }