Merge branch 'master' of ssh://gitea.ttstd.com:2222/tt/VibeCoding
# Conflicts: # WebRTCController/app/src/main/res/layout/activity_main.xml
This commit is contained in:
@@ -61,6 +61,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
private TextView tvStatusControl;
|
||||
private TextView tvStats;
|
||||
private Spinner spinnerResolution;
|
||||
private Button btnDisconnectControl;
|
||||
|
||||
// 屏幕串流"自编码"模式相关 UI 与解码器
|
||||
private Switch switchStreamMode;
|
||||
@@ -114,6 +115,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
tvStatusControl = findViewById(R.id.tv_status_control);
|
||||
tvStats = findViewById(R.id.tv_stats);
|
||||
spinnerResolution = findViewById(R.id.spinner_resolution);
|
||||
btnDisconnectControl = findViewById(R.id.btn_disconnect_control);
|
||||
|
||||
// 默认服务器地址
|
||||
etServerUrl.setText("ws://175.178.213.60:8088/ws/signal");
|
||||
@@ -123,6 +125,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
btnConnect.setOnClickListener(v -> showAuthDialog());
|
||||
btnDisconnect.setOnClickListener(v -> disconnect());
|
||||
btnDisconnectControl.setOnClickListener(v -> disconnect());
|
||||
|
||||
// 初始化 EGL 和远端视频渲染
|
||||
eglBase = EglBase.create();
|
||||
@@ -228,7 +231,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
});
|
||||
}
|
||||
|
||||
/** 弹出鉴权输入对话框:选择动态验证码或固定密码,输入后发起连接。 */
|
||||
/** 弹出鉴权输入对话框:选择免密连接、动态验证码或固定密码,输入后发起连接。 */
|
||||
private void showAuthDialog() {
|
||||
String serverUrl = etServerUrl.getText().toString().trim();
|
||||
String target = etTargetDeviceId.getText().toString().trim();
|
||||
@@ -243,13 +246,22 @@ public class MainActivity extends AppCompatActivity {
|
||||
EditText et = view.findViewById(R.id.et_auth_value);
|
||||
TextView tip = view.findViewById(R.id.tv_auth_tip);
|
||||
|
||||
// 根据选中的鉴权方式切换输入框与提示文案。默认选中“免密连接”,输入框隐藏。
|
||||
rg.setOnCheckedChangeListener((group, checkedId) -> {
|
||||
if (checkedId == R.id.rb_password) {
|
||||
et.setHint("请输入固定密码");
|
||||
tip.setText("固定密码为被控端设置的固定密码");
|
||||
if (checkedId == R.id.rb_none) {
|
||||
et.setVisibility(View.GONE);
|
||||
tip.setVisibility(View.VISIBLE);
|
||||
tip.setText(R.string.auth_none_tip);
|
||||
} else if (checkedId == R.id.rb_password) {
|
||||
et.setVisibility(View.VISIBLE);
|
||||
et.setHint(R.string.auth_password_hint);
|
||||
tip.setVisibility(View.VISIBLE);
|
||||
tip.setText(R.string.auth_password_tip);
|
||||
} else {
|
||||
et.setHint("请输入动态验证码");
|
||||
tip.setText("动态验证码为被控端界面显示的 6 位大小写字母与数字组合");
|
||||
et.setVisibility(View.VISIBLE);
|
||||
et.setHint(R.string.auth_code_hint);
|
||||
tip.setVisibility(View.VISIBLE);
|
||||
tip.setText(R.string.auth_code_tip);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -263,15 +275,22 @@ public class MainActivity extends AppCompatActivity {
|
||||
// 校验失败时不关闭对话框,引导用户重新输入
|
||||
dialog.setOnShowListener(d -> dialog.getButton(AlertDialog.BUTTON_POSITIVE)
|
||||
.setOnClickListener(v -> {
|
||||
boolean isPassword = (rg.getCheckedRadioButtonId() == R.id.rb_password);
|
||||
String authType = isPassword ? "PASSWORD" : "CODE";
|
||||
String authValue = et.getText().toString().trim();
|
||||
if (authValue.isEmpty()) {
|
||||
Toast.makeText(MainActivity.this, "请输入验证码或密码", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
int checkedId = rg.getCheckedRadioButtonId();
|
||||
// 免密连接(NONE)无需输入验证码/密码
|
||||
if (checkedId == R.id.rb_none) {
|
||||
pendingAuthType = "NONE";
|
||||
pendingAuthValue = "";
|
||||
} else {
|
||||
boolean isPassword = (checkedId == R.id.rb_password);
|
||||
String authType = isPassword ? "PASSWORD" : "CODE";
|
||||
String authValue = et.getText().toString().trim();
|
||||
if (authValue.isEmpty()) {
|
||||
Toast.makeText(MainActivity.this, "请输入验证码或密码", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
pendingAuthType = authType;
|
||||
pendingAuthValue = authValue;
|
||||
}
|
||||
pendingAuthType = authType;
|
||||
pendingAuthValue = authValue;
|
||||
dialog.dismiss();
|
||||
connectToControlled();
|
||||
}));
|
||||
|
||||
@@ -146,12 +146,20 @@
|
||||
android:textSize="12sp" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+rid/spinner_resolution"
|
||||
android:id="@+id/spinner_resolution"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:backgroundTint="#80FFFFFF" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_disconnect_control"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:backgroundTint="#E53935"
|
||||
android:text="断开连接"
|
||||
android:textColor="@android:color/white" />
|
||||
<Switch
|
||||
android:id="@+rid/switch_stream_mode"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -12,17 +12,23 @@
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rb_code"
|
||||
android:id="@+id/rb_none"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:text="动态验证码" />
|
||||
android:text="@string/auth_none" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rb_code"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/auth_code" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rb_password"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="固定密码" />
|
||||
android:text="@string/auth_password" />
|
||||
</RadioGroup>
|
||||
|
||||
<EditText
|
||||
@@ -30,15 +36,16 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:hint="请输入动态验证码"
|
||||
android:inputType="textVisiblePassword" />
|
||||
android:hint="@string/auth_input_hint"
|
||||
android:inputType="textVisiblePassword"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_auth_tip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="动态验证码为被控端界面显示的 6 位大小写字母与数字组合"
|
||||
android:text="@string/auth_none_tip"
|
||||
android:textSize="12sp"
|
||||
android:textColor="#888888" />
|
||||
</LinearLayout>
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">WebRTC控制端</string>
|
||||
|
||||
<!-- 连接鉴权 -->
|
||||
<string name="auth_none">免密连接</string>
|
||||
<string name="auth_code">动态验证码</string>
|
||||
<string name="auth_password">固定密码</string>
|
||||
<string name="auth_none_tip">免密连接:被控端将弹出手动确认对话框,无需输入验证码或密码。</string>
|
||||
<string name="auth_code_tip">动态验证码为被控端界面显示的 6 位大小写字母与数字组合</string>
|
||||
<string name="auth_password_tip">固定密码为被控端设置的固定密码</string>
|
||||
<string name="auth_code_hint">请输入动态验证码</string>
|
||||
<string name="auth_password_hint">请输入固定密码</string>
|
||||
<string name="auth_input_hint">请输入验证码或密码</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user