0704提交手机号加解密等

This commit is contained in:
jjLv 2025-07-04 10:36:25 +08:00
parent 4e863e8384
commit f55583ce19
11 changed files with 294 additions and 14 deletions

View File

@ -49,7 +49,6 @@ import com.bonus.canteen.receiver.ShutdownReceiver;
import com.bonus.canteen.utils.SimplePopupWindow;
import com.bonus.canteen.utils.ThreadPoolManager;
import com.ccb.facedevice.sdk.utils.NetworkUtils;
import com.google.android.material.tabs.TabLayout;
import com.xuexiang.xui.widget.dialog.DialogLoader;
import com.xuexiang.xutil.common.ClickUtils;
@ -61,7 +60,6 @@ import java.util.Date;
import java.util.Locale;
public class MainActivity extends BaseActivity<ActivityMainBinding> implements ClickUtils.OnClick2ExitListener{
TabLayout mTabLayout;
TextView titleView;
private TextView timeShow;
private static final String COLOR_SELECT = "#409eff";

View File

@ -0,0 +1,138 @@
package com.bonus.canteen.activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.text.InputType;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import com.bonus.canteen.core.BaseActivity;
import com.bonus.canteen.db.AppDatabase;
import com.bonus.canteen.db.entity.base.LoginInfo;
import com.bonus.canteen.utils.OkHttpService;
import com.bonus.canteen.utils.ThreadPoolManager;
import com.xuexiang.xui.XUI;
import com.xuexiang.xui.utils.XToastUtils;
import org.easydarwin.easypusher.R;
import org.easydarwin.easypusher.databinding.ActivityOfflineLoginBinding;
public class OffLineLoginActivity extends BaseActivity<ActivityOfflineLoginBinding> {
public final OkHttpService service = new OkHttpService();
private Boolean isChecked = false;
@Override
protected ActivityOfflineLoginBinding viewBindingInflate(LayoutInflater inflater) {
return ActivityOfflineLoginBinding.inflate(inflater);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
XUI.initTheme(this);
super.onCreate(savedInstanceState);
setupImmersiveMode();
initView();
}
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);
}
public void initView() {
initListener();
}
public void initListener() {
findViewById(R.id.btn_login).setOnClickListener(v -> {
String password = binding.etPassword.getText().toString();
boolean tf = checkParameters(password);
if (!tf) {
return;
}
login(password);
});
// 查看密码
binding.checkPassword.setOnClickListener(view -> {
if (isChecked) {
isChecked = false;
binding.checkPassword.setImageResource(R.drawable.ic_eye_close);
binding.etPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
} else {
isChecked = true;
binding.checkPassword.setImageResource(R.drawable.ic_eye_open);
binding.etPassword.setInputType(InputType.TYPE_CLASS_TEXT);
}
});
}
private void login(String password) {
if (!"2025".equals(password)){
XToastUtils.error("登录密码错误,请重新输入");
return;
}
XToastUtils.success("登录成功");
ThreadPoolManager.getExecutor().execute(()->{
AppDatabase.getDatabase(this).loginInfoDao().deleteAll();
LoginInfo loginInfo = new LoginInfo();
loginInfo.setUserName("离线操作员");
loginInfo.setUserPwd(password);
loginInfo.setUserId("-1"); // 假设用户ID为1实际应用中应从服务器获取
loginInfo.setPhone("-1"); // 假设手机号为1234567890实际应用中应从服务器获取
loginInfo.setToken("-1"); // 假设令牌为sample_token实际应用中应从服务器获取
AppDatabase.getDatabase(this).loginInfoDao().insert(loginInfo);
startActivity(new Intent(this, MainActivity.class));
finish();
});
}
private boolean checkParameters(String password) {
if (password.isEmpty()) {
XToastUtils.warning("登录密码不能为空");
return false;
}
return true;
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
View v = getCurrentFocus();
if (v instanceof EditText) {
int[] location = new int[2];
v.getLocationOnScreen(location);
float x = ev.getRawX() + v.getLeft() - location[0];
float y = ev.getRawY() + v.getTop() - location[1];
if (x < v.getLeft() || x > v.getRight() || y < v.getTop() || y > v.getBottom()) {
hideKeyboard(v);
}
}
}
return super.dispatchTouchEvent(ev);
}
private void hideKeyboard(View view) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
}

View File

@ -22,7 +22,6 @@ import android.view.KeyEvent;
import com.bonus.canteen.db.AppDatabase;
import com.bonus.canteen.db.entity.base.ParamSettingInfo;
import com.bonus.canteen.upgrade.UpdateDown;
import com.bonus.canteen.utils.TokenUtils;
import com.bonus.canteen.utils.WorkConfig;
import com.ccb.facedevice.sdk.utils.NetworkUtils;
import com.xuexiang.xui.utils.KeyboardUtils;
@ -84,10 +83,10 @@ public class SplashActivity extends BaseSplashActivity implements CancelAdapt {
}
}
private void navigateToNextPage() {
if (TokenUtils.hasToken()) {
if (NetworkUtils.isNetworkConnected(this)) {
ActivityUtils.startActivity(LoginActivity.class);
} else {
ActivityUtils.startActivity(LoginActivity.class);
ActivityUtils.startActivity(OffLineLoginActivity.class);
}
finish();
}

View File

@ -119,6 +119,10 @@ public class SalesMenuAdapter extends BaseAdapter {
});
holder.tvAdd.setOnClickListener(view -> {
//查询限购
if (bean.getName().equals("按键金额")){
XToastUtils.warning("该菜品不支持加购操作!");
return;
}
ThreadPoolManager.getExecutor().execute(() -> {
CookMealTimesInfo cookMealTimesInfo = AppDatabase.getDatabase(context).cookMeetTimesDao().getDefaultCookMeetTime();
CookDetailInfo cookDetailInfo = AppDatabase.getDatabase(context).cookMeetDetailDao().getCookMeetDetailByIdAndTime(bean.getId(), cookMealTimesInfo.getIntervalId());
@ -150,6 +154,10 @@ public class SalesMenuAdapter extends BaseAdapter {
});
holder.tvFoodNum.setOnClickListener(view -> {
//弹窗
if (bean.getName().equals("按键金额")){
XToastUtils.warning("该菜品不支持加购操作!");
return;
}
DialogShow(list.get(i));
});
return convertView;

View File

@ -149,7 +149,7 @@ public class OfflineCheckoutFragment extends BaseFragment<ActivityOfflineCheckou
binding.btnOkPay.setOnClickListener(view -> {
String moneyStr = binding.salesTotalMoney.getText().toString();
String money = moneyStr.replace("总金额:", "").replace("", "");
if (premiumAmount.toString().isEmpty() && salesMenuEntityList.isEmpty()) {
if (salesMenuEntityList.isEmpty()) {
XToastUtils.warning("请先点餐!");
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.please_choose_food));
return;

View File

@ -153,7 +153,7 @@ public class SupermarketCashierFragment extends BaseFragment<ActivityOfflineChec
binding.btnOkPay.setOnClickListener(view -> {
String moneyStr = binding.salesTotalMoney.getText().toString();
String money = moneyStr.replace("总金额:", "").replace("", "");
if (premiumAmount.toString().isEmpty() && salesMenuEntityList.isEmpty()) {
if (salesMenuEntityList.isEmpty()) {
XToastUtils.warning("请先点餐!");
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.please_choose_food));
return;

View File

@ -40,6 +40,7 @@ import com.bonus.canteen.db.entity.base.UserInfo;
import com.bonus.canteen.service.data.entity.ResponseVo;
import com.bonus.canteen.utils.DateTimeHelper;
import com.bonus.canteen.utils.OkHttpService;
import com.bonus.canteen.utils.SM4EncryptUtils;
import com.bonus.canteen.utils.UrlConfig;
import com.bonus.canteen.utils.WorkConfig;
import com.ccb.facedevice.sdk.utils.AppUtil;
@ -72,7 +73,7 @@ public class UpdateBasicData {
private static final String MEAL_ERROR = "获取餐次信息失败!";
private static final String DEVICE_ERROR = "获取设备信息失败!";
private static final String PARAM_SETTING_ERROR = "获取参数设置信息失败!";
private static final int PHONE_LENGTH = 11;
public UpdateBasicData(Context context) {
this.context = context;
}
@ -125,10 +126,13 @@ public class UpdateBasicData {
JSONObject jsonObject = JSONObject.parseObject(result);
if (jsonObject.containsKey("data")) {
Log.d(TAG, "人员信息更新完成更新list:" + jsonObject.getString("data"));
List<UserInfo> list = new Gson().fromJson(jsonObject.getString("data"), new TypeToken<List<UserInfo>>() {
}.getType());
List<UserInfo> list = new Gson().fromJson(jsonObject.getString("data"), new TypeToken<List<UserInfo>>() {
}.getType());
Log.d(TAG, "人员信息更新完成更新list:" + list.toString());
for (UserInfo userInfo : list) {
if (userInfo.getPhone().length() > PHONE_LENGTH) {
userInfo.setPhone(SM4EncryptUtils.sm4Decrypt(userInfo.getPhone()));
}
AppDatabase.getDatabase(context).userDao().insert(userInfo);
}
DeviceInfoDao deviceInfoDao = AppDatabase.getDatabase(context).deviceInfoDao();
@ -445,7 +449,7 @@ public class UpdateBasicData {
.post(body).build();
try {
String result = service.httpPost(url, body, context, request);
Log.i("getParamSettingInfo result", result);
Log.i("getParamSettingInfo result", result);
JSONObject firstJson = JSONObject.parseObject(result);
if (firstJson.containsKey("data")) {
String data = firstJson.getString("data");

View File

@ -27,8 +27,8 @@ public class WorkConfig {
//本地
// protected static String baseUrl = "http://192.168.0.34:48380/smart-canteen";
// protected static String prefixesUrl = "http://192.168.0.34:48380";
protected static String baseUrl = "http://192.168.0.34:48380/smart-canteen";
protected static String prefixesUrl = "http://192.168.0.34:48380";
protected static String baseUrl = "http://192.168.0.244:48380/smart-canteen";
protected static String prefixesUrl = "http://192.168.0.244:48380";
protected static String fileUrl = "http://192.168.0.244:48380/lnyst/";
protected static String updateUrl = "https://www.baidu.com";
protected static String serverUri = "tcp://192.168.0.244:1883";

View File

@ -13,7 +13,7 @@
android:orientation="horizontal">
<LinearLayout
android:id="@+id/linear_container"
android:layout_width="80dp"
android:layout_width="100dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/xui_list_item_bg_with_border_top">

View File

@ -0,0 +1,132 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2019 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.
~
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ic_login_bg"
android:orientation="vertical">
<LinearLayout
android:layout_width="500dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="50dp"
android:background="@drawable/btn_border_green_bg"
android:orientation="vertical">
<ImageView
android:layout_gravity="center"
android:layout_width="120dp"
android:layout_height="120dp"
android:contentDescription="@string/image_desc"
android:src="@drawable/ic_login_logo"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="28sp"
android:layout_marginTop="10dp"
android:textFontWeight="1000"
android:text="@string/app_name"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="30dp"
android:orientation="horizontal"
android:visibility="gone"
android:background="@drawable/edit_text_bg"
android:padding="10dp">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_person_input"
android:contentDescription="@string/image_desc" />
<EditText
android:id="@+id/et_username"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLength="20"
android:text="admin"
android:hint="@string/login_username"
android:inputType="textPersonName"
android:background="@android:color/transparent"
android:paddingLeft="10dp"
android:autofillHints="" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal"
android:background="@drawable/edit_text_bg"
android:padding="10dp">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_password_input"
android:contentDescription="@string/image_desc" />
<EditText
android:id="@+id/et_password"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:autofillHints=""
android:background="@android:color/transparent"
android:hint="@string/login_password"
android:layout_marginRight="5dp"
android:inputType="textPassword"
android:paddingLeft="10dp"
android:text="Bonus$2028" />
<ImageView
android:id="@+id/check_password"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_eye_close"
android:contentDescription="@string/image_desc" />
</LinearLayout>
<com.xuexiang.xui.widget.layout.XUIButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="@string/login_login"
android:textColor="@color/white"
android:textSize="18sp"
android:backgroundTint="#006e6b"
android:id="@+id/btn_login"/>
<TextView
android:id="@+id/tv_forget_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="@string/login_forgot_password"
android:visibility="gone"
android:textColor="@color/color_blue"
tools:ignore="RtlHardcoded" />
</LinearLayout>
</FrameLayout>

View File

@ -39,6 +39,7 @@
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/config_margin_10dp"
android:visibility="gone"
android:background="@drawable/ic_keybroad_del"
android:textColor="#333"
android:textFontWeight="1000" />