0
0
Переглянути джерело

Merge branch 'master' of lhm/ich-android into master

李慧明 3 роки тому
батько
коміт
61741b6f8d
26 змінених файлів з 639 додано та 479 видалено
  1. 3 1
      app/build.gradle
  2. 32 3
      app/src/main/AndroidManifest.xml
  3. 213 212
      app/src/main/java/com/emato/ich/MainActivity.java
  4. 26 0
      app/src/main/java/com/emato/ich/crash/BootBroadcastReceiver.java
  5. 6 6
      app/src/main/java/com/emato/ich/device/DeviceControl.java
  6. 26 0
      app/src/main/java/com/emato/ich/fragment/ExceptionFragment.java
  7. 5 0
      app/src/main/java/com/emato/ich/fragment/InputInfoFragment.java
  8. 8 6
      app/src/main/java/com/emato/ich/fragment/MainFragment.java
  9. 4 0
      app/src/main/java/com/emato/ich/fragment/SendFragment.java
  10. 49 43
      app/src/main/java/com/emato/ich/fragment/TakeCodeFragment.java
  11. 2 0
      app/src/main/java/com/emato/ich/fragment/TakeSuccessFragment.java
  12. 13 0
      app/src/main/java/com/emato/ich/local/LocalStorage.java
  13. 1 1
      app/src/main/java/com/emato/ich/update/APKUpdateDownload.java
  14. 1 1
      app/src/main/java/com/emato/ich/update/InstallResultReceiver.java
  15. 17 17
      app/src/main/java/com/emato/ich/update/PackageManagerCompat.java
  16. 28 0
      app/src/main/java/com/emato/ich/utils/BaseUtils.java
  17. BIN
      app/src/main/res/drawable/top_image.jpg
  18. 13 4
      app/src/main/res/layout/activity_main.xml
  19. 3 2
      app/src/main/res/layout/content_main.xml
  20. 8 8
      app/src/main/res/layout/fragment_main.xml
  21. 28 28
      app/src/main/res/layout/fragment_send_info_confirm.xml
  22. 2 2
      app/src/main/res/layout/fragment_send_main.xml
  23. 34 32
      app/src/main/res/layout/fragment_take.xml
  24. 81 81
      app/src/main/res/layout/fragment_take_code.xml
  25. 32 32
      app/src/main/res/layout/fragment_take_success.xml
  26. 4 0
      app/src/main/res/xml/file_paths.xml

+ 3 - 1
app/build.gradle

@@ -41,7 +41,6 @@ dependencies {
     implementation 'androidx.annotation:annotation:1.1.0'
     implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
     implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
-    implementation 'com.squareup.okhttp3:okhttp:4.4.0'
     androidTestImplementation 'androidx.test.ext:junit:1.1.2'
     androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
     implementation fileTree(dir: "libs", include: ["*.jar"])
@@ -52,6 +51,9 @@ dependencies {
     implementation 'com.squareup.okhttp3:okhttp:4.0.1'
     implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
     implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'
+    implementation "org.permissionsdispatcher:permissionsdispatcher:4.3.1"//权限
+    annotationProcessor "org.permissionsdispatcher:permissionsdispatcher-processor:4.3.1"//权限
+
 
     testImplementation 'junit:junit:4.12'
     implementation files('libs/moterndevicecontroller.aar')

+ 32 - 3
app/src/main/AndroidManifest.xml

@@ -4,6 +4,7 @@
     package="com.emato.ich" >
 
 <!--    android:sharedUserId="android.uid.system"-->
+    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
     <!-- networkSecurityConfig: 这里配置为强制使用HTTP请求 -->
     <uses-permission android:name="android.permission.READ_PHONE_STATE" />
     <uses-permission android:name="android.permission.INTERNET" />
@@ -15,7 +16,7 @@
     <uses-permission android:name="android.permission.INTERNET"/>
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><!-- android10+ 不能用 -->
-<!--    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />-->
+    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
     <permission android:name="android.permission.INSTALL_PACKAGES" />
     <application
         android:networkSecurityConfig="@xml/network_security_config"
@@ -33,11 +34,39 @@
             android:windowSoftInputMode="adjustResize|stateHidden"
             android:configChanges="orientation|keyboardHidden"><!-- 禁止弹出输入键盘 -->
             <intent-filter>
+                <action android:name="android.intent.action.BOOT_COMPLETED" />
+                <category android:name="android.intent.category.HOME" />
+                <category android:name="android.intent.category.DEFAULT" />
                 <action android:name="android.intent.action.MAIN" />
-
+                <action android:name="android.intent.action.PACKAGE_REPLACED"/>
+                <action android:name="android.intent.action.PACKAGE_ADDED" />
+                <action android:name="android.intent.action.PACKAGE_REMOVED" />
+                <data android:scheme="package"/>
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
-        <service android:name="org.eclipse.paho.android.service.MqttService"/>
+        <receiver android:name="com.emato.ich.crash.BootBroadcastReceiver">
+            <intent-filter>
+                <category android:name="android.intent.category.HOME" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <action android:name="android.intent.action.BOOT_COMPLETED" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </receiver>
+<!--        <receiver android:name=".update.InstallResultReceiver">-->
+<!--            <intent-filter>-->
+<!--                <action android:name="MyAction" />-->
+<!--            </intent-filter>-->
+<!--        </receiver>-->
+<!--        <provider-->
+<!--            android:name="androidx.core.content.FileProvider"-->
+<!--            android:authorities="com.fengzhi.wuyemanagement.fileprovider"-->
+<!--            android:grantUriPermissions="true"-->
+<!--            android:exported="false">-->
+<!--            <meta-data-->
+<!--                android:name="android.support.FILE_PROVIDER_PATHS"-->
+<!--                android:resource="@xml/file_paths" />-->
+<!--        </provider>-->
+<!--        <service android:name="org.eclipse.paho.android.service.MqttService"/>-->
     </application>
 </manifest>

+ 213 - 212
app/src/main/java/com/emato/ich/MainActivity.java

@@ -90,6 +90,7 @@ public class MainActivity extends AppCompatActivity  {
         // 强制关闭输入法
         getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
 //        setSupportActionBar(binding.toolbar);
+        setContentView(binding.getRoot());
 //        NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main);
 //        appBarConfiguration = new AppBarConfiguration.Builder(navController.getGraph()).build();
 //        NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
@@ -105,221 +106,221 @@ public class MainActivity extends AppCompatActivity  {
 //        });
 
 
-//         获取系统配置
-//        ICSPClient.getSystemConfig("", BaseUtils.getClientId(), new Callback() {
-//            @Override
-//            public void onFailure(@NotNull Call call, @NotNull IOException e) {
-//                Log.e(TAG, "onFailure: 获取系统配置错误! 网络错误! ", e);
-//            }
-//
-//            @Override
-//            public void onResponse
-//                    (@NotNull Call call, @NotNull Response response) throws IOException {
-//
-//                try {
-//                    OnDownloadListener listener = new OnDownloadListener() {
-//
-//                        @Override
-//                        public void onDownloadSuccess(File file) {
-//
-//                        }
-//
-//                        @Override
-//                        public void onDownloading(int progress) {
-//
+        // 获取系统配置
+        ICSPClient.getSystemConfig("", BaseUtils.getClientId(), new Callback() {
+            @Override
+            public void onFailure(@NotNull Call call, @NotNull IOException e) {
+                Log.e(TAG, "onFailure: 获取系统配置错误! 网络错误! ", e);
+            }
+
+            @Override
+            public void onResponse
+                    (@NotNull Call call, @NotNull Response response) throws IOException {
+
+                try {
+                    OnDownloadListener listener = new OnDownloadListener() {
+
+                        @Override
+                        public void onDownloadSuccess(File file) {
+
+                        }
+
+                        @Override
+                        public void onDownloading(int progress) {
+
+                        }
+
+                        @Override
+                        public void onDownloadFailed(Exception e) {
+
+                        }
+                    };
+                    String parseResponse = ICSPClient.isSuccessfulAndParseResponse(response);
+                    ObjectMapper objectMapper = new ObjectMapper();
+                    ResponseData<Map<String, String>> readValue = objectMapper.readValue(parseResponse, new TypeReference<ResponseData<Map<String, String>>>() {
+                    });
+                    if (null != readValue && readValue.getCode().equals(ICSPResponseCodeEnum.OK.getCode())) {
+                        configMap.putAll(readValue.getData());
+                        String qrcode_url = configMap.get(SystemConfigConstant.cabinet_take_object_qrcode_url);
+
+                        try {
+                            ICSPClient.download(qrcode_url, new Callback() {
+                                @Override
+                                public void onFailure(@NotNull Call call, @NotNull IOException e) {
+
+                                }
+
+                                @Override
+                                public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
+                                    InputStream is = null;
+                                    byte[] buf = new byte[2048];
+                                    int len = 0;
+                                    FileOutputStream fos = null;
+                                    final String destFileDir = "res/drawable/";
+                                    String destFileName = "e_mp_qrcode_8x8.jpg";
+                                    //储存下载文件的目录
+                                    File dir = new File(getApplication().getFilesDir().getAbsolutePath() + "/" +destFileDir);
+                                    if (!dir.exists()) {
+                                        dir.mkdirs();
+                                    }
+//                destFileName = apk_url.substring(apk_url.lastIndexOf('/'), apk_url.length() - 1);
+                                    File file = new File(dir, destFileName);
+
+                                    try {
+
+                                        is = response.body().byteStream();
+                                        long total = response.body().contentLength();
+                                        fos = new FileOutputStream(file);
+                                        long sum = 0;
+                                        while ((len = is.read(buf)) != -1) {
+                                            fos.write(buf, 0, len);
+                                            sum += len;
+                                            int progress = (int) (sum * 1.0f / total * 100);
+                                            //下载中更新进度条
+                                            listener.onDownloading(progress);
+                                        }
+                                        fos.flush();
+                                        //下载完成
+                                        listener.onDownloadSuccess(file);
+                                    } catch (Exception e) {
+                                        listener.onDownloadFailed(e);
+                                    }finally {
+                                        try {
+                                            if (is != null) {
+                                                is.close();
+                                            }
+                                            if (fos != null) {
+                                                fos.close();
+                                            }
+                                        } catch (IOException e) {
+
+                                        }
+
+                                    }
+                                }
+                            }, listener);
+                        } catch (Exception e) {
+
+                        }
+                        Log.i(TAG, "onResponse: 获取系统配置成功! ");
+                    } else {
+                        Log.w(TAG, "onResponse: code==>" + readValue.getCode() + ", msg==>" + readValue.getMsg());
+                    }
+                } catch (RuntimeException e) {
+                    Log.e(TAG, "onResponse: 获取系统配置错误! 未知错误! ", e);
+                }
+            }
+        });
+
+        ICHPublishClient ichPublishClient = ICHPublishClient.getInstance();
+
+        String clientId = BaseUtils.getClientId();
+        ICHTopic.CLIENT_ID = clientId;
+        // 订阅主题
+//        ICHSubscribeClient ichSubscribeClient = ICHSubscribeClient.getInstance();
+        ichPublishClient.subscribe(ICHTopic.LOCK + clientId, (s, msg) -> {
+            String payload = new String(msg.getPayload());
+            ObjectMapper objectMapper = new ObjectMapper();
+            Message message = objectMapper.readValue(payload, Message.class);
+            Log.i(TAG, "onCreate: message id: " + s + "--------------消息体: " + message);
+
+            DeviceControl.unlockLocker(message.getSection(), message.getPort(), (var1, var2) -> {
+                Log.i(TAG, "onCreate: 开锁返回码: " + var1 + "--------------返回消息: " + Arrays.asList(var2));
+                MqttMessage mqttMessage;
+                if (var1 != 0) {
+                    try {
+                        mqttMessage = wrapMessage(message, objectMapper);
+                        ichPublishClient.publish(String.format(ICHTopic.CALLBACK_FAILED, BaseUtils.getClientId()), mqttMessage);
+                    } catch (JsonProcessingException e) {
+                        Log.e(TAG, "onCreate: ---------------------序列化开锁错误消息失败! ", e);
+                    } catch (Exception e) {
+                        Log.e(TAG, "onCreate: ---------------------未知错误! ", e);
+                    }
+                } else {
+                    // TODO 暂时不做 成功需要不断去请求查询锁是否关闭, 关闭后推送成功消息
+                    Log.i(TAG, "onCreate: -------------------------开锁成功");
+//                    AtomicBoolean atomicBoolean = new AtomicBoolean(true);
+//                    AtomicInteger atomicInteger = new AtomicInteger(5);
+//                    do {
+//                        try {
+//                            TimeUnit.SECONDS.sleep(30);
+//                        } catch (InterruptedException e) {
+//                            Log.e(TAG, "onCreate: 等待查询锁状态时线程中断! ", e);
 //                        }
-//
-//                        @Override
-//                        public void onDownloadFailed(Exception e) {
-//
+//                        DeviceControl.queryLocker(message.getSection(), message.getPort(), (var3, var4) -> {
+//                            List<String> strings = Arrays.asList(var4);
+//                            if (var3 == 0 && strings.size() > 0 && !strings.get(0).equals("locked")) {
+//                                atomicBoolean.set(false);
+//                            }
+//                            atomicInteger.decrementAndGet();
+//                        });
+//                        if (atomicInteger.get() <= 0) {
+//                            atomicBoolean.set(false);
 //                        }
-//                    };
-//                    String parseResponse = ICSPClient.isSuccessfulAndParseResponse(response);
-//                    ObjectMapper objectMapper = new ObjectMapper();
-//                    ResponseData<Map<String, String>> readValue = objectMapper.readValue(parseResponse, new TypeReference<ResponseData<Map<String, String>>>() {
-//                    });
-//                    if (null != readValue && readValue.getCode().equals(ICSPResponseCodeEnum.OK.getCode())) {
-//                        configMap.putAll(readValue.getData());
-//                        String qrcode_url = configMap.get(SystemConfigConstant.cabinet_take_object_qrcode_url);
-//
-//                        try {
-//                            ICSPClient.download(qrcode_url, new Callback() {
-//                                @Override
-//                                public void onFailure(@NotNull Call call, @NotNull IOException e) {
-//
-//                                }
-//
-//                                @Override
-//                                public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
-//                                    InputStream is = null;
-//                                    byte[] buf = new byte[2048];
-//                                    int len = 0;
-//                                    FileOutputStream fos = null;
-//                                    final String destFileDir = "res/drawable/";
-//                                    String destFileName = "e_mp_qrcode_8x8.jpg";
-//                                    //储存下载文件的目录
-//                                    File dir = new File(getApplication().getFilesDir().getAbsolutePath() + "/" +destFileDir);
-//                                    if (!dir.exists()) {
-//                                        dir.mkdirs();
-//                                    }
-////                destFileName = apk_url.substring(apk_url.lastIndexOf('/'), apk_url.length() - 1);
-//                                    File file = new File(dir, destFileName);
-//
-//                                    try {
-//
-//                                        is = response.body().byteStream();
-//                                        long total = response.body().contentLength();
-//                                        fos = new FileOutputStream(file);
-//                                        long sum = 0;
-//                                        while ((len = is.read(buf)) != -1) {
-//                                            fos.write(buf, 0, len);
-//                                            sum += len;
-//                                            int progress = (int) (sum * 1.0f / total * 100);
-//                                            //下载中更新进度条
-//                                            listener.onDownloading(progress);
-//                                        }
-//                                        fos.flush();
-//                                        //下载完成
-//                                        listener.onDownloadSuccess(file);
-//                                    } catch (Exception e) {
-//                                        listener.onDownloadFailed(e);
-//                                    }finally {
-//                                        try {
-//                                            if (is != null) {
-//                                                is.close();
-//                                            }
-//                                            if (fos != null) {
-//                                                fos.close();
-//                                            }
-//                                        } catch (IOException e) {
-//
-//                                        }
-//
-//                                    }
-//                                }
-//                            }, listener);
-//                        } catch (Exception e) {
-//
+//                    } while(atomicBoolean.get());
+                    try {
+                        mqttMessage = wrapMessage(message, objectMapper);
+//                        if (atomicInteger.get() <= 0) {
+//                            message.setCause("长时间未关闭柜门!");
+//                            mqttMessage.setPayload(objectMapper.writeValueAsBytes(message));
+//                            ichPublishClient.publish(String.format(ICHTopic.CALLBACK_FAILED, BaseUtils.getClientId()), mqttMessage);
 //                        }
-//                        Log.i(TAG, "onResponse: 获取系统配置成功! ");
-//                    } else {
-//                        Log.w(TAG, "onResponse: code==>" + readValue.getCode() + ", msg==>" + readValue.getMsg());
-//                    }
-//                } catch (RuntimeException e) {
-//                    Log.e(TAG, "onResponse: 获取系统配置错误! 未知错误! ", e);
-//                }
-//            }
-//        });
-//
-//        ICHPublishClient ichPublishClient = ICHPublishClient.getInstance();
-//
-//        String clientId = BaseUtils.getClientId();
-//        ICHTopic.CLIENT_ID = clientId;
-//        // 订阅主题
-////        ICHSubscribeClient ichSubscribeClient = ICHSubscribeClient.getInstance();
-//        ichPublishClient.subscribe(ICHTopic.LOCK + clientId, (s, msg) -> {
-//            String payload = new String(msg.getPayload());
-//            ObjectMapper objectMapper = new ObjectMapper();
-//            Message message = objectMapper.readValue(payload, Message.class);
-//            Log.i(TAG, "onCreate: message id: " + s + "--------------消息体: " + message);
-//
-//            DeviceControl.unlockLocker(message.getSection(), message.getPort(), (var1, var2) -> {
-//                Log.i(TAG, "onCreate: 开锁返回码: " + var1 + "--------------返回消息: " + Arrays.asList(var2));
-//                MqttMessage mqttMessage;
-//                if (var1 != 0) {
-//                    try {
-//                        mqttMessage = wrapMessage(message, objectMapper);
-//                        ichPublishClient.publish(String.format(ICHTopic.CALLBACK_FAILED, BaseUtils.getClientId()), mqttMessage);
-//                    } catch (JsonProcessingException e) {
-//                        Log.e(TAG, "onCreate: ---------------------序列化开锁错误消息失败! ", e);
-//                    } catch (Exception e) {
-//                        Log.e(TAG, "onCreate: ---------------------未知错误! ", e);
-//                    }
-//                } else {
-//                    // TODO 暂时不做 成功需要不断去请求查询锁是否关闭, 关闭后推送成功消息
-//                    Log.i(TAG, "onCreate: -------------------------开锁成功");
-////                    AtomicBoolean atomicBoolean = new AtomicBoolean(true);
-////                    AtomicInteger atomicInteger = new AtomicInteger(5);
-////                    do {
-////                        try {
-////                            TimeUnit.SECONDS.sleep(30);
-////                        } catch (InterruptedException e) {
-////                            Log.e(TAG, "onCreate: 等待查询锁状态时线程中断! ", e);
-////                        }
-////                        DeviceControl.queryLocker(message.getSection(), message.getPort(), (var3, var4) -> {
-////                            List<String> strings = Arrays.asList(var4);
-////                            if (var3 == 0 && strings.size() > 0 && !strings.get(0).equals("locked")) {
-////                                atomicBoolean.set(false);
-////                            }
-////                            atomicInteger.decrementAndGet();
-////                        });
-////                        if (atomicInteger.get() <= 0) {
-////                            atomicBoolean.set(false);
-////                        }
-////                    } while(atomicBoolean.get());
-//                    try {
-//                        mqttMessage = wrapMessage(message, objectMapper);
-////                        if (atomicInteger.get() <= 0) {
-////                            message.setCause("长时间未关闭柜门!");
-////                            mqttMessage.setPayload(objectMapper.writeValueAsBytes(message));
-////                            ichPublishClient.publish(String.format(ICHTopic.CALLBACK_FAILED, BaseUtils.getClientId()), mqttMessage);
-////                        }
-//
-//                        ichPublishClient.publish(String.format(ICHTopic.CALLBACK_SUCCESS, BaseUtils.getClientId()), mqttMessage);
-//                    } catch (JsonProcessingException e) {
-//                        Log.e(TAG, "onCreate: ---------------------序列化开锁成功消息失败! ", e);
-//                    } catch (RuntimeException e) {
-//                        Log.e(TAG, "onCreate: ---------------------未知错误! ", e);
-//                    }
-//                }
-//            });
-//
-//        });
-//
-//        // 注册柜子信息
-//
-//        String appVersion = BaseUtils.getAppVersion(getApplicationContext());
-//        String androidVersion = BaseUtils.getVersionName();
-//        CountDownLatch countDownLatch = new CountDownLatch(10);
-//        Cabinet cabinet = DeviceControl.queryCabinetInfo(countDownLatch);
-//        try {
-//            countDownLatch.await();
-//        } catch (InterruptedException e) {
-//            e.printStackTrace();
-//        }
-//
-//        cabinet.setClientId(clientId);
-//        cabinet.setSoftwareVersion(appVersion);
-//        cabinet.setAndroidVersion(androidVersion);
-//        cabinet.setSoftwareType("android");
-//        cabinet.setImei(BaseUtils.getIMEI(getApplicationContext()));
-//        cabinet.setMacIpv4("111");
-//        cabinet.setMacIpv6("unknown");
-//        cabinet.setNetType("111");
-//        cabinet.setPlatType("S905");
-//        cabinet.setSim("111");
-//        cabinet.setWifiSSid("111");
-//
-//        ObjectMapper objectMapper = new ObjectMapper();
-//
-//        try {
-//            String jsonData = objectMapper.writeValueAsString(cabinet);
-//            Log.i(TAG, "onCreate: jsonData===============>" + jsonData);
-//
-//            MqttMessage message = new MqttMessage();
-//            message.setQos(1);
-//            message.setPayload(jsonData.getBytes());
-//            ichPublishClient.publish(String.format(ICHTopic.CABINET_INFO_REPORT, clientId), message);
-//        } catch (JsonProcessingException e) {
-//            Log.e(TAG, "onCreate: 解析成JSON失败!", e);
-//        }
-//
-//        // TODO 更新版本监听
-//        ichPublishClient.subscribe(String.format(ICHTopic.APK_UPDATE_PATH, BaseUtils.getClientId()), (msgId, msg) -> {
-//            String path = new String(msg.getPayload());
-//            // 发起请求下载APK
-//            APKUpdateDownload.getInstance().downloadAPK(MainActivity.this, getApplication(), path);
-//        });
+
+                        ichPublishClient.publish(String.format(ICHTopic.CALLBACK_SUCCESS, BaseUtils.getClientId()), mqttMessage);
+                    } catch (JsonProcessingException e) {
+                        Log.e(TAG, "onCreate: ---------------------序列化开锁成功消息失败! ", e);
+                    } catch (RuntimeException e) {
+                        Log.e(TAG, "onCreate: ---------------------未知错误! ", e);
+                    }
+                }
+            });
+
+        });
+
+        // 注册柜子信息
+
+        String appVersion = BaseUtils.getAppVersion(getApplicationContext());
+        String androidVersion = BaseUtils.getVersionName();
+        CountDownLatch countDownLatch = new CountDownLatch(10);
+        Cabinet cabinet = DeviceControl.queryCabinetInfo(countDownLatch);
+        try {
+            countDownLatch.await();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+
+        cabinet.setClientId(clientId);
+        cabinet.setSoftwareVersion(appVersion);
+        cabinet.setAndroidVersion(androidVersion);
+        cabinet.setSoftwareType("android");
+        cabinet.setImei(BaseUtils.getIMEI(getApplicationContext()));
+        cabinet.setMacIpv4("111");
+        cabinet.setMacIpv6("unknown");
+        cabinet.setNetType("111");
+        cabinet.setPlatType("S905");
+        cabinet.setSim("111");
+        cabinet.setWifiSSid("111");
+
+        ObjectMapper objectMapper = new ObjectMapper();
+
+        try {
+            String jsonData = objectMapper.writeValueAsString(cabinet);
+            Log.i(TAG, "onCreate: jsonData===============>" + jsonData);
+
+            MqttMessage message = new MqttMessage();
+            message.setQos(1);
+            message.setPayload(jsonData.getBytes());
+            ichPublishClient.publish(String.format(ICHTopic.CABINET_INFO_REPORT, clientId), message);
+        } catch (JsonProcessingException e) {
+            Log.e(TAG, "onCreate: 解析成JSON失败!", e);
+        }
+
+        // TODO 更新版本监听
+        ichPublishClient.subscribe(String.format(ICHTopic.APK_UPDATE_PATH, BaseUtils.getClientId()), (msgId, msg) -> {
+            String path = new String(msg.getPayload());
+            // 发起请求下载APK
+            APKUpdateDownload.getInstance().downloadAPK(MainActivity.this, getApplication(), path);
+        });
     }
 
     @Override

+ 26 - 0
app/src/main/java/com/emato/ich/crash/BootBroadcastReceiver.java

@@ -0,0 +1,26 @@
+package com.emato.ich.crash;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+import com.emato.ich.MainActivity;
+
+public class BootBroadcastReceiver extends BroadcastReceiver {
+    static final String ACTION = "android.intent.action.BOOT_COMPLETED";
+
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        if (intent.getAction().equals(ACTION)) {
+            // 开机启动的Activity
+            Intent activityIntent = new Intent(context, MainActivity.class);
+            activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+            // 启动Activity
+            context.startActivity(activityIntent);
+            //2.如果自启动Activity
+            context.startActivity(activityIntent);
+            //3.如果自启动服务
+//            context.startService(intent);
+        }
+    }
+}

+ 6 - 6
app/src/main/java/com/emato/ich/device/DeviceControl.java

@@ -225,12 +225,12 @@ public class DeviceControl {
 
                 try {
                     List<Cabinet.CabinetLocker> lockInfos = objectMapper.readValue(s, javaType);
-
-                    if (finalI <= 3) {
-                        lockInfos = lockInfos.stream().filter(lockInfo -> lockInfo.getLocked().equals("false")).collect(Collectors.toList()).subList(0, 12);
-                    } else if (finalI > 3) {
-                        lockInfos = lockInfos.stream().filter(lockInfo -> lockInfo.getLocked().equals("false")).collect(Collectors.toList()).subList(0, 8);
-                    }
+                    lockInfos = lockInfos.stream().filter(lockInfo -> lockInfo.getLocked().equals("false")).collect(Collectors.toList());
+//                    if (finalI <= 3) {
+//                        lockInfos = lockInfos.stream().filter(lockInfo -> lockInfo.getLocked().equals("false")).collect(Collectors.toList()).subList(0, 12);
+//                    } else if (finalI > 3) {
+//                        lockInfos = lockInfos.stream().filter(lockInfo -> lockInfo.getLocked().equals("false")).collect(Collectors.toList()).subList(0, 8);
+//                    }
                     Cabinet.CabinetPlat lockPlateInfo = new Cabinet.CabinetPlat();
                     lockPlateInfo.setCabinetLockers(lockInfos);
                     lockPlateInfo.setSection(finalI);

+ 26 - 0
app/src/main/java/com/emato/ich/fragment/ExceptionFragment.java

@@ -18,6 +18,7 @@ import com.emato.ich.api.ICSPClient;
 import com.emato.ich.api.ICSPResponseCodeEnum;
 import com.emato.ich.data.DecisionEnum;
 import com.emato.ich.databinding.FragmentExceptionBinding;
+import com.emato.ich.device.DeviceControl;
 import com.emato.ich.entity.vo.ConfirmOrderVo;
 import com.emato.ich.entity.vo.PreparedOrderResponseVo;
 import com.emato.ich.entity.vo.ResponseData;
@@ -51,6 +52,15 @@ public class ExceptionFragment extends Fragment {
 
 
     public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
+
+        if (!LocalStorage.getInstance().getSession().getException()) {
+            binding.issueCancel.setEnabled(false);
+            binding.issueDoorNotOpen.setEnabled(false);
+            binding.issueOpenAgain.setEnabled(false);
+            binding.issueSize.setEnabled(false);
+            binding.issueTakeCancel.setEnabled(false);
+        }
+
         Bundle arguments = null;
         MainActivity activity = null;
         try {
@@ -79,6 +89,10 @@ public class ExceptionFragment extends Fragment {
         // 拿出快递 取消
         binding.issueTakeCancel.setOnClickListener(view1 -> handleExceptionScene(finalArguments, DecisionEnum.CANCEL_12, view1));
 
+        // 联系我们
+        binding.issueOther.setOnClickListener(view1 -> {
+            Snackbar.make(view1, "电话: 16274237018! 请说明原由! ", Snackbar.LENGTH_LONG).show();
+        });
         MainActivity finalActivity = activity;
         binding.returnBtn.setOnClickListener(view1 -> {
             Bundle bundle = finalActivity.getBundleMap().get(SendInfoConfirmFragment.class.getName());
@@ -116,27 +130,39 @@ public class ExceptionFragment extends Fragment {
                 case CANCEL_11:
                     // 未投递 取消
                     confirmOrderVo.setDecision(DecisionEnum.CANCEL_11.getDecision());
+                    Snackbar.make(view, "异常处理只能处理一次! 如未处理您的问题! 请联系我们处理! ", Snackbar.LENGTH_LONG).show();
                     break;
                 case CANCEL_12:
                     // 拿出快递 取消
                     confirmOrderVo.setDecision(DecisionEnum.CANCEL_12.getDecision());
+                    Snackbar.make(view, "异常处理只能处理一次! 如未处理您的问题! 请联系我们处理! ", Snackbar.LENGTH_LONG).show();
                     break;
                 case REOPEN_01:
                     // 大小不合适
                     confirmOrderVo.setDecision(DecisionEnum.REOPEN_01.getDecision());
+                    Snackbar.make(view, "异常处理只能处理一次! 如未处理您的问题! 请联系我们处理! ", Snackbar.LENGTH_LONG).show();
                     break;
                 case REOPEN_02:
                     // 门没开换柜门
                     confirmOrderVo.setDecision(DecisionEnum.REOPEN_02.getDecision());
+                    Snackbar.make(view, "异常处理只能处理一次! 如未处理您的问题! 请联系我们处理! ", Snackbar.LENGTH_LONG).show();
                     break;
                 case REOPEN_03:
                     // 门没开再开一次
                     confirmOrderVo.setDecision(DecisionEnum.REOPEN_03.getDecision());
+                    Snackbar.make(view, "异常处理只能处理一次! 如未处理您的问题! 请联系我们处理! ", Snackbar.LENGTH_LONG).show();
                     break;
                 default:
                     break;
             }
 
+            LocalStorage.getInstance().getSession().setException(false);
+            binding.issueCancel.setEnabled(false);
+            binding.issueDoorNotOpen.setEnabled(false);
+            binding.issueOpenAgain.setEnabled(false);
+            binding.issueSize.setEnabled(false);
+            binding.issueTakeCancel.setEnabled(false);
+
             ICSPClient.confirmOrder(LocalStorage.getInstance().getSession().getToken(), confirmOrderVo, new Callback() {
                 @Override
                 public void onFailure(@NotNull Call call, @NotNull IOException e) {

+ 5 - 0
app/src/main/java/com/emato/ich/fragment/InputInfoFragment.java

@@ -64,6 +64,11 @@ public class InputInfoFragment extends Fragment {
 
 
     public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
+
+        BaseUtils.disableEditText(binding.delivererPhone);
+        BaseUtils.disableEditText(binding.delivererPhoneConfirm);
+        BaseUtils.disableEditText(binding.mailNo);
+
         Bundle arguments = null;
         String sectionType = null;
         try {

+ 8 - 6
app/src/main/java/com/emato/ich/fragment/MainFragment.java

@@ -46,12 +46,14 @@ public class MainFragment extends Fragment {
                     InputStream is = (InputStream) new URL(url).getContent();
                     final Drawable d = Drawable.createFromStream(is, "src");
                     is.close();
-                    activity.runOnUiThread(new Runnable() {
-                        @Override
-                        public void run() {
-                            binding.fastTakeSend.setBackground(d);
-                        }
-                    });
+                    if (null != d) {
+                        activity.runOnUiThread(new Runnable() {
+                            @Override
+                            public void run() {
+                                binding.fastTakeSend.setBackground(d);
+                            }
+                        });
+                    }
                 } catch (IOException e) {
                     e.printStackTrace();
                 }

+ 4 - 0
app/src/main/java/com/emato/ich/fragment/SendFragment.java

@@ -54,6 +54,10 @@ public class SendFragment extends Fragment {
     public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
 
+
+        BaseUtils.disableEditText(binding.editTextTextPersonName4);
+        BaseUtils.disableEditText(binding.editTextTextPersonName5);
+
         binding.inputButtonConfirm.setOnClickListener(view1 -> {
             // 登录逻辑  editTextTextPersonName4 手机 editTextTextPersonName5 密码
             String sendPhone = binding.editTextTextPersonName4.getText().toString();

+ 49 - 43
app/src/main/java/com/emato/ich/fragment/TakeCodeFragment.java

@@ -59,6 +59,8 @@ public class TakeCodeFragment extends Fragment {
     public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
 
+        BaseUtils.disableEditText(binding.editTextTextPersonName6);
+
 //        binding.textView.setBackgroundResource(R.drawable.e_mp_qrcode_8x8_backup);
         MainActivity activity = (MainActivity) getActivity();
         String url = activity.getConfigMap().get(SystemConfigConstant.cabinet_take_object_qrcode_url);
@@ -141,52 +143,56 @@ public class TakeCodeFragment extends Fragment {
         binding.takeInputButtonConfirm.setOnClickListener(view1 -> {
             // TODO 取件逻辑
             String takeParcelCode = binding.editTextTextPersonName6.getText().toString();
-            TakeParcelVo takeParcelVo = new TakeParcelVo();
-            takeParcelVo.setClientId(BaseUtils.getClientId());
-            takeParcelVo.setPickUp(takeParcelCode);
-            takeParcelVo.setReopen("0");
-            ICSPClient.takeParcel("", takeParcelVo, new Callback() {
-                @Override
-                public void onFailure(@NotNull Call call, @NotNull IOException e) {
-                    // TODO 取件接口请求失败逻辑处理
-                    Snackbar.make(view, "取件失败!网络异常!", Snackbar.LENGTH_LONG).show();
-                    Log.e(TAG, "onFailure: 取件请求失败!", e);
-                }
-
-                @Override
-                public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
-                    // TODO 返回锁板和锁id, 开柜门
-                    getActivity().runOnUiThread(() -> {
-                        String parseResponse = ICSPClient.isSuccessfulAndParseResponse(response);
-                        try {
-                            ObjectMapper objectMapper = new ObjectMapper();
-                            ResponseData responseData = null;
+            if (null != takeParcelCode && !"".equals(takeParcelCode.trim()) && takeParcelCode.length() > 0) {
+                TakeParcelVo takeParcelVo = new TakeParcelVo();
+                takeParcelVo.setClientId(BaseUtils.getClientId());
+                takeParcelVo.setPickUp(takeParcelCode);
+                takeParcelVo.setReopen("0");
+                ICSPClient.takeParcel("", takeParcelVo, new Callback() {
+                    @Override
+                    public void onFailure(@NotNull Call call, @NotNull IOException e) {
+                        // TODO 取件接口请求失败逻辑处理
+                        Snackbar.make(view, "取件失败!网络异常!", Snackbar.LENGTH_LONG).show();
+                        Log.e(TAG, "onFailure: 取件请求失败!", e);
+                    }
+
+                    @Override
+                    public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
+                        // TODO 返回锁板和锁id, 开柜门
+                        getActivity().runOnUiThread(() -> {
+                            String parseResponse = ICSPClient.isSuccessfulAndParseResponse(response);
                             try {
-                                responseData = objectMapper.readValue(parseResponse, new TypeReference<ResponseData>() {
-                                });
-                                ICSPResponseCodeEnum.responseHint(view1, responseData);
-                            } catch (JsonProcessingException e) {
-                                Log.e(TAG, "onResponse: 解析取件开门响应信息失败! ", e);
+                                ObjectMapper objectMapper = new ObjectMapper();
+                                ResponseData responseData = null;
+                                try {
+                                    responseData = objectMapper.readValue(parseResponse, new TypeReference<ResponseData>() {
+                                    });
+                                    ICSPResponseCodeEnum.responseHint(view1, responseData);
+                                } catch (JsonProcessingException e) {
+                                    Log.e(TAG, "onResponse: 解析取件开门响应信息失败! ", e);
+                                } catch (RuntimeException e) {
+                                    Log.e(TAG, "onResponse: 未知错误! ", e);
+                                    Snackbar.make(view1, "未知错误!", Snackbar.LENGTH_LONG).show();
+                                }
+                                if (null != responseData && responseData.getCode().equals(ICSPResponseCodeEnum.OK.getCode())) {
+                                    // 开门
+                                    Log.i(TAG, "onResponse: 取件成功! ");
+                                    Snackbar.make(view1, "取件成功!", Snackbar.LENGTH_LONG).show();
+                                    Bundle bundle = new Bundle();
+                                    bundle.putString("takeParcelCode", takeParcelCode);
+                                    ((MainActivity) getActivity()).getBundleMap().put(TakeCodeFragment.class.getName(), bundle);
+                                    NavHostFragment.findNavController(TakeCodeFragment.this).navigate(R.id.action_takeCodeFragment_to_takeSuccessFragment);
+                                }
                             } catch (RuntimeException e) {
-                                Log.e(TAG, "onResponse: 未知错误! ", e);
-                                Snackbar.make(view1, "未知错误!", Snackbar.LENGTH_LONG).show();
+                                Log.e(TAG, "onResponse: 取件失败! ", e);
+                                Snackbar.make(view1, "取件失败!", Snackbar.LENGTH_LONG).show();
                             }
-                            if (null != responseData && responseData.getCode().equals(ICSPResponseCodeEnum.OK.getCode())) {
-                                // 开门
-                                Log.i(TAG, "onResponse: 取件成功! ");
-                                Snackbar.make(view1, "取件成功!", Snackbar.LENGTH_LONG).show();
-                                Bundle bundle = new Bundle();
-                                bundle.putString("takeParcelCode", takeParcelCode);
-                                ((MainActivity) getActivity()).getBundleMap().put(TakeCodeFragment.class.getName(), bundle);
-                                NavHostFragment.findNavController(TakeCodeFragment.this).navigate(R.id.action_takeCodeFragment_to_takeSuccessFragment);
-                            }
-                        } catch (RuntimeException e) {
-                            Log.e(TAG, "onResponse: 取件失败! ", e);
-                            Snackbar.make(view1, "取件失败!", Snackbar.LENGTH_LONG).show();
-                        }
-                    });
-                }
-            });
+                        });
+                    }
+                });
+            } else {
+                Snackbar.make(view, "取件失败!取件码不能为空!", Snackbar.LENGTH_LONG).show();
+            }
 
         });
         binding.returnBtn.setOnClickListener(view1 -> NavHostFragment.findNavController(TakeCodeFragment.this)

+ 2 - 0
app/src/main/java/com/emato/ich/fragment/TakeSuccessFragment.java

@@ -83,6 +83,8 @@ public class TakeSuccessFragment extends Fragment {
 
         binding.reOpenCabinetBtn.setOnClickListener(view1 -> {
 
+            binding.reOpenCabinetBtn.setEnabled(false);
+
             // TODO 取件逻辑
             String takeParcelCode = null;
             MainActivity activity = null;

+ 13 - 0
app/src/main/java/com/emato/ich/local/LocalStorage.java

@@ -64,6 +64,11 @@ public class LocalStorage {
 
         private int expiryTime = 15;
 
+        /**
+         * 新增字段 只能做一次异常处理, 点击异常处理的 异常事件按钮 后该值为false
+         */
+        private boolean exception = true;
+
         private TimeUnit timeUnit = TimeUnit.MINUTES;
 
         public String getPhone() {
@@ -105,5 +110,13 @@ public class LocalStorage {
         public void setTimeUnit(TimeUnit timeUnit) {
             this.timeUnit = timeUnit;
         }
+
+        public boolean getException() {
+            return exception;
+        }
+
+        public void setException(boolean exception) {
+            this.exception = exception;
+        }
     }
 }

+ 1 - 1
app/src/main/java/com/emato/ich/update/APKUpdateDownload.java

@@ -55,7 +55,7 @@ public class APKUpdateDownload {
                     @Override
                     public void onInstallSuccess() {
                         // TODO 重启应用 重启失败? 一直重启?
-                        PackageManagerCompat.restartApp(context);
+//                        PackageManagerCompat.restartApp(context);
                     }
                 });
             }

+ 1 - 1
app/src/main/java/com/emato/ich/update/InstallResultReceiver.java

@@ -16,7 +16,7 @@ public class InstallResultReceiver extends BroadcastReceiver {
             final int status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS,PackageInstaller.STATUS_FAILURE);
             if (status == PackageInstaller.STATUS_SUCCESS) {
                 // TODO 安装成功 启动应用
-                PackageManagerCompat.restartApp(context);
+//                PackageManagerCompat.restartApp(context);
             } else {
                 // 失败
                 Log.e(TAG, "onReceive: 自动安装失败! ");

+ 17 - 17
app/src/main/java/com/emato/ich/update/PackageManagerCompat.java

@@ -67,10 +67,10 @@ public class PackageManagerCompat {
 
             int sessionId = createSession(packageInstaller, sessionParams);
             if (sessionId != -1) {
-//                boolean copySuccess = copyInstallFile(packageInstaller, sessionId, apkFilePath, listener);
-//                if (copySuccess) {
+                boolean copySuccess = copyInstallFile(packageInstaller, sessionId, apkFilePath, listener);
+                if (copySuccess) {
                     execInstallCommand(context, packageInstaller, sessionId, listener);
-//                }
+                }
             }
             Log.i(TAG, "install: 应用程序安装完成! " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
         } catch (Exception e) {
@@ -148,18 +148,18 @@ public class PackageManagerCompat {
      * 重启
      * @param context   应用上下文
      */
-    public static void restartApp(Context context) {
-        Log.i(TAG, "restartApp: 应用程序重启中! 日期=====>" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
-        Intent intent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
-        PendingIntent restartIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT);
-        AlarmManager mgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
-
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {// 6.0及以上
-            mgr.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 10000, restartIntent);
-
-        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {// 4.4及以上
-            mgr.setExact(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 10000, restartIntent);
-        }
-        Log.i(TAG, "restartApp: 应用程序重启完成! 日期=====>" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
-    }
+//    public static void restartApp(Context context) {
+//        Log.i(TAG, "restartApp: 应用程序重启中! 日期=====>" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+//        Intent intent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
+//        PendingIntent restartIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT);
+//        AlarmManager mgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
+//
+//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {// 6.0及以上
+//            mgr.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 10000, restartIntent);
+//
+//        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {// 4.4及以上
+//            mgr.setExact(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 10000, restartIntent);
+//        }
+//        Log.i(TAG, "restartApp: 应用程序重启完成! 日期=====>" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+//    }
 }

+ 28 - 0
app/src/main/java/com/emato/ich/utils/BaseUtils.java

@@ -11,10 +11,12 @@ import android.os.Build;
 import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
+import android.text.InputType;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.View;
 import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
 
 import androidx.core.app.ActivityCompat;
 import androidx.core.content.ContextCompat;
@@ -263,5 +265,31 @@ public class BaseUtils {
 
     }
 
+    public static void disableEditText(EditText editText) {
+
+        if (Build.VERSION.SDK_INT <= 10) {
+            editText.setInputType(InputType.TYPE_NULL);
+        } else {
+            Class<EditText> editTextClass = EditText.class;
+
+            Method method;
+            try {
+                method = editTextClass.getMethod("setShowSoftInputOnFocus", boolean.class);
+                method.setAccessible(true);
+                method.invoke(editText, false);
+            } catch (Exception e) {
+
+            }
+
+            try {
+                method = editTextClass.getMethod("setSoftInputShownOnFocus", boolean.class);
+                method.setAccessible(true);
+                method.invoke(editText, false);
+            } catch (Exception e) {
+
+            }
+        }
+
+    }
 
 }

BIN
app/src/main/res/drawable/top_image.jpg


+ 13 - 4
app/src/main/res/layout/activity_main.xml

@@ -8,10 +8,19 @@
     android:focusable="true"
     android:focusableInTouchMode="true">
 
-    <com.google.android.material.appbar.AppBarLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:theme="@style/Theme.Ichandroid.AppBarOverlay"/>
+<!--    <com.google.android.material.appbar.AppBarLayout-->
+<!--        android:layout_width="match_parent"-->
+<!--        android:layout_height="wrap_content"-->
+<!--        android:theme="@style/Theme.Ichandroid.AppBarOverlay">-->
+
+<!--        <androidx.appcompat.widget.Toolbar-->
+<!--            android:id="@+id/toolbar"-->
+<!--            android:layout_width="match_parent"-->
+<!--            android:layout_height="?attr/actionBarSize"-->
+<!--            android:background="?attr/colorPrimary"-->
+<!--            app:popupTheme="@style/Theme.Ichandroid.PopupOverlay" />-->
+
+<!--    </com.google.android.material.appbar.AppBarLayout>-->
 
     <include layout="@layout/content_main" />
 

+ 3 - 2
app/src/main/res/layout/content_main.xml

@@ -26,8 +26,9 @@
 
     <ImageView
         android:id="@+id/imageView"
-        android:layout_width="320dp"
-        android:layout_height="260dp"
+        android:layout_width="360dp"
+        android:layout_height="280dp"
+        android:scaleType="fitXY"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintHorizontal_bias="0.0"
         app:layout_constraintStart_toStartOf="parent"

+ 8 - 8
app/src/main/res/layout/fragment_main.xml

@@ -7,8 +7,8 @@
         android:id="@+id/fast_take_send_bg"
         android:layout_width="160dp"
         android:layout_height="250dp"
-        android:layout_x="145dp"
-        android:layout_y="283dp"
+        android:layout_x="162dp"
+        android:layout_y="314dp"
         android:background="@drawable/textview_border"
         android:gravity="center_horizontal"
         android:paddingTop="15dp"
@@ -19,8 +19,8 @@
         android:id="@+id/send_btn"
         android:layout_width="120dp"
         android:layout_height="70dp"
-        android:layout_x="12dp"
-        android:layout_y="332dp"
+        android:layout_x="29dp"
+        android:layout_y="363dp"
         android:background="@drawable/button_radius"
         android:text="@string/send_btn"
         android:textSize="20sp"
@@ -30,8 +30,8 @@
         android:id="@+id/take_btn"
         android:layout_width="120dp"
         android:layout_height="70dp"
-        android:layout_x="12dp"
-        android:layout_y="432dp"
+        android:layout_x="29dp"
+        android:layout_y="463dp"
         android:background="@drawable/button_radius"
         android:text="@string/take_btn"
         android:textSize="20sp"
@@ -41,8 +41,8 @@
         android:id="@+id/fast_take_send"
         android:layout_width="134dp"
         android:layout_height="135dp"
-        android:layout_x="157dp"
-        android:layout_y="340dp"
+        android:layout_x="174dp"
+        android:layout_y="371dp"
         android:background="@drawable/e_mp_qrcode_8x8_backup" />
 
 

+ 28 - 28
app/src/main/res/layout/fragment_send_info_confirm.xml

@@ -7,28 +7,18 @@
         android:id="@+id/open_cabinet_hint1"
         android:layout_width="200dp"
         android:layout_height="50dp"
-        android:layout_x="61dp"
-        android:layout_y="245dp"
+        android:layout_x="65dp"
+        android:layout_y="281dp"
         android:gravity="center"
         android:text="@string/open_cabinet_hint_ok"
         android:textSize="30dp" />
 
     <Button
-        android:id="@+id/already_send"
-        android:layout_width="80dp"
-        android:layout_height="40dp"
-        android:layout_x="61dp"
-        android:layout_y="475dp"
-        android:background="@drawable/button_radius"
-        android:text="@string/already_send"
-        android:textSize="12dp" />
-
-    <Button
         android:id="@+id/none_send"
         android:layout_width="80dp"
         android:layout_height="40dp"
-        android:layout_x="181dp"
-        android:layout_y="475dp"
+        android:layout_x="185dp"
+        android:layout_y="511dp"
         android:background="@drawable/button_radius"
         android:text="@string/none_send"
         android:textSize="12dp" />
@@ -37,8 +27,8 @@
         android:id="@+id/take_number_hint"
         android:layout_width="100dp"
         android:layout_height="40dp"
-        android:layout_x="61dp"
-        android:layout_y="435dp"
+        android:layout_x="65dp"
+        android:layout_y="471dp"
         android:gravity="center"
         android:text="@string/take_number_hint"
         android:textSize="15dp" />
@@ -47,8 +37,8 @@
         android:id="@+id/open_cabinet_hint2"
         android:layout_width="200dp"
         android:layout_height="50dp"
-        android:layout_x="61dp"
-        android:layout_y="345dp"
+        android:layout_x="65dp"
+        android:layout_y="381dp"
         android:gravity="center"
         android:text="@string/open_cabinet_hint"
         android:textSize="15dp" />
@@ -57,8 +47,8 @@
         android:id="@+id/take_no_hint"
         android:layout_width="100dp"
         android:layout_height="40dp"
-        android:layout_x="61dp"
-        android:layout_y="395dp"
+        android:layout_x="65dp"
+        android:layout_y="431dp"
         android:gravity="center"
         android:text="@string/take_no_hint"
         android:textSize="15dp" />
@@ -67,8 +57,8 @@
         android:id="@+id/take_no"
         android:layout_width="100dp"
         android:layout_height="40dp"
-        android:layout_x="161dp"
-        android:layout_y="395dp"
+        android:layout_x="165dp"
+        android:layout_y="431dp"
         android:gravity="center"
         android:text="@string/take_no"
         android:textSize="15dp" />
@@ -77,8 +67,8 @@
         android:id="@+id/take_number"
         android:layout_width="100dp"
         android:layout_height="40dp"
-        android:layout_x="161dp"
-        android:layout_y="435dp"
+        android:layout_x="165dp"
+        android:layout_y="471dp"
         android:gravity="center"
         android:text="@string/take_number"
         android:textSize="15dp" />
@@ -87,8 +77,8 @@
         android:id="@+id/open_cabinet_no"
         android:layout_width="200dp"
         android:layout_height="50dp"
-        android:layout_x="61dp"
-        android:layout_y="295dp"
+        android:layout_x="65dp"
+        android:layout_y="331dp"
         android:gravity="center"
         android:text="@string/open_cabinet_no"
         android:textColor="@color/cardview_dark_background"
@@ -98,10 +88,20 @@
         android:id="@+id/exception_btn"
         android:layout_width="80dp"
         android:layout_height="40dp"
-        android:layout_x="-12dp"
-        android:layout_y="249dp"
+        android:layout_x="-8dp"
+        android:layout_y="285dp"
         android:background="@drawable/button_radius"
         android:text="@string/exception_btn"
         android:textSize="8dp" />
 
+    <Button
+        android:id="@+id/already_send"
+        android:layout_width="80dp"
+        android:layout_height="40dp"
+        android:layout_x="65dp"
+        android:layout_y="511dp"
+        android:background="@drawable/button_radius"
+        android:text="@string/already_send"
+        android:textSize="12dp" />
+
 </AbsoluteLayout>

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

@@ -17,7 +17,7 @@
         android:id="@+id/send_confirm_btn"
         android:layout_width="60dp"
         android:layout_height="60dp"
-        android:layout_x="100dp"
+        android:layout_x="30dp"
         android:layout_y="360dp"
         android:background="@drawable/button_radius"
         android:text="@string/send_confirm"
@@ -27,7 +27,7 @@
         android:id="@+id/exception_handle_btn"
         android:layout_width="60dp"
         android:layout_height="60dp"
-        android:layout_x="30dp"
+        android:layout_x="100dp"
         android:layout_y="360dp"
         android:background="@drawable/button_radius"
         android:text="@string/exception_handle"

+ 34 - 32
app/src/main/res/layout/fragment_take.xml

@@ -3,64 +3,66 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent">
 
-    <Button
-        android:id="@+id/return_btn"
-        android:layout_width="60dp"
-        android:layout_height="30dp"
-        android:layout_x="25dp"
-        android:layout_y="494dp"
-        android:background="@drawable/button_radius"
-        android:text="@string/return_btn"
-        android:textSize="8dp" />
-
-    <Button
-        android:id="@+id/to_input_take_code_btn"
-        android:layout_width="130dp"
-        android:layout_height="50dp"
-        android:layout_x="180dp"
-        android:layout_y="404dp"
-        android:background="@drawable/button_radius"
-        android:text="@string/android_take"
-        android:textSize="20dp" />
-
     <TextView
         android:id="@+id/fast_take_send_bg1"
         android:layout_width="160dp"
         android:layout_height="250dp"
-        android:layout_x="9dp"
-        android:layout_y="238dp"
+        android:layout_x="15dp"
+        android:layout_y="295dp"
         android:background="@drawable/textview_border"
         android:gravity="center_horizontal"
         android:paddingTop="15dp"
         android:text="@string/wx_scan_take"
         android:textSize="20dp" />
 
+    <Button
+        android:id="@+id/return_btn"
+        android:layout_width="60dp"
+        android:layout_height="30dp"
+        android:layout_x="31dp"
+        android:layout_y="551dp"
+        android:background="@drawable/button_radius"
+        android:text="@string/return_btn"
+        android:textSize="8dp" />
+
     <TextView
         android:id="@+id/textView3"
-        android:layout_width="130dp"
+        android:layout_width="140dp"
         android:layout_height="50dp"
-        android:layout_x="180dp"
-        android:layout_y="337dp"
+        android:layout_x="186dp"
+        android:layout_y="353dp"
         android:gravity="center"
         android:text="@string/prompt_word_bottom"
-        android:textSize="12dp" />
+        android:textSize="15dp"
+        android:textStyle="bold" />
 
     <TextView
         android:id="@+id/textView2"
-        android:layout_width="130dp"
+        android:layout_width="140dp"
         android:layout_height="50dp"
-        android:layout_x="180dp"
-        android:layout_y="275dp"
+        android:layout_x="186dp"
+        android:layout_y="309dp"
         android:gravity="center"
+        android:textStyle="bold"
         android:text="@string/prompt_word_top"
-        android:textSize="12dp" />
+        android:textSize="15dp" />
 
     <TextView
         android:id="@+id/textView"
         android:layout_width="134dp"
         android:layout_height="135dp"
-        android:layout_x="21dp"
-        android:layout_y="295dp"
+        android:layout_x="27dp"
+        android:layout_y="352dp"
         android:background="@drawable/e_mp_qrcode_8x8_backup" />
 
+    <Button
+        android:id="@+id/to_input_take_code_btn"
+        android:layout_width="130dp"
+        android:layout_height="50dp"
+        android:layout_x="186dp"
+        android:layout_y="461dp"
+        android:background="@drawable/button_radius"
+        android:text="@string/android_take"
+        android:textSize="20dp" />
+
 </AbsoluteLayout>

+ 81 - 81
app/src/main/res/layout/fragment_take_code.xml

@@ -5,154 +5,154 @@
     android:focusable="true"
     android:focusableInTouchMode="true">
 
-    <Button
-        android:id="@+id/return_btn"
-        android:layout_width="60dp"
-        android:layout_height="30dp"
-        android:layout_x="25dp"
-        android:layout_y="494dp"
-        android:background="@drawable/button_radius"
-        android:text="@string/return_btn"
-        android:textSize="8dp" />
-
     <TextView
         android:id="@+id/fast_take_send_bg1"
         android:layout_width="160dp"
         android:layout_height="250dp"
-        android:layout_x="3dp"
-        android:layout_y="240dp"
+        android:layout_x="14dp"
+        android:layout_y="317dp"
         android:background="@drawable/textview_border"
         android:gravity="center_horizontal"
         android:paddingTop="15dp"
         android:text="@string/wx_scan_take"
         android:textSize="20dp" />
 
+    <Button
+        android:id="@+id/take_input_button1"
+        android:layout_width="48dp"
+        android:layout_height="40dp"
+        android:layout_x="177dp"
+        android:layout_y="377dp"
+        android:text="@string/number_1"
+        android:textSize="10dp" />
+
     <TextView
         android:id="@+id/textView"
         android:layout_width="134dp"
         android:layout_height="135dp"
-        android:layout_x="17dp"
-        android:layout_y="297dp"
+        android:layout_x="28dp"
+        android:layout_y="374dp"
         android:background="@drawable/e_mp_qrcode_8x8_backup" />
 
     <Button
-        android:id="@+id/take_input_button2"
-        android:layout_width="48dp"
+        android:id="@+id/take_input_button_cancel"
+        android:layout_width="98dp"
         android:layout_height="40dp"
-        android:layout_x="216dp"
-        android:layout_y="300dp"
-        android:text="@string/number_2"
+        android:layout_x="227dp"
+        android:layout_y="467dp"
+        android:text="@string/cancel_btn"
         android:textSize="10dp" />
 
     <Button
-        android:id="@+id/take_input_button7"
+        android:id="@+id/take_input_button4"
         android:layout_width="48dp"
         android:layout_height="40dp"
-        android:layout_x="166dp"
-        android:layout_y="360dp"
-        android:text="@string/number_7"
+        android:layout_x="177dp"
+        android:layout_y="407dp"
+        android:text="@string/number_4"
         android:textSize="10dp" />
 
+    <EditText
+        android:id="@+id/editTextTextPersonName6"
+        android:layout_width="148dp"
+        android:layout_height="50dp"
+        android:layout_x="177dp"
+        android:layout_y="327dp"
+        android:ems="15"
+        android:hint="@string/input_take_code"
+        android:inputType="phone"
+        android:longClickable="false"
+        android:textSize="15dp" />
+
     <Button
-        android:id="@+id/take_input_button8"
+        android:id="@+id/take_input_button2"
         android:layout_width="48dp"
         android:layout_height="40dp"
-        android:layout_x="216dp"
-        android:layout_y="360dp"
-        android:text="@string/number_8"
+        android:layout_x="227dp"
+        android:layout_y="377dp"
+        android:text="@string/number_2"
         android:textSize="10dp" />
 
     <Button
-        android:id="@+id/take_input_button3"
+        android:id="@+id/take_input_button7"
         android:layout_width="48dp"
         android:layout_height="40dp"
-        android:layout_x="266dp"
-        android:layout_y="300dp"
-        android:text="@string/number_3"
+        android:layout_x="177dp"
+        android:layout_y="437dp"
+        android:text="@string/number_7"
         android:textSize="10dp" />
 
     <Button
-        android:id="@+id/take_input_button5"
+        android:id="@+id/take_input_button9"
         android:layout_width="48dp"
         android:layout_height="40dp"
-        android:layout_x="216dp"
-        android:layout_y="330dp"
-        android:text="@string/number_5"
+        android:layout_x="277dp"
+        android:layout_y="437dp"
+        android:text="@string/number_9"
         android:textSize="10dp" />
 
     <Button
-        android:id="@+id/take_input_button4"
+        android:id="@+id/take_input_button6"
         android:layout_width="48dp"
         android:layout_height="40dp"
-        android:layout_x="166dp"
-        android:layout_y="330dp"
-        android:text="@string/number_4"
+        android:layout_x="277dp"
+        android:layout_y="407dp"
+        android:text="@string/number_6"
         android:textSize="10dp" />
 
     <Button
-        android:id="@+id/take_input_button_cancel"
-        android:layout_width="98dp"
+        android:id="@+id/take_input_button3"
+        android:layout_width="48dp"
         android:layout_height="40dp"
-        android:layout_x="216dp"
-        android:layout_y="390dp"
-        android:text="@string/cancel_btn"
+        android:layout_x="277dp"
+        android:layout_y="377dp"
+        android:text="@string/number_3"
         android:textSize="10dp" />
 
     <Button
-        android:id="@+id/take_input_button0"
+        android:id="@+id/take_input_button8"
         android:layout_width="48dp"
         android:layout_height="40dp"
-        android:layout_x="166dp"
-        android:layout_y="390dp"
-        android:text="@string/number_0"
+        android:layout_x="227dp"
+        android:layout_y="437dp"
+        android:text="@string/number_8"
         android:textSize="10dp" />
 
     <Button
-        android:id="@+id/take_input_button_confirm"
-        android:layout_width="148dp"
+        android:id="@+id/take_input_button5"
+        android:layout_width="48dp"
         android:layout_height="40dp"
-        android:layout_x="166dp"
-        android:layout_y="420dp"
-        android:text="@string/confirm_btn"
+        android:layout_x="227dp"
+        android:layout_y="407dp"
+        android:text="@string/number_5"
         android:textSize="10dp" />
 
     <Button
-        android:id="@+id/take_input_button6"
-        android:layout_width="48dp"
-        android:layout_height="40dp"
-        android:layout_x="266dp"
-        android:layout_y="330dp"
-        android:text="@string/number_6"
-        android:textSize="10dp" />
+        android:id="@+id/return_btn"
+        android:layout_width="60dp"
+        android:layout_height="30dp"
+        android:layout_x="36dp"
+        android:layout_y="571dp"
+        android:background="@drawable/button_radius"
+        android:text="@string/return_btn"
+        android:textSize="8dp" />
 
     <Button
-        android:id="@+id/take_input_button9"
+        android:id="@+id/take_input_button0"
         android:layout_width="48dp"
         android:layout_height="40dp"
-        android:layout_x="266dp"
-        android:layout_y="360dp"
-        android:text="@string/number_9"
+        android:layout_x="177dp"
+        android:layout_y="467dp"
+        android:text="@string/number_0"
         android:textSize="10dp" />
 
     <Button
-        android:id="@+id/take_input_button1"
-        android:layout_width="48dp"
+        android:id="@+id/take_input_button_confirm"
+        android:layout_width="148dp"
         android:layout_height="40dp"
-        android:layout_x="166dp"
-        android:layout_y="300dp"
-        android:text="@string/number_1"
+        android:layout_x="177dp"
+        android:layout_y="497dp"
+        android:text="@string/confirm_btn"
         android:textSize="10dp" />
 
-    <EditText
-        android:id="@+id/editTextTextPersonName6"
-        android:layout_width="148dp"
-        android:layout_height="50dp"
-        android:layout_x="166dp"
-        android:layout_y="250dp"
-        android:ems="15"
-        android:hint="@string/input_take_code"
-        android:inputType="phone"
-        android:longClickable="false"
-        android:textSize="15dp" />
-
 </AbsoluteLayout>

+ 32 - 32
app/src/main/res/layout/fragment_take_success.xml

@@ -6,52 +6,32 @@
     android:focusableInTouchMode="true">
 
 
-    <Button
-        android:id="@+id/return_main_btn"
-        android:layout_width="60dp"
-        android:layout_height="30dp"
-        android:layout_x="25dp"
-        android:layout_y="494dp"
-        android:background="@drawable/button_radius"
-        android:text="@string/return_main_btn"
-        android:textSize="6dp" />
-
     <TextView
         android:id="@+id/open_cabinet_hint3"
         android:layout_width="200dp"
         android:layout_height="50dp"
         android:layout_x="61dp"
-        android:layout_y="254dp"
+        android:layout_y="298dp"
         android:gravity="center_horizontal"
         android:text="@string/open_cabinet_hint_ok"
         android:textSize="30dp" />
 
-    <TextView
-        android:id="@+id/open_cabinet_count_down_hint"
-        android:layout_width="200dp"
-        android:layout_height="50dp"
-        android:layout_x="62dp"
-        android:layout_y="364dp"
-        android:gravity="center"
-        android:textSize="15dp" />
-
-    <TextView
-        android:id="@+id/open_cabinet_hint_no"
-        android:layout_width="200dp"
-        android:layout_height="60dp"
-        android:layout_x="61dp"
-        android:layout_y="304dp"
-        android:gravity="center"
-        android:text="006"
-        android:textSize="50dp"
-        android:textStyle="bold" />
+    <Button
+        android:id="@+id/return_main_btn"
+        android:layout_width="60dp"
+        android:layout_height="30dp"
+        android:layout_x="25dp"
+        android:layout_y="506dp"
+        android:background="@drawable/button_radius"
+        android:text="@string/return_main_btn"
+        android:textSize="6dp" />
 
     <Button
         android:id="@+id/continue_take_btn"
         android:layout_width="80dp"
         android:layout_height="40dp"
         android:layout_x="182dp"
-        android:layout_y="420dp"
+        android:layout_y="464dp"
         android:background="@drawable/button_radius"
         android:text="@string/continue_take"
         android:textSize="10dp" />
@@ -61,9 +41,29 @@
         android:layout_width="80dp"
         android:layout_height="40dp"
         android:layout_x="62dp"
-        android:layout_y="420dp"
+        android:layout_y="464dp"
         android:background="@drawable/button_radius"
         android:text="@string/re_open_cabinet"
         android:textSize="10dp" />
 
+    <TextView
+        android:id="@+id/open_cabinet_count_down_hint"
+        android:layout_width="200dp"
+        android:layout_height="50dp"
+        android:layout_x="62dp"
+        android:layout_y="408dp"
+        android:gravity="center"
+        android:textSize="15dp" />
+
+    <TextView
+        android:id="@+id/open_cabinet_hint_no"
+        android:layout_width="200dp"
+        android:layout_height="60dp"
+        android:layout_x="61dp"
+        android:layout_y="348dp"
+        android:gravity="center"
+        android:text="006"
+        android:textSize="50dp"
+        android:textStyle="bold" />
+
 </AbsoluteLayout>

+ 4 - 0
app/src/main/res/xml/file_paths.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<paths>
+    <external-path path="." name="external_storage_root" />
+</paths>