Browse Source

提交配置界面

plate
fyf 1 year ago
parent
commit
bb9edb47f6
12 changed files with 513 additions and 24 deletions
  1. +2
    -2
      app/src/main/AndroidManifest.xml
  2. +3
    -4
      app/src/main/java/com/bpa/scalage/MainActivity.java
  3. +36
    -0
      app/src/main/java/com/bpa/scalage/app/Main.java
  4. +129
    -2
      app/src/main/java/com/bpa/scalage/pagefragment/ParameterSetFragment.java
  5. +34
    -0
      app/src/main/res/drawable/spinner_border.xml
  6. +8
    -6
      app/src/main/res/layout/controlview/layout/dialog_view.xml
  7. +6
    -3
      app/src/main/res/layout/controlview/layout/system_bottom.xml
  8. +259
    -6
      app/src/main/res/layout/page/layout/parameter_set.xml
  9. BIN
     
  10. +29
    -0
      app/src/main/res/values/array.xml
  11. +1
    -0
      app/src/main/res/values/dimen.xml
  12. +6
    -1
      app/src/main/res/values/styles.xml

+ 2
- 2
app/src/main/AndroidManifest.xml View File

@@ -17,14 +17,14 @@
android:theme="@style/FullscreenTheme">
<activity
android:name=".SystemSetActivity"
android:exported="false" />
android:exported="false"
android:windowSoftInputMode="adjustPan|stateHidden" />
<activity
android:name=".MenuSelectionActivity"
android:configChanges="orientation|screenSize|keyboard|keyboardHidden|navigation"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>


+ 3
- 4
app/src/main/java/com/bpa/scalage/MainActivity.java View File

@@ -367,7 +367,7 @@ public class MainActivity extends AppCompatActivity {
String text = new String(heavy);
int k= (int) (Double.parseDouble(text)*1000);
DataBus.getInstance().weight=k;
RefreshWeight(heavy);
RefreshWeight();
}
}
}
@@ -408,19 +408,18 @@ public class MainActivity extends AppCompatActivity {
//endregion

//region 界面操作函数
public void RefreshWeight(final byte[] heavy)
public void RefreshWeight()
{
MainActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (DataBus.getInstance().weight<150)
if (DataBus.getInstance().weight<50)
{
welcome.setVisibility(View.VISIBLE);
}else
{
welcome.setVisibility(View.GONE);
}

if(DataBus.getInstance().CartNo.equals(""))//记录初始重量
{
DataBus.getInstance().start_weight=DataBus.getInstance().weight;


+ 36
- 0
app/src/main/java/com/bpa/scalage/app/Main.java View File

@@ -57,6 +57,42 @@ public class Main {
ConfigName.getInstance().Plate_Com_Format =ConfigUtil.read(DataBus.getInstance().dishesCon,"Plate_Com_Format", ConfigName.getInstance().Plate_Com_Format);
}

/**
* 保存配置
*/
public void SavePZ()
{
//1.店铺配置
ConfigUtil.write(DataBus.getInstance().dishesCon,"Shop_Name", ConfigName.getInstance().Shop_Name);
ConfigUtil.write(DataBus.getInstance().dishesCon,"Shop_Id", ConfigName.getInstance().Shop_Id);
ConfigUtil.write(DataBus.getInstance().dishesCon,"Shop_DeviceId", ConfigName.getInstance().Shop_DeviceId);
//2.API接口
ConfigUtil.write(DataBus.getInstance().dishesCon,"GetFruitUrl", ConfigName.getInstance().GetFruitUrl);
ConfigUtil.write(DataBus.getInstance().dishesCon,"GetUserUrl", ConfigName.getInstance().GetUserUrl);
//3.菜品放置区端口名称
ConfigUtil.write(DataBus.getInstance().dishesCon,"Dishes_Com_Name", ConfigName.getInstance().Dishes_Com_Name);
ConfigUtil.write(DataBus.getInstance().dishesCon,"Dishes_Com_Port", ConfigName.getInstance().Dishes_Com_Port);
//4.餐盘感应区域端口名称
ConfigUtil.write(DataBus.getInstance().dishesCon,"Plate_Com_Name", ConfigName.getInstance().Plate_Com_Name);
ConfigUtil.write(DataBus.getInstance().dishesCon,"Plate_Com_Port", ConfigName.getInstance().Plate_Com_Port);
ConfigUtil.write(DataBus.getInstance().dishesCon,"Plate_Com_Format", ConfigName.getInstance().Plate_Com_Format);
}

/**
* 写配置
* @param name
* @param value
*/
public void write(String name,Object value)
{
if(value instanceof Integer)
{
ConfigUtil.write(DataBus.getInstance().dishesCon,name,(int)value);
}else
{
ConfigUtil.write(DataBus.getInstance().dishesCon,name,(String) value);
}
}
/**
* 获取菜品
*/


+ 129
- 2
app/src/main/java/com/bpa/scalage/pagefragment/ParameterSetFragment.java View File

@@ -1,20 +1,147 @@
package com.bpa.scalage.pagefragment;
import android.os.Bundle;
import android.os.ParcelUuid;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.bpa.scalage.R;
import com.bpa.scalage.app.Main;
import com.bpa.scalage.config.ConfigName;
import com.bpa.scalage.helper.T;

/**
* 其他页面
*/
public class ParameterSetFragment extends Fragment {

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.parameter_set, container, false);
return view;
MainView = inflater.inflate(R.layout.parameter_set, container, false);
Init();
return MainView;
}
//region 界面变量

//店铺信息
private EditText Shop_Name,Shop_Id,Shop_DeviceId,GetFruitUrl,GetUserUrl;
//菜品放置区
private Spinner Dishes_Com_Name,Dishes_Com_Port;
//菜品放置区
private Spinner Plate_Com_Name,Plate_Com_Port,Plate_Com_Format;
//当前界面
private View MainView;
//保存按钮
private TextView Save;
//endregion

//region 界面函数
/**
* 初始化
*/
public void Init()
{
Shop_Name=MainView.findViewById(R.id.tv_dp_name);
Shop_Id=MainView.findViewById(R.id.tv_dp_id);
Shop_DeviceId=MainView.findViewById(R.id.tv_dp_devid);
GetFruitUrl=MainView.findViewById(R.id.tv_cp_url);
GetUserUrl=MainView.findViewById(R.id.tv_yh_url);
Dishes_Com_Name=MainView.findViewById(R.id.tv_cp_com);
Dishes_Com_Port=MainView.findViewById(R.id.tv_cp_port);
Plate_Com_Name=MainView.findViewById(R.id.tv_cpgy_com);
Plate_Com_Port=MainView.findViewById(R.id.tv_cpgy_port);
Plate_Com_Format=MainView.findViewById(R.id.tv_cpgy_jy);
Save=MainView.findViewById(R.id.parameter_save);
SetShowText();
Save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SaveData();
}
});
}

/**
* 设置界面显示
*/
public void SetShowText()
{
Shop_Name.setText(ConfigName.getInstance().Shop_Name);
Shop_Id.setText(ConfigName.getInstance().Shop_Id);
Shop_DeviceId.setText(ConfigName.getInstance().Shop_DeviceId);
GetFruitUrl.setText(ConfigName.getInstance().GetFruitUrl);
GetUserUrl.setText(ConfigName.getInstance().GetUserUrl);
SelectText(Dishes_Com_Name,ConfigName.getInstance().Dishes_Com_Name);
SelectText(Dishes_Com_Port, Integer.toString(ConfigName.getInstance().Dishes_Com_Port));
SelectText(Plate_Com_Name,ConfigName.getInstance().Plate_Com_Name);
SelectText(Plate_Com_Port, Integer.toString(ConfigName.getInstance().Plate_Com_Port));
SelectText(Plate_Com_Format,ConfigName.getInstance().Plate_Com_Format);
}

/**
* 保存数据
*/
public void SaveData()
{
if (Shop_Name.getText().toString().isEmpty())
{
T.show(MainView.getContext(),"店铺名称不能为空!");
return;
}
if (Shop_Id.getText().toString().isEmpty())
{
T.show(MainView.getContext(),"店铺ID不能为空!");
return;
}
if (Shop_DeviceId.getText().toString().isEmpty())
{
T.show(MainView.getContext(),"设备ID不能为空!");
return;
}
if (GetFruitUrl.getText().toString().isEmpty())
{
T.show(MainView.getContext(),"获取菜品地址不能为空!");
return;
}
if (GetUserUrl.getText().toString().isEmpty())
{
T.show(MainView.getContext(),"用户同步接口不能为空!");
return;
}
ConfigName.getInstance().Shop_Name=Shop_Name.getText().toString();
ConfigName.getInstance().Shop_Id=Shop_Id.getText().toString();
ConfigName.getInstance().Shop_DeviceId=Shop_DeviceId.getText().toString();
ConfigName.getInstance().GetFruitUrl=GetFruitUrl.getText().toString();
ConfigName.getInstance().GetUserUrl=GetUserUrl.getText().toString();
Main.getInstance().SavePZ();
T.show(MainView.getContext(),"配置保存成功!");
}

/**
* 选中下拉框
* @param spinner
* @param value
*/
public void SelectText(Spinner spinner,String value)
{
SpinnerAdapter apsAdapter= spinner.getAdapter(); //得到SpinnerAdapter对象
int k= apsAdapter.getCount();
for(int i=0;i<k;i++){

if(value.equals(apsAdapter.getItem(i).toString())){
spinner.setSelection(i,true);// 默认选中项
break;
}
}
}

//endregion

}

+ 34
- 0
app/src/main/res/drawable/spinner_border.xml View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 第一组item:设置边框 -->
<item>
<shape>
<!-- 设置边框线宽度和颜色 -->
<stroke
android:width="0.5dp"
android:color="#000000" >
</stroke>
<!-- 设置圆角度数 -->
<corners android:radius="5dp" />
<!-- 设置背景颜色 -->
<solid android:color="#8A8C8A" />
<!-- padding:设置边距 -->
<!-- <padding-->
<!-- android:bottom="5dp"-->
<!-- android:left="5dp"-->
<!-- android:right="5dp"-->
<!-- android:top="5dp" >-->
<!-- </padding>-->
</shape>
</item>

<!-- 第二组item:设置spinner箭头图片(替换默认箭头) -->
<!-- <item>-->
<!-- &lt;!&ndash; bitmap.gravity:设置spinner的箭头放置位置 &ndash;&gt;-->
<!-- &lt;!&ndash; bitmap.src:设置替换原spinner的箭头的图片资源 &ndash;&gt;-->
<!-- <bitmap-->
<!-- android:gravity="end"-->
<!-- android:src="@mipmap/drop_down">-->
<!-- </bitmap>-->
<!-- </item>-->
</layer-list>

+ 8
- 6
app/src/main/res/layout/controlview/layout/dialog_view.xml View File

@@ -19,14 +19,14 @@
android:layout_centerInParent="true"
android:background="@drawable/yuanjiao_dialog_bg"
android:gravity="center_horizontal"
android:orientation="vertical" >
android:orientation="vertical">

<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:drawableLeft="@drawable/about"
android:drawablePadding="5dp"
android:gravity="center"
@@ -34,6 +34,7 @@
android:textColor="#000"
android:textSize="18sp"
android:textStyle="bold" />

<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
@@ -53,7 +54,7 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
@@ -73,7 +74,7 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
@@ -93,7 +94,7 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
@@ -120,7 +121,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal" >
android:orientation="horizontal">

<Button
android:id="@+id/positiveButton"
android:layout_width="100dp"


+ 6
- 3
app/src/main/res/layout/controlview/layout/system_bottom.xml View File

@@ -24,7 +24,8 @@
android:background="@drawable/pay_zfb_pressed"
android:gravity="center"
android:text="参数设置"
android:textColor="#000" />
android:textColor="#000"
android:textSize="@dimen/submit_text_size"/>
<TextView
android:id="@+id/tv_xtts"
android:layout_width="0dp"
@@ -33,7 +34,8 @@
android:background="@drawable/tab_z_normal"
android:gravity="center"
android:text="系统调试"
android:textColor="#000" />
android:textColor="#000"
android:textSize="@dimen/submit_text_size"/>
<TextView
android:id="@+id/tv_over"
android:layout_width="0dp"
@@ -42,7 +44,8 @@
android:background="@drawable/pay_wx_normal"
android:gravity="center"
android:text="其他设置"
android:textColor="#000" />
android:textColor="#000"
android:textSize="@dimen/submit_text_size" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

+ 259
- 6
app/src/main/res/layout/page/layout/parameter_set.xml View File

@@ -1,12 +1,265 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
<LinearLayout
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:textSize="30sp"
android:text="参数设置"/>
</LinearLayout>
android:layout_centerInParent="true"
android:gravity="center_horizontal"
android:orientation="vertical">
<!--店铺信息配置 -->
<LinearLayout
android:layout_marginTop="20dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="35dip"
android:layout_gravity="center"
android:background="@color/green_light"
android:gravity="center"
android:text="店铺信息配置"
android:textColor="@color/white"
android:textSize="@dimen/submit_text_size"
/>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#369FE5" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="店铺名称:"
android:textColor="#000" android:textSize="@dimen/text_size"/>
<EditText
android:id="@+id/tv_dp_name"
android:layout_width="440dp"
android:layout_height="40dp"
android:hint="请输入店铺名称"
android:singleLine="true"
android:textSize="@dimen/text_size" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="店铺ID号:"
android:textColor="#000" android:textSize="@dimen/text_size"/>
<EditText
android:id="@+id/tv_dp_id"
android:layout_width="440dp"
android:layout_height="40dp"
android:hint="请输入店铺ID号"
android:singleLine="true"
android:textSize="@dimen/text_size" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="店铺设备:"
android:textColor="#000" android:textSize="@dimen/text_size"/>
<EditText
android:id="@+id/tv_dp_devid"
android:layout_width="440dp"
android:layout_height="40dp"
android:hint="请输入店铺设备"
android:singleLine="true"
android:textSize="@dimen/text_size" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="菜品接口:"
android:textColor="#000" android:textSize="@dimen/text_size"/>
<EditText
android:id="@+id/tv_cp_url"
android:layout_width="440dp"
android:layout_height="40dp"
android:hint="请输入获取菜品接口"
android:singleLine="true"
android:textSize="@dimen/text_size" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="菜品接口:"
android:textColor="#000" android:textSize="@dimen/text_size"/>
<EditText
android:id="@+id/tv_yh_url"
android:layout_width="440dp"
android:layout_height="40dp"
android:hint="请输入获取用户信息"
android:singleLine="true"
android:textSize="@dimen/text_size" />
</LinearLayout>
<!--称重区域连接端口配置 -->
<LinearLayout
android:layout_marginTop="20dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="35dip"
android:layout_gravity="center"
android:background="@color/green_light"
android:gravity="center"
android:text="称重模块连接信息配置"
android:textColor="@color/white"
android:textSize="@dimen/submit_text_size"/>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#369FE5" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="连接名称:"
android:textColor="#000" android:textSize="@dimen/text_size"/>
<Spinner
android:id="@+id/tv_cp_com"
android:layout_width="440dp"
android:layout_height="wrap_content"
android:spinnerMode="dropdown"
android:entries="@array/com"
android:textSize="@dimen/text_size"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="连接端口:"
android:textColor="#000" android:textSize="@dimen/text_size"/>
<Spinner
android:id="@+id/tv_cp_port"
android:layout_width="440dp"
android:layout_height="wrap_content"
android:entries="@array/port"
android:spinnerMode="dropdown"
android:textSize="@dimen/text_size"/>
</LinearLayout>
<!--称重区域连接端口配置 -->
<LinearLayout
android:layout_marginTop="20dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="35dip"
android:layout_gravity="center"
android:background="@color/green_light"
android:gravity="center"
android:text="餐盘感应区连接信息配置"
android:textColor="@color/white"
android:textSize="@dimen/submit_text_size"/>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#369FE5" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="连接名称:"
android:textColor="#000" android:textSize="@dimen/text_size"/>
<Spinner
android:id="@+id/tv_cpgy_com"
android:layout_width="440dp"
android:layout_height="wrap_content"
android:spinnerMode="dropdown"
android:entries="@array/com"
android:textSize="@dimen/text_size"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="连接端口:"
android:textColor="#000" android:textSize="@dimen/text_size"/>
<Spinner
android:id="@+id/tv_cpgy_port"
android:layout_width="440dp"
android:layout_height="wrap_content"
android:entries="@array/port"
android:spinnerMode="dropdown"
android:textSize="@dimen/text_size"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="校验方式:"
android:textColor="#000" android:textSize="@dimen/text_size"/>
<Spinner
android:id="@+id/tv_cpgy_jy"
android:layout_width="440dp"
android:layout_height="wrap_content"
android:entries="@array/format"
android:spinnerMode="dropdown"
android:textSize="@dimen/text_size"/>
</LinearLayout>
<TextView
android:id="@+id/parameter_save"
android:layout_width="fill_parent"
android:layout_height="48dp"
android:layout_marginTop="20dp"
android:background="@drawable/selector_green_corners_button"
android:gravity="center"
android:text="保存"
android:textColor="@color/white"
android:textSize="@dimen/submit_text_size" />
</LinearLayout>
</RelativeLayout>

BIN
View File


+ 29
- 0
app/src/main/res/values/array.xml View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="com">
<item>/dev/ttyS3</item>
<item>/dev/ttyS0</item>
<item>/dev/ttyS1</item>
<item>/dev/ttyS2</item>
<item>/dev/ttyS4</item>
</string-array>
<string-array name="port">
<item>4800</item>
<item>9600</item>
<item>19200</item>
<item>38400</item>
<item>57600</item>
<item>115200</item>
<item>230400</item>
<item>460800</item>
<item>500000</item>
<item>576000</item>
<item>921600</item>
<item>1000000</item>
</string-array>
<string-array name="format">
<item>8N1</item>
<item>8E1</item>
<item>8O1</item>
</string-array>
</resources>

+ 1
- 0
app/src/main/res/values/dimen.xml View File

@@ -28,6 +28,7 @@
<dimen name="content_margin">8.0dip</dimen>
<dimen name="content_padding">13.0dip</dimen>
<dimen name="cell_height">48.0dip</dimen>
<dimen name="text_size">16.0sp</dimen>
<dimen name="submit_text_size">20.0sp</dimen>
<dimen name="third_icon_size">50.0dip</dimen>
<!-- 标题配置 -->


+ 6
- 1
app/src/main/res/values/styles.xml View File

@@ -52,5 +52,10 @@
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
</style>

<style name="ThemeSpinner">
<!-- Color when pressed -->
<item name="colorAccent">#ffd8584a</item>
<!-- Default color for the dropdown arrow and line -->
<item name="colorControlNormal">#ffd8584a</item>
</style>
</resources>

Loading…
Cancel
Save