diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 8f68f94..3a8b4fa 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -11,7 +11,7 @@ android { applicationId = "com.shuwei.intelligent.shelves" minSdk = 25 //noinspection ExpiredTargetSdkVersion - targetSdk = 25 + targetSdk = 30 versionCode = 1 versionName = "1.0" @@ -50,19 +50,21 @@ dependencies { androidTestImplementation(libs.androidx.junit) androidTestImplementation(libs.androidx.espresso.core) implementation("androidx.activity:activity-ktx:1.8.0") + implementation("androidx.work:work-runtime-ktx:2.8.1") + implementation("io.github.cymchad:BaseRecyclerViewAdapterHelper4:4.1.2") implementation("com.squareup.okhttp3:okhttp:4.9.1") implementation("com.google.code.gson:gson:2.10.1") -// implementation("io.github.jeremyliao:live-event-bus-x:1.8.0") - - -// implementation("com.hoho:android-usb-serial:1.3.0") - implementation("io.github.jeadyx:kmp-serialport:1.0.0") + + // 基础依赖包,必须要依赖 + implementation("com.geyifeng.immersionbar:immersionbar:3.2.2") + // kotlin扩展(可选) + implementation("com.geyifeng.immersionbar:immersionbar-ktx:3.2.2") +// implementation("io.github.jeremyliao:live-event-bus-x:1.8.0") +// implementation("com.hoho:android-usb-serial:1.3.0") // implementation("io.github.jeadyx:jserialport:1.5") - - implementation("androidx.work:work-runtime-ktx:2.8.1") } \ No newline at end of file diff --git a/app/src/main/java/com/shuwei/intelligent/shelves/adapter/SearchAdapter.kt b/app/src/main/java/com/shuwei/intelligent/shelves/adapter/SearchAdapter.kt index aa5ff6a..47a3725 100644 --- a/app/src/main/java/com/shuwei/intelligent/shelves/adapter/SearchAdapter.kt +++ b/app/src/main/java/com/shuwei/intelligent/shelves/adapter/SearchAdapter.kt @@ -27,7 +27,7 @@ class SearchAdapter(list: MutableList) : override fun onBindViewHolder(holder: VH, position: Int, item: SearchModel?) { val binding = holder.binding binding.btnFoodName.run { - text = item!!.foodName + text = " ${item!!.foodName}" setTextColor( getColor(if (item.isClicked) R.color.shelf_name_blue else R.color.black999) ) diff --git a/app/src/main/java/com/shuwei/intelligent/shelves/base/BaseActivity.kt b/app/src/main/java/com/shuwei/intelligent/shelves/base/BaseActivity.kt index 5691937..9796a88 100644 --- a/app/src/main/java/com/shuwei/intelligent/shelves/base/BaseActivity.kt +++ b/app/src/main/java/com/shuwei/intelligent/shelves/base/BaseActivity.kt @@ -1,14 +1,19 @@ package com.shuwei.intelligent.shelves.base import android.content.Intent +import android.os.Build import android.os.Bundle import android.view.View +import android.view.WindowInsets +import android.view.WindowInsetsController import android.widget.TextView import androidx.activity.enableEdgeToEdge import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat +import com.gyf.immersionbar.BarHide +import com.gyf.immersionbar.ImmersionBar import com.shuwei.intelligent.shelves.R import com.shuwei.intelligent.shelves.databinding.ActivityBaseBinding @@ -33,7 +38,7 @@ open class BaseActivity : AppCompatActivity() { super.onCreate(savedInstanceState) binding = ActivityBaseBinding.inflate(layoutInflater) setContentView(binding.root) - statusBarDarkFont(enable = false) + statusBarDarkFont() launcher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> if (result.resultCode == RESULT_OK) { @@ -41,22 +46,29 @@ open class BaseActivity : AppCompatActivity() { } } -// window.setDecorFitsSystemWindows(false) // 启用 Edge-to-Edge -// window.insetsController?.apply { -// hide(WindowInsets.Type.statusBars()) // 隐藏状态栏 -// systemBarsBehavior = -// WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE // 滑动时临时显示 -// } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + window.setDecorFitsSystemWindows(false) + window.insetsController?.apply { + hide(WindowInsets.Type.statusBars()) // 隐藏状态栏 + systemBarsBehavior = + WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE // 滑动时临时显示 + } + } + } fun hideStatusBar() { - enableEdgeToEdge() +// enableEdgeToEdge() // val uiOptions = (View.SYSTEM_UI_FLAG_FULLSCREEN // 隐藏状态栏 // or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) // 隐藏导航栏(可选) - window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN +// window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN + + ImmersionBar.with(this) + .hideBar(BarHide.FLAG_HIDE_STATUS_BAR) + .init() } - fun statusBarDarkFont(enable: Boolean) { + fun statusBarDarkFont() { //window.decorView.systemUiVisibility = if (enable) View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR else 0 val color = ContextCompat.getColor(this, R.color.white) binding.tvLeftStatus.setTextColor(color) diff --git a/app/src/main/res/layout-sw360dp/activity_base.xml b/app/src/main/res/layout-sw360dp/activity_base.xml new file mode 100644 index 0000000..61f3bc4 --- /dev/null +++ b/app/src/main/res/layout-sw360dp/activity_base.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-sw360dp/activity_home.xml b/app/src/main/res/layout-sw360dp/activity_home.xml new file mode 100644 index 0000000..8ceae06 --- /dev/null +++ b/app/src/main/res/layout-sw360dp/activity_home.xml @@ -0,0 +1,20 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-sw360dp/activity_shelf.xml b/app/src/main/res/layout-sw360dp/activity_shelf.xml new file mode 100644 index 0000000..8124a52 --- /dev/null +++ b/app/src/main/res/layout-sw360dp/activity_shelf.xml @@ -0,0 +1,202 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-sw360dp/custom_toast.xml b/app/src/main/res/layout-sw360dp/custom_toast.xml new file mode 100644 index 0000000..cc72175 --- /dev/null +++ b/app/src/main/res/layout-sw360dp/custom_toast.xml @@ -0,0 +1,22 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-sw360dp/list_item_search.xml b/app/src/main/res/layout-sw360dp/list_item_search.xml new file mode 100644 index 0000000..d4278a7 --- /dev/null +++ b/app/src/main/res/layout-sw360dp/list_item_search.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout-sw360dp/list_item_shelf.xml b/app/src/main/res/layout-sw360dp/list_item_shelf.xml new file mode 100644 index 0000000..ff79b9a --- /dev/null +++ b/app/src/main/res/layout-sw360dp/list_item_shelf.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/list_item_search.xml b/app/src/main/res/layout/list_item_search.xml index 343c584..5c00083 100644 --- a/app/src/main/res/layout/list_item_search.xml +++ b/app/src/main/res/layout/list_item_search.xml @@ -36,6 +36,9 @@ android:maxLines="1" app:paddingStart="5dp" app:paddingEnd="5dp" + android:insetRight="0dp" + android:insetLeft="0dp" + android:paddingHorizontal="8dp" android:textColor="@color/black999" android:textSize="30sp" app:cornerRadius="12dp" diff --git a/app/src/main/res/layout/list_item_shelf.xml b/app/src/main/res/layout/list_item_shelf.xml index 1ff3323..3945ebb 100644 --- a/app/src/main/res/layout/list_item_shelf.xml +++ b/app/src/main/res/layout/list_item_shelf.xml @@ -13,7 +13,7 @@