|
|
QZ¾ò½ðÔÉúUI½çÃæ
- /**
- * QZ¾ò½ð - ÅäÖùÜÀí½çÃæ
- *½»Á÷QQȺ: 711841924 (Ⱥһ) / 528816639 (°²×¿ÄÚ²âȺ)
- * ·ÂÕÕ½ØÍ¼½çÃæÉè¼Æ£º°æ±¾ºÅ + ¿ªÊ¼ÔËÐа´Å¥ + ²Ù×÷°´Å¥ + »ù´¡ÅäÖÃ
- */
- var ac = new activity();
- ac.loadSXML(`
- <ScrollView
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="#f5f5f5">
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:padding="16dp">
- <!-- ¶¥²¿±êÌâÀ¸ -->
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="QZ¾ò½ð"
- android:textSize="24sp"
- android:textStyle="bold"
- android:textColor="#4A90E2"
- android:gravity="center"
- android:layout_marginBottom="15dp"/>
- <!-- °æ±¾ºÅºÍ¿ªÊ¼ÔËÐа´Å¥ -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:gravity="center"
- android:layout_marginBottom="15dp">
- <TextView
- android:id="@+id/tvVersion"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="°æ±¾ºÅ: 3.32"
- android:textSize="16sp"
- android:textColor="#ffffff"
- android:background="#9E9E9E"
- android:padding="10dp"
- android:layout_marginRight="15dp"/>
- <Button
- android:id="@+id/btnStart"
- android:layout_width="80dp"
- android:layout_height="80dp"
- android:text="¿ªÊ¼\nÔËÐÐ"
- android:textSize="16sp"
- android:textColor="#ffffff"
- android:background="#4CAF50"
- android:gravity="center"
- android:padding="5dp"/>
- </LinearLayout>
- <!-- ²Ù×÷°´Å¥ÐÐ -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:layout_marginBottom="20dp">
- <Button
- android:id="@+id/btnStop"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="Í£Ö¹ÔËÐÐ"
- android:textColor="#ffffff"
- android:backgroundTint="#F44336"
- android:layout_marginRight="5dp"
- android:padding="8dp"/>
- <Button
- android:id="@+id/btnSave"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="±£´æÅäÖÃ"
- android:textColor="#ffffff"
- android:backgroundTint="#3F51B5"
- android:layout_marginLeft="5dp"
- android:layout_marginRight="5dp"
- android:padding="8dp"/>
- <Button
- android:id="@+id/btnResetForm"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="ÖØÖÃ±íµ¥"
- android:textColor="#ffffff"
- android:backgroundTint="#FF9800"
- android:layout_marginLeft="5dp"
- android:layout_marginRight="5dp"
- android:padding="8dp"/>
- <Button
- android:id="@+id/btnResetExecutor"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="ÖØÖÃÖ´ÐÐÆ÷"
- android:textColor="#ffffff"
- android:backgroundTint="#673AB7"
- android:layout_marginLeft="5dp"
- android:padding="8dp"/>
- </LinearLayout>
- <!-- »ù´¡ÅäÖÃÇøÓò -->
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="»ù´¡ÅäÖÃ"
- android:textSize="20sp"
- android:textStyle="bold"
- android:textColor="#333333"
- android:layout_marginBottom="15dp"/>
- <!-- É豸Ãû³Æ -->
- <EditText
- android:id="@+id/etDeviceName"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:hint="ÇëÊäÈëÉ豸Ãû³Æ"
- android:padding="12dp"
- android:backgroundTint="#4CAF50"
- android:layout_marginBottom="5dp"/>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="É豸Ãû³Æ£¬ÍÆËÍÏûÏ¢µÄʱºò·½±ãÇø·ÖÉ豸"
- android:textSize="12sp"
- android:textColor="#999999"
- android:layout_marginBottom="15dp"/>
- <!-- HIDÓ²¼þÀàÐÍ -->
- <Button
- android:id="@+id/spinnerHIDType"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="ffChUSB°æ"
- android:backgroundTint="#E0E0E0"
- android:textColor="#333333"
- android:textSize="16sp"
- android:gravity="left|center_vertical"
- android:padding="12dp"
- android:layout_marginBottom="5dp"/>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="Ñ¡ÔñHIDÓ²¼þÀàÐÍ"
- android:textSize="12sp"
- android:textColor="#999999"
- android:layout_marginBottom="15dp"/>
- <!-- UIDÊäÈë¿ò -->
- <EditText
- android:id="@+id/etUID"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:hint="ÇëÊäÈëwxPusherµÄUID"
- android:padding="12dp"
- android:backgroundTint="#4CAF50"
- android:layout_marginBottom="5dp"/>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="wxPusherµÄUID£¬ÓÃÓÚ΢ÐÅÍÆËÍÏûÏ¢"
- android:textSize="12sp"
- android:textColor="#999999"
- android:layout_marginBottom="15dp"/>
- <!-- ¶¨Ê±ÍÆËÍʱ¼ä -->
- <EditText
- android:id="@+id/etPushTime"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:hint="ÀýÈç: 8,12,18"
- android:padding="12dp"
- android:backgroundTint="#4CAF50"
- android:layout_marginBottom="5dp"/>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="ÿÈÕ¶¨Ê±ÍÆËÍʱ¼ä£¨Ð¡Ê±,¸ô¿ª£©"
- android:textSize="12sp"
- android:textColor="#999999"
- android:layout_marginBottom="15dp"/>
- <!-- ÇåÀíºǫ́ÀàÐÍ -->
- <Button
- android:id="@+id/spinnerCleanupType"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="»¬¶¯"
- android:backgroundTint="#E0E0E0"
- android:textColor="#333333"
- android:textSize="16sp"
- android:gravity="left|center_vertical"
- android:padding="12dp"
- android:layout_marginBottom="5dp"/>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="ÇåÀíºǫ́ÀàÐÍ"
- android:textSize="12sp"
- android:textColor="#999999"
- android:layout_marginBottom="15dp"/>
- <!-- ×óÓÒ»¬¶¯Ñ¡Ïî -->
- <Button
- android:id="@+id/spinnerSlideDirection"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="×óÓÒ»¬¶¯"
- android:backgroundTint="#E0E0E0"
- android:textColor="#333333"
- android:textSize="16sp"
- android:gravity="left|center_vertical"
- android:padding="12dp"
- android:layout_marginBottom="5dp"/>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="»¬¶¯·½Ïò"
- android:textSize="12sp"
- android:textColor="#999999"
- android:layout_marginBottom="15dp"/>
- <!-- ÈÕÖ¾ÏÔÊ¾ÇøÓò -->
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="ÔËÐÐÈÕÖ¾"
- android:textSize="18sp"
- android:textStyle="bold"
- android:textColor="#333333"
- android:layout_marginTop="10dp"
- android:layout_marginBottom="10dp"/>
- <TextView
- android:id="@+id/tvLog"
- android:layout_width="match_parent"
- android:layout_height="200dp"
- android:text="ÈÕÖ¾½«ÏÔʾÔÚÕâÀï"
- android:textSize="14sp"
- android:textColor="#666666"
- android:padding="10dp"
- android:background="#ffffff"
- android:gravity="left|top"
- android:scrollbars="vertical"/>
- </LinearLayout>
- </ScrollView>
- `);
- // »ñÈ¡UI×é¼þ
- var tvVersion = ac.findViewById("tvVersion");
- var btnStart = ac.findViewById("btnStart");
- var btnStop = ac.findViewById("btnStop");
- var btnSave = ac.findViewById("btnSave");
- var btnResetForm = ac.findViewById("btnResetForm");
- var btnResetExecutor = ac.findViewById("btnResetExecutor");
- var etDeviceName = ac.findViewById("etDeviceName");
- var spinnerHIDType = ac.findViewById("spinnerHIDType");
- var etUID = ac.findViewById("etUID");
- var etPushTime = ac.findViewById("etPushTime");
- var spinnerCleanupType = ac.findViewById("spinnerCleanupType");
- var spinnerSlideDirection = ac.findViewById("spinnerSlideDirection");
- var tvLog = ac.findViewById("tvLog");
- // SpinnerÑ¡ÏîÊý¾Ý
- var hidTypes = ["ffChUSB°æ", "±ê×¼HID", "À¶ÑÀHID", "WiFi HID"];
- var cleanupTypes = ["»¬¶¯", "Ç¿ÖÆÍ£Ö¹", "Çå³ýÊý¾Ý", "²»´¦Àí"];
- var slideDirections = ["×óÓÒ»¬¶¯", "ÉÏÏ»¬¶¯", "Ëæ»ú»¬¶¯"];
- // Spinner״̬¶ÔÏó
- var spinnerState = {
- hidIndex: 0,
- cleanupIndex: 0,
- slideIndex: 0
- };
- // ÉèÖÃSpinnerµã»÷ʼþ
- function setupSpinnerClick(spinnerBtn, items, stateKey) {
- spinnerBtn.setOnClickListener(function() {
- try {
- // ÔÚÈÕÖ¾ÇøÓòÏÔʾËùÓÐÑ¡Ïî
- var optionsText = "";
- for (var i = 0; i < items.length; i++) {
- optionsText += (i + 1) + ". " + items[i] + "\n";
- }
- tvLog.setText("📋 Ñ¡ÏîÁбí:\n" + optionsText);
-
- // »ñÈ¡µ±Ç°Ë÷Òý²¢¼ÆËãÐÂË÷Òý
- var currentIndex = spinnerState[stateKey];
- var newIndex = (currentIndex + 1) % items.length;
-
- // ¸üÐÂ״̬
- spinnerState[stateKey] = newIndex;
-
- // ¸üÐÂÏÔʾ
- spinnerBtn.setText(" " + items[newIndex]);
- tvLog.setText("✅ ÒÑÑ¡Ôñ: " + items[newIndex]);
- console.log("Ñ¡Ôñ: " + items[newIndex]);
- } catch (e) {
- tvLog.setText(" Ñ¡Ôñʧ°Ü: " + e);
- console.log("Ñ¡Ôñʧ°Ü: " + e);
- }
- });
- }
- setupSpinnerClick(spinnerHIDType, hidTypes, 'hidIndex');
- setupSpinnerClick(spinnerCleanupType, cleanupTypes, 'cleanupIndex');
- setupSpinnerClick(spinnerSlideDirection, slideDirections, 'slideIndex');
- // ¼ÓÔØ±£´æµÄÅäÖÃ
- function loadConfig() {
- try {
- var deviceName = config.getConfig('/sdcard/qz_config.ini', 'device_name', '');
- var hidType = config.getConfig('/sdcard/qz_config.ini', 'hid_type', '0');
- var uid = config.getConfig('/sdcard/qz_config.ini', 'uid', '');
- var pushTime = config.getConfig('/sdcard/qz_config.ini', 'push_time', '');
- var cleanupType = config.getConfig('/sdcard/qz_config.ini', 'cleanup_type', '0');
- var slideDirection = config.getConfig('/sdcard/qz_config.ini', 'slide_direction', '0');
-
- if (deviceName) etDeviceName.setText(deviceName);
- spinnerHIDType.setText(" " + hidTypes[parseInt(hidType) || 0]);
- spinnerState.hidIndex = parseInt(hidType) || 0;
- if (uid) etUID.setText(uid);
- if (pushTime) etPushTime.setText(pushTime);
- spinnerCleanupType.setText(" " + cleanupTypes[parseInt(cleanupType) || 0]);
- spinnerState.cleanupIndex = parseInt(cleanupType) || 0;
- spinnerSlideDirection.setText(" " + slideDirections[parseInt(slideDirection) || 0]);
- spinnerState.slideIndex = parseInt(slideDirection) || 0;
-
- tvLog.setText("✅ ÅäÖüÓÔØÍê³É");
- console.log("ÅäÖüÓÔØÍê³É");
- } catch (e) {
- tvLog.setText("⚠️ ÅäÖüÓÔØÊ§°Ü: " + e);
- console.log("ÅäÖüÓÔØÊ§°Ü: " + e);
- }
- }
- // ±£´æÅäÖÃ
- function saveConfig() {
- try {
- config.setConfig('/sdcard/qz_config.ini', 'device_name', etDeviceName.getText().toString());
- config.setConfig('/sdcard/qz_config.ini', 'hid_type', spinnerState.hidIndex.toString());
- config.setConfig('/sdcard/qz_config.ini', 'uid', etUID.getText().toString());
- config.setConfig('/sdcard/qz_config.ini', 'push_time', etPushTime.getText().toString());
- config.setConfig('/sdcard/qz_config.ini', 'cleanup_type', spinnerState.cleanupIndex.toString());
- config.setConfig('/sdcard/qz_config.ini', 'slide_direction', spinnerState.slideIndex.toString());
-
- tvLog.setText("✅ ÅäÖñ£´æ³É¹¦");
- console.log("ÅäÖñ£´æ³É¹¦");
- } catch (e) {
- tvLog.setText("⚠️ ÅäÖñ£´æÊ§°Ü: " + e);
- console.log("ÅäÖñ£´æÊ§°Ü: " + e);
- }
- }
- // ÖØÖÃ±íµ¥
- function resetForm() {
- etDeviceName.setText("");
- etUID.setText("");
- etPushTime.setText("");
- spinnerHIDType.setText(" " + hidTypes[0]);
- spinnerState.hidIndex = 0;
- spinnerCleanupType.setText(" " + cleanupTypes[0]);
- spinnerState.cleanupIndex = 0;
- spinnerSlideDirection.setText(" " + slideDirections[0]);
- spinnerState.slideIndex = 0;
- tvLog.setText("🔄 ±íµ¥ÒÑÖØÖÃ");
- console.log("±íµ¥ÒÑÖØÖÃ");
- }
- // ÖØÖÃÖ´ÐÐÆ÷
- function resetExecutor() {
- tvLog.setText(" Ö´ÐÐÆ÷ÒÑÖØÖÃ");
- console.log("Ö´ÐÐÆ÷ÒÑÖØÖÃ");
- }
- // ÔËÐÐ״̬¿ØÖÆ
- var isRunning = false;
- // °´Å¥Ê¼þ°ó¶¨
- btnStart.setOnClickListener(function() {
- if (isRunning) {
- tvLog.setText(" ½Å±¾ÕýÔÚÔËÐÐÖУ¬ÇëÉÔºò...");
- console.log("½Å±¾ÕýÔÚÔËÐÐÖÐ");
- return;
- }
-
- // ¸üÐÂUI״̬
- isRunning = true;
- btnStart.setText("⏳ ÔËÐÐÖÐ...");
- btnStart.setBackgroundTintList(android.content.res.ColorStateList.valueOf(
- android.graphics.Color.parseColor("#FF9800")
- ));
- tvLog.setText("▶ ¿ªÊ¼ÔËÐÐÖ÷½Å±¾...");
- console.log("¿ªÊ¼ÔËÐÐÖ÷½Å±¾");
-
- try {
- // Ö±½Óµ¼Èë²¢ÔËÐÐÖ÷½Å±¾
- Import("Ö÷½Å±¾.js");
-
- // ÔËÐÐÍê³Éºó¸üÐÂ״̬
- btnStart.setText("¿ªÊ¼\nÔËÐÐ");
- btnStart.setBackgroundTintList(android.content.res.ColorStateList.valueOf(
- android.graphics.Color.parseColor("#4CAF50")
- ));
- isRunning = false;
-
- tvLog.setText("✅ Ö÷½Å±¾ÔËÐÐÍê³É");
- console.log("Ö÷½Å±¾ÔËÐÐÍê³É");
- } catch (e) {
- btnStart.setText("¿ªÊ¼\nÔËÐÐ");
- btnStart.setBackgroundTintList(android.content.res.ColorStateList.valueOf(
- android.graphics.Color.parseColor("#4CAF50")
- ));
- isRunning = false;
-
- tvLog.setText(" ÔËÐÐʧ°Ü: " + e);
- console.log("ÔËÐÐʧ°Ü: " + e);
- }
- });
- btnStop.setOnClickListener(function() {
- tvLog.setText("⏹️ ÒÑÍ£Ö¹ÔËÐÐ");
- console.log("Í£Ö¹ÔËÐÐ");
- });
- btnSave.setOnClickListener(function() {
- saveConfig();
- });
- btnResetForm.setOnClickListener(function() {
- resetForm();
- });
- btnResetExecutor.setOnClickListener(function() {
- resetExecutor();
- });
- // ³õʼ»¯¼ÓÔØÅäÖÃ
- loadConfig();
- console.log("✅ QZ¾ò½ðÅäÖýçÃæÒÑÆô¶¯");
¸´ÖÆ´úÂë
|
|