@@ -143,8 +207,9 @@
document.getElementById('address').value = d.address;
document.getElementById('port').value = d.port;
document.getElementById('path').value = d.path;
- document.getElementById('screen_rotation').value = d.screen_rotation;
- document.getElementById('hide_bar').value = d.hide_bar;
+ 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_=========================");
}
}
@@ -156,8 +221,9 @@
"address":document.getElementById('address').value,
"port":document.getElementById('port').value,
"path":document.getElementById('path').value,
- "screen_rotation":document.getElementById('screen_rotation').value,
- "hide_bar":document.getElementById('hide_bar').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,
});
window.NetworkSettingEngine.saveSetting(data);
window.View.reload();
diff --git a/app/src/main/java/chaoran/business/activity/MainActivity.java b/app/src/main/java/chaoran/business/activity/MainActivity.java
index f591b51..01511ce 100644
--- a/app/src/main/java/chaoran/business/activity/MainActivity.java
+++ b/app/src/main/java/chaoran/business/activity/MainActivity.java
@@ -70,6 +70,7 @@ 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;
@@ -307,9 +308,21 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
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);
}
@Override
@@ -342,6 +355,7 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
vibrator.cancel();
}
completionListener = null;
+ myOrientationDetector.disable();
}
@Override
@@ -370,8 +384,8 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
Map
map = null;
if (port == -1) {
try {
-// String init = readInitFile(this);
- String init = null;
+ String init = readInitFile(this);
+// String init = null;
if (init != null && init.length() > 0) {
Gson gson = new Gson();
map = gson.fromJson(init, new TypeToken