Browse Source

Merge branch 'master-new-炒锅' of http://10.2.1.24:10244/fyf/AndroidSmartClient into master-new-炒锅

授权码生成工具
liup 2 months ago
parent
commit
8ad4a3aeee
19 changed files with 732 additions and 53 deletions
  1. +8
    -0
      .idea/misc.xml
  2. +4
    -0
      app/src/main/java/com/bonait/bnframework/business/MainInit.java
  3. +19
    -1
      app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java
  4. +2
    -0
      app/src/main/java/com/bonait/bnframework/common/db/file/DBHelper.java
  5. +11
    -0
      app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_AUTHORIZE.java
  6. +18
    -15
      app/src/main/java/com/bonait/bnframework/common/helper/AES.java
  7. +425
    -0
      app/src/main/java/com/bonait/bnframework/common/helper/AuthorizeHelper.java
  8. +8
    -0
      app/src/main/java/com/bonait/bnframework/common/helper/SdCart.java
  9. +30
    -31
      app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigation2Activity.java
  10. +3
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java
  11. +15
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home2Fragment.java
  12. +26
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home4Fragment.java
  13. +11
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentSBKZ.java
  14. +2
    -0
      app/src/main/java/com/bonait/bnframework/ui/dialog/EditGoodsDialog.java
  15. +6
    -3
      app/src/main/java/com/bonait/bnframework/ui/fragment/goods/LocalGoodsFragment.java
  16. +10
    -0
      app/src/main/res/drawable/btn_authorize.xml
  17. +1
    -1
      app/src/main/res/drawable/input_bj.xml
  18. +17
    -0
      app/src/main/res/layout/fragment_home4.xml
  19. +116
    -0
      app/src/main/res/layout/item/layout/layout_authority.xml

+ 8
- 0
.idea/misc.xml View File

@@ -1,4 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="corretto-11" project-jdk-type="JavaSDK" />
<component name="VisualizationToolProject">
<option name="state">
<ProjectState>
<option name="scale" value="0.5" />
</ProjectState>
</option>
</component>
</project>

+ 4
- 0
app/src/main/java/com/bonait/bnframework/business/MainInit.java View File

@@ -31,6 +31,7 @@ import com.bonait.bnframework.common.db.mode.BPA_SILOS_CALIBRATE;
import com.bonait.bnframework.common.db.mode.BPA_USER;
import com.bonait.bnframework.common.db.res.AlertLogEnum;
import com.bonait.bnframework.common.db.res.UserLogEnum;
import com.bonait.bnframework.common.helper.AuthorizeHelper;
import com.bonait.bnframework.common.helper.CrashHandler;
import com.bonait.bnframework.common.helper.I.IMessageLogNotify;
import com.bonait.bnframework.common.helper.LogcatHelper;
@@ -84,6 +85,9 @@ public class MainInit {
//2.初始化SD卡,数据库DB
SdCart.getInstance().initSD();

//3.授权检查
AuthorizeHelper.AuthorizeVerify();

//4.初始化Main,并且增加本地图片库
ConfigData.getInstance().AddImage(app);
// activity生命周期管理


+ 19
- 1
app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java View File

@@ -97,7 +97,25 @@ public class ConfigName {
/**
* Db文件路径
*/
public static String dbPath = "";
public String dbPath = "";
/**
* 授权文件路径
*/
public String AuthorizeCodePath="";

/**
* 当前授权码
*/
public String CurrentAuthorizeCode="";

/**
* 验证是否已经授权
*/
public boolean IsAuthorize=false;
/**
* 是否显示授权提醒
*/
public boolean IsVisibleAuthorize=false;
//endregion

//region 店铺配置


+ 2
- 0
app/src/main/java/com/bonait/bnframework/common/db/file/DBHelper.java View File

@@ -9,6 +9,7 @@ import com.apkfuns.logutils.LogUtils;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_ATTRIBUTE;
import com.bonait.bnframework.common.db.mode.BPA_AUTHORIZE;
import com.bonait.bnframework.common.db.mode.BPA_CLOUDDATA;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_CLASSIFY;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_PROCESS_DETAIL;
@@ -153,6 +154,7 @@ public class DBHelper extends SQLiteOpenHelper {
CreateTablesAll(BPA_ORDER_LIST.class,null);//子属性
CreateTablesAll(BPA_PROPERTY_CLASSIFY.class,null);//属性分类表
CreateTablesAll(BPA_MATERIAL_TYPE.class,null);//物料分类表
CreateTablesAll(BPA_AUTHORIZE.class,null);//物料分类表
ForeignKeys();
}
/**


+ 11
- 0
app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_AUTHORIZE.java View File

@@ -0,0 +1,11 @@
package com.bonait.bnframework.common.db.mode;

/**
* 授权数据库
*/
public class BPA_AUTHORIZE extends ModeBase{
/**
* 授权码
*/
public String authorizeCode;
}

+ 18
- 15
app/src/main/java/com/bonait/bnframework/common/helper/AES.java View File

@@ -16,21 +16,24 @@ public class AES {
* 加密
* @return 加密后的字符串
*/
public static String Encrypt(String src) throws Exception {
// 判断密钥是否为空
if (key == null) {
System.out.print("密钥不能为空");
return null;
}

byte[] data = key.getBytes("utf-8");
SecretKeySpec skeySpec = new SecretKeySpec(data, "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); // 算法/模式/补码方式
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
byte[] encrypted = cipher.doFinal(src.getBytes("utf-8"));

//return new Base64().encodeToString(encrypted);//base64
return binary(encrypted, 16); //十六进制
public static String Encrypt(String src) {
try{
// 判断密钥是否为空
if (key == null) {
System.out.print("密钥不能为空");
return null;
}

byte[] data = key.getBytes("utf-8");
SecretKeySpec skeySpec = new SecretKeySpec(data, "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); // 算法/模式/补码方式
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
byte[] encrypted = cipher.doFinal(src.getBytes("utf-8"));
//return new Base64().encodeToString(encrypted);//base64
return binary(encrypted, 16); //十六进制
}catch (Exception e){
return e.getMessage();
}
}

/**


+ 425
- 0
app/src/main/java/com/bonait/bnframework/common/helper/AuthorizeHelper.java View File

@@ -0,0 +1,425 @@
package com.bonait.bnframework.common.helper;

import android.os.Build;

import androidx.appcompat.app.AppCompatActivity;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.databinding.LayoutAuthorityBinding;
import com.bonait.bnframework.ui.util.DisplayManager;
import com.bonait.bnframework.ui.widget.NewToastUtil;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.UUID;

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;

public class AuthorizeHelper {


// 加密方法,将字符串每个字符向右移动offset位
public static String encrypt(String input, int offset) {
if (input == null || input.isEmpty()) {
return input;
}
StringBuilder encrypted = new StringBuilder();
for (char c : input.toCharArray()) {
encrypted.append((char)(c + offset));
}
return toHex(encrypted.toString().getBytes());
}


// 解密方法,将字符串每个字符向左移动同样的offset位
public static String decrypt(String encrypted, int offset) {
if (encrypted == null || encrypted.isEmpty()) {
return encrypted;
}
encrypted = new String(toByte(encrypted));
StringBuilder decrypted = new StringBuilder();
for (char c : encrypted.toCharArray()) {
decrypted.append((char)(c - offset));
}
return decrypted.toString();
}

private static String CurrentRegistraCode="";

public static String getRegistraCode(){
CurrentRegistraCode = UUID.randomUUID().toString().replace("-","").substring(0,16).toUpperCase();
return CurrentRegistraCode;
}

/**
* 获取授权码
* @return
*/
public static String getAuthorizeCode(){
String data = "";
try{
File AuthorizeCodePathFile = new File(ConfigName.getInstance().AuthorizeCodePath);
byte[] buffer = new byte[1024];
int bytesRead;
FileInputStream fis = new FileInputStream(AuthorizeCodePathFile);
while ((bytesRead = fis.read(buffer)) != -1) {
data += new String(buffer, 0, bytesRead);
}
fis.close();
return data;
}catch (Exception e){
}
return data;
}

/**
* 授权验证
*/
public static void AuthorizeVerify(){
String AuthorizeCode= getAuthorizeCode();
try{
StringBuffer sb = new StringBuffer(AuthorizeCode);
sb.insert(4,";");
sb.insert(7,";");
String[] date = sb.toString().split("[;]");
if(date!=null && date.length==3){
int year=Integer.parseInt(date[0]);
int month=Integer.parseInt(date[1]);
int day=Integer.parseInt(date[2]);
LocalDate authorizeDate=LocalDate.of(year,month,day);
LocalDate currentDate=LocalDate.now();
//compareTo 等于0表示两个时间相等
//compareTo 大于0,authorizeDate 时间在 currentDate 之后
//compareTo 小于0,authorizeDate 时间在 currentDate 之前
//如果授权时间小于当前时间,授权过期
//如果授权时间大于当前时间,在授权时间内
ConfigName.getInstance().IsAuthorize=authorizeDate.compareTo(currentDate)>=0;
}else{
ConfigName.getInstance().IsAuthorize=Integer.parseInt(AuthorizeCode)==0;
}
}catch (Exception e){

}
}

public static void AuthorizeInAdvanceNotify(AppCompatActivity activity){
if(!ConfigName.getInstance().IsAuthorize)return;
String AuthorizeCode= getAuthorizeCode();
try{
StringBuffer sb = new StringBuffer(AuthorizeCode);
sb.insert(4,";");
sb.insert(7,";");
String[] date = sb.toString().split("[;]");
if(date!=null && date.length==3){
int year=Integer.parseInt(date[0]);
int month=Integer.parseInt(date[1]);
int day=Integer.parseInt(date[2]);
LocalDate authorizeDate=LocalDate.of(year,month,day);
LocalDate currentDate=LocalDate.now();
long daysBetween = ChronoUnit.DAYS.between( currentDate,authorizeDate)+1;
if(daysBetween<=5&&daysBetween>0){
AlertDialogUtils.showDialog(activity,"授权提醒","您的【黑菠萝小炒】授权即将到期,为避免影响后期使用,请您及时联系黑菠萝科技有限公司进行重新授权!\r\n"+"剩余 "+daysBetween+" 天");
ConfigName.getInstance().IsVisibleAuthorize=true;
}
}
}catch (Exception e){

}
}

public static void AuthorizeDialog(AppCompatActivity activity){
AlertDialogUtils.showCancelAndConfirmDialog(activity, R.layout.layout_authority, (layoutView, xCom) -> {
LayoutAuthorityBinding binding = LayoutAuthorityBinding.bind(layoutView);
DisplayManager.scaleViewGroup(binding.getRoot());
binding.authorityCode.setText(getRegistraCode());
binding.submit.setOnClickListener(view1 -> {
try{
String code = binding.editName.getText().toString().toUpperCase();
if(code==null||code.isEmpty()||code.length()==0){
NewToastUtil.getInstance().showToast("请输入有效的授权码!","Please enter a valid authorization code!");
return;
}

String dataBlock1 = "";
String dataBlock2 = "";//拼接首字符
String dataBlock3 = "";//拼接最后一个字符
int count = 0;
for (int i = 0; i < CurrentRegistraCode.length(); i += 4)
{
dataBlock1 =dataBlock1+ CurrentRegistraCode.substring(i + count, i + count+1);
dataBlock2 =dataBlock2+ CurrentRegistraCode.substring(i, i +1);
dataBlock3 =dataBlock3+ CurrentRegistraCode.substring(i + 3, i + 3+1);
count++;
}
String res = decrypt(code,6);
if(res.substring(0,4).equals(dataBlock1)){

if(res.substring(4).equals(dataBlock2+dataBlock3)){
//永久授权码设置
File AuthorizeCodePathFile = new File(ConfigName.getInstance().AuthorizeCodePath);
FileOutputStream fos = new FileOutputStream(AuthorizeCodePathFile);
fos.write("0000".getBytes());
fos.close();
}else{
//到期授权码设置
File AuthorizeCodePathFile = new File(ConfigName.getInstance().AuthorizeCodePath);
FileOutputStream fos = new FileOutputStream(AuthorizeCodePathFile);
fos.write(res.substring(4).getBytes());
fos.close();
}
}else{
NewToastUtil.getInstance().showToast("无效的授权码!","Authorization code error!");
return;
}


// String[] resArray = res.split("[@]");
// if(resArray.length==2 && resArray[0].equals(getId())){
// String[] date = resArray[1].split("[;]");
// if(date!=null && date.length==4){
// int year=Integer.parseInt(date[0]);
// int month=Integer.parseInt(date[1]);
// int day=Integer.parseInt(date[2]);
// int currentDay = Integer.parseInt(date[3]);
// if(LocalDate.now().getDayOfMonth()==currentDay){
// String tempValue =year+";"+month+";"+day;
// File AuthorizeCodePathFile = new File(ConfigName.getInstance().AuthorizeCodePath);
// FileOutputStream fos = new FileOutputStream(AuthorizeCodePathFile);
// fos.write(tempValue.getBytes());
// fos.close();
// }else{
// NewToastUtil.getInstance().showToast("无效的授权码!","Authorization code error!");
// }
// }
// else{
// if(Integer.parseInt(resArray[1])==LocalDate.now().getDayOfMonth()) {
// File AuthorizeCodePathFile = new File(ConfigName.getInstance().AuthorizeCodePath);
// FileOutputStream fos = new FileOutputStream(AuthorizeCodePathFile);
// fos.write(resArray[1].getBytes());
// fos.close();
// }else{
// NewToastUtil.getInstance().showToast("无效的授权码!","Authorization code error!");
// }
// }
// }
AuthorizeVerify();
xCom.dismissX();
}catch (Exception e){
NewToastUtil.getInstance().showToast("授权码错误!","Authorization code error!");
}
});
binding.btnClose1.setOnClickListener(view->{
xCom.dismissX();
});
binding.btnLast1.setOnClickListener(view->{
xCom.dismissX();
});

});
}

/**
* 授权通知
* @param activity
*/
public static void AuthorizeNotify(AppCompatActivity activity){
if(ConfigName.getInstance().IsAuthorize)return;
if(!ConfigName.getInstance().versionSelectionEnum.equals("800炒锅带投料"))return;
AuthorizeDialog(activity);
}

//region 获取Android 硬件信息
public static String getModel() {
return Build.MODEL;
}

public static String getManufacturer() {
return Build.MANUFACTURER;
}

public static String getBrand() {
return Build.BRAND;
}

public static String getBoard() {
return Build.BOARD;
}

public static String getDevice() {
return Build.DEVICE;
}

public static String getHardware() {
return Build.HARDWARE;
}

public static String getProduct() {
return Build.PRODUCT;
}

public static String getSerial() {
return Build.SERIAL;
}

public static String getUser() {
return Build.USER;
}

public static String getId() {
return Build.ID;
}

public static String getBootloader() {
return Build.BOOTLOADER;
}

public static String getRadioVersion() {
return Build.getRadioVersion();
}

public static String getAllInformation() {
return "Model: " + getModel() + "\n" +
"Manufacturer: " + getManufacturer() + "\n" +
"Brand: " + getBrand() + "\n" +
"Board: " + getBoard() + "\n" +
"Device: " + getDevice() + "\n" +
"Hardware: " + getHardware() + "\n" +
"Product: " + getProduct() + "\n" +
"Serial: " + getSerial() + "\n" +
"User: " + getUser() + "\n" +
"ID: " + getId() + "\n" +
"Bootloader: " + getBootloader() + "\n" +
"Radio Version: " + getRadioVersion();
}
//endregion

//region AES加密辅助方法
private static byte[] getRawKey(byte[] seed) {

try {
//获取密钥生成器
KeyGenerator kgen = KeyGenerator.getInstance("AES");
SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
sr.setSeed(seed);
//生成位的AES密码生成器
kgen.init(128, sr);
//生成密钥
SecretKey skey = kgen.generateKey();
//编码格式
byte[] raw = skey.getEncoded();
return raw;

} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return null;

}

private static byte[] encrypt(byte[] raw, byte[] clear) {

try {
//生成一系列扩展密钥,并放入一个数组中
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
Cipher cipher = Cipher.getInstance("AES");
//使用ENCRYPT_MODE模式,用skeySpec密码组,生成AES加密方法
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
//得到加密数据
byte[] encrypted = cipher.doFinal(clear);
return encrypted;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
}
return null;
}

private static byte[] decrypt(byte[] raw, byte[] encrypted) {

try {
//生成一系列扩展密钥,并放入一个数组中
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
Cipher cipher = null;
cipher = Cipher.getInstance("AES");
//使用DECRYPT_MODE模式,用skeySpec密码组,生成AES解密方法
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
//得到加密数据
byte[] decrypted = cipher.doFinal(encrypted);
return decrypted;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
}
return null;

}

//将十进制数转为十六进制
public static String toHex(String txt) {
return toHex(txt.getBytes());
}

//将十六进制字符串转换位十进制字符串
public static String fromHex(String hex) {
return new String(toByte(hex));
}

//将十六进制字符串转为十进制字节数组
public static byte[] toByte(String hexString) {
int len = hexString.length() / 2;
byte[] result = new byte[len];
for (int i = 0; i < len; i++) {
result[i] = Integer.valueOf(hexString.substring(2 * i, 2 * i + 2), 16).byteValue();
}
return result;
}

//将十进制字节数组转换为十六进制
public static String toHex(byte[]buf){
if(buf==null){
return "";
}
StringBuffer result=new StringBuffer(2*buf.length);
for(int i=0;i<buf.length;i++){
appendHex(result,buf[i]);
}
return result.toString();
}

private final static String HEX="0123456789ABCDEF";

private static void appendHex(StringBuffer sb,byte b){
sb.append(HEX.charAt((b>>4)&0x0f)).append(HEX.charAt(b&0x0f));
}
//endregion

}

+ 8
- 0
app/src/main/java/com/bonait/bnframework/common/helper/SdCart.java View File

@@ -44,6 +44,7 @@ public class SdCart {

ConfigName.getInstance().appResRoot = ConfigName.getInstance().sdCardPath +ConfigName.dataPath;
ConfigName.getInstance().dbPath = ConfigName.getInstance().appResRoot + "/hbl.db";

File rootFile = new File(ConfigName.getInstance().appResRoot);
if (!rootFile.exists()) //创建目录
{ Log.i("日志",ConfigName.getInstance().sdCardPath);
@@ -58,6 +59,13 @@ public class SdCart {
//2.创建数据库结构
DBHelper.getInstance(ConfigName.getInstance().dishesCon).CreateTables();
}

ConfigName.getInstance(). AuthorizeCodePath=ConfigName.getInstance().appResRoot + "/AuthorizeCode.aes";
File AuthorizeCodePathFile = new File(ConfigName.getInstance().AuthorizeCodePath);
if (!AuthorizeCodePathFile.exists()) //创建目录
{
// AuthorizeCodePathFile.mkdirs();
}
Log.i("日志","初始化数据库目录:"+ConfigName.getInstance().dbPath);
}



+ 30
- 31
app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigation2Activity.java View File

@@ -5,36 +5,24 @@ import android.os.Bundle;
import androidx.annotation.NonNull;

import com.bonait.bnframework.business.ConfigData;
import com.bonait.bnframework.business.UpDataModel;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.DataBus;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE;
import com.bonait.bnframework.common.helper.AES;
import com.bonait.bnframework.common.helper.AuthorizeHelper;
import com.bonait.bnframework.common.helper.BatchSync;
import com.bonait.bnframework.common.helper.HttpServer;
import com.bonait.bnframework.common.helper.I.IRunT;
import com.bonait.bnframework.common.helper.I.IThread;
import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.helper.TcpClient;
import com.bonait.bnframework.common.helper.ThreadManager;
import com.bonait.bnframework.common.http.callback.json.JsonDialogCallback;
import com.bonait.bnframework.common.modbus.ModbusTcpMainServer;
import com.bonait.bnframework.common.modbus.ModbusTcpServer;
import com.bonait.bnframework.common.model.ResAPI;
import com.bonait.bnframework.common.model.mode.ActionJsonMode;
import com.bonait.bnframework.common.model.mode.BPA_GoodsTechnologyAction;
import com.bonait.bnframework.common.model.mode.BatchingInfo;
import com.bonait.bnframework.common.model.mode.BomTechnologyActionInfo;
import com.bonait.bnframework.common.model.mode.CloudGood;
import com.bonait.bnframework.common.model.mode.GoodsTechnology;
import com.bonait.bnframework.common.model.mode.TechnologyAction;
import com.bonait.bnframework.common.model.mode.UpdateBomInfo;
import com.bonait.bnframework.common.model.mode.UpdateCloudGood;
import com.bonait.bnframework.common.oss.OssHelper;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.NetworkUtils;
import com.google.android.material.bottomnavigation.BottomNavigationView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

import android.util.Log;
@@ -52,24 +40,22 @@ import com.bonait.bnframework.modules.home.fragment.Home1Fragment;
import com.bonait.bnframework.modules.home.fragment.Home2Fragment;
import com.bonait.bnframework.modules.home.adapter.FragmentAdapter;
import com.bonait.bnframework.modules.mine.fragment.MyFragment;
import com.google.gson.Gson;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpHeaders;
import com.lzy.okgo.model.Response;
import com.qmuiteam.qmui.widget.QMUIViewPager;

import org.apache.commons.codec.binary.Base32;
import org.litepal.util.BaseUtility;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Date;
import java.util.InvalidPropertiesFormatException;
import java.util.UUID;

import butterknife.BindView;
import butterknife.ButterKnife;
import okhttp3.MediaType;
import okhttp3.RequestBody;

public class BottomNavigation2Activity extends BaseActivity {


@BindView(R.id.navigation)
BottomNavigationView bottomNavigationView;
@BindView(R.id.viewpager)
@@ -90,12 +76,21 @@ public class BottomNavigation2Activity extends BaseActivity {
viewPager.setOffscreenPageLimit(3);
bottomNavigationView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
Init();
// new Thread(()->{
// try{
// Thread.sleep(10000);
// test();
// }catch (Exception e){}
// }).start();

String info = AuthorizeHelper.getId();
String aa = AES.Encrypt(info);

Base32 bb = new Base32();
String ba = bb.encodeAsString(info.getBytes());

String guid = UUID.randomUUID().toString();

// Date dt = new Date();
LocalDate currentDate=LocalDate.now();
String info2 = info+"@"+currentDate.getYear()+";"+currentDate.getMonthValue()+";"+currentDate.getDayOfMonth();
String s1 = AuthorizeHelper.encrypt(info2,5);
String s2 = AuthorizeHelper.decrypt(s1,5);

if(ConfigName.getInstance().versionSelectionEnum.contains("一拖")){
hs = new HttpServer();
new Thread(()->{
@@ -105,6 +100,8 @@ public class BottomNavigation2Activity extends BaseActivity {
}catch (Exception e){}
}).start();
}


}

@Override
@@ -146,6 +143,8 @@ public class BottomNavigation2Activity extends BaseActivity {
}
}
});


}

//-------------------------配置viewPager与fragment关联----------------------------//


+ 3
- 0
app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java View File

@@ -1,5 +1,6 @@
package com.bonait.bnframework.modules.home.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

import android.app.Activity;
@@ -23,6 +24,7 @@ import com.bonait.bnframework.common.db.mode.BPA_GOODS_PROCESS_DETAIL;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_SUBATTRIBUTE_GROUP;
import com.bonait.bnframework.common.db.util.GoodsProcessDetailDBUtil;
import com.bonait.bnframework.common.db.util.SubAttributeGroupDBUtil;
import com.bonait.bnframework.common.helper.AuthorizeHelper;
import com.bonait.bnframework.common.helper.CountDownTimerExt;
import com.bonait.bnframework.common.helper.HttpServer;
import com.bonait.bnframework.common.helper.I.IRunT;
@@ -225,6 +227,7 @@ public class BottomNavigationNewActivity extends BaseActivity {

@Override
public void onPageSelected(int position) {

bottomNavigationView.SelectIndexTab(position);
}



+ 15
- 1
app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home2Fragment.java View File

@@ -10,6 +10,7 @@ import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;

import android.view.LayoutInflater;
@@ -19,6 +20,7 @@ import com.bonait.bnframework.R;
import com.bonait.bnframework.common.base.BaseFragment;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.MessageName;
import com.bonait.bnframework.common.helper.AuthorizeHelper;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.utils.ScreenUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
@@ -65,10 +67,22 @@ public class Home2Fragment extends BaseFragment {
super.onViewCreated(view, savedInstanceState);
context = getContext();
initTopBar();

appbarlayout.setExpanded(ConfigName.getInstance().IsPortraitScreen);
new Thread(()->{
try {
Thread.sleep(3000);
getActivity().runOnUiThread(()->{
AuthorizeHelper.AuthorizeNotify((AppCompatActivity) getActivity());
AuthorizeHelper.AuthorizeInAdvanceNotify((AppCompatActivity) getActivity());
});
}catch (Exception e){

}
}).start();
}



private void initTopBar() {
mCollapsingTopBarLayout.setTitle("功能菜单");
}


+ 26
- 1
app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home4Fragment.java View File

@@ -10,6 +10,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

@@ -18,6 +19,7 @@ import com.bonait.bnframework.business.ExecuteTheRecipe;
import com.bonait.bnframework.common.base.BaseFragment;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.MessageName;
import com.bonait.bnframework.common.helper.AuthorizeHelper;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
@@ -41,6 +43,9 @@ public class Home4Fragment extends BaseFragment {

@BindView(R.id.yauser_gn)
LinearLayout yauser_gn;//

@BindView(R.id.authorize)
Button authorize;
private Context context;

@Override
@@ -56,6 +61,21 @@ public class Home4Fragment extends BaseFragment {
context = getContext();
initTopBar();
initData();

new Thread(()->{
try {
Thread.sleep(3000);
getActivity().runOnUiThread(()->{
AuthorizeHelper.AuthorizeNotify((AppCompatActivity) getActivity());
AuthorizeHelper.AuthorizeInAdvanceNotify((AppCompatActivity) getActivity());
authorize.setVisibility(ConfigName.getInstance().IsVisibleAuthorize?View.VISIBLE:View.GONE);
});
}catch (Exception e){

}
}).start();


}

/**
@@ -70,7 +90,7 @@ public class Home4Fragment extends BaseFragment {
*
* @param view
*/
@OnClick({R.id.kaishipengren, R.id.shebeikongzhi, R.id.zhuxiaodenglu
@OnClick({R.id.kaishipengren, R.id.shebeikongzhi, R.id.zhuxiaodenglu,R.id.authorize
, R.id.liaochangshezhi, R.id.caipinyanfa,})
public void onViewClicked(View view) {
switch (view.getId()) {
@@ -78,8 +98,13 @@ public class Home4Fragment extends BaseFragment {
MessageManager.getInstance().sendMessage(MessageName.SelectZY, 0);
break;
case R.id.shebeikongzhi:
AuthorizeHelper.AuthorizeNotify((AppCompatActivity)getActivity());
if(!ConfigName.getInstance().IsAuthorize&&ConfigName.getInstance().versionSelectionEnum.equals("800炒锅带投料"))return;
MessageManager.getInstance().sendMessage(MessageName.SelectZY, 2);
break;
case R.id.authorize:
AuthorizeHelper.AuthorizeDialog((AppCompatActivity)getActivity());
break;
case R.id.liaochangshezhi:
OpenActivity(BunkerSetupActivity.class);
break;


+ 11
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentSBKZ.java View File

@@ -31,6 +31,7 @@ import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.db.mode.BPA_SILOS;
import com.bonait.bnframework.common.db.res.lcMode;
import com.bonait.bnframework.common.helper.AuthorizeHelper;
import com.bonait.bnframework.common.helper.I.IRun;
import com.bonait.bnframework.common.helper.I.IWriteCallBack;
import com.bonait.bnframework.common.helper.I.MyClickListener;
@@ -42,6 +43,7 @@ import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.modules.home.fragment.mode.imagebuttom3;
import com.bonait.bnframework.modules.home.fragment.mode.newhuoli_control;
import com.bonait.bnframework.ui.widget.NewToastUtil;
import com.orhanobut.logger.Logger;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
@@ -502,6 +504,8 @@ public class HomeFragmentSBKZ extends BaseFragment {
public MyClickListener myClickListener = new MyClickListener() {
@Override
public void clickListener(View v, Object data) {
AuthorizeHelper.AuthorizeNotify((AppCompatActivity)activity);
if(!ConfigName.getInstance().IsAuthorize&&ConfigName.getInstance().versionSelectionEnum.equals("800炒锅带投料"))return;
boolean isclick = false;
int hl = 0;
if (v.getId() == R.id.huoli) {
@@ -577,6 +581,8 @@ public class HomeFragmentSBKZ extends BaseFragment {
}
};

private boolean IsOpen=false;

/**
* 设置是否按下
*
@@ -584,6 +590,11 @@ public class HomeFragmentSBKZ extends BaseFragment {
* @param ismode
*/
public void SetIDTouch(int id, boolean ismode) {
if(ismode){
if(ConfigName.getInstance().isFastClick())return;
AuthorizeHelper.AuthorizeNotify((AppCompatActivity)activity);
if(!ConfigName.getInstance().IsAuthorize&&ConfigName.getInstance().versionSelectionEnum.equals("800炒锅带投料"))return;
}
switch (id) {
case R.id.chushui:
//PumpWater(ismode);


+ 2
- 0
app/src/main/java/com/bonait/bnframework/ui/dialog/EditGoodsDialog.java View File

@@ -18,6 +18,7 @@ import android.widget.AdapterView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.DialogFragment;

import com.apkfuns.logutils.LogUtils;
@@ -36,6 +37,7 @@ import com.bonait.bnframework.common.db.util.GoodsDBUtil;
import com.bonait.bnframework.common.db.util.GoodsProcessDetailDBUtil;
import com.bonait.bnframework.common.db.util.SubAttributeGroupDBUtil;

import com.bonait.bnframework.common.helper.AuthorizeHelper;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.utils.ProcessValueUtil;
import com.bonait.bnframework.common.utils.ToastUtils;


+ 6
- 3
app/src/main/java/com/bonait/bnframework/ui/fragment/goods/LocalGoodsFragment.java View File

@@ -21,17 +21,15 @@ import com.bonait.bnframework.R;
import com.bonait.bnframework.business.RecordManager;
import com.bonait.bnframework.common.base.BaseFragment;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.mode.BPA_ATTRIBUTE;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_CLASSIFY;
import com.bonait.bnframework.common.db.mode.BPA_PROPERTY_CLASSIFY;
import com.bonait.bnframework.common.db.util.AttributeDBUtil;
import com.bonait.bnframework.common.db.util.GoodsClassifyDBUtil;
import com.bonait.bnframework.common.db.util.GoodsDBUtil;
import com.bonait.bnframework.common.db.util.GoodsProcessDetailDBUtil;
import com.bonait.bnframework.common.db.util.PropClassifyDBUtil;
import com.bonait.bnframework.common.db.util.SubAttributeDBUtil;
import com.bonait.bnframework.common.db.util.SubAttributeGroupDBUtil;
import com.bonait.bnframework.common.helper.AuthorizeHelper;
import com.bonait.bnframework.common.utils.AlertDialogUtils;

import com.bonait.bnframework.databinding.DialogDeleteClassifyBinding;
@@ -119,6 +117,7 @@ public class LocalGoodsFragment extends BaseFragment {
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

initView();
updateData();
EventBus.getDefault().register(this);
@@ -239,6 +238,8 @@ public class LocalGoodsFragment extends BaseFragment {
return;
}
try {
AuthorizeHelper.AuthorizeNotify((AppCompatActivity)getActivity());
if(!ConfigName.getInstance().IsAuthorize&&ConfigName.getInstance().versionSelectionEnum.equals("800炒锅带投料"))return;
if(!ConfigName.getInstance().user.name.equals("一般用户")){
if(editGoodsDialog == null){
editGoodsDialog = new EditGoodsDialog();
@@ -378,6 +379,8 @@ public class LocalGoodsFragment extends BaseFragment {
};
goodClassifyAdapter.setCurrentPosition(0);
viewBinding.recyclerClassify.setAdapter(goodClassifyAdapter);


}

/**


+ 10
- 0
app/src/main/res/drawable/btn_authorize.xml View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:right="10dp" android:height="50dp" >
<shape android:shape="rectangle">
<solid android:color="#E91E63"/>
<corners android:topRightRadius="20dp" android:bottomRightRadius="20dp"/>
</shape>
</item>
<!-- <item android:drawable="@mipmap/home_exit" android:gravity="left|center" android:height="40dp" android:width="40dp" android:left="10dp"/>-->
</layer-list>

+ 1
- 1
app/src/main/res/drawable/input_bj.xml View File

@@ -6,7 +6,7 @@
<shape>
<solid android:color="@color/tab_panel_bg" />
<stroke
android:width="1dp"
android:width="2dp"
android:color="@color/color3" />
</shape>
</inset>

+ 17
- 0
app/src/main/res/layout/fragment_home4.xml View File

@@ -178,5 +178,22 @@
android:textColor="@color/white"
android:background="@drawable/btn_exit"
android:elevation="40dp"></Button>

<Button
android:id="@+id/authorize"
android:layout_width="120dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_marginLeft="0dp"
android:layout_marginBottom="50dp"
android:text="授权"
android:textStyle="bold"
android:textSize="30dp"
android:gravity="center|center"
android:textColor="@color/white"
android:background="@drawable/btn_authorize"
android:elevation="40dp"></Button>

</RelativeLayout>
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>

+ 116
- 0
app/src/main/res/layout/item/layout/layout_authority.xml View File

@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="660dp"
android:layout_height="500dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/bg_round25_white">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/title1"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_80"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:textStyle="bold"
android:background="@drawable/bg_round25_top_yellow"
style="@style/TextView_btn_dialog"
android:text="授权"/>

<ImageView
android:id="@+id/btn_close1"
android:layout_width="@dimen/dp_80"
android:layout_height="@dimen/dp_80"
android:layout_alignParentRight="true"
style="@style/TextView_btn_dialog"
android:background="@mipmap/ic_clear_white_48dp"/>
</RelativeLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_40"
android:layout_marginRight="@dimen/dp_40"
android:layout_marginTop="@dimen/dp_20"
android:orientation="horizontal">
<TextView
android:id="@+id/desc1"
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_150"
android:text="注册码:"
style="@style/TextView_desc"/>

<TextView
android:id="@+id/authority_code"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_150"
android:layout_centerInParent="true"
android:text="授权信息"
android:textSize="32sp"
android:textColor="@color/gray"
android:gravity="center_vertical"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_40"
android:layout_marginRight="@dimen/dp_40"
android:layout_marginTop="@dimen/dp_20"
android:orientation="horizontal">
<TextView
android:id="@+id/desc_name"
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_90"
android:text="授权码:"
style="@style/TextView_desc"/>

<EditText
android:id="@+id/edit_name"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_90"
android:background="@drawable/input_bj"
android:hint="请输入授权码"
android:inputType="text"
android:lines="1"
android:padding="@dimen/dp_3"
android:maxLength="100"
android:layout_gravity="center"
android:gravity="center_vertical"
android:textSize="@dimen/sp_32" />
</LinearLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_40"
android:layout_marginBottom="@dimen/dp_20">
<TextView
android:id="@+id/btn_last1"
android:layout_width="@dimen/dp_155"
android:layout_height="@dimen/dp_80"
android:layout_marginLeft="@dimen/dp_40"
android:layout_alignParentLeft="true"
style="@style/TextView_btn_dialog"
android:text="@string/btn_cancel"/>

<TextView
android:id="@+id/submit"
android:layout_width="@dimen/dp_155"
android:layout_height="@dimen/dp_80"
android:layout_marginRight="@dimen/dp_40"
android:layout_alignParentRight="true"
style="@style/TextView_btn_dialog"
android:text="确认"/>
</RelativeLayout>
</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

Loading…
Cancel
Save