@@ -209,7 +207,6 @@
document.getElementById('path').value = d.path;
document.querySelector('input[name="screen_rotation"][value="'+d.screen_rotation+'"]').checked = true;
document.querySelector('input[name="hide_bar"][value="'+d.hide_bar+'"]').checked = true;
- document.querySelector('input[name="start_direction"][value="'+d.start_direction+'"]').checked = true;
console.log("d_data_end_=========================");
}
}
@@ -222,8 +219,7 @@
"port":document.getElementById('port').value,
"path":document.getElementById('path').value,
"screen_rotation":document.querySelector('input[name="screen_rotation"]:checked').value,
- "hide_bar":document.querySelector('input[name="hide_bar"]:checked').value,
- "start_direction":document.querySelector('input[name="start_direction"]:checked').value,
+ "hide_bar":document.querySelector('input[name="hide_bar"]:checked').value
});
window.NetworkSettingEngine.saveSetting(data);
window.View.reload();
diff --git a/app/src/main/assets/init.json b/app/src/main/assets/init.json
index eda6bda..fc77855 100644
--- a/app/src/main/assets/init.json
+++ b/app/src/main/assets/init.json
@@ -3,7 +3,6 @@
"_ip":"ip地址",
"_port":"端口号",
"_path":"访问路径",
- "_screen_rotation":"屏幕旋转:1竖、2横、3横竖、4禁止",
- "_hide_bar":"状态拦:1隐藏、2显示",
- "_start_direction":"默认屏幕方向:1正竖、2倒竖、3正横、4倒横"
+ "_screen_rotation":"屏幕方向:5正竖;6倒竖;7正横;8倒横;1竖;2横;3横竖;4禁止",
+ "_hide_bar":"状态拦:1隐藏、2显示"
}
\ No newline at end of file
diff --git a/app/src/main/java/chaoran/business/activity/MainActivity.java b/app/src/main/java/chaoran/business/activity/MainActivity.java
index b9ea98c..2180214 100644
--- a/app/src/main/java/chaoran/business/activity/MainActivity.java
+++ b/app/src/main/java/chaoran/business/activity/MainActivity.java
@@ -70,9 +70,6 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
public static int SCREEN_ROTATION = 3; // 屏幕旋转的设置
public static int hideBar = 0; // 屏幕旋转的设置
- public static int startDirection = 1; // 初始化屏幕方向
-
- MyOrientationDetector myOrientationDetector;
private WebView webView;
private Adapter adapter;
@@ -97,9 +94,27 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
//SCREEN_ORIENTATION_USER,不能旋转180,0、90、270都可以旋转
//SCREEN_ORIENTATION_FULL_SENSOR 都可以旋转,但是在不打开旋转的情况下,一样可以旋转
//SCREEN_ORIENTATION_FULL_USER 关闭旋转则不会旋转了
- this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_USER);
- myOrientationDetector = new MyOrientationDetector(this, this);
- myOrientationDetector.enable();
+ // 取消监听屏幕方向,使用用户的,等出现了问题再来调整;之前有一款pda系统旋转有bug
+// this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE);
+ if (SCREEN_ROTATION == 1) {
+ this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT);//竖
+ }else if (SCREEN_ROTATION == 2) {
+ this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE);//横
+ }else if (SCREEN_ROTATION == 3){
+ this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_USER);//随便
+ }else if (SCREEN_ROTATION == 5) { // 正竖
+ this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+ }else if (SCREEN_ROTATION == 6) {// 倒竖
+ this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
+ }else if (SCREEN_ROTATION == 7) {// 正横
+ this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
+ }else if (SCREEN_ROTATION == 8) {// 倒横
+ this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+ }else {
+ this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); // 禁止
+ }
+// myOrientationDetector = new MyOrientationDetector(this, this);
+// myOrientationDetector.enable();
}
@@ -310,22 +325,20 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
// voiceEngine.reload();
super.onResume();
if (adapter != null) {
- myOrientationDetector.disable();
- myOrientationDetector.enable();
adapter.stop2();
adapter.start();
}
- int rotate = 1;
- if (startDirection == 1) {
- rotate = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; // 正竖屏
- }else if (startDirection == 2) {
- rotate = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; // 倒竖屏
- }else if (startDirection == 3) {
- rotate = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; // 正横屏
- }else if (startDirection == 4) {
- rotate = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; // 倒横屏
- }
- this.setRequestedOrientation(rotate);
+// int rotate = 1;
+// if (startDirection == 1) {
+// rotate = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; // 正竖屏
+// }else if (startDirection == 2) {
+// rotate = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; // 倒竖屏
+// }else if (startDirection == 3) {
+// rotate = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; // 正横屏
+// }else if (startDirection == 4) {
+// rotate = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; // 倒横屏
+// }
+// this.setRequestedOrientation(rotate);
}
@Override
@@ -358,7 +371,6 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
vibrator.cancel();
}
completionListener = null;
- myOrientationDetector.disable();
}
@Override
@@ -400,7 +412,6 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
initData.setPath(map.get("path").toString());
initData.setScreen_rotation(Integer.parseInt(map.getOrDefault("screen_rotation", "3").toString()));
initData.setHide_bar(Integer.parseInt(map.getOrDefault("hide_bar", "0").toString()));
- initData.setStart_direction(Integer.parseInt(map.getOrDefault("start_direction", "1").toString()));
settingEngine.saveSetting(initData);
spf = this.getSharedPreferences("crtech", Context.MODE_PRIVATE);
port = initData.getPort();
@@ -421,24 +432,11 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
String link = address.concat(":").concat(String.valueOf(port)).concat(path);
SCREEN_ROTATION = spf.getInt("screen_rotation", 3);
hideBar = spf.getInt("hide_bar", 0);
- startDirection = spf.getInt("start_direction", 1);
return link.startsWith("http://") ? link : "http://".concat(link);
}
@JavascriptInterface
public void reload() {
- // 第一次设置,点击保存,初始化屏幕方向问题
- int rotate = 1;
- if (startDirection == 1) {
- rotate = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; // 正竖屏
- }else if (startDirection == 2) {
- rotate = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; // 倒竖屏
- }else if (startDirection == 3) {
- rotate = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; // 正横屏
- }else if (startDirection == 4) {
- rotate = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; // 倒横屏
- }
- this.setRequestedOrientation(rotate);
runOnUiThread(() -> {
webView.loadUrl(url());
});
@@ -504,52 +502,6 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
});
}
- /* 监听角度的变化 */
- class MyOrientationDetector extends OrientationEventListener {
-
- private int rotate;
-
- private Activity activity;
-
- public MyOrientationDetector(Context context, Activity activity) {
- super(context);
- this.activity = activity;
- }
-
- @Override
- public void onOrientationChanged(int orientation) {
- //假设屏幕旋转被打开。则设置屏幕可旋转
- //0-57度 125-236度 306-360度 这些区间范围内为竖屏
- //58-124度 237-305度 这些区间范围内为横屏
- if (orientation >=0 && orientation <= 57 ) {
- rotate = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; // 正竖屏
- }else if (orientation >=125 && orientation <= 236 ) {
- rotate = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; // 倒竖屏
- }else if (orientation >=306 && orientation <= 360 ) {
- rotate = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; // 正竖屏
- }else if (orientation >=58 && orientation <= 124 ) {
- rotate = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; // 正横屏
- }else if (orientation >=237 && orientation <= 305 ) {
- rotate = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; // 倒横屏
- }else {
- rotate = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; // 默认正竖屏
- }
- if (SCREEN_ROTATION == 1 || SCREEN_ROTATION == 3) {
- if (rotate == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || rotate == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT) {
- activity.setRequestedOrientation(rotate);
- }
- }
- if (SCREEN_ROTATION == 2 || SCREEN_ROTATION == 3) {
- if (rotate == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || rotate == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) {
- activity.setRequestedOrientation(rotate);
- }
- }
- }
-
-
-
- }
-
@SuppressLint("WrongConstant")
@Override
public void onConfigurationChanged(Configuration newConfig) {
diff --git a/app/src/main/java/chaoran/business/activity/NetworkSettingActivity.java b/app/src/main/java/chaoran/business/activity/NetworkSettingActivity.java
index a9c366a..8b1227c 100644
--- a/app/src/main/java/chaoran/business/activity/NetworkSettingActivity.java
+++ b/app/src/main/java/chaoran/business/activity/NetworkSettingActivity.java
@@ -19,7 +19,7 @@ import chaoran.business.R;
public class NetworkSettingActivity extends AppCompatActivity {
- private EditText address, path, port, screen_rotation, hide_bar,start_direction;
+ private EditText address, path, port, screen_rotation, hide_bar;
private Button save, cancel;
@Override
@@ -37,7 +37,6 @@ public class NetworkSettingActivity extends AppCompatActivity {
port = findViewById(R.id.port);
screen_rotation = findViewById(R.id.screen_rotation);
hide_bar = findViewById(R.id.hide_bar);
- start_direction = findViewById(R.id.start_direction);
save = findViewById(R.id.save);
cancel = findViewById(R.id.cancel);
SharedPreferences sharedPreferences = this.getSharedPreferences("crtech", Context.MODE_PRIVATE);
@@ -46,7 +45,6 @@ public class NetworkSettingActivity extends AppCompatActivity {
port.setText(String.valueOf(sharedPreferences.getInt("port", -1)));
screen_rotation.setText(String.valueOf(sharedPreferences.getInt("screen_rotation", 3)));
hide_bar.setText(String.valueOf(sharedPreferences.getInt("hide_bar", 0)));
- start_direction.setText(String.valueOf(sharedPreferences.getInt("start_direction", 1)));
cancel.setOnClickListener((e) -> this.finish());
save.setOnClickListener((e) -> saveSetting());
}
@@ -58,7 +56,6 @@ public class NetworkSettingActivity extends AppCompatActivity {
editor.putInt("port", Integer.parseInt(port.getText().toString().trim()));
editor.putInt("screen_rotation", Integer.parseInt(screen_rotation.getText().toString().trim()));
editor.putInt("hide_bar", Integer.parseInt(hide_bar.getText().toString().trim()));
- editor.putInt("start_direction", Integer.parseInt(start_direction.getText().toString().trim()));
editor.commit();
this.finish();
}
diff --git a/app/src/main/java/chaoran/business/adapter/RockChipAdapter.java b/app/src/main/java/chaoran/business/adapter/RockChipAdapter.java
index 0433b2b..64b1164 100644
--- a/app/src/main/java/chaoran/business/adapter/RockChipAdapter.java
+++ b/app/src/main/java/chaoran/business/adapter/RockChipAdapter.java
@@ -9,6 +9,8 @@ package chaoran.business.adapter;
import android.content.Context;
+import android.os.Build;
+
import chaoran.business.activity.ResultListener;
import chaoran.business.strategy.Strategy;
@@ -40,7 +42,11 @@ public class RockChipAdapter implements Adapter {
public RockChipAdapter(Context context, ResultListener resultListener) {
this.resultListener = resultListener;
this.context = context;
- this.strategy = new Reader(new File("/dev/ttyS1"), 115200, 0);
+ String fileName = "/dev/ttyS1";
+ if (Build.MODEL.equalsIgnoreCase("rk3568_r")) {
+ fileName = "/dev/ttyS8";
+ }
+ this.strategy = new Reader(new File(fileName), 115200, 0);
}
public class Reader implements Strategy {
diff --git a/app/src/main/java/chaoran/business/engine/entity/NetworkSetting.java b/app/src/main/java/chaoran/business/engine/entity/NetworkSetting.java
index 2aeba5e..6ce663f 100644
--- a/app/src/main/java/chaoran/business/engine/entity/NetworkSetting.java
+++ b/app/src/main/java/chaoran/business/engine/entity/NetworkSetting.java
@@ -15,7 +15,6 @@ public class NetworkSetting extends Setting {
private Integer screen_rotation;
private Integer hide_bar;
- private Integer start_direction;
public String getAddress() {
return address;
@@ -57,11 +56,4 @@ public class NetworkSetting extends Setting {
this.hide_bar = hide_bar;
}
- public Integer getStart_direction() {
- return start_direction;
- }
-
- public void setStart_direction(Integer start_direction) {
- this.start_direction = start_direction;
- }
}
\ No newline at end of file
diff --git a/app/src/main/java/chaoran/business/engine/impl/NetworkSettingEngine.java b/app/src/main/java/chaoran/business/engine/impl/NetworkSettingEngine.java
index b008b9f..47b2fa2 100644
--- a/app/src/main/java/chaoran/business/engine/impl/NetworkSettingEngine.java
+++ b/app/src/main/java/chaoran/business/engine/impl/NetworkSettingEngine.java
@@ -46,7 +46,6 @@ public class NetworkSettingEngine implements SettingEngine {
networkSetting.setPath(path);
networkSetting.setScreen_rotation(screen_rotation);
networkSetting.setHide_bar(spf.getInt("hide_bar", 0));
- networkSetting.setStart_direction(spf.getInt("start_direction", 0));
return networkSetting;
}
@@ -59,11 +58,10 @@ public class NetworkSettingEngine implements SettingEngine {
editor.putInt("port", networkSetting.getPort());
editor.putInt("screen_rotation", networkSetting.getScreen_rotation());
editor.putInt("hide_bar", networkSetting.getHide_bar());
- editor.putInt("start_direction", networkSetting.getStart_direction());
editor.commit();
MainActivity.SCREEN_ROTATION = networkSetting.getScreen_rotation();
MainActivity.hideBar = networkSetting.getHide_bar();
- MainActivity.startDirection = networkSetting.getStart_direction();
+// MainActivity.startDirection = networkSetting.getStart_direction();
return true;
}
diff --git a/app/src/main/res/layout/activity_setting_network.xml b/app/src/main/res/layout/activity_setting_network.xml
index 6f4dfc7..2d8e620 100644
--- a/app/src/main/res/layout/activity_setting_network.xml
+++ b/app/src/main/res/layout/activity_setting_network.xml
@@ -103,7 +103,7 @@
+ android:text="屏幕方向:" />
+ android:hint="5正竖;6倒竖;7正横;8倒横;1竖;2横;3横竖;4禁止" />
-
-
-
-
-
-
-
-
-
-
-