Browse Source

增加兼容高版本Android系统导致功能弹窗显示不全问题.修复储位转移页存在闪退问题,

songw 2 days ago
parent
commit
f268dca637

+ 4 - 0
app/src/main/AndroidManifest.xml

@@ -28,6 +28,10 @@
     <!-- 允许装载和卸载文件系统权限 -->
     <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
 
+    <!--悬浮窗-->
+    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
+
+
     <application
         android:name="uas.erp.xinchuangxiang_wms.application.PdaApplication"
         android:allowBackup="true"

+ 1 - 1
app/src/main/java/uas/erp/xinchuangxiang_wms/activity/IndexActivity.java

@@ -116,7 +116,7 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
                     public void onSuccess(int flag, Object o) throws Exception {
                         try {
                             String result = o.toString();
-                            Log.e("prints", result);
+                            Log.e("", result);
                             if (FastjsonUtil.validate(result)) {
                                 JSONObject resultObject = JSON.parseObject(result);
                                 JSONArray dataArray = resultObject.getJSONArray("data");

+ 0 - 51
app/src/main/java/uas/erp/xinchuangxiang_wms/fragment/IOCOutMakeMaterialOper.java

@@ -110,7 +110,6 @@ import uas.erp.xinchuangxiang_wms.util.JsonUtils;
 import uas.erp.xinchuangxiang_wms.util.LogUtil;
 import uas.erp.xinchuangxiang_wms.util.PrintUtils;
 import uas.erp.xinchuangxiang_wms.util.VolleyRequest;
-import uas.erp.xinchuangxiang_wms.util.VolleyRequest;
 import uas.erp.xinchuangxiang_wms.view.ClearableEditText;
 
 /**
@@ -1192,56 +1191,6 @@ public class IOCOutMakeMaterialOper extends BaseFragment implements View.OnClick
                             mCollectBarProdcodeTv.setText(mResult3);
 
                             PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BARCODE_RESULT + pi_inoutno, mResults);
-                        } else if (false) {
-                            String part1 = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
-                                    + "\n箱号:" + JsonUtils.optStringNotNull(messageObject, "BAR_OUTBOXCODE1")
-                                    + ";数量:" ;
-                            String part2 = CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"));
-                            String part3 = ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
-                                    + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
-                                    + ";名称规格:" + messageObject.optString("PR_DETAIL")
-                                    + "  " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC");
-                            if (listArray != null && listArray.length() > 0) {
-                                for (int i = 0; i < listArray.length(); i++) {
-                                    JSONObject listObject = listArray.optJSONObject(i);
-                                    part3 = part3
-                                            + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
-                                            + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
-                                            + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
-                                }
-                            }
-
-                            SpannableStringBuilder style1 = new SpannableStringBuilder(part1);
-                            SpannableStringBuilder style2 = new SpannableStringBuilder(part2);
-                            SpannableStringBuilder style3 = new SpannableStringBuilder(part3);
-                            style1.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.green)),0,part1.length(),Spannable.SPAN_EXCLUSIVE_INCLUSIVE);     //设置指定位置文字的颜色
-                            style2.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.red)),0,part2.length(),Spannable.SPAN_EXCLUSIVE_INCLUSIVE);     //设置指定位置文字的颜色
-                            style3.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.green)),0,part3.length(),Spannable.SPAN_EXCLUSIVE_INCLUSIVE);     //设置指定位置文字的颜色
-                            style1 = style1.append(style2).append(style3);
-                            mCollectResultTextView.setText(style1);
-
-                            mBarcodeTableLayout.setVisibility(View.GONE);
-                            mBoxTableLayout.setVisibility(View.GONE);
-
-                            tvBoxCollectionSuccess.setVisibility(View.VISIBLE);
-                            tvBoxCollectionSuccess.setText("采集成功");
-
-                            mResult1 = messageObject.optString("PA_OUTBOXCODE");
-                            mResult2 = messageObject.optInt("PA_TOTALQTY") + "";
-                            mResult3 = messageObject.optString("PA_PRODCODE");
-                            mResult4 = messageObject.optString("PA_WHCODE");
-
-                            mResults.add(mResult1);
-                            mResults.add(mResult2);
-                            mResults.add(mResult3);
-                            mResults.add(mResult4);
-
-                            mCollectBoxTv.setText(mResult1);
-                            mCollectBoxNumTv.setText(mResult2);
-                            mCollectBoxrProdcodeTv.setText(mResult3);
-                            mCollectBoxWhcodeTv.setText(mResult4);
-
-                            PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BOX_RESULT + pi_inoutno, mResults);
                         }
                         CommonUtil.toastNoRepeat(getActivity(), "采集成功");
 

+ 1 - 0
app/src/main/java/uas/erp/xinchuangxiang_wms/fragment/LoginFragment.java

@@ -188,6 +188,7 @@ public class LoginFragment extends BaseFragment implements AdapterView.OnItemSel
         if (maFunName != null) {
             CommonUtil.setSpinnerItemSelectedByValue(masterSpinner, maFunName);
         }
+
     }
 
     @Override

+ 49 - 20
app/src/main/java/uas/erp/xinchuangxiang_wms/util/CommonUtil.java

@@ -22,7 +22,9 @@ import android.text.style.AbsoluteSizeSpan;
 import android.text.style.ForegroundColorSpan;
 import android.util.DisplayMetrics;
 import android.util.TypedValue;
+import android.view.Gravity;
 import android.view.KeyEvent;
+import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.WindowManager;
@@ -97,8 +99,8 @@ public class CommonUtil {
                     InputMethodManager imm = (InputMethodManager) mContext
                             .getSystemService(Context.INPUT_METHOD_SERVICE);
                     imm.showSoftInput(mEditText, 0);
-//            imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,
-//                    InputMethodManager.HIDE_IMPLICIT_ONLY);
+                    //            imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,
+                    //                    InputMethodManager.HIDE_IMPLICIT_ONLY);
                 }
             }, 100);
         }
@@ -112,14 +114,14 @@ public class CommonUtil {
      */
     public static void closeKeybord(final EditText mEditText, final Context mContext) {
         if (mContext != null) {
-//            mEditText.postDelayed(new Runnable() {
-//                @Override
-//                public void run() {
-//                    InputMethodManager imm = (InputMethodManager) mContext
-//                            .getSystemService(Context.INPUT_METHOD_SERVICE);
-//                    imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
-//                }
-//            }, 100);
+            //            mEditText.postDelayed(new Runnable() {
+            //                @Override
+            //                public void run() {
+            //                    InputMethodManager imm = (InputMethodManager) mContext
+            //                            .getSystemService(Context.INPUT_METHOD_SERVICE);
+            //                    imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
+            //                }
+            //            }, 100);
 
             final Activity activity = (Activity) mContext;
             activity.runOnUiThread(new Runnable() {
@@ -128,13 +130,14 @@ public class CommonUtil {
                     InputMethodManager mInputKeyBoard = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
                     if (activity.getCurrentFocus() != null) {
                         mInputKeyBoard.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
-//                        activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
+                        //                        activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
                     }
                 }
             });
         }
 
     }
+
     /**
      * 判断double是否是整数
      *
@@ -420,7 +423,7 @@ public class CommonUtil {
         String result = "";
         if (!TextUtils.isEmpty(s)) {
             Pattern pattern = Pattern.compile("\\s*|\t|\r|\n");
-//            Pattern pattern = Pattern.compile("\r|\n");
+            //            Pattern pattern = Pattern.compile("\r|\n");
             Matcher matcher = pattern.matcher(s);
             result = matcher.replaceAll("");
         }
@@ -474,13 +477,38 @@ public class CommonUtil {
      * @param content
      */
     public static void toastNoRepeat(Context context, String content) {
+        //        if (content != null) {
+        //            Toast toast = Toast.makeText(context, content, Toast.LENGTH_LONG);
+        //            toast.setGravity(Gravity.CENTER, 0, 0); // 可以调整位置
+        //            if (!content.equals(oldMsg)) {
+        //                toast = Toast.makeText(context, content, Toast.LENGTH_LONG);
+        //                time = System.currentTimeMillis();
+        //            } else {
+        //                if ((System.currentTimeMillis() - time) > 3000) {
+        //                    toast = Toast.makeText(context, content, Toast.LENGTH_LONG);
+        //                    time = System.currentTimeMillis();
+        //                }
+        //            }
+        //            oldMsg = content;
+        //            toast.show();
+        //        }
+
         if (content != null) {
+            View toastLayout = LayoutInflater.from(context).inflate(R.layout.custom_toast, null);
+            TextView text = toastLayout.findViewById(R.id.tv_text);
+            text.setText(content);
+
+            Toast customToast = new Toast(context);
+            customToast.setGravity(Gravity.BOTTOM, 0, 0);
+            customToast.setDuration(Toast.LENGTH_LONG);
+            customToast.setView(toastLayout);
+
             if (!content.equals(oldMsg)) {
-                Toast.makeText(context, content, Toast.LENGTH_LONG).show();
+                customToast.show();
                 time = System.currentTimeMillis();
             } else {
                 if ((System.currentTimeMillis() - time) > 3000) {
-                    Toast.makeText(context, content, Toast.LENGTH_LONG).show();
+                    customToast.show();
                     time = System.currentTimeMillis();
                 }
             }
@@ -488,6 +516,7 @@ public class CommonUtil {
         }
     }
 
+
     /**
      * 访问出错的提示
      *
@@ -589,7 +618,7 @@ public class CommonUtil {
                 errorStr = new String(volleyError.networkResponse.data);
             }
         }
-        MyLog.d("aaa","响应失败:" + errorStr);
+        MyLog.d("aaa", "响应失败:" + errorStr);
         //振动提示
         makeNotice();
         /*MediaPlayer mp = new MediaPlayer();
@@ -778,9 +807,9 @@ public class CommonUtil {
             // 添加矩形View到布局中
             ViewGroup decorView = (ViewGroup) context.getWindow().getDecorView();
             decorView.addView(rectView);
-//            ViewGroup rootView = ((ViewGroup) context.findViewById(android.R.id.content));
-//            rootView.setFitsSystemWindows(true);
-//            rootView.setClipToPadding(true);
+            //            ViewGroup rootView = ((ViewGroup) context.findViewById(android.R.id.content));
+            //            rootView.setFitsSystemWindows(true);
+            //            rootView.setClipToPadding(true);
         }
     }
 
@@ -801,8 +830,8 @@ public class CommonUtil {
         //定义一种颜色span
         int valueColor = context.getResources().getColor(color);
         ForegroundColorSpan colorSpan = new ForegroundColorSpan(valueColor);
-//        AbsoluteSizeSpan sizeSpan = new AbsoluteSizeSpan(size, true);
-//        spanValue.setSpan(sizeSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+        //        AbsoluteSizeSpan sizeSpan = new AbsoluteSizeSpan(size, true);
+        //        spanValue.setSpan(sizeSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
         spanValue.setSpan(colorSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
 
         return spanValue;

+ 13 - 3
app/src/main/java/uas/erp/xinchuangxiang_wms/util/PrintUtils.java

@@ -8,12 +8,13 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.uas.bluetooth.PrintHelper;
+
 import uas.erp.xinchuangxiang_wms.tools.SharedPreUtil;
 
 public class PrintUtils {
 
     public static int printBar(Context context, String dataJson, int dpi, String printTemplate) {
-        Log.e("listArraythree1",dataJson);
+        Log.e("需要打印的数据:",dataJson);
         try {
             if (dpi <= 0) {
                 dpi = 203;
@@ -41,6 +42,7 @@ public class PrintUtils {
             int la_h = FastjsonUtil.getInt(templateObj, "LA_H") == 0 ? 400 : FastjsonUtil.getInt(templateObj, "LA_H");
             int la_y = FastjsonUtil.getInt(templateObj, "LA_Y") == 0 ? 800 : FastjsonUtil.getInt(templateObj, "LA_Y");
             int la_height = FastjsonUtil.getInt(templateObj, "LA_HEIGHT") == 0 ? 600 : FastjsonUtil.getInt(templateObj, "LA_HEIGHT");
+//            int la_height = 300;
             int la_qty = FastjsonUtil.getInt(templateObj, "LA_QTY") == 0 ? 1 : FastjsonUtil.getInt(templateObj, "LA_QTY");
             if (templateArray != null && templateArray.size() > 0) {
 //                PrintHelper printHelper = new PrintHelper(offset, h, v, height, qty);
@@ -95,6 +97,14 @@ public class PrintUtils {
 ////                                            .setTextFont(fontSize)
 //                                            .build();
 
+                                    //HPRTPrinterHelper.LanguageEncode = "UTF-8";
+                                    //HPRTPrinterHelper.LanguageEncode = "GBK";
+                                    //HPRTPrinterHelper.LanguageEncode = "ISO-8859-1";      //打印出来的是 "?" 号
+                                    //HPRTPrinterHelper.LanguageEncode = "GB18030";
+                                    //HPRTPrinterHelper.LanguageEncode = "GB2312";
+                                    //HPRTPrinterHelper.LanguageEncode = "Unicode";
+                                    //HPRTPrinterHelper.LanguageEncode = "GB13000";
+
                                     fontSize = 0;
                                     int textFont = 0;
                                     if ("BAR_BATCHCODE".equals(printKey)) {
@@ -105,7 +115,7 @@ public class PrintUtils {
                                             .setY(printY)
                                             .setBold(1)
                                             .setTextFont(textFont)//字号
-                                            .setTextSize(fontSize)//字体大小,取接口的值
+                                            .setTextSize(fontSize)//字体大小,取接口的值,
                                             .build();
 
                                     ///**
@@ -150,7 +160,7 @@ public class PrintUtils {
 //                                            .setY(printY)
 //                                            .setBold(2)
 //                                            .setTextFont(textFont2)//字号
-//                                            .setTextSize(fontSize)//字体大小,取接口的值
+//                                            .setTextSize(fontSize)//字体大小,取接口的值,
 //                                            .build();
 //                                    break;
                             }

+ 15 - 0
app/src/main/res/layout/custom_toast.xml

@@ -0,0 +1,15 @@
+<?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">
+
+    <TextView
+        android:id="@+id/tv_text"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textSize="16sp"
+        android:textColor="@color/black"
+        />
+
+</LinearLayout>

+ 2 - 2
app/src/main/res/layout/popwin_dialog_confirm.xml

@@ -16,7 +16,7 @@
                     android:id="@+id/title_dialog_confirm"
                     style="@style/PopWinTitleStyle"
                     android:text="提示"/>
-                <com.uas.pda_smart_com.view.CustomScrollView
+                <uas.erp.xinchuangxiang_wms.view.CustomScrollView
                     android:layout_below="@id/title_dialog_confirm"
                     android:id="@+id/sl_popwin_confirm"
                     android:layout_marginBottom="@dimen/space_bottom_8"
@@ -25,7 +25,7 @@
                     <TextView
                         android:id="@+id/tv_dialog_confirm_notice"
                         style="@style/PopWinContentTextStyle"/>
-                </com.uas.pda_smart_com.view.CustomScrollView>
+                </uas.erp.xinchuangxiang_wms.view.CustomScrollView>
                 <RelativeLayout
                     android:id="@+id/rl_btn_confirmdialog"
                     android:layout_below="@id/sl_popwin_confirm"

+ 2 - 2
build.gradle

@@ -54,8 +54,8 @@ ext {
             targetSdkVersion : 31,
             compileSdkVersion: 31,
             buildToolsVersion: "35.0.0",
-            versionCode      : 2,
-            versionName      : "1.0.1"
+            versionCode      : 4,
+            versionName      : "1.0.3"
     ]
 
     depsVersion = [