新增本机信息页面,菜品输入份数逻辑修改
This commit is contained in:
parent
f97d981ae8
commit
883d9c2e0c
|
|
@ -134,6 +134,10 @@
|
|||
android:name="com.bonus.canteen.activity.setting.ParamSettingsActivity"
|
||||
android:configChanges="keyboardHidden|keyboard"
|
||||
android:windowSoftInputMode="adjustPan|stateHidden" />
|
||||
<activity
|
||||
android:name="com.bonus.canteen.activity.setting.NativeInfoActivity"
|
||||
android:configChanges="keyboardHidden|keyboard"
|
||||
android:windowSoftInputMode="adjustPan|stateHidden" />
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -817,12 +817,12 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
if (originalTypeId != -1 && Objects.equals(mealItem.getTypeId(), originalTypeId)) {
|
||||
dishEntityList.add(new DishEntity(dishItem.getDishesId(), mealItem.getProductName(), dishItem.getPrefPrice(), dishItem.getSalePrice()
|
||||
, jsonObject.getRecipeType(), jsonObject.getRecipeId(), mealItem.getCustomId(), mealItem.getTypeId(), mealItem.getTypeName(),
|
||||
mealItem.getCalories(), mealItem.getProtein(), mealItem.getFat(), mealItem.getSodium(), mealItem.getCarbohydrate(),dishItem.getSupplyNum(), dishItem.getSurplusNum(), dishItem.getRestrictNum()));
|
||||
mealItem.getCalories(), mealItem.getProtein(), mealItem.getFat(), mealItem.getSodium(), mealItem.getCarbohydrate(), dishItem.getSupplyNum(), dishItem.getSurplusNum(), dishItem.getRestrictNum()));
|
||||
}
|
||||
if (originalTypeId == -1) {
|
||||
dishEntityList.add(new DishEntity(dishItem.getDishesId(), mealItem.getProductName(), dishItem.getPrefPrice(), dishItem.getSalePrice()
|
||||
, jsonObject.getRecipeType(), jsonObject.getRecipeId(), mealItem.getCustomId(), mealItem.getTypeId(), mealItem.getTypeName(),
|
||||
mealItem.getCalories(), mealItem.getProtein(), mealItem.getFat(), mealItem.getSodium(), mealItem.getCarbohydrate(),dishItem.getSupplyNum(), dishItem.getSurplusNum(), dishItem.getRestrictNum()));
|
||||
mealItem.getCalories(), mealItem.getProtein(), mealItem.getFat(), mealItem.getSodium(), mealItem.getCarbohydrate(), dishItem.getSupplyNum(), dishItem.getSurplusNum(), dishItem.getRestrictNum()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1010,6 +1010,8 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
openBalanceDialog();
|
||||
openPayWay("balance");
|
||||
});
|
||||
|
||||
|
||||
TextView reboot = view.findViewById(R.id.reboot);
|
||||
reboot.setOnClickListener(v3 -> DialogLoader.getInstance().showConfirmDialog(
|
||||
this,
|
||||
|
|
@ -1039,7 +1041,31 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
getString(R.string.lab_no),
|
||||
(dialog, which) -> dialog.dismiss()
|
||||
));
|
||||
|
||||
TextView exitApp = view.findViewById(R.id.exitApp);
|
||||
exitApp.setOnClickListener(v3 -> DialogLoader.getInstance().showConfirmDialog(
|
||||
this,
|
||||
"是否确认退出程序?",
|
||||
getString(R.string.lab_yes),
|
||||
(dialog, which) -> {
|
||||
// 获取应用的包名
|
||||
String packageName = getBaseContext().getPackageName();
|
||||
// 获取ActivityManager服务
|
||||
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
|
||||
// 终止所有后台进程
|
||||
if (activityManager != null) {
|
||||
activityManager.killBackgroundProcesses(packageName);
|
||||
}
|
||||
// 终止当前进程
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
System.exit(0);
|
||||
dialog.dismiss();
|
||||
},
|
||||
getString(R.string.lab_no),
|
||||
(dialog, which) -> dialog.dismiss()
|
||||
));
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -1110,7 +1136,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
});
|
||||
}
|
||||
|
||||
public void openSetLoginDialog(){
|
||||
public void openSetLoginDialog() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(OperationActivity.this);
|
||||
View view = LayoutInflater.from(OperationActivity.this).inflate(R.layout.dialog_login, null);
|
||||
@SuppressLint({"MissingInflatedId", "LocalSuppress"}) LinearLayout userLayout = view.findViewById(R.id.user_layout);
|
||||
|
|
@ -1128,7 +1154,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
XToastUtils.warning("请先输入密码!");
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.please_input_password));
|
||||
return;
|
||||
}else{
|
||||
} else {
|
||||
if (!etPasswordInput.getText().toString().equals("jyy2025")) {
|
||||
XToastUtils.warning("密码错误!");
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.password_error));
|
||||
|
|
@ -1300,7 +1326,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
binding.keyboardMain.findViewById(R.id.tv_ok).setOnClickListener(view -> {
|
||||
if (premiumAmount.toString().isEmpty() && !salesMenuEntityList.isEmpty()) {
|
||||
//弹出支付弹窗 可取消支付 或 记账
|
||||
if(isPayShow) return;
|
||||
if (isPayShow) return;
|
||||
openDialog();
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.please_pay));
|
||||
openPayWay("pay");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* Copyright (C) 2025 xuexiangjys(xuexiangjys@163.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.bonus.canteen.activity.setting;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.bonus.canteen.core.BaseActivity;
|
||||
import com.bonus.canteen.db.AppDatabase;
|
||||
import com.bonus.canteen.db.entity.base.DeviceInfo;
|
||||
import com.bonus.canteen.utils.ThreadPoolManager;
|
||||
import com.ccb.facedevice.sdk.utils.AppUtil;
|
||||
import com.ccb.facedevice.sdk.utils.DeviceUtil;
|
||||
import com.xuexiang.xui.XUI;
|
||||
|
||||
import org.easydarwin.easypusher.R;
|
||||
import org.easydarwin.easypusher.databinding.ActivityCanteenNativeInfoBinding;
|
||||
|
||||
public class NativeInfoActivity extends BaseActivity<ActivityCanteenNativeInfoBinding> {
|
||||
|
||||
private DeviceInfo deviceInfo = new DeviceInfo();
|
||||
|
||||
@Override
|
||||
protected ActivityCanteenNativeInfoBinding viewBindingInflate(LayoutInflater inflater) {
|
||||
return ActivityCanteenNativeInfoBinding.inflate(inflater);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
XUI.initTheme(this);
|
||||
setupImmersiveMode();
|
||||
intView();
|
||||
}
|
||||
|
||||
private void setupImmersiveMode() {
|
||||
View decorView = getWindow().getDecorView();
|
||||
int flags = View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
||||
}
|
||||
decorView.setSystemUiVisibility(flags);
|
||||
}
|
||||
|
||||
private void intView() {
|
||||
TextView tvTitle = findViewById(R.id.page_title);
|
||||
TextView ivBack = findViewById(R.id.page_back);
|
||||
tvTitle.setText("本机信息");
|
||||
ivBack.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(this, SettingsActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
});
|
||||
initData();
|
||||
}
|
||||
|
||||
|
||||
protected void initData() {
|
||||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
deviceInfo = AppDatabase.getDatabase(this).deviceInfoDao().getDeviceInfoOne();
|
||||
boolean isExist = deviceInfo == null;
|
||||
binding.tvSn.setText(AppUtil.getSn(this));
|
||||
binding.tvKey.setText(DeviceUtil.getDeviceKey());
|
||||
binding.tvDeviceCode.setText(isExist ? "" : deviceInfo.getDeviceName());
|
||||
binding.tvMerchantId.setText(isExist ? "" : deviceInfo.getTenantId());
|
||||
binding.tvCanteenId.setText(isExist ? "" : deviceInfo.getCanteenId());
|
||||
binding.tvCanteenName.setText(isExist ? "" : deviceInfo.getCanteenName());
|
||||
binding.tvStallId.setText(isExist ? "" : deviceInfo.getStallId());
|
||||
binding.tvStallName.setText(isExist ? "" : deviceInfo.getStallName());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
|
|
@ -87,6 +87,7 @@ public class SettingsActivity extends BaseActivity<AcvtivityCanteenSettingBindin
|
|||
lists.add("参数配置");
|
||||
lists.add("人员信息");
|
||||
lists.add("餐次信息");
|
||||
lists.add("本机信息");
|
||||
}
|
||||
|
||||
public void openNewPage(String name) {
|
||||
|
|
@ -107,6 +108,11 @@ public class SettingsActivity extends BaseActivity<AcvtivityCanteenSettingBindin
|
|||
startActivity(intent);
|
||||
finish();
|
||||
break;
|
||||
case "nativeInfo":
|
||||
intent = new Intent(this, NativeInfoActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ public class SalesMenuAdapter extends BaseAdapter {
|
|||
CookMeetTimesInfo cookMeetTimesInfo = AppDatabase.getDatabase(context).cookMeetTimesDao().getDefaultCookMeetTime();
|
||||
CookMeetDetailInfo cookMeetDetailInfo = AppDatabase.getDatabase(context).cookMeetDetailDao().getCookMeetDetailByIdAndTime(bean.getId(), cookMeetTimesInfo.getIntervalId());
|
||||
int restrictNum = cookMeetDetailInfo.getRestrictNum();
|
||||
if(restrictNum > 0 && restrictNum < Integer.parseInt(bean.getNum().add(BigDecimal.valueOf(1)) + "")){
|
||||
if(restrictNum > 0 && restrictNum < Integer.parseInt(input.toString())){
|
||||
((Activity) context).runOnUiThread(() -> {
|
||||
XToastUtils.warning("该菜品已达个人限购上限!");
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.purchase_limit));
|
||||
|
|
@ -195,12 +195,9 @@ public class SalesMenuAdapter extends BaseAdapter {
|
|||
}))
|
||||
.inputRange(1, 2)
|
||||
.positiveText("确定")
|
||||
.onPositive((dialog, which) -> {
|
||||
})
|
||||
.onPositive((dialog, which) -> {})
|
||||
.negativeText("取消")
|
||||
.onNegative((dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
})
|
||||
.onNegative((dialog, which) -> dialog.dismiss())
|
||||
.cancelable(false)
|
||||
.show();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,10 @@ public class SettingAdapter extends BaseAdapter {
|
|||
//打开餐次页面
|
||||
((SettingsActivity) context).openNewPage("mealTime");
|
||||
break;
|
||||
case "本机信息":
|
||||
//打开本机信息页面
|
||||
((SettingsActivity) context).openNewPage("nativeInfo");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,235 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#F4F4F4"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include layout="@layout/activity_title" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/config_margin_10dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="SN:"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_sn"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="7"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="#7E7E7E" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/config_margin_10dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="KEY:"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_key"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="7"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="#7E7E7E" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/config_margin_10dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="设备名称:"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_device_code"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="7"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="#7E7E7E" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/config_margin_10dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="商户ID:"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_merchant_id"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="7"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="#7E7E7E" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/config_margin_10dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="食堂ID:"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_canteen_id"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="7"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="#7E7E7E" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/config_margin_10dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="食堂名称:"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_canteen_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="7"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="#7E7E7E" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/config_margin_10dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="档口ID:"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_stall_id"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="7"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="#7E7E7E" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/config_margin_10dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="档口名称:"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_stall_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="7"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="#7E7E7E" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -43,15 +43,16 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_gravity="end">
|
||||
<ImageView
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="45dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_more"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="45dp"
|
||||
android:textColor="@color/white"
|
||||
android:text="@string/more"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:textFontWeight="800"
|
||||
android:textSize="30sp"/>
|
||||
|
|
@ -382,7 +383,8 @@
|
|||
android:id="@+id/menu_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="591dp"
|
||||
android:layout_weight="10">
|
||||
android:layout_weight="10"
|
||||
android:padding="5dp">
|
||||
|
||||
<include layout="@layout/canteen_ordering_menu" />
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -54,4 +54,16 @@
|
|||
android:text="重启APP"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="22sp" />
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.2dp"
|
||||
android:background="#8A8A8A" />
|
||||
<TextView
|
||||
android:id="@+id/exitApp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:gravity="center"
|
||||
android:text="退出程序"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="22sp" />
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -34,4 +34,5 @@ dependencies {
|
|||
implementation files('libs\\f3sdk.jar')
|
||||
implementation files('libs\\SDKLib.jar')
|
||||
implementation 'com.sunmi:printerlibrary:1.0.18'
|
||||
implementation 'com.blankj:utilcodex:1.30.5'
|
||||
}
|
||||
|
|
@ -2,10 +2,13 @@ package com.ccb.facedevice.sdk.utils;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
|
||||
import com.ccb.facedevice.sdk.FaceSdkInitCallback;
|
||||
import com.ccb.facedevice.sdk.mainboard.MainboardManage;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class DeviceUtil {
|
||||
private static Context mContext = null;
|
||||
|
||||
|
|
@ -34,7 +37,23 @@ public class DeviceUtil {
|
|||
return "";
|
||||
}
|
||||
}
|
||||
public static String getDeviceKey() {
|
||||
String str2 = FileIOUtil.readFile2String(keyFilePath());
|
||||
String str1 = str2;
|
||||
if(StringUtil.isEmpty(str2)) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(RandomUtil.getSixRadndomNum());
|
||||
stringBuilder.append("");
|
||||
str1 = stringBuilder.toString();
|
||||
FileIOUtil.writeFileFromString(keyFilePath(), str1);
|
||||
}
|
||||
return str1;
|
||||
}
|
||||
|
||||
|
||||
private static String keyFilePath() {
|
||||
return (new File(FileUtil.createOrExistsDir(Environment.getExternalStorageDirectory(), "key"), "key.txt")).getAbsolutePath();
|
||||
}
|
||||
public static String getDeviceModel() {
|
||||
try {
|
||||
return Build.MODEL;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright (C) 2025 xuexiangjys(xuexiangjys@163.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.ccb.facedevice.sdk.utils;
|
||||
|
||||
|
||||
import com.blankj.utilcode.util.FileIOUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class FileIOUtil {
|
||||
public static byte[] readFile2BytesByMap(File paramFile) {
|
||||
return FileIOUtils.readFile2BytesByMap(paramFile);
|
||||
}
|
||||
|
||||
public static String readFile2String(File paramFile) {
|
||||
return FileIOUtils.readFile2String(paramFile);
|
||||
}
|
||||
|
||||
public static String readFile2String(File paramFile, String paramString) {
|
||||
return FileIOUtils.readFile2String(paramFile, paramString);
|
||||
}
|
||||
|
||||
public static String readFile2String(String paramString) {
|
||||
return FileIOUtils.readFile2String(paramString);
|
||||
}
|
||||
|
||||
public static String readFile2String(String paramString1, String paramString2) {
|
||||
return FileIOUtils.readFile2String(paramString1, paramString2);
|
||||
}
|
||||
|
||||
public static boolean writeFileFromBytesByStream(File paramFile, byte[] paramArrayOfbyte) {
|
||||
return FileIOUtils.writeFileFromBytesByStream(paramFile, paramArrayOfbyte);
|
||||
}
|
||||
|
||||
public static boolean writeFileFromString(File paramFile, String paramString) {
|
||||
return FileIOUtils.writeFileFromString(paramFile, paramString);
|
||||
}
|
||||
|
||||
public static boolean writeFileFromString(String paramString1, String paramString2) {
|
||||
return FileIOUtils.writeFileFromString(paramString1, paramString2);
|
||||
}
|
||||
|
||||
public static boolean writeFileFromString2(String paramString1, String paramString2, boolean paramBoolean) {
|
||||
return FileIOUtils.writeFileFromString(paramString1, paramString2, paramBoolean);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package com.ccb.facedevice.sdk.utils;
|
||||
public class RandomUtil {
|
||||
public static int getSixRadndomNum() {
|
||||
return (int)((Math.random() * 9.0D + 1.0D) * 100000.0D);
|
||||
}
|
||||
}
|
||||
|
|
@ -46,6 +46,10 @@ public class StringUtil {
|
|||
return new String(chars);
|
||||
}
|
||||
|
||||
public static boolean isEmpty(String paramString) {
|
||||
return paramString == null || paramString.isEmpty() || paramString.equals("null");
|
||||
}
|
||||
|
||||
public static String double2String(Double d) {
|
||||
return d == null ? null : String.valueOf(d);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue