Skip to content

Commit

Permalink
更新V1.4.3
Browse files Browse the repository at this point in the history
- 有线设备地址自动恢复,避免被误修改导致问题
- 修复崩溃的 bug
- 调整 ui
- 修复无法传送名词包含汉字的文件的问题
  • Loading branch information
mingzhixian committed Mar 9, 2024
1 parent 991295d commit 558904a
Show file tree
Hide file tree
Showing 22 changed files with 380 additions and 308 deletions.
4 changes: 2 additions & 2 deletions easycontrol/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "top.saymzx.easycontrol.app"
minSdk 21
targetSdk 34
versionCode 10402
versionName "1.4.2"
versionCode 10403
versionName "1.4.3"
ndk {
abiFilters "arm64-v8a", "armeabi-v7a", "x86", "x86_64"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class ActiveActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ViewTools.setStatusAndNavBar(this);
ViewTools.setLocale(this);
activityActiveBinding = ActivityActiveBinding.inflate(this.getLayoutInflater());
Expand All @@ -29,7 +30,6 @@ protected void onCreate(Bundle savedInstanceState) {
setButtonListener();
// 绘制UI
drawUi();
super.onCreate(savedInstanceState);
}

private void drawUi() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class AdbKeyActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ViewTools.setStatusAndNavBar(this);
ViewTools.setLocale(this);
activityAdbKeyBinding = ActivityAdbKeyBinding.inflate(this.getLayoutInflater());
Expand All @@ -30,7 +31,6 @@ protected void onCreate(Bundle savedInstanceState) {
readKey();
activityAdbKeyBinding.backButton.setOnClickListener(v -> finish());
activityAdbKeyBinding.ok.setOnClickListener(v -> writeKey());
super.onCreate(savedInstanceState);
}

// 读取旧的密钥公钥文件
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class DeviceDetailActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ViewTools.setStatusAndNavBar(this);
ViewTools.setLocale(this);
activityDeviceDetailBinding = ActivityDeviceDetailBinding.inflate(this.getLayoutInflater());
Expand All @@ -45,7 +46,6 @@ protected void onCreate(Bundle savedInstanceState) {
drawUI();
// 设置监听
setListener();
super.onCreate(savedInstanceState);
}

// 绘制UI
Expand Down Expand Up @@ -103,10 +103,14 @@ private void setListener() {
activityDeviceDetailBinding.buttonScan.setOnClickListener(v -> scanAddress());
// 设置确认按钮监听
activityDeviceDetailBinding.ok.setOnClickListener(v -> {
String name = String.valueOf(activityDeviceDetailBinding.address.getText());
if (name.equals("----") || name.equals("")) return;
device.name = String.valueOf(activityDeviceDetailBinding.name.getText());
device.address = String.valueOf(activityDeviceDetailBinding.address.getText());
String name = String.valueOf(activityDeviceDetailBinding.name.getText());
String address = String.valueOf(activityDeviceDetailBinding.address.getText());
if (name.equals("----") || name.equals("") || address.equals("")) {
Toast.makeText(this, getString(R.string.toast_config), Toast.LENGTH_SHORT).show();
return;
}
device.name = name;
device.address = device.isLinkDevice() ? device.uuid + (address.contains("#") ? ("#" + address.split("#")[1]) : "") : address;
// 自定义分辨率
String width = String.valueOf(activityDeviceDetailBinding.customResolutionWidth.getText());
String height = String.valueOf(activityDeviceDetailBinding.customResolutionHeight.getText());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ public class IpActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ViewTools.setStatusAndNavBar(this);
ViewTools.setLocale(this);
activityIpBinding = ActivityIpBinding.inflate(this.getLayoutInflater());
setContentView(activityIpBinding.getRoot());
setButtonListener();
// 绘制UI
drawUi();
super.onCreate(savedInstanceState);
}

private void drawUi() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class MainActivity extends Activity {
@SuppressLint("SourceLockedOrientationActivity")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AppData.init(this);
ViewTools.setStatusAndNavBar(this);
ViewTools.setLocale(this);
Expand All @@ -45,7 +46,6 @@ public void onCreate(Bundle savedInstanceState) {
// 检测权限
if (!checkPermission()) createAlert();
else startApp();
super.onCreate(savedInstanceState);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ public class SetActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ViewTools.setStatusAndNavBar(this);
ViewTools.setLocale(this);
activitySetBinding = ActivitySetBinding.inflate(this.getLayoutInflater());
setContentView(activitySetBinding.getRoot());
// 设置页面
drawUi();
setButtonListener();
super.onCreate(savedInstanceState);
}

// 设置默认值
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ public void pushFile(InputStream file, String remotePath, MyInterface.MyFunction
bufferStream.write(ByteBuffer.wrap(bytes));
// 发送文件
byte[] byteArray = new byte[10240 - 8];
int len = file.read(byteArray, 0, byteArray.length);
int hasSendLen = 0;
int allNeedSendLen = file.available();
int lastProcess = 0;
int len = file.read(byteArray, 0, byteArray.length);
do {
bufferStream.write(AdbProtocol.generateSyncHeader("DATA", len));
bufferStream.write(ByteBuffer.wrap(byteArray, 0, len));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package top.saymzx.easycontrol.app.client.tools;

import android.hardware.usb.UsbDevice;
import android.util.Log;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;
import java.util.regex.Pattern;

import top.saymzx.easycontrol.app.adb.Adb;
import top.saymzx.easycontrol.app.entity.AppData;
Expand Down Expand Up @@ -58,9 +61,14 @@ public static void restartOnTcpip(Device device, MyInterface.MyFunctionBoolean h
public static void pushFile(Device device, InputStream file, String fileName, MyInterface.MyFunctionInt handleProcess) {
new Thread(() -> {
try {
String tempFileName = fileName;
Adb adb = connectADB(device);
adb.pushFile(file, "/sdcard/Download/Easycontrol/" + fileName, handleProcess);
handleProcess.run(100);
// 因为糟糕的ADB,如果使用中文名的话,会崩溃,所以此处使用随机名词
if (!Pattern.compile("^[a-zA-Z0-9\\(\\)\\-\\_\\[\\]\\.]+$").matcher(tempFileName).matches()) {
int dotIndex = tempFileName.lastIndexOf(".");
tempFileName = UUID.randomUUID() + (dotIndex == -1 ? "" : tempFileName.substring(dotIndex));
}
adb.pushFile(file, "/sdcard/Download/Easycontrol/" + tempFileName, handleProcess);
} catch (Exception ignored) {
handleProcess.run(-1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ private void reCalculateTextureViewSize() {
// 检查画面是否超出
private void checkSizeAndSite() {
// 碎碎念,感谢 波瑠卡 的关爱,今天一家四口一起去医院进年货去了,每人提了一袋子(´;ω;`)
AppData.uiHandler.post(smallView::checkSizeAndSite);
if (smallView != null) AppData.uiHandler.post(smallView::checkSizeAndSite);
}

// 设置视频区域触摸监听
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class FullActivity extends Activity implements SensorEventListener {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ViewTools.setFullScreen(this);
activityFullBinding = ActivityFullBinding.inflate(this.getLayoutInflater());
setContentView(activityFullBinding.getRoot());
Expand Down Expand Up @@ -61,7 +62,6 @@ protected void onCreate(Bundle savedInstanceState) {
activityFullBinding.textureViewLayout.post(this::updateMaxSize);
// 页面自动旋转
AppData.sensorManager.registerListener(this, AppData.sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
super.onCreate(savedInstanceState);
}

@Override
Expand Down Expand Up @@ -105,36 +105,39 @@ public void hide() {

// 设置按钮监听
private void setButtonListener() {
activityFullBinding.buttonRotate.setOnClickListener(v -> clientController.handleAction("buttonRotate", null, 0));
activityFullBinding.buttonBack.setOnClickListener(v -> clientController.handleAction("buttonBack", null, 0));
activityFullBinding.buttonHome.setOnClickListener(v -> clientController.handleAction("buttonHome", null, 0));
activityFullBinding.buttonSwitch.setOnClickListener(v -> clientController.handleAction("buttonSwitch", null, 0));
activityFullBinding.buttonNavBar.setOnClickListener(v -> {
setNavBarHide(activityFullBinding.navBar.getVisibility() == View.GONE);
activityFullBinding.buttonApp.setOnClickListener(v -> {
clientController.handleAction("changeToApp", null, 0);
changeBarView();
});
activityFullBinding.buttonMini.setOnClickListener(v -> clientController.handleAction("changeToMini", null, 0));
activityFullBinding.buttonSmall.setOnClickListener(v -> clientController.handleAction("changeToSmall", null, 0));
activityFullBinding.buttonClose.setOnClickListener(v -> Client.sendAction(device.uuid, "close", null, 0));
activityFullBinding.buttonRotate.setOnClickListener(v -> {
clientController.handleAction("buttonRotate", null, 0);
changeBarView();
});
activityFullBinding.buttonNavBar.setOnClickListener(v -> {
setNavBarHide(activityFullBinding.navBar.getVisibility() == View.GONE);
changeBarView();
});
activityFullBinding.buttonPower.setOnClickListener(v -> {
clientController.handleAction("buttonPower", null, 0);
changeBarView();
});
activityFullBinding.buttonLight.setOnClickListener(v -> {
light = !light;
activityFullBinding.buttonLight.setImageResource(light ? R.drawable.lightbulb_off : R.drawable.lightbulb);
clientController.handleAction(light ? "buttonLight" : "buttonLightOff", null, 0);
});
activityFullBinding.buttonPower.setOnClickListener(v -> {
clientController.handleAction("buttonPower", null, 0);
changeBarView();
});
activityFullBinding.bar.setOnClickListener(v -> changeBarView());
activityFullBinding.buttonAutoRotate.setOnClickListener(v -> {
autoRotate = !autoRotate;
AppData.setting.setAutoRotate(autoRotate);
activityFullBinding.buttonAutoRotate.setImageResource(autoRotate ? R.drawable.un_auto : R.drawable.auto);
changeBarView();
});
activityFullBinding.buttonApp.setOnClickListener(v -> {
clientController.handleAction("changeToApp", null, 0);
changeBarView();
});
}

Expand All @@ -147,7 +150,7 @@ private void setNavBarHide(boolean isShow) {

private void changeBarView() {
boolean toShowView = activityFullBinding.barView.getVisibility() == View.GONE;
ViewTools.viewAnim(activityFullBinding.barView, toShowView, 0, PublicTools.dp2px(-40f), (isStart -> {
ViewTools.viewAnim(activityFullBinding.barView, toShowView, PublicTools.dp2px(40f), 0, (isStart -> {
if (isStart && toShowView) activityFullBinding.barView.setVisibility(View.VISIBLE);
else if (!isStart && !toShowView) activityFullBinding.barView.setVisibility(View.GONE);
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,28 +162,32 @@ private void setBarListener() {

// 设置按钮监听
private void setButtonListener() {
smallView.buttonRotate.setOnClickListener(v -> clientController.handleAction("buttonRotate", null, 0));
smallView.buttonBack.setOnClickListener(v -> clientController.handleAction("buttonBack", null, 0));
smallView.buttonHome.setOnClickListener(v -> clientController.handleAction("buttonHome", null, 0));
smallView.buttonSwitch.setOnClickListener(v -> clientController.handleAction("buttonSwitch", null, 0));
smallView.buttonNavBar.setOnClickListener(v -> {
setNavBarHide(smallView.navBar.getVisibility() == View.GONE);
smallView.buttonApp.setOnClickListener(v -> {
clientController.handleAction("changeToApp", null, 0);
changeBarView();
});
smallView.buttonMini.setOnClickListener(v -> clientController.handleAction("changeToMini", null, 0));
smallView.buttonFull.setOnClickListener(v -> clientController.handleAction("changeToFull", null, 0));
smallView.buttonClose.setOnClickListener(v -> Client.sendAction(device.uuid, "close", null, 0));
smallView.buttonLight.setOnClickListener(v -> {
light = !light;
smallView.buttonLight.setImageResource(light ? R.drawable.lightbulb_off : R.drawable.lightbulb);
clientController.handleAction(light ? "buttonLight" : "buttonLightOff", null, 0);
smallView.buttonRotate.setOnClickListener(v -> {
clientController.handleAction("buttonRotate", null, 0);
changeBarView();
});
smallView.buttonNavBar.setOnClickListener(v -> {
setNavBarHide(smallView.navBar.getVisibility() == View.GONE);
changeBarView();
});
smallView.buttonPower.setOnClickListener(v -> {
clientController.handleAction("buttonPower", null, 0);
changeBarView();
});
smallView.buttonApp.setOnClickListener(v -> {
clientController.handleAction("changeToApp", null, 0);
smallView.buttonLight.setOnClickListener(v -> {
light = !light;
smallView.buttonLight.setImageResource(light ? R.drawable.lightbulb_off : R.drawable.lightbulb);
clientController.handleAction(light ? "buttonLight" : "buttonLightOff", null, 0);
changeBarView();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ public synchronized void updateUSB() {
Device device = AppData.dbHelper.getByUUID(uuid);
if (device == null) {
device = new Device(uuid, Device.TYPE_LINK);
device.address = uuid;
AppData.dbHelper.insert(device);
}
device.address = uuid + (device.address.contains("#") ? device.address.split("#")[1] : "");
AdbTools.usbDevicesList.put(uuid, usbDevice);
break;
}
Expand Down
9 changes: 0 additions & 9 deletions easycontrol/app/src/main/res/drawable/ellipsis_vertical.xml

This file was deleted.

Loading

0 comments on commit 558904a

Please sign in to comment.