增加开机启动,食堂切换功能

This commit is contained in:
2025-08-22 09:18:33 +08:00
parent a6cef6155b
commit cde2dccd04
8 changed files with 105 additions and 20 deletions
+10
View File
@@ -13,6 +13,8 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
@@ -79,6 +81,14 @@
<activity android:name="com.shuwei.dish.match.ui.DeviceConfigActivity" />
<activity android:name="com.shuwei.dish.match.ui.SubmitFoodActivity" />
<receiver
android:name=".utils.BootReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
</application>
+12 -12
View File
@@ -11,7 +11,7 @@
"allEdible" : 1,
"useWeight" : 0.0,
"popularName" : "食盐、精制盐",
"canteenId" : "1678234139391512577",
"canteenId" : "0",
"relateionType_dictText" : "食材原材料",
"sort" : 0,
"isDel" : 0,
@@ -28,7 +28,7 @@
"allEdible" : 1,
"useWeight" : 0.0,
"popularName" : "鸡精、家乐鸡精",
"canteenId" : "1678234139391512577",
"canteenId" : "0",
"relateionType_dictText" : "食材原材料",
"sort" : 1,
"isDel" : 0,
@@ -45,7 +45,7 @@
"allEdible" : 1,
"useWeight" : 0.0,
"popularName" : "双桥味精,莲花味精、味精",
"canteenId" : "1678234139391512577",
"canteenId" : "0",
"relateionType_dictText" : "食材原材料",
"sort" : 2,
"isDel" : 0,
@@ -62,7 +62,7 @@
"allEdible" : 1,
"useWeight" : 0.0,
"popularName" : "老抽",
"canteenId" : "1678234139391512577",
"canteenId" : "0",
"relateionType_dictText" : "食材原材料",
"sort" : 3,
"isDel" : 0,
@@ -79,7 +79,7 @@
"allEdible" : 1,
"useWeight" : 0.0,
"popularName" : "白醋,唯加白醋",
"canteenId" : "1678234139391512577",
"canteenId" : "0",
"relateionType_dictText" : "食材原材料",
"sort" : 4,
"isDel" : 0,
@@ -96,7 +96,7 @@
"allEdible" : 1,
"useWeight" : 0.0,
"popularName" : "胡椒粉",
"canteenId" : "1678234139391512577",
"canteenId" : "0",
"relateionType_dictText" : "食材原材料",
"sort" : 5,
"isDel" : 0,
@@ -113,7 +113,7 @@
"allEdible" : 1,
"useWeight" : 0.0,
"popularName" : "酱油",
"canteenId" : "1678234139391512577",
"canteenId" : "0",
"relateionType_dictText" : "食材原材料",
"sort" : 6,
"isDel" : 0,
@@ -130,7 +130,7 @@
"allEdible" : 1,
"useWeight" : 0.0,
"popularName" : "料酒",
"canteenId" : "1678234139391512577",
"canteenId" : "0",
"relateionType_dictText" : "食材原材料",
"sort" : 7,
"isDel" : 0,
@@ -147,7 +147,7 @@
"allEdible" : 1,
"useWeight" : 0.0,
"popularName" : "五香粉",
"canteenId" : "1678234139391512577",
"canteenId" : "0",
"relateionType_dictText" : "食材原材料",
"sort" : 8,
"isDel" : 0,
@@ -164,7 +164,7 @@
"allEdible" : 1,
"useWeight" : 0.0,
"popularName" : "豆瓣酱、郫县豆瓣酱",
"canteenId" : "1678234139391512577",
"canteenId" : "0",
"relateionType_dictText" : "食材原材料",
"sort" : 9,
"isDel" : 0,
@@ -181,7 +181,7 @@
"allEdible" : 1,
"useWeight" : 0.0,
"popularName" : "生抽",
"canteenId" : "1678234139391512577",
"canteenId" : "0",
"relateionType_dictText" : "食材原材料",
"sort" : 11,
"isDel" : 0,
@@ -198,7 +198,7 @@
"allEdible" : 1,
"useWeight" : 0.0,
"popularName" : "菜籽油,爱菊菜籽油",
"canteenId" : "1678234139391512577",
"canteenId" : "0",
"relateionType_dictText" : "食材原材料",
"sort" : 10,
"isDel" : 0,
@@ -2,9 +2,13 @@ package com.shuwei.dish.match.base
import android.app.Application
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.SharedPreferences
import com.shuwei.dish.match.R
import com.shuwei.dish.match.db.DatabaseProvider
import com.shuwei.dish.match.utils.BootReceiver
class BaseApp : Application() {
@@ -16,12 +20,15 @@ class BaseApp : Application() {
override fun onCreate() {
super.onCreate()
instance = this
val filter = IntentFilter(Intent.ACTION_BOOT_COMPLETED)
registerReceiver(BootReceiver(), filter)
}
companion object {
// const val canteenId = "1678234139391512577"
const val canteenId = "0"
var canteenId = "0"
@Volatile
private var sharedPref: SharedPreferences? = null
@@ -114,6 +114,7 @@ class BottomDialog(
}
}
binding.refreshLayout.setEnableRefresh(false)
binding.refreshLayout.setEnableLoadMore(false)
}
private fun searchGoods(v: View) {
@@ -6,8 +6,8 @@ object UrlConfig {
// const val DISH_DETAIL = "$BASE_URL/scales/goodsUseList?foodId={foodId}&foodWeight={foodWeight}"
// const val DISH_LIST = "$BASE_URL/scales/getRestInfoFoods?eaId=99&type=0&foodName"
const val BASE_URL = "http://192.168.1.207:9102"
// const val BASE_URL = "https://yyjk.shuziweidao.com/gateway"
// const val BASE_URL = "http://192.168.1.207:9102"
const val BASE_URL = "https://yyjk.shuziweidao.com/gateway"
// const val DISH_LIST = "$BASE_URL/scales/getRestInfoFoods?eaId=99&type=0&foodName"
const val DISH_DETAIL = "$BASE_URL/food/stFoodInfoMatching/queryById"
@@ -47,7 +47,14 @@ class HomeActivity : BaseActivity() {
binding = ActivityHomeBinding.inflate(layoutInflater)
setContentView(binding.root)
setHeaderBackground(isHomePage = true)
binding.radioGroup?.setOnCheckedChangeListener { group, checkedId ->
if (checkedId == R.id.radioSw) {
BaseApp.canteenId = "1678234139391512577"
} else {
BaseApp.canteenId = "0"
}
}
binding.radioGroup?.check(R.id.radioZk)
initRecyclerView()
getAppToken()
WeightUtil.connect { connect ->
@@ -0,0 +1,17 @@
package com.shuwei.dish.match.utils
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.shuwei.dish.match.ui.HomeActivity
class BootReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (Intent.ACTION_BOOT_COMPLETED == intent.action) {
// 启动服务或Activity
val launchIntent = Intent(context, HomeActivity::class.java)
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(launchIntent)
}
}
}
+47 -4
View File
@@ -4,16 +4,17 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:background="@color/bg_color"
android:gravity="center_horizontal"
android:orientation="vertical">
android:orientation="vertical"
tools:background="@color/bg_color"
tools:ignore="HardcodedText">
<TextView
android:id="@+id/tvTopText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/home_title"
android:layout_marginTop="300dp"
android:text="@string/home_title"
android:textColor="@color/home_title"
android:textSize="48sp"
android:textStyle="bold" />
@@ -33,6 +34,48 @@
android:layout_marginTop="30dp"
android:overScrollMode="never"
tools:itemCount="3"
tools:listitem="@layout/list_item_home_mode"/>
tools:listitem="@layout/list_item_home_mode" />
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginBottom="100dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="切换食堂:"
android:textColor="@color/black666"
android:textSize="36sp" />
<RadioButton
android:id="@+id/radioZk"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:checked="true"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:text="总库食堂"
android:textColor="@color/dish_type_font"
android:textSize="36sp" />
<RadioButton
android:id="@+id/radioSw"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:text="数味智餐食堂"
android:textColor="@color/dish_type_font"
android:textSize="36sp" />
</RadioGroup>
</LinearLayout>