Преглед изворни кода

修改设备id使用随机生成的时间id,同时升级版本到1.8

weizhengliang пре 3 година
родитељ
комит
dadb512da2

+ 1 - 1
app/build.gradle

@@ -8,7 +8,7 @@ android {
         minSdkVersion 15
         targetSdkVersion 30
         versionCode 1
-        versionName "1.7"
+        versionName "1.8"
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
     }
     buildTypes {

+ 7 - 1
app/src/main/java/com/example/informationkanban/InitActivity.java

@@ -49,6 +49,11 @@ public class InitActivity extends AppCompatActivity {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.init_layout);
 
+        if ("NULL".equals(NetFunctionConfig.getUUID())) {
+            String uuid = "UUID" + System.currentTimeMillis();
+            NetFunctionConfig.setUUID(uuid);
+        }
+
         tvMac = findViewById(R.id.textView_mac);
         tvIP = findViewById(R.id.textView_ip);
         tvServer = findViewById(R.id.textView_server_ip);
@@ -238,7 +243,8 @@ public class InitActivity extends AppCompatActivity {
             @Override
             public void run() {
                 if (tvMac != null && tvIP != null) {
-                    tvMac.setText("MAC地址: " + GetInformationUtils.getMacAddress(InitActivity.this));
+                    //tvMac.setText("MAC地址: " + GetInformationUtils.getMacAddress(InitActivity.this));
+                    tvMac.setText("设备ID: " + NetFunctionConfig.getUUID());
                     tvIP.setText("本机IP地址: " + GetInformationUtils.getLocalIP());
                     tvServer.setText("服务器IP: " + NetFunctionConfig.getServerIp() + ":" + NetFunctionConfig.getServerPort());
                 }

+ 2 - 1
app/src/main/java/com/example/informationkanban/MainActivity.java

@@ -43,7 +43,8 @@ public class MainActivity extends AppCompatActivity {
 //        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
         setContentView(R.layout.activity_main);
         init();
-        MAC = GetInformationUtils.getMacAddress(this);
+        //MAC = GetInformationUtils.getMacAddress(this);
+        MAC = NetFunctionConfig.getUUID();
         Log.e(TAG, "MAC地址 " + MAC);
         if (!TextUtils.isEmpty(MAC)) {
             accessTheWebpage();

+ 2 - 1
app/src/main/java/com/example/informationkanban/XwalkMainActivity.java

@@ -59,7 +59,8 @@ public class XwalkMainActivity extends XWalkActivity {
 
     @Override
     protected void onXWalkReady() {
-        MAC = GetInformationUtils.getMacAddress(this);
+        //MAC = GetInformationUtils.getMacAddress(this);
+        MAC = NetFunctionConfig.getUUID();
         Log.e(TAG, "MAC地址 " + MAC);
         if (TextUtils.isEmpty(MAC)) {
             Toast.makeText(this, "设备信息获取失败", Toast.LENGTH_LONG).show();

+ 10 - 0
app/src/main/java/com/example/informationkanban/utils/NetFunctionConfig.java

@@ -16,6 +16,8 @@ public class NetFunctionConfig {
 
     private static final String SERVER_PORT = "SERVER_PORT";
 
+    private static final String UUID = "UUID";
+
     public static void setWebviewType(int type) {
         getEditor().putInt(WEBVIEW_TYPE, type).apply();
     }
@@ -48,6 +50,14 @@ public class NetFunctionConfig {
         return getSP().getString(SERVER_PORT, "8100");
     }
 
+    public static void setUUID(String uuid) {
+        getEditor().putString(UUID, uuid).apply();
+    }
+
+    public static String getUUID() {
+        return getSP().getString(UUID, "NULL");
+    }
+
     private static SharedPreferences getSP() {
         return MyApplication.getInstance().getSharedPreferences(INFORMATION_KAN_BAN_KEY, Context.MODE_PRIVATE);
     }

+ 7 - 8
app/src/main/res/layout/init_layout.xml

@@ -53,6 +53,13 @@
             android:layout_marginLeft="20dp"
             android:text="进入设置"
             android:textSize="20sp"/>
+        <TextView
+            android:id="@+id/textView_version"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="20dp"
+            android:text="APP版本"
+            android:textSize="20sp" />
     </LinearLayout>
 
     <RadioGroup
@@ -94,12 +101,4 @@
         android:text="倒计时"
         android:textColor="#ff0000"
         android:textSize="28sp" />
-
-    <TextView
-        android:id="@+id/textView_version"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginTop="40dp"
-        android:text="APP版本"
-        android:textSize="28sp" />
 </LinearLayout>