2.9和2.10一并提交,

2.9:添加了初始化屏幕方向
2.10:添加了init.json,进行初始化ip等,使用mt管理器进行修改,从而实现医院不用配置ip
This commit is contained in:
2025-09-23 09:09:47 +08:00
parent bc8142c157
commit c3e3d6de61
7 changed files with 189 additions and 58 deletions

View File

@ -11,7 +11,7 @@ android {
minSdk 28
targetSdk 28
versionCode 1
versionName "2.8"
versionName "2.10"
// 1.0 IDATA广播模式处理
// 1.1 霍尼韦尔的监听修改扫描网站二维码跳出程序监听失效调整、斑马PDA广播模式设置
@ -43,6 +43,8 @@ android {
// 3、根据官方文档将code的判断进行修改添加了一个网络错误的页面进行提示(并且添加了一个重新加载的按钮执行webview重新加载)
// 2.7 海康威视 mv-idp5204 适配广播模式和之前的idp5102厂家code不一样 宿州市立医院-李德
// 2.8 编写一个通用的广播模式actionchaoran.crtech.cn.pda.scan keybarcode
// 2.9 初始化屏幕方向
// 2.10 再次添加了init.json文件进行初始化ip等参数
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
abiFilters 'armeabi-v7a'

View File

@ -96,7 +96,24 @@
outline: -webkit-focus-ring-color auto 0px;
}
.radio-group {
display: flex;
padding: 10px;
}
.radio-group>span {
display: inline-block;
width: 110px;
min-width: 110px;
}
.radio-group .radio-group-box {
display: flex;
flex-wrap: wrap; /* 允许换行 */
gap: 10px 20px; /* 垂直和水平间距 */
width: 100%;
}
.radio-group .radio-group-box .radio-item {
width: calc(50% - 10px);
}
</style>
@ -118,13 +135,60 @@
<label>访问子路径</label>
<input id="path" name="path" placeholder="访问子路径">
</div>
<div class="net-list">
<label>屏幕旋转</label>
<input id="screen_rotation" value="3" name="screen_rotation" placeholder="1:强制竖屏2:强制横屏3:横竖都转">
<div class="radio-group">
<span>屏幕旋转</span>
<div class="radio-group-box">
<label class="radio-item">
<input type="radio" name="screen_rotation" value="1" checked>
竖屏
</label>
<label class="radio-item">
<input type="radio" name="screen_rotation" value="2">
横屏
</label>
<label class="radio-item">
<input type="radio" name="screen_rotation" value="3">
横竖
</label>
<label class="radio-item">
<input type="radio" name="screen_rotation" value="4">
禁止
</label>
</div>
</div>
<div class="radio-group">
<span>隐藏状态栏</span>
<div class="radio-group-box">
<label class="radio-item">
<input type="radio" name="hide_bar" value="1" checked>
隐藏
</label>
<label class="radio-item">
<input type="radio" name="hide_bar" value="2">
显示
</label>
</div>
</div>
<div class="radio-group">
<span>默认屏幕方向</span>
<div class="radio-group-box">
<label class="radio-item">
<input type="radio" name="start_direction" value="1" checked>
正竖屏
</label>
<label class="radio-item">
<input type="radio" name="start_direction" value="2">
倒竖屏
</label>
<label class="radio-item">
<input type="radio" name="start_direction" value="3">
正横屏
</label>
<label class="radio-item">
<input type="radio" name="start_direction" value="4">
倒横屏
</label>
</div>
<div class="net-list">
<label>隐藏状态栏</label>
<input id="hide_bar" value="1" name="hide_bar" placeholder="1:隐藏0:显示">
</div>
</div>
<div class="operation">
@ -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();

View File

@ -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<String, Object> 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<Map<String, Object>>(){}.getType());
@ -383,6 +397,7 @@ 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();
@ -402,6 +417,7 @@ 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);
}

View File

@ -19,7 +19,7 @@ import chaoran.business.R;
public class NetworkSettingActivity extends AppCompatActivity {
private EditText address, path, port, screen_rotation, hide_bar;
private EditText address, path, port, screen_rotation, hide_bar,start_direction;
private Button save, cancel;
@Override
@ -37,6 +37,7 @@ 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);
@ -45,6 +46,7 @@ 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());
}
@ -56,6 +58,7 @@ 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();
}

View File

@ -15,6 +15,7 @@ public class NetworkSetting extends Setting {
private Integer screen_rotation;
private Integer hide_bar;
private Integer start_direction;
public String getAddress() {
return address;
@ -55,4 +56,12 @@ public class NetworkSetting extends Setting {
public void setHide_bar(Integer hide_bar) {
this.hide_bar = hide_bar;
}
public Integer getStart_direction() {
return start_direction;
}
public void setStart_direction(Integer start_direction) {
this.start_direction = start_direction;
}
}

View File

@ -46,6 +46,7 @@ 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;
}
@ -58,9 +59,11 @@ 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();
return true;
}

View File

@ -7,49 +7,6 @@
android:id="@+id/table">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="隐藏状态栏:" />
<EditText
android:id="@+id/hide_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="1:隐藏0显示"
android:minWidth="150dp"
android:singleLine="true" />
<TextView />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="屏幕旋转:" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="150dp"
android:id="@+id/screen_rotation"
android:singleLine="true"
android:hint="1:强制竖屏2:强制横屏3:横竖都转" />
<TextView />
</TableRow>
<TableRow>
@ -86,6 +43,7 @@
android:minWidth="150dp"
android:id="@+id/port"
android:singleLine="true"
android:inputType="number"
android:hint="介于1024-65535之间的数字" />
<TextView />
@ -112,6 +70,80 @@
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="隐藏状态栏:" />
<EditText
android:id="@+id/hide_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="1:隐藏0显示"
android:minWidth="150dp"
android:inputType="number"
android:digits="01"
android:singleLine="true" />
<TextView />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="屏幕旋转:" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="150dp"
android:id="@+id/screen_rotation"
android:singleLine="true"
android:inputType="number"
android:digits="1234"
android:hint="1:竖屏2:横屏3:横竖4:禁止" />
<TextView />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="默认屏幕方向:" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="150dp"
android:id="@+id/start_direction"
android:singleLine="true"
android:inputType="number"
android:digits="1234"
android:hint="1:正竖2:倒竖3:正横4:倒横" />
<TextView />
</TableRow>
<TableRow>
<TextView />