Browse Source

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

李慧明 3 năm trước cách đây
mục cha
commit
dbc83a6537

+ 1 - 1
app/src/main/AndroidManifest.xml

@@ -15,7 +15,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"

+ 15 - 5
app/src/main/java/com/emato/ich/MainActivity.java

@@ -4,6 +4,7 @@ import android.content.pm.ActivityInfo;
 import android.os.Build;
 import android.os.Bundle;
 
+import com.cherry.sdk.controller.BuildConfig;
 import com.cherry.sdk.controller.callback.CmdCallback;
 import com.cherry.sdk.controller.callback.OnScanListen;
 import com.cherry.sdk.controller.utils.ScanGunKeyEventHelper;
@@ -50,6 +51,7 @@ import com.emato.ich.databinding.ActivityMainBinding;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.WindowManager;
+import android.widget.ArrayAdapter;
 
 import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
 import org.eclipse.paho.client.mqttv3.IMqttMessageListener;
@@ -89,15 +91,23 @@ public class MainActivity extends AppCompatActivity  {
 
         binding = ActivityMainBinding.inflate(getLayoutInflater());
         setContentView(binding.getRoot());
-        setSupportActionBar(binding.toolbar);
-        NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main);
-        appBarConfiguration = new AppBarConfiguration.Builder(navController.getGraph()).build();
-        NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
+//        setSupportActionBar(binding.toolbar);
+//        NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main);
+//        appBarConfiguration = new AppBarConfiguration.Builder(navController.getGraph()).build();
+//        NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
 
         // 自动重启
         UncaughtExceptionHandlerImpl.getInstance().init(getApplication(), BuildConfig.DEBUG, true, 1000, MainActivity.class);
 
-        // 获取系统配置
+//        DeviceControl.unlockLocker(4, 2, new CmdCallback() {
+//            @Override
+//            public void onMessage(int i, String... strings) {
+//                Log.i(TAG, "onMessage: ===============================>" + i + Arrays.asList(strings));
+//            }
+//        });
+
+
+//         获取系统配置
         ICSPClient.getSystemConfig("", BaseUtils.getClientId(), new Callback() {
             @Override
             public void onFailure(@NotNull Call call, @NotNull IOException e) {

+ 2 - 1
app/src/main/java/com/emato/ich/api/ICSPConstant.java

@@ -2,7 +2,8 @@ package com.emato.ich.api;
 
 public class ICSPConstant {
 
-    public static final String ICSP_SERVICE = "http://68rfyvi.nat.ipyingshe.com";
+    public static final String ICSP_SERVICE = "http://icsp-api.ds-bay.com";
+//    public static final String ICSP_SERVICE = "http://68rfyvi.nat.ipyingshe.com";
 //    public static final String ICSP_SERVICE = "http://icsp-testend.ds-bay.com";
 
     public static final String MQTT_SERVER_ADDRESS = "tcp://8.135.102.238:1883";

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

@@ -225,12 +225,17 @@ public class DeviceControl {
 
                 try {
                     List<Cabinet.CabinetLocker> lockInfos = objectMapper.readValue(s, javaType);
-                    lockInfos = lockInfos.stream().filter(lockInfo -> lockInfo.getLocked().equals("true")).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);
                     // TODO 查询锁版本
-
+//                    lockPlateInfo.setType("类型");
                     lockPlateInfos.add(lockPlateInfo);
                 } catch (JsonProcessingException e) {
                     Log.e(TAG, new Date() + "queryCabinetInfo: JSON转换对象失败!", e);

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

@@ -14,6 +14,8 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 import okhttp3.Call;
 import okhttp3.Callback;
@@ -47,7 +49,7 @@ public class APKUpdateDownload {
                 PackageManagerCompat.install(context, absolutePath, context.getPackageManager(), new OnInstallListener() {
                     @Override
                     public void onInstallException(Exception e) {
-                        Log.e(TAG, "onInstallException: 安装出现异常! ", e);
+                        Log.e(TAG, "onInstallException: 安装出现异常! " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()), e);
                     }
 
                     @Override

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

@@ -58,6 +58,9 @@ public class PackageManagerCompat {
         try {
             Log.i(TAG, "install: 应用程序开始安装! " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
             File apkFile = new File(apkFilePath);
+            if (!apkFile.exists()) {
+                throw new RuntimeException("文件不存在! 更新失败! ");
+            }
             PackageInstaller packageInstaller = packageManager.getPackageInstaller();
             PackageInstaller.SessionParams sessionParams = new PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL);
             sessionParams.setSize(apkFile.length());
@@ -69,10 +72,10 @@ public class PackageManagerCompat {
                     execInstallCommand(context, packageInstaller, sessionId, listener);
 //                }
             }
+            Log.i(TAG, "install: 应用程序安装完成! " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
         } catch (Exception e) {
             listener.onInstallException(e);
         }
-        Log.i(TAG, "install: 应用程序安装完成! " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
     }
 
     @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)

+ 1 - 1
app/src/main/res/drawable/button_radius.xml

@@ -4,5 +4,5 @@
     android:shape="rectangle">
     <!-- 设置按钮的四个角为弧形 -->
     <!-- android:radius 弧形的半径 -->
-    <corners android:radius="35dip" />
+    <corners android:radius="20dip" />
 </shape>

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

@@ -4,21 +4,14 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    tools:context=".MainActivity">
+    tools:context=".MainActivity"
+    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">
-
-        <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>
+        android:theme="@style/Theme.Ichandroid.AppBarOverlay"/>
 
     <include layout="@layout/content_main" />
 

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

@@ -3,7 +3,9 @@
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    app:layout_behavior="@string/appbar_scrolling_view_behavior">
+    app:layout_behavior="@string/appbar_scrolling_view_behavior"
+    android:focusable="true"
+    android:focusableInTouchMode="true">
 
     <fragment
         android:id="@+id/nav_host_fragment_content_main"

+ 3 - 1
app/src/main/res/layout/fragment_choose_cabinet.xml

@@ -1,7 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
 <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
+    android:layout_height="match_parent"
+    android:focusable="true"
+    android:focusableInTouchMode="true">
 
     <Button
         android:id="@+id/return_btn"

+ 3 - 1
app/src/main/res/layout/fragment_exception.xml

@@ -1,7 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
 <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
+    android:layout_height="match_parent"
+    android:focusable="true"
+    android:focusableInTouchMode="true">
 
     <Button
         android:id="@+id/return_btn"

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

@@ -4,49 +4,49 @@
     android:layout_height="match_parent">
 
     <TextView
+        android:id="@+id/fast_take_send"
+        android:layout_width="134dp"
+        android:layout_height="135dp"
+        android:layout_x="159dp"
+        android:layout_y="305dp"
+        android:background="@drawable/e_mp_qrcode_8x8_backup" />
+
+    <TextView
         android:id="@+id/fast_take_send_bg"
-        android:layout_width="500dp"
-        android:layout_height="800dp"
-        android:layout_x="552dp"
-        android:layout_y="891dp"
+        android:layout_width="160dp"
+        android:layout_height="250dp"
+        android:layout_x="147dp"
+        android:layout_y="248dp"
         android:background="@drawable/textview_border"
         android:gravity="center_horizontal"
         android:paddingTop="15dp"
         android:text="@string/fast_take_or_send"
-        android:textSize="50sp" />
+        android:textSize="20sp" />
+
+    <Button
+        android:id="@+id/take_btn"
+        android:layout_width="120dp"
+        android:layout_height="70dp"
+        android:layout_x="16dp"
+        android:layout_y="402dp"
+        android:background="@drawable/button_radius"
+        android:text="@string/take_btn"
+        android:textSize="20sp"
+        android:textStyle="bold" />
 
     <Button
         android:id="@+id/send_btn"
-        android:layout_width="450dp"
-        android:layout_height="250dp"
-        android:layout_x="48dp"
-        android:layout_y="891dp"
+        android:layout_width="120dp"
+        android:layout_height="70dp"
+        android:layout_x="16dp"
+        android:layout_y="302dp"
         android:background="@drawable/button_radius"
         android:shadowColor="@color/black"
         android:shadowDx="10"
         android:shadowDy="40"
         android:text="@string/send_btn"
-        android:textSize="30sp"
+        android:textSize="20sp"
         android:textStyle="bold" />
 
-    <Button
-        android:id="@+id/take_btn"
-        android:layout_width="450dp"
-        android:layout_height="250dp"
-        android:layout_x="48dp"
-        android:layout_y="1431dp"
-        android:background="@drawable/button_radius"
-        android:text="@string/take_btn"
-        android:textSize="30sp"
-        android:textStyle="bold" />
-
-    <TextView
-        android:id="@+id/fast_take_send"
-        android:layout_width="460dp"
-        android:layout_height="460dp"
-        android:layout_x="573dp"
-        android:layout_y="1055dp"
-        android:background="@drawable/e_mp_qrcode_8x8_backup" />
-
 
 </AbsoluteLayout>

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

@@ -123,21 +123,21 @@
         android:textSize="40dp" />
 
     <Button
-        android:id="@+id/input_button_confirm"
-        android:layout_width="470dp"
+        android:id="@+id/input_button7"
+        android:layout_width="150dp"
         android:layout_height="80dp"
         android:layout_x="424dp"
-        android:layout_y="1413dp"
-        android:text="@string/confirm_btn"
+        android:layout_y="1253dp"
+        android:text="@string/number_7"
         android:textSize="40dp" />
 
     <Button
-        android:id="@+id/input_button7"
-        android:layout_width="150dp"
+        android:id="@+id/input_button_confirm"
+        android:layout_width="470dp"
         android:layout_height="80dp"
         android:layout_x="424dp"
-        android:layout_y="1253dp"
-        android:text="@string/number_7"
+        android:layout_y="1413dp"
+        android:text="@string/confirm_btn"
         android:textSize="40dp" />
 
     <EditText