first commit

This commit is contained in:
2026-04-25 17:22:36 +08:00
commit 8c691b0f68
62 changed files with 2290 additions and 0 deletions

15
.gitignore vendored Normal file
View File

@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties

3
.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

6
.idea/AndroidProjectSystem.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidProjectSystem">
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
</component>
</project>

6
.idea/compiler.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="21" />
</component>
</project>

11
.idea/deploymentTargetSelector.xml generated Normal file
View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetSelector">
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
<DialogSelection />
</SelectionState>
</selectionStates>
</component>
</project>

18
.idea/gradle.xml generated Normal file
View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="CHOOSE_PER_TEST" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

22
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,22 @@
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
<component name="StoredSessionsInfoStore">
<option name="sessions">
<list>
<SessionInfoState>
<option name="id" value="20260424-112231-c7574f1f-5cc0-411e-b657-576a7f103e77" />
<option name="lastUpdateTimestamp" value="1777000951923" />
<option name="responseMode" value="Agent" />
<option name="title" value="New Agent Session" />
<option name="user" value="guest" />
</SessionInfoState>
</list>
</option>
</component>
</project>

17
.idea/runConfigurations.xml generated Normal file
View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
</set>
</option>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

1
app/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

54
app/build.gradle.kts Normal file
View File

@@ -0,0 +1,54 @@
plugins {
alias(libs.plugins.android.application)
}
android {
namespace = "com.example.defenseapplication"
compileSdk {
version = release(36) {
minorApiLevel = 1
}
}
defaultConfig {
applicationId = "com.example.defenseapplication"
minSdk = 24
targetSdk = 36
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
buildFeatures {
viewBinding=true
}
}
dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.activity)
implementation(libs.androidx.constraintlayout)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
implementation("com.squareup.okhttp3:okhttp:4.12.0")
// 可选:协程扩展支持
implementation("com.squareup.okhttp3:okhttp-coroutines:4.12.0")
}

21
app/proguard-rules.pro vendored Normal file
View File

@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -0,0 +1,24 @@
package com.example.defenseapplication
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.example.defenseapplication", appContext.packageName)
}
}

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.DefenseApplication">
<activity
android:name=".login.ForgetPasswordActivity"
android:exported="false" />
<activity
android:name=".login.RegisterActivity"
android:exported="false" />
<activity
android:name=".login.LoginActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,205 @@
package com.example.defenseapplication.login
import android.os.Bundle
import android.os.CountDownTimer
import android.text.InputType
import android.text.TextUtils
import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.example.defenseapplication.R
import com.example.defenseapplication.databinding.ForgetPasswordActivityBinding
import com.example.defenseapplication.okhttp.OkHttpClientManager
import java.util.regex.Pattern
import kotlin.random.Random
class ForgetPasswordActivity : AppCompatActivity() {
private lateinit var binding: ForgetPasswordActivityBinding
private var verifyCode: String? = null // 存储模拟验证码
private var countDownTimer: CountDownTimer? = null
private var isSendingCode = false // 防止重复发送验证码
companion object {
private const val COUNTDOWN_DURATION = 60000L // 60秒倒计时
private const val COUNTDOWN_INTERVAL = 1000L
private const val MIN_PASSWORD_LENGTH = 6
private const val MAX_PASSWORD_LENGTH = 20
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ForgetPasswordActivityBinding.inflate(layoutInflater)
setContentView(binding.root)
setupClickListeners()
}
private fun setupClickListeners() {
// 返回按钮
binding.backIcon.setOnClickListener {
finish()
}
// 发送验证码按钮
binding.sendCodeBtn.setOnClickListener {
if (!isSendingCode && countDownTimer == null) {
val phoneNumber = binding.etPhoneNumber.text.toString().trim()
if (isPhoneNumberValid(phoneNumber)) {
sendVerificationCode(phoneNumber)
} else {
Toast.makeText(this, "请输入有效的11位手机号", Toast.LENGTH_SHORT).show()
}
} else {
Toast.makeText(this, "请稍后再试", Toast.LENGTH_SHORT).show()
}
}
// 确定按钮(重置密码)
binding.btnNext.setOnClickListener {
performResetPassword()
}
}
/**
* 手机号格式校验简单1开头的11位数字
*/
private fun isPhoneNumberValid(phone: String): Boolean {
if (TextUtils.isEmpty(phone)) return false
val pattern = Pattern.compile("^1[0-9]{10}$")
return pattern.matcher(phone).matches()
}
/**
* 发送验证码
*/
private fun sendVerificationCode(phoneNumber: String) {
isSendingCode = true
binding.sendCodeBtn.isEnabled = false
OkHttpClientManager.postForm(
url = "https://httpbin.org/post",
params = mapOf("phone" to phoneNumber)
) { result ->
result.onSuccess {
verifyCode = (100000 + Random.nextInt(900000)).toString()
startCountDown()
Toast.makeText(this, "验证码已发送(演示码:$verifyCode", Toast.LENGTH_SHORT).show()
}.onFailure {
Toast.makeText(this@ForgetPasswordActivity, "发送失败,请重试", Toast.LENGTH_SHORT).show()
resetSendButton()
}
isSendingCode = false
}
}
/**
* 开始验证码按钮倒计时
*/
private fun startCountDown() {
countDownTimer = object : CountDownTimer(COUNTDOWN_DURATION, COUNTDOWN_INTERVAL) {
override fun onTick(millisUntilFinished: Long) {
val secondsRemaining = (millisUntilFinished / 1000).toInt()
binding.sendCodeBtn.text = "${secondsRemaining}秒后重试"
binding.sendCodeBtn.isEnabled = false
}
override fun onFinish() {
resetSendButton()
}
}.start()
}
/**
* 重置发送按钮状态
*/
private fun resetSendButton() {
countDownTimer?.cancel()
countDownTimer = null
binding.sendCodeBtn.text = "发送验证码"
binding.sendCodeBtn.isEnabled = true
}
/**
* 执行重置密码请求
*/
private fun performResetPassword() {
val phoneNumber = binding.etPhoneNumber.text.toString().trim()
val code = binding.etSmsCode.text.toString().trim()
val newPassword = binding.etPassword.text.toString().trim()
val confirmPassword = binding.etInviteCode.text.toString().trim()
// 1. 手机号校验
if (!isPhoneNumberValid(phoneNumber)) {
Toast.makeText(this, "手机号格式不正确", Toast.LENGTH_SHORT).show()
return
}
// 2. 验证码校验
if (TextUtils.isEmpty(code)) {
Toast.makeText(this, "请输入验证码", Toast.LENGTH_SHORT).show()
return
}
if (verifyCode == null) {
Toast.makeText(this, "请先获取验证码", Toast.LENGTH_SHORT).show()
return
}
if (code != verifyCode) {
Toast.makeText(this, "验证码错误", Toast.LENGTH_SHORT).show()
return
}
// 3. 密码校验
if (TextUtils.isEmpty(newPassword) || TextUtils.isEmpty(confirmPassword)) {
Toast.makeText(this, "密码不能为空", Toast.LENGTH_SHORT).show()
return
}
if (newPassword.length < MIN_PASSWORD_LENGTH || newPassword.length > MAX_PASSWORD_LENGTH) {
Toast.makeText(this, "密码长度需为${MIN_PASSWORD_LENGTH}-${MAX_PASSWORD_LENGTH}", Toast.LENGTH_SHORT).show()
return
}
if (!newPassword.matches(Regex(".*[A-Za-z].*")) || !newPassword.matches(Regex(".*[0-9].*"))) {
Toast.makeText(this, "密码需同时包含字母和数字", Toast.LENGTH_SHORT).show()
return
}
if (newPassword != confirmPassword) {
Toast.makeText(this, "两次输入的密码不一致", Toast.LENGTH_SHORT).show()
return
}
// 禁用确定按钮,防重复提交
binding.btnNext.isEnabled = false
binding.btnNext.text = "重置中..."
val requestJson = """
{
"phone":"$phoneNumber",
"code":"$code",
"newPassword":"$newPassword"
}
""".trimIndent()
OkHttpClientManager.postJson(
url = "https://httpbin.org/post",
json = requestJson
) { result ->
result.onSuccess {
Toast.makeText(this, "密码重置成功,请重新登录", Toast.LENGTH_LONG).show()
finish()
}.onFailure {
Toast.makeText(this, "网络异常,请重试", Toast.LENGTH_SHORT).show()
}
binding.btnNext.isEnabled = true
binding.btnNext.text = "确定"
}
}
override fun onDestroy() {
super.onDestroy()
countDownTimer?.cancel()
countDownTimer = null
}
}

View File

@@ -0,0 +1,162 @@
package com.example.defenseapplication.login
import android.content.Intent
import com.example.defenseapplication.R
import android.os.Bundle
import android.os.CountDownTimer
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import com.example.defenseapplication.databinding.ActivityLoginBinding
class LoginActivity : AppCompatActivity() {
private lateinit var binding: ActivityLoginBinding
private var currentLoginMode = LoginMode.SMS
enum class LoginMode { SMS, PASSWORD }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityLoginBinding.inflate(layoutInflater)
setContentView(binding.root)
setupTabListeners()
setupClickListeners()
switchToSmsMode()
}
private fun setupTabListeners() {
binding.tvSmsLogin.setOnClickListener {
if (currentLoginMode != LoginMode.SMS) {
currentLoginMode = LoginMode.SMS
switchToSmsMode()
}
}
binding.tvPwdLogin.setOnClickListener {
if (currentLoginMode != LoginMode.PASSWORD) {
currentLoginMode = LoginMode.PASSWORD
switchToPasswordMode()
}
}
}
private fun switchToSmsMode() {
binding.tvSmsLogin.setTextColor(getColor(R.color.black))
binding.tvPwdLogin.setTextColor(getColor(R.color.gray))
binding.smsRowLayout.visibility = View.VISIBLE
binding.passwordRowLayout.visibility = View.GONE // 隐藏密码行容器
binding.registerText.visibility = View.VISIBLE
binding.forgetText.visibility = View.GONE
updateRegisterTextConstraints(center = true)
//需要正确的方法名和参数
updateLoginButtonTopConstraint(R.id.smsRowLayout)
}
private fun switchToPasswordMode() {
binding.tvPwdLogin.setTextColor(getColor(R.color.black))
binding.tvSmsLogin.setTextColor(getColor(R.color.gray))
binding.smsRowLayout.visibility = View.GONE
//正确的属性访问
binding.passwordRowLayout.visibility = View.VISIBLE // 显示密码行容器
binding.registerText.visibility = View.VISIBLE
binding.forgetText.visibility = View.VISIBLE
updateRegisterTextConstraints(center = false)
updateLoginButtonTopConstraint(R.id.passwordRowLayout)
}
// 动态修改登录按钮的顶部约束
private fun updateLoginButtonTopConstraint(topTargetId: Int) {
val params = binding.loginBtn.layoutParams as ConstraintLayout.LayoutParams
params.topToBottom = topTargetId
params.topMargin = 32
binding.loginBtn.layoutParams = params
}
// 动态修改立即注册的约束(居中/左对齐)
private fun updateRegisterTextConstraints(center: Boolean) {
val params = binding.registerText.layoutParams as ConstraintLayout.LayoutParams
if (center) {
// 短信模式:居中显示
params.startToStart = ConstraintSet.PARENT_ID
params.endToEnd = ConstraintSet.PARENT_ID
} else {
// 密码模式:左对齐登录按钮
params.startToStart = binding.loginBtn.id
params.endToEnd = ConstraintSet.UNSET
}
params.topToBottom = binding.loginBtn.id
params.topMargin = 20
binding.registerText.layoutParams = params
}
private fun setupClickListeners() {
binding.loginBtn.setOnClickListener {
val phone = binding.etPhone.text.toString()
if (phone.isEmpty()) {
Toast.makeText(this, "请输入手机号", Toast.LENGTH_SHORT).show()
return@setOnClickListener
}
when (currentLoginMode) {
LoginMode.SMS -> {
val code = binding.etSmsCode.text.toString()
if (code.isEmpty()) {
Toast.makeText(this, "请输入验证码", Toast.LENGTH_SHORT).show()
} else {
Toast.makeText(this, "验证码登录成功\n手机号:$phone\n验证码:$code", Toast.LENGTH_SHORT).show()
}
}
LoginMode.PASSWORD -> {
val pwd = binding.etPassword.text.toString()
if (pwd.isEmpty()) {
Toast.makeText(this, "请输入密码", Toast.LENGTH_SHORT).show()
} else {
Toast.makeText(this, "密码登录成功\n手机号:$phone\n密码:$pwd", Toast.LENGTH_SHORT).show()
}
}
}
}
binding.sendCodeBtn.setOnClickListener {
val phone = binding.etPhone.text.toString()
if (phone.isEmpty()) {
Toast.makeText(this, "请先输入手机号", Toast.LENGTH_SHORT).show()
return@setOnClickListener
}
Toast.makeText(this, "验证码已发送至 $phone", Toast.LENGTH_SHORT).show()
startCountDown()
}
binding.registerText.setOnClickListener {
val intent= Intent(this, RegisterActivity::class.java)
startActivity(intent)
Toast.makeText(this, "跳转到注册页面", Toast.LENGTH_SHORT).show()
}
binding.forgetText.setOnClickListener {
val intent= Intent(this, ForgetPasswordActivity::class.java)
startActivity(intent)
Toast.makeText(this, "找回密码", Toast.LENGTH_SHORT).show()
}
}
private fun startCountDown() {
binding.sendCodeBtn.isEnabled = false
object : CountDownTimer(60000, 1000) {
override fun onTick(millisUntilFinished: Long) {
binding.sendCodeBtn.text = "${millisUntilFinished / 1000}秒后重试"
}
override fun onFinish() {
binding.sendCodeBtn.text = "发送验证码"
binding.sendCodeBtn.isEnabled = true
}
}.start()
}
}

View File

@@ -0,0 +1,185 @@
package com.example.defenseapplication.login
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.example.defenseapplication.databinding.RegisterActivityBinding
/**
* 注册页面
* 功能:收集用户信息(手机号、身份证号、密码、邀请码),
* 进行前端格式校验,模拟注册请求并反馈结果。
*/
class RegisterActivity : AppCompatActivity() {
private lateinit var binding: RegisterActivityBinding
private var isLoading = false // 防止重复点击
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = RegisterActivityBinding.inflate(layoutInflater)
setContentView(binding.root)
setupListeners()
//setupTextWatchers()
}
private fun setupListeners() {
// 返回按钮
binding.backIcon.setOnClickListener {
finish()
}
// 下一步按钮
binding.btnNext.setOnClickListener {
if (!isLoading) {
//performRegistration()
}
}
}
//
// /**
// * 为输入框添加文字监听,实时清除错误提示
// */
// private fun setupTextWatchers() {
// val errorClearWatcher = object : TextWatcher {
// override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
// override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
// override fun afterTextChanged(s: Editable?) {
// // 当用户开始输入时,清除该字段的错误
// when (binding.etPhoneNumber.hasFocus()) {
// true -> binding.etPhoneNumber.error = null
// else -> Unit
// }
// when (binding.etIdNumber.hasFocus()) {
// true -> binding.etIdNumber.error = null
// else -> Unit
// }
// when (binding.etPassword.hasFocus()) {
// true -> binding.etPassword.error = null
// else -> Unit
// }
// }
// }
//
// binding.etPhoneNumber.addTextChangedListener(errorClearWatcher)
// binding.etIdNumber.addTextChangedListener(errorClearWatcher)
// binding.etPassword.addTextChangedListener(errorClearWatcher)
// }
//
// /**
// * 执行注册流程:校验输入 -> 模拟网络请求
// */
// private fun performRegistration() {
// val phone = binding.etPhoneNumber.text.toString().trim()
// val idNumber = binding.etIdNumber.text.toString().trim()
// val password = binding.etPassword.text.toString().trim()
// val inviteCode = binding.etInviteCode.text.toString().trim()
//
// // 1. 校验
// val phoneValid = validatePhone(phone)
// val idValid = validateIdNumber(idNumber)
// val passwordValid = validatePassword(password)
//
// if (!phoneValid) {
// binding.etPhoneNumber.error = "请输入有效的11位手机号"
// binding.etPhoneNumber.requestFocus()
// return
// }
// if (!idValid) {
// binding.etIdNumber.error = "请输入正确的身份证号"
// binding.etIdNumber.requestFocus()
// return
// }
// if (!passwordValid) {
// binding.etPassword.error = "密码长度需为6~20位"
// binding.etPassword.requestFocus()
// return
// }
//
// // 2. 模拟注册请求(展示加载状态)
// isLoading = true
// binding.btnNext.isEnabled = false
// binding.btnNext.text = "注册中..."
//
// lifecycleScope.launch {
// // 模拟网络延迟 1.5 秒
// val registerResult = simulateRegister(phone, idNumber, password, inviteCode)
// delay(1500)
//
// isLoading = false
// binding.btnNext.isEnabled = true
// binding.btnNext.text = "下一步"
//
// if (registerResult) {
// Toast.makeText(this@RegisterActivity, "注册成功!", Toast.LENGTH_SHORT).show()
// // 实际项目中通常跳转到登录页或主页,这里简单关闭当前页面
// finish()
// } else {
// Toast.makeText(this@RegisterActivity, "注册失败,请稍后重试", Toast.LENGTH_SHORT).show()
// }
// }
// }
//
// /**
// * 模拟注册请求(实际应替换为 Retrofit/OkHttp 调用)
// */
// private suspend fun simulateRegister(
// phone: String,
// idNumber: String,
// password: String,
// inviteCode: String
// ): Boolean {
// // 模拟网络请求,此处始终返回成功(实际根据后端响应决定)
// // 您可以在这里添加真实网络请求逻辑
// return true
// }
// /**
// * 校验手机号中国大陆手机号简单校验1开头的11位数字第二位3-9
// */
// private fun validatePhone(phone: String): Boolean {
// val phoneRegex = Pattern.compile("^1[3-9]\\d{9}$")
// return phone.isNotEmpty() && phoneRegex.matcher(phone).matches()
// }
//
// /**
// * 校验身份证号支持15位和18位18位时校验最后一位校验码
// */
// private fun validateIdNumber(idNumber: String): Boolean {
// if (idNumber.isEmpty()) return false
// // 长度校验
// if (idNumber.length != 15 && idNumber.length != 18) return false
//
// // 15位全数字
// if (idNumber.length == 15) {
// return idNumber.all { it.isDigit() }
// }
//
// // 18位前17位为数字最后一位为数字或大写X
// val regex = Regex("^\\d{17}[\\dXx]$")
// if (!regex.matches(idNumber)) return false
//
// // 校验最后一位校验码(可选,提升准确性)
// return verifyIdCardChecksum(idNumber)
// }
//
// /**
// * 身份证最后一位校验码校验仅18位
// */
// private fun verifyIdCardChecksum(id18: String): Boolean {
// val weights = intArrayOf(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2)
// val checkCodes = charArrayOf('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2')
// var sum = 0
// for (i in 0 until 17) {
// sum += (id18[i] - '0') * weights[i]
// }
// val mod = sum % 11
// val expectedCheckCode = checkCodes[mod]
// return id18[17].uppercaseChar() == expectedCheckCode
// }
//
// /**
// * 校验密码长度6~20位
// */
// private fun validatePassword(password: String): Boolean {
// return password.length in 6..20
// }
}

View File

@@ -0,0 +1,4 @@
package com.example.defenseapplication.okhttp
class OkHttpClient {
}

View File

@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>

View File

@@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/green"/>
<corners android:radius="16dp"/>
</shape>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/white"/>
<corners android:radius="10dp"/>
</shape>

View File

@@ -0,0 +1,258 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/login_background"
android:id="@+id/main"
android:padding="16dp">
<!-- Logo 图片:水平居中 -->
<ImageView
android:id="@+id/logoFrame"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="@mipmap/loge"
android:contentDescription="Logo"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="32dp" />
<!-- 文字:放在图片下方,水平居中 -->
<TextView
android:id="@+id/logoText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="智能防御机"
android:textSize="28sp"
android:textStyle="bold"
android:textColor="@color/black"
app:layout_constraintTop_toBottomOf="@id/logoFrame"
app:layout_constraintStart_toStartOf="@id/logoFrame"
app:layout_constraintEnd_toEndOf="@id/logoFrame"
android:layout_marginTop="12dp" />
<!-- Tab 切换栏背景(可选下划线指示器) -->
<View
android:id="@+id/tabDivider"
android:layout_width="0dp"
android:layout_height="2dp"
app:layout_constraintTop_toBottomOf="@+id/tvSmsLogin"
app:layout_constraintStart_toStartOf="@+id/tvSmsLogin"
app:layout_constraintEnd_toEndOf="@+id/tvPwdLogin"
app:layout_constraintWidth_percent="0.5"
android:visibility="invisible" />
<!-- 验证码登录 Tab -->
<TextView
android:id="@+id/tvSmsLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="58dp"
android:gravity="center"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:text="验证码登录"
android:textColor="@color/black"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/logoText" />
<!-- 密码登录 Tab -->
<TextView
android:id="@+id/tvPwdLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密码登录"
android:textSize="18sp"
android:gravity="center"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:textColor="@color/gray"
app:layout_constraintTop_toTopOf="@+id/tvSmsLogin"
app:layout_constraintStart_toEndOf="@+id/tvSmsLogin"
android:layout_marginStart="24dp" />
<!-- 手机号输入行容器 -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/phoneRowLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/textinput_white_bg"
app:layout_constraintTop_toBottomOf="@+id/tvSmsLogin"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:paddingStart="16dp"
android:paddingEnd="16dp">
<ImageView
android:id="@+id/ivPhoneIcon"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@mipmap/lg"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
<!-- 手机号输入框 -->
<EditText
android:id="@+id/etPhone"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:hint="请输入手机号"
android:textColorHint="@color/gray"
android:textColor="@android:color/black"
android:background="@null"
android:inputType="phone"
android:paddingVertical="16dp"
app:layout_constraintStart_toEndOf="@+id/ivPhoneIcon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- 验证码登录专用区域:图标 + 验证码输入框 + 发送按钮 -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/smsRowLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/textinput_white_bg"
android:paddingStart="16dp"
android:paddingEnd="16dp"
app:layout_constraintTop_toBottomOf="@+id/phoneRowLayout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:visibility="visible">
<!-- 左侧图标 -->
<ImageView
android:id="@+id/ivSmsIcon"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@mipmap/vc"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
<!-- 验证码输入框(无背景) -->
<EditText
android:id="@+id/etSmsCode"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:hint="请输入验证码"
android:textColorHint="@color/gray"
android:textColor="@android:color/black"
android:background="@null"
android:inputType="number"
android:paddingVertical="16dp"
app:layout_constraintStart_toEndOf="@+id/ivSmsIcon"
app:layout_constraintEnd_toStartOf="@+id/sendCodeBtn"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
<!-- 发送验证码按钮 -->
<android.widget.Button
android:id="@+id/sendCodeBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="发送验证码"
android:textSize="16sp"
android:textColor="@color/white"
android:background="@drawable/rounded_blue_bg"
android:paddingHorizontal="12dp"
android:maxWidth="120dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginStart="12dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- 密码登录专用区域:图标 + 密码输入框 -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/passwordRowLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/textinput_white_bg"
android:paddingStart="16dp"
android:paddingEnd="16dp"
app:layout_constraintTop_toBottomOf="@+id/phoneRowLayout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:visibility="gone"> <!-- 初始隐藏 -->
<!-- 左侧图标 -->
<ImageView
android:id="@+id/ivPasswordIcon"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@mipmap/ma"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
<!-- 密码输入框(无背景) -->
<EditText
android:id="@+id/etPassword"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:hint="请输入密码"
android:textColorHint="@color/gray"
android:textColor="@android:color/black"
android:background="@null"
android:inputType="textPassword"
android:paddingVertical="16dp"
app:layout_constraintStart_toEndOf="@+id/ivPasswordIcon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- 登录按钮 -->
<android.widget.Button
android:id="@+id/loginBtn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="登录"
android:textSize="18sp"
android:background="@drawable/rounded_blue_bg"
android:textColor="@color/white"
app:layout_constraintTop_toBottomOf="@+id/smsRowLayout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<!-- 立即注册 -->
<TextView
android:id="@+id/registerText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="立即注册"
android:textSize="14sp"
android:textColor="@color/green"
android:padding="8dp"
app:layout_constraintTop_toBottomOf="@+id/loginBtn"
app:layout_constraintStart_toStartOf="@+id/loginBtn"
android:layout_marginTop="20dp" />
<!-- 忘记密码 -->
<TextView
android:id="@+id/forgetText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="忘记密码"
android:textSize="14sp"
android:textColor="@color/green"
android:padding="8dp"
android:visibility="gone"
app:layout_constraintTop_toTopOf="@+id/registerText"
app:layout_constraintEnd_toEndOf="@+id/loginBtn" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,259 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="@color/login_background"
android:id="@+id/main"
android:padding="16dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".login.RegisterActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/topContainer"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:paddingStart="16dp"
android:paddingEnd="16dp">
<ImageView
android:id="@+id/backIcon"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@mipmap/back"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
<!-- 标题:找回密码 -->
<TextView
android:id="@+id/tvRegisterTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="找回密码"
android:textColor="@color/black"
android:textSize="32sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@id/backIcon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/backIcon" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- 副标题:找回密码 -->
<TextView
android:id="@+id/tvRegisterSubtitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="找回密码"
android:textColor="@color/black"
android:textSize="20dp"
android:textStyle="bold"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/topContainer" />
<!-- 手机号输入行容器 -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/phoneRowLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:background="@drawable/textinput_white_bg"
android:paddingStart="16dp"
android:paddingEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvRegisterSubtitle">
<ImageView
android:id="@+id/ivPhoneIcon"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@mipmap/lg"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/etPhoneNumber"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:background="@null"
android:hint="请输入手机号"
android:inputType="phone"
android:maxLength="11"
android:paddingVertical="16dp"
android:textColor="@android:color/black"
android:textColorHint="@color/gray"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/ivPhoneIcon"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- 验证码登录专用区域:图标 + 验证码输入框 + 发送按钮 -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/smsRowLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/textinput_white_bg"
android:paddingStart="16dp"
android:paddingEnd="16dp"
app:layout_constraintTop_toBottomOf="@+id/phoneRowLayout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:visibility="visible">
<!-- 左侧图标 -->
<ImageView
android:id="@+id/ivSmsIcon"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@mipmap/vc"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
<!-- 验证码输入框(无背景) -->
<EditText
android:id="@+id/etSmsCode"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:hint="请输入验证码"
android:textColorHint="@color/gray"
android:textColor="@android:color/black"
android:background="@null"
android:inputType="number"
android:paddingVertical="16dp"
app:layout_constraintStart_toEndOf="@+id/ivSmsIcon"
app:layout_constraintEnd_toStartOf="@+id/sendCodeBtn"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
<!-- 发送验证码按钮 -->
<android.widget.Button
android:id="@+id/sendCodeBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="发送验证码"
android:textSize="16sp"
android:textColor="@color/white"
android:background="@drawable/rounded_blue_bg"
android:paddingHorizontal="12dp"
android:maxWidth="120dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginStart="12dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- 请输入新密码 -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/passwordRowLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/textinput_white_bg"
android:paddingStart="16dp"
android:paddingEnd="16dp"
app:layout_constraintTop_toBottomOf="@+id/smsRowLayout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<!-- 左侧图标 -->
<ImageView
android:id="@+id/ivPasswordIcon"
android:layout_width="20dp"
android:layout_height="20dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
<!-- 密码输入框(无背景) -->
<EditText
android:id="@+id/etPassword"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:hint="请输入新密码"
android:textColorHint="@color/gray"
android:textColor="@android:color/black"
android:background="@null"
android:inputType="text"
android:paddingVertical="16dp"
app:layout_constraintStart_toEndOf="@+id/ivPasswordIcon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- 请再次输入新密码 -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/inviteRowLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/textinput_white_bg"
android:paddingStart="16dp"
android:paddingEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/passwordRowLayout">
<ImageView
android:id="@+id/ivInviteIcon"
android:layout_width="20dp"
android:layout_height="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/etInviteCode"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:background="@null"
android:hint="请再次输入新密码"
android:inputType="text"
android:maxLength="10"
android:paddingVertical="16dp"
android:textColor="@android:color/black"
android:textColorHint="@color/gray"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/ivInviteIcon"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- 确定按钮 -->
<android.widget.Button
android:id="@+id/btnNext"
android:layout_width="0dp"
android:layout_height="56dp"
android:layout_marginTop="32dp"
android:text="确定"
android:textAllCaps="false"
android:textSize="16sp"
app:cornerRadius="12dp"
android:textColor="@color/white"
android:background="@drawable/rounded_blue_bg"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/inviteRowLayout" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,244 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="@color/login_background"
android:id="@+id/main"
android:padding="16dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".login.RegisterActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/topContainer"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:paddingStart="16dp"
android:paddingEnd="16dp">
<ImageView
android:id="@+id/backIcon"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@mipmap/back"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
<!-- 标题:注册 -->
<TextView
android:id="@+id/tvRegisterTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="注册"
android:textColor="@color/black"
android:textSize="32sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@id/backIcon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/backIcon" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- 副标题:注册用户 -->
<TextView
android:id="@+id/tvRegisterSubtitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="注册用户"
android:textColor="@color/black"
android:textSize="20dp"
android:textStyle="bold"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/topContainer" />
<!-- 手机号输入行容器 -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/phoneRowLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:background="@drawable/textinput_white_bg"
android:paddingStart="16dp"
android:paddingEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvRegisterSubtitle">
<ImageView
android:id="@+id/ivPhoneIcon"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@mipmap/lg"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/etPhoneNumber"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:background="@null"
android:hint="请输入手机号"
android:inputType="phone"
android:maxLength="11"
android:paddingVertical="16dp"
android:textColor="@android:color/black"
android:textColorHint="@color/gray"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/ivPhoneIcon"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- 身份证号输入框 -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/idRowLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/textinput_white_bg"
android:paddingStart="16dp"
android:paddingEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/phoneRowLayout">
<ImageView
android:id="@+id/ivIdIcon"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@mipmap/id_card"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/etIdNumber"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:background="@null"
android:hint="请输入身份证号"
android:inputType="text"
android:maxLength="18"
android:paddingVertical="16dp"
android:textColor="@android:color/black"
android:textColorHint="@color/gray"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/ivIdIcon"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- 密码输入框 -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/passwordRowLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/textinput_white_bg"
android:paddingStart="16dp"
android:paddingEnd="16dp"
app:layout_constraintTop_toBottomOf="@+id/idRowLayout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<!-- 左侧图标 -->
<ImageView
android:id="@+id/ivPasswordIcon"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@mipmap/ma"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
<!-- 密码输入框 -->
<EditText
android:id="@+id/etPassword"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:hint="请输入密码"
android:textColorHint="@color/gray"
android:textColor="@android:color/black"
android:background="@null"
android:inputType="text"
android:paddingVertical="16dp"
app:layout_constraintStart_toEndOf="@+id/ivPasswordIcon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- 邀请码输入框(非必填) -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/inviteRowLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/textinput_white_bg"
android:paddingStart="16dp"
android:paddingEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/passwordRowLayout">
<ImageView
android:id="@+id/ivInviteIcon"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@mipmap/ic"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/etInviteCode"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:background="@null"
android:hint="请输入邀请码(非必填)"
android:inputType="text"
android:maxLength="10"
android:paddingVertical="16dp"
android:textColor="@android:color/black"
android:textColorHint="@color/gray"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/ivInviteIcon"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- 下一步按钮 -->
<android.widget.Button
android:id="@+id/btnNext"
android:layout_width="0dp"
android:layout_height="56dp"
android:layout_marginTop="32dp"
android:text="下一步"
android:textAllCaps="false"
android:textSize="16sp"
app:cornerRadius="12dp"
android:textColor="@color/white"
android:background="@drawable/rounded_blue_bg"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/inviteRowLayout" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 848 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 855 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

@@ -0,0 +1,7 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Base.Theme.DefenseApplication" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Customize your dark theme here. -->
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
</style>
</resources>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="green">#09C2BD </color>
<color name="gray">#999999</color>
<color name="login_background">#EDF4FF</color>
<color name="red">#E34D59</color>
</resources>

View File

@@ -0,0 +1,3 @@
<resources>
<string name="app_name">DefenseApplication</string>
</resources>

View File

@@ -0,0 +1,9 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Base.Theme.DefenseApplication" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Customize your light theme here. -->
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
</style>
<style name="Theme.DefenseApplication" parent="Base.Theme.DefenseApplication" />
</resources>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample backup rules file; uncomment and customize as necessary.
See https://developer.android.com/guide/topics/data/autobackup
for details.
Note: This file is ignored for devices older than API 31
See https://developer.android.com/about/versions/12/backup-restore
-->
<full-backup-content>
<!--
<include domain="sharedpref" path="."/>
<exclude domain="sharedpref" path="device.xml"/>
-->
</full-backup-content>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample data extraction rules file; uncomment and customize as necessary.
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
for details.
-->
<data-extraction-rules>
<cloud-backup>
<!-- TODO: Use <include> and <exclude> to control what is backed up.
<include .../>
<exclude .../>
-->
</cloud-backup>
<!--
<device-transfer>
<include .../>
<exclude .../>
</device-transfer>
-->
</data-extraction-rules>

View File

@@ -0,0 +1,17 @@
package com.example.defenseapplication
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}

4
build.gradle.kts Normal file
View File

@@ -0,0 +1,4 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.application) apply false
}

15
gradle.properties Normal file
View File

@@ -0,0 +1,15 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. For more details, visit
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
# org.gradle.parallel=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official

View File

@@ -0,0 +1,12 @@
#This file is generated by updateDaemonJvm
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/ec7520a1e057cd116f9544c42142a16b/redirect
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/4c4f879899012ff0a8b2e2117df03b0e/redirect
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/ec7520a1e057cd116f9544c42142a16b/redirect
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/4c4f879899012ff0a8b2e2117df03b0e/redirect
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/73bcfb608d1fde9fb62e462f834a3299/redirect
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/846ee0d876d26a26f37aa1ce8de73224/redirect
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/ec7520a1e057cd116f9544c42142a16b/redirect
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/4c4f879899012ff0a8b2e2117df03b0e/redirect
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/9482ddec596298c84656d31d16652665/redirect
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/39701d92e1756bb2f141eb67cd4c660e/redirect
toolchainVersion=21

24
gradle/libs.versions.toml Normal file
View File

@@ -0,0 +1,24 @@
[versions]
agp = "9.1.1"
coreKtx = "1.10.1"
junit = "4.13.2"
junitVersion = "1.1.5"
espressoCore = "3.5.1"
appcompat = "1.6.1"
material = "1.10.0"
activity = "1.8.0"
constraintlayout = "2.1.4"
[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,9 @@
#Sat Apr 25 09:23:25 CST 2026
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=b266d5ff6b90eada6dc3b20cb090e3731302e553a27c5d3e4df1f0d76beaff06
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

251
gradlew vendored Normal file
View File

@@ -0,0 +1,251 @@
#!/bin/sh
#
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH="\\\"\\\""
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

94
gradlew.bat vendored Normal file
View File

@@ -0,0 +1,94 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

27
settings.gradle.kts Normal file
View File

@@ -0,0 +1,27 @@
pluginManagement {
repositories {
google {
content {
includeGroupByRegex("com\\.android.*")
includeGroupByRegex("com\\.google.*")
includeGroupByRegex("androidx.*")
}
}
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "DefenseApplication"
include(":app")