演示界面调整
This commit is contained in:
parent
9340aa319d
commit
15b04be06f
|
|
@ -4,9 +4,11 @@ import android.content.Intent
|
|||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.EditText
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
|
||||
class DeveloperActivity : AppCompatActivity() {
|
||||
|
|
@ -29,6 +31,48 @@ class DeveloperActivity : AppCompatActivity() {
|
|||
startActivity(Intent(this, com.stand.standapp.printer.PrintTestActivity::class.java))
|
||||
}
|
||||
|
||||
// 本地演示界面
|
||||
findViewById<LinearLayout>(R.id.item_demo_ui).setOnClickListener {
|
||||
val builder = androidx.appcompat.app.AlertDialog.Builder(this)
|
||||
builder.setTitle("本地演示登录")
|
||||
|
||||
val layout = LinearLayout(this).apply {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
setPadding(50, 40, 50, 10)
|
||||
}
|
||||
|
||||
val etUser = EditText(this).apply {
|
||||
hint = "账号"
|
||||
setText("test007")
|
||||
}
|
||||
layout.addView(etUser)
|
||||
|
||||
val etPwd = EditText(this).apply {
|
||||
hint = "密码"
|
||||
setText("123456")
|
||||
inputType = android.text.InputType.TYPE_CLASS_TEXT or android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD
|
||||
}
|
||||
layout.addView(etPwd)
|
||||
|
||||
builder.setView(layout)
|
||||
builder.setPositiveButton("登录") { _, _ ->
|
||||
val username = etUser.text.toString().trim()
|
||||
val password = etPwd.text.toString().trim()
|
||||
if (username.isEmpty() || password.isEmpty()) {
|
||||
Toast.makeText(this, "账号密码不能为空", Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
val intent = Intent(this, LoginActivity::class.java).apply {
|
||||
putExtra("official_mode_login", false)
|
||||
putExtra("extra_username", username)
|
||||
putExtra("extra_password", password)
|
||||
}
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
builder.setNegativeButton("取消", null)
|
||||
builder.show()
|
||||
}
|
||||
|
||||
// 崩溃模拟
|
||||
findViewById<LinearLayout>(R.id.item_crash_test).setOnClickListener {
|
||||
androidx.appcompat.app.AlertDialog.Builder(this)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ class LoginActivity : AppCompatActivity() {
|
|||
val etPassword = findViewById<EditText>(R.id.et_password)
|
||||
val cbRemember = findViewById<CheckBox>(R.id.cb_remember)
|
||||
val btnLogin = findViewById<Button>(R.id.btn_login)
|
||||
val btnLoginOfficial = findViewById<Button>(R.id.btn_login_official)
|
||||
val btnExit = findViewById<Button>(R.id.btn_exit)
|
||||
val ivSettings = findViewById<ImageView>(R.id.iv_settings)
|
||||
val tvCopyright = findViewById<TextView>(R.id.tv_copyright)
|
||||
|
|
@ -46,12 +45,22 @@ class LoginActivity : AppCompatActivity() {
|
|||
etPassword.setText(AppConfig.getSavedPassword(this))
|
||||
}
|
||||
|
||||
// 检查是否有传递过来的用户名和密码(来自开发者界面的演示登录)
|
||||
val extraUsername = intent.getStringExtra("extra_username")
|
||||
val extraPassword = intent.getStringExtra("extra_password")
|
||||
if (!extraUsername.isNullOrEmpty() && !extraPassword.isNullOrEmpty()) {
|
||||
etUsername.setText(extraUsername)
|
||||
etPassword.setText(extraPassword)
|
||||
val isOfficialMode = intent.getBooleanExtra("official_mode_login", true)
|
||||
performLogin(extraUsername, extraPassword, cbRemember.isChecked, isOfficialMode)
|
||||
}
|
||||
|
||||
// 2. 服务器配置图标点击事件
|
||||
ivSettings.setOnClickListener {
|
||||
showServerConfigDialog()
|
||||
}
|
||||
|
||||
// 3. 登录按钮点击事件
|
||||
// 3. 登录按钮点击事件(进行正式界面登录)
|
||||
btnLogin.setOnClickListener {
|
||||
val username = etUsername.text.toString().trim()
|
||||
val password = etPassword.text.toString().trim()
|
||||
|
|
@ -61,21 +70,9 @@ class LoginActivity : AppCompatActivity() {
|
|||
return@setOnClickListener
|
||||
}
|
||||
|
||||
// 执行真实接口登录
|
||||
performLogin(username, password, cbRemember.isChecked, false)
|
||||
}
|
||||
|
||||
// 3.1 正式界面登录按钮点击事件
|
||||
btnLoginOfficial.setOnClickListener {
|
||||
val username = etUsername.text.toString().trim()
|
||||
val password = etPassword.text.toString().trim()
|
||||
|
||||
if (username.isEmpty() || password.isEmpty()) {
|
||||
Toast.makeText(applicationContext, "请输入账号和密码", Toast.LENGTH_SHORT).show()
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
performLogin(username, password, cbRemember.isChecked, true)
|
||||
// 根据传入的 Intent 决定是正式登录还是演示登录,默认是正式登录(true)
|
||||
val isOfficialMode = intent.getBooleanExtra("official_mode_login", true)
|
||||
performLogin(username, password, cbRemember.isChecked, isOfficialMode)
|
||||
}
|
||||
|
||||
// 4. 退出按钮
|
||||
|
|
|
|||
|
|
@ -149,6 +149,53 @@
|
|||
android:tint="#CBD5E1" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 演示界面入口卡片 -->
|
||||
<LinearLayout
|
||||
android:id="@+id/item_demo_ui"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="72dp"
|
||||
android:background="@drawable/bg_developer_item"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:src="@android:drawable/ic_menu_gallery"
|
||||
android:tint="#F59E0B" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginStart="16dp"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="本地演示界面"
|
||||
android:textColor="#1E293B"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="启动本地 H5 打印及 PTT 控制演示页面"
|
||||
android:textColor="#94A3B8"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:src="@android:drawable/ic_media_next"
|
||||
android:tint="#CBD5E1" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 崩溃测试卡片 -->
|
||||
<LinearLayout
|
||||
android:id="@+id/item_crash_test"
|
||||
|
|
|
|||
|
|
@ -268,17 +268,6 @@
|
|||
android:textStyle="bold"
|
||||
android:letterSpacing="0.2" />
|
||||
|
||||
<!-- 正式界面登录按钮 -->
|
||||
<Button
|
||||
android:id="@+id/btn_login_official"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="44dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@drawable/shape_button_secondary"
|
||||
android:text="正式界面登录"
|
||||
android:textColor="#3A7A9A"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<!-- 退出应用 -->
|
||||
<Button
|
||||
android:id="@+id/btn_exit"
|
||||
|
|
|
|||
Loading…
Reference in New Issue