diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
deleted file mode 100644
index 295d4f2..0000000
--- a/app/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- CSAMS
-
\ No newline at end of file
diff --git a/app/.gitignore b/background/.gitignore
similarity index 100%
rename from app/.gitignore
rename to background/.gitignore
diff --git a/background/build.gradle.kts b/background/build.gradle.kts
new file mode 100644
index 0000000..06240ee
--- /dev/null
+++ b/background/build.gradle.kts
@@ -0,0 +1,62 @@
+plugins {
+ id("com.android.application")
+ id("kotlin-android")
+}
+
+android {
+ compileSdk = 30
+
+ defaultConfig {
+ applicationId = "com.gyf.csams.background"
+ minSdk = 21
+ targetSdk = 30
+ versionCode = 1
+ versionName = "1.0"
+
+ testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
+ vectorDrawables {
+ useSupportLibrary = true
+ }
+ }
+
+ buildTypes {
+ release {
+ isMinifyEnabled = false
+ proguardFiles(
+ getDefaultProguardFile("proguard-android-optimize.txt"),
+ "proguard-rules.pro"
+ )
+ }
+ }
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_1_8
+ targetCompatibility = JavaVersion.VERSION_1_8
+ }
+ kotlinOptions {
+ jvmTarget = "1.8"
+ useIR = true
+ }
+ buildFeatures {
+ compose = true
+ }
+ composeOptions {
+ kotlinCompilerExtensionVersion = rootProject.extra["compose_version"] as String
+ kotlinCompilerVersion = "1.4.32"
+ }
+}
+
+dependencies {
+
+ implementation("androidx.core:core-ktx:1.3.2")
+ implementation("androidx.appcompat:appcompat:1.2.0")
+ implementation("com.google.android.material:material:1.3.0")
+ implementation("androidx.compose.ui:ui:${rootProject.extra["compose_version"]}")
+ implementation("androidx.compose.material:material:${rootProject.extra["compose_version"]}")
+ implementation("androidx.compose.ui:ui-tooling:${rootProject.extra["compose_version"]}")
+ implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.3.1")
+ implementation("androidx.activity:activity-compose:1.3.0-alpha07")
+ testImplementation("junit:junit:4.13.2")
+ androidTestImplementation("androidx.test.ext:junit:1.1.2")
+ androidTestImplementation("androidx.test.espresso:espresso-core:3.3.0")
+ androidTestImplementation("androidx.compose.ui:ui-test-junit4:${rootProject.extra["compose_version"]}")
+}
\ No newline at end of file
diff --git a/app/proguard-rules.pro b/background/proguard-rules.pro
similarity index 100%
rename from app/proguard-rules.pro
rename to background/proguard-rules.pro
diff --git a/app/src/androidTest/java/com/gyf/csams/ExampleInstrumentedTest.kt b/background/src/androidTest/java/com/gyf/csams/ExampleInstrumentedTest.kt
similarity index 100%
rename from app/src/androidTest/java/com/gyf/csams/ExampleInstrumentedTest.kt
rename to background/src/androidTest/java/com/gyf/csams/ExampleInstrumentedTest.kt
diff --git a/background/src/main/AndroidManifest.xml b/background/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..0a19ee2
--- /dev/null
+++ b/background/src/main/AndroidManifest.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/background/src/main/java/com/gyf/csams/MainActivity.kt b/background/src/main/java/com/gyf/csams/MainActivity.kt
new file mode 100644
index 0000000..8007e4c
--- /dev/null
+++ b/background/src/main/java/com/gyf/csams/MainActivity.kt
@@ -0,0 +1,38 @@
+package com.gyf.csams
+
+import android.os.Bundle
+import androidx.activity.ComponentActivity
+import androidx.activity.compose.setContent
+import androidx.compose.material.MaterialTheme
+import androidx.compose.material.Surface
+import androidx.compose.material.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.tooling.preview.Preview
+import com.gyf.csams.uikit.theme.CSAMSTheme
+
+class MainActivity : ComponentActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContent {
+ CSAMSTheme {
+ // A surface container using the 'background' color from the theme
+ Surface(color = MaterialTheme.colors.background) {
+ Greeting("Android")
+ }
+ }
+ }
+ }
+}
+
+@Composable
+fun Greeting(name: String) {
+ Text(text = "Hello $name!")
+}
+
+@Preview(showBackground = true)
+@Composable
+fun DefaultPreview() {
+ CSAMSTheme {
+ Greeting("Android")
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/gyf/csams/uikit/theme/Color.kt b/background/src/main/java/com/gyf/csams/uikit/theme/Color.kt
similarity index 100%
rename from app/src/main/java/com/gyf/csams/uikit/theme/Color.kt
rename to background/src/main/java/com/gyf/csams/uikit/theme/Color.kt
diff --git a/app/src/main/java/com/gyf/csams/uikit/theme/Shape.kt b/background/src/main/java/com/gyf/csams/uikit/theme/Shape.kt
similarity index 100%
rename from app/src/main/java/com/gyf/csams/uikit/theme/Shape.kt
rename to background/src/main/java/com/gyf/csams/uikit/theme/Shape.kt
diff --git a/background/src/main/java/com/gyf/csams/uikit/theme/Theme.kt b/background/src/main/java/com/gyf/csams/uikit/theme/Theme.kt
new file mode 100644
index 0000000..4392080
--- /dev/null
+++ b/background/src/main/java/com/gyf/csams/uikit/theme/Theme.kt
@@ -0,0 +1,44 @@
+package com.gyf.csams.uikit.theme
+
+import androidx.compose.foundation.isSystemInDarkTheme
+import androidx.compose.material.MaterialTheme
+import androidx.compose.material.darkColors
+import androidx.compose.material.lightColors
+import androidx.compose.runtime.Composable
+
+private val DarkColorPalette = darkColors(
+ primary = Purple200,
+ primaryVariant = Purple700,
+ secondary = Teal200
+)
+
+private val LightColorPalette = lightColors(
+ primary = Purple500,
+ primaryVariant = Purple700,
+ secondary = Teal200
+
+ /* Other default colors to override
+ background = Color.White,
+ surface = Color.White,
+ onPrimary = Color.White,
+ onSecondary = Color.Black,
+ onBackground = Color.Black,
+ onSurface = Color.Black,
+ */
+)
+
+@Composable
+fun CSAMSTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable() () -> Unit) {
+ val colors = if (darkTheme) {
+ DarkColorPalette
+ } else {
+ LightColorPalette
+ }
+
+ MaterialTheme(
+ colors = colors,
+ typography = Typography,
+ shapes = Shapes,
+ content = content
+ )
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/gyf/csams/uikit/theme/Type.kt b/background/src/main/java/com/gyf/csams/uikit/theme/Type.kt
similarity index 100%
rename from app/src/main/java/com/gyf/csams/uikit/theme/Type.kt
rename to background/src/main/java/com/gyf/csams/uikit/theme/Type.kt
diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/background/src/main/res/drawable-v24/ic_launcher_foreground.xml
similarity index 100%
rename from app/src/main/res/drawable-v24/ic_launcher_foreground.xml
rename to background/src/main/res/drawable-v24/ic_launcher_foreground.xml
diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/background/src/main/res/drawable/ic_launcher_background.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_launcher_background.xml
rename to background/src/main/res/drawable/ic_launcher_background.xml
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/background/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
similarity index 100%
rename from app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
rename to background/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/background/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
similarity index 100%
rename from app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
rename to background/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/background/src/main/res/mipmap-hdpi/ic_launcher.webp
similarity index 100%
rename from app/src/main/res/mipmap-hdpi/ic_launcher.webp
rename to background/src/main/res/mipmap-hdpi/ic_launcher.webp
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/background/src/main/res/mipmap-hdpi/ic_launcher_round.webp
similarity index 100%
rename from app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
rename to background/src/main/res/mipmap-hdpi/ic_launcher_round.webp
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/background/src/main/res/mipmap-mdpi/ic_launcher.webp
similarity index 100%
rename from app/src/main/res/mipmap-mdpi/ic_launcher.webp
rename to background/src/main/res/mipmap-mdpi/ic_launcher.webp
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/background/src/main/res/mipmap-mdpi/ic_launcher_round.webp
similarity index 100%
rename from app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
rename to background/src/main/res/mipmap-mdpi/ic_launcher_round.webp
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/background/src/main/res/mipmap-xhdpi/ic_launcher.webp
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/ic_launcher.webp
rename to background/src/main/res/mipmap-xhdpi/ic_launcher.webp
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/background/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
rename to background/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/background/src/main/res/mipmap-xxhdpi/ic_launcher.webp
similarity index 100%
rename from app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
rename to background/src/main/res/mipmap-xxhdpi/ic_launcher.webp
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/background/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
similarity index 100%
rename from app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
rename to background/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/background/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
similarity index 100%
rename from app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
rename to background/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/background/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
similarity index 100%
rename from app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
rename to background/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
diff --git a/app/src/main/res/values-night/themes.xml b/background/src/main/res/values-night/themes.xml
similarity index 100%
rename from app/src/main/res/values-night/themes.xml
rename to background/src/main/res/values-night/themes.xml
diff --git a/app/src/main/res/values/colors.xml b/background/src/main/res/values/colors.xml
similarity index 100%
rename from app/src/main/res/values/colors.xml
rename to background/src/main/res/values/colors.xml
diff --git a/background/src/main/res/values/strings.xml b/background/src/main/res/values/strings.xml
new file mode 100644
index 0000000..6b30d8d
--- /dev/null
+++ b/background/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/themes.xml b/background/src/main/res/values/themes.xml
similarity index 100%
rename from app/src/main/res/values/themes.xml
rename to background/src/main/res/values/themes.xml
diff --git a/background/src/test/java/com/gyf/csams/ExampleUnitTest.kt b/background/src/test/java/com/gyf/csams/ExampleUnitTest.kt
new file mode 100644
index 0000000..8acd231
--- /dev/null
+++ b/background/src/test/java/com/gyf/csams/ExampleUnitTest.kt
@@ -0,0 +1,16 @@
+package com.gyf.csams
+
+import org.junit.Assert.assertEquals
+import org.junit.Test
+
+/**
+ * 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)
+ }
+}
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
index b5bab5d..c697028 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,14 +1,15 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
//Jetpack Compose版本
- val compose_version by extra("1.0.0-beta04")
+ val compose_version by extra("1.0.0-beta05")
//生命周期组件版本
val lifecycle_version by extra("2.3.1")
//APP应用名字
- val APP_NAME by extra("大学生社团管理系统")
+ val foreground_app_name by extra("学生社团")
val SERVER_ADDRESS by extra("http://192.168.50.107:8080")
val room_version by extra("2.2.6")
val kotlin_version by extra("1.4.32")
+ val background_app_name by extra("社团管理")
repositories {
maven("https://maven.aliyun.com/repository/google")
maven("https://maven.aliyun.com/repository/public")
diff --git a/foreground/.gitignore b/foreground/.gitignore
new file mode 100644
index 0000000..42afabf
--- /dev/null
+++ b/foreground/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/app/build.gradle.kts b/foreground/build.gradle.kts
similarity index 88%
rename from app/build.gradle.kts
rename to foreground/build.gradle.kts
index da5402c..2b19d69 100644
--- a/app/build.gradle.kts
+++ b/foreground/build.gradle.kts
@@ -9,7 +9,7 @@ android {
compileSdk = 30
defaultConfig {
- applicationId = "com.gyf.csams"
+ applicationId = "com.gyf.csams.foreground"
minSdk = 21
targetSdk = 30
versionCode = 1
@@ -22,14 +22,14 @@ android {
}
buildTypes {
- val appName="${rootProject.extra["APP_NAME"]}"
- val serverAddress=rootProject.extra["SERVER_ADDRESS"]
+ val appName = "${rootProject.extra["foreground_app_name"]}"
+ val serverAddress = rootProject.extra["SERVER_ADDRESS"]
debug {
manifestPlaceholders.apply {
- this["APP_NAME"] = appName
+ this["foreground_app_name"] = appName
}
- buildConfigField(type="String",name="APP_NAME",value = "\"$appName\"")
- buildConfigField(type="String",name="SERVER_ADDRESS",value = "\"$serverAddress\"")
+ buildConfigField(type = "String", name = "foreground_app_name", value = "\"$appName\"")
+ buildConfigField(type = "String", name = "SERVER_ADDRESS", value = "\"$serverAddress\"")
}
release {
isMinifyEnabled = false
@@ -38,10 +38,10 @@ android {
"proguard-rules.pro"
)
manifestPlaceholders.apply {
- this["APP_NAME"] = appName
+ this["foreground_app_name"] = appName
}
- buildConfigField(type="String",name="APP_NAME",value = "\"$appName\"")
- buildConfigField(type="String",name="SERVER_ADDRESS",value = "\"$serverAddress\"")
+ buildConfigField(type = "String", name = "foreground_app_name", value = "\"$appName\"")
+ buildConfigField(type = "String", name = "SERVER_ADDRESS", value = "\"$serverAddress\"")
}
}
compileOptions {
diff --git a/foreground/proguard-rules.pro b/foreground/proguard-rules.pro
new file mode 100644
index 0000000..481bb43
--- /dev/null
+++ b/foreground/proguard-rules.pro
@@ -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
\ No newline at end of file
diff --git a/foreground/src/androidTest/java/com/gyf/csams/ExampleInstrumentedTest.kt b/foreground/src/androidTest/java/com/gyf/csams/ExampleInstrumentedTest.kt
new file mode 100644
index 0000000..6833343
--- /dev/null
+++ b/foreground/src/androidTest/java/com/gyf/csams/ExampleInstrumentedTest.kt
@@ -0,0 +1,22 @@
+package com.gyf.csams
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.platform.app.InstrumentationRegistry
+import org.junit.Assert.assertEquals
+import org.junit.Test
+import org.junit.runner.RunWith
+
+/**
+ * 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.gyf.csams", appContext.packageName)
+ }
+}
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/gyf/csams/MainActivityTest.kt b/foreground/src/androidTest/java/com/gyf/csams/MainActivityTest.kt
similarity index 100%
rename from app/src/androidTest/java/com/gyf/csams/MainActivityTest.kt
rename to foreground/src/androidTest/java/com/gyf/csams/MainActivityTest.kt
diff --git a/app/src/androidTest/java/com/gyf/csams/TestPreview.kt b/foreground/src/androidTest/java/com/gyf/csams/TestPreview.kt
similarity index 100%
rename from app/src/androidTest/java/com/gyf/csams/TestPreview.kt
rename to foreground/src/androidTest/java/com/gyf/csams/TestPreview.kt
diff --git a/app/src/main/AndroidManifest.xml b/foreground/src/main/AndroidManifest.xml
similarity index 94%
rename from app/src/main/AndroidManifest.xml
rename to foreground/src/main/AndroidManifest.xml
index 629b084..c9897ce 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/foreground/src/main/AndroidManifest.xml
@@ -12,7 +12,7 @@
android:allowBackup="true"
android:fullBackupOnly="true"
android:icon="@mipmap/ic_launcher"
- android:label="${APP_NAME}"
+ android:label="${foreground_app_name}"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.CSAMS"
@@ -51,12 +51,12 @@
+ android:exported="true" />
+ android:exported="true" />
()
- val studentId: LiveData = _studentId
+ val studentId = object : StringForm(formDesc = "学号", textLength = 8) {
+ override fun onChange(value: String) {
+ super.onChange(value)
+ viewModelScope.launch {
+ checkRepeat()
+ }
+ }
+ }
private val _isValidStudentId = MutableLiveData()
val isValidStudentId: LiveData = _isValidStudentId
- val studentIdDesc = "学号"
- val studentIdPlaceholder = "请输入$studentIdDesc"
+
val studentIdFormat = "入学年份(四位)+班级代码(两位)+学生代码(两位)"
//学号已存在
private val _isRepeat = MutableLiveData()
+ val isRepeat: LiveData = _isRepeat
val regBtnDesc = "注册"
@@ -86,23 +93,27 @@ class AccountViewModel(application: Application) : AndroidViewModel(application)
//提示信息
val checkRegTip = "检测学号是否已${regBtnDesc}。。。"
- val isRepeat: LiveData = _isRepeat
+
private var checkJob: Job? = null
//姓名
- private val _name = MutableLiveData()
- val name: LiveData = _name
- val nameDesc = "姓名"
- val namePlaceholder = "请输入$nameDesc"
+ val name = object : StringForm(formDesc = "姓名", textLength = 4) {
+ override fun onChange(value: String) {
+ super.onChange(value)
+ checkForm()
+ }
+ }
private val _isValidName = MutableLiveData()
val isValidName: LiveData = _isValidName
val nameFormat = "姓名不能为空"
//密码
- private val _password = MutableLiveData()
- val password: LiveData = _password
- val passwordDesc = "密码"
- val passwordPlaceholder = "请输入$passwordDesc"
+ val password = object : StringForm(formDesc = "密码", textLength = 8) {
+ override fun onChange(value: String) {
+ super.onChange(value)
+ checkForm()
+ }
+ }
private val _isValidPwd = MutableLiveData()
val isValidPwd: LiveData = _isValidPwd
val passwordFormat = "八位纯数字"
@@ -145,27 +156,12 @@ class AccountViewModel(application: Application) : AndroidViewModel(application)
lateinit var route: AccountRoute
- /**
- * 更新学号
- *
- * @param studentId 学号
- */
- fun onStudentIdChange(studentId: String) {
- _studentId.value = studentId
-
- viewModelScope.launch {
- checkRepeat()
- }
-
- }
-
/**
* 检查学号格式
*
*/
private fun checkStudentId(): Boolean {
-
- _isValidStudentId.value = _studentId.value?.matches(Regex("\\d{8}"))
+ _isValidStudentId.value = studentId.formValue.value?.matches(Regex("\\d{8}"))
return _isValidStudentId.value == true
}
@@ -181,17 +177,17 @@ class AccountViewModel(application: Application) : AndroidViewModel(application)
_isRepeat.postValue(null)
checkJob = viewModelScope.launch {
val url = Api.buildUrl(AccountApi.checkId)
- Logger.i("检测$studentIdDesc,请求接口$url")
+ Logger.i("检测${studentId.formDesc},请求接口$url")
HttpClient.get(
url, SimpleCallback(
- action = "${studentIdDesc}重复检测",
+ action = "${studentId.formDesc}重复检测",
onSuccess = {
_isRepeat.postValue(it.body)
_isValidForm.postValue(_isValidName.value == true && it.body == false)
},
onFail = { _snackBarMsg.postValue(it) },
type = object : TypeToken>() {}.type
- ), mapOf("studentId" to "${_studentId.value}")
+ ), mapOf("studentId" to "${studentId.formValue.value}")
)
}
}
@@ -200,44 +196,23 @@ class AccountViewModel(application: Application) : AndroidViewModel(application)
}
}
-
- /**
- * 更新姓名
- *
- * @param name 姓名
- */
- fun onNameChange(name: String) {
- _name.value = name
- checkForm()
- }
-
/**
* 检测姓名
*
* @return
*/
private fun checkName(): Boolean {
- _isValidName.value = _name.value?.isNotEmpty()
+ _isValidName.value = name.formValue.value?.isNotEmpty()
return _isValidName.value == true
}
- /**
- * 更新密码
- *
- * @param password 密码
- */
- fun onPasswordChange(password: String) {
- _password.value = password
- checkForm()
- }
-
/**
* 检测密码
*
* @return
*/
private fun checkPassword(): Boolean {
- _isValidPwd.value = _password.value?.matches(Regex("\\d{8}"))
+ _isValidPwd.value = password.formValue.value?.matches(Regex("\\d{8}"))
return _isValidPwd.value == true
}
@@ -275,8 +250,8 @@ class AccountViewModel(application: Application) : AndroidViewModel(application)
),
jsonBody = Gson().toJson(
UserVo(
- studentId = "${studentId.value}",
- name = "${name.value}"
+ studentId = "${studentId.formValue.value}",
+ name = "${name.formValue.value}"
)
)
)
@@ -303,8 +278,8 @@ class AccountViewModel(application: Application) : AndroidViewModel(application)
}
private fun resetForm() {
- _studentId.value = ""
- _name.value = ""
+ studentId.onChange("")
+ name.onChange("")
}
/**
@@ -339,8 +314,8 @@ class AccountViewModel(application: Application) : AndroidViewModel(application)
),
jsonBody = Gson().toJson(
UserLoginVo(
- studentId = "${studentId.value}",
- password = "${password.value}",
+ studentId = "${studentId.formValue.value}",
+ password = "${password.formValue.value}",
device = "${Build.MANUFACTURER} ${Build.MODEL}"
)
)
diff --git a/app/src/main/java/com/gyf/csams/account/ui/AccountActivity.kt b/foreground/src/main/java/com/gyf/csams/account/ui/AccountActivity.kt
similarity index 82%
rename from app/src/main/java/com/gyf/csams/account/ui/AccountActivity.kt
rename to foreground/src/main/java/com/gyf/csams/account/ui/AccountActivity.kt
index daced9f..d313046 100644
--- a/app/src/main/java/com/gyf/csams/account/ui/AccountActivity.kt
+++ b/foreground/src/main/java/com/gyf/csams/account/ui/AccountActivity.kt
@@ -5,7 +5,6 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.*
-import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.*
import androidx.compose.runtime.Composable
@@ -15,7 +14,6 @@ import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
-import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
@@ -31,8 +29,10 @@ import com.gyf.csams.BuildConfig
import com.gyf.csams.account.model.AccountViewModel
import com.gyf.csams.account.model.DialogMessage
import com.gyf.csams.uikit.AnimationText
+import com.gyf.csams.uikit.BaseTextField
import com.gyf.csams.uikit.Body
import com.gyf.csams.uikit.theme.CSAMSTheme
+import com.orhanobut.logger.Logger
enum class AccountRoute {
@@ -139,13 +139,12 @@ private fun Account(
modifier = Modifier.fillMaxSize()
) {
Column(modifier = Modifier.width(IntrinsicSize.Min)) {
- val name: String by accountViewModel.name.observeAsState("")
Text(buildAnnotatedString {
withStyle(
style = MaterialTheme.typography.subtitle1.toSpanStyle()
.copy(color = MaterialTheme.colors.primary)
) {
- append(name)
+ append(accountViewModel.name.formValue.value ?: "")
}
withStyle(style = MaterialTheme.typography.subtitle1.toSpanStyle()) {
append(accountViewModel.welcomeStart)
@@ -157,7 +156,7 @@ private fun Account(
style = MaterialTheme.typography.subtitle2.toSpanStyle()
.copy(color = MaterialTheme.colors.secondary)
) {
- append(BuildConfig.APP_NAME)
+ append(BuildConfig.foreground_app_name)
}
})
@@ -165,7 +164,7 @@ private fun Account(
Spacer(modifier = Modifier.height(10.dp))
- if (route == AccountRoute.register) Name(name = name) else Password()
+ if (route == AccountRoute.register) Name() else Password()
Spacer(modifier = Modifier.height(10.dp))
PasswordTip()
@@ -190,55 +189,47 @@ private fun Account(
/**
* 学号
- *TODO 需要把逻辑封装到[com.gyf.csams.uikit.BaseTextField]
* @param accountViewModel
*/
@Composable
private fun StudentId(accountViewModel: AccountViewModel = viewModel(), checkRepeat: Boolean) {
Column {
- val studentId: String by accountViewModel.studentId.observeAsState("")
+
val isValidStudentId: Boolean by accountViewModel.isValidStudentId.observeAsState(false)
- val focusManager = LocalFocusManager.current
- OutlinedTextField(
- value = studentId,
- onValueChange = { accountViewModel.onStudentIdChange(it) },
- label = { Text(text = accountViewModel.studentIdDesc) },
- placeholder = { Text(text = accountViewModel.studentIdPlaceholder) },
- keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
- keyboardOptions = KeyboardOptions.Default.copy(
+ BaseTextField(
+ form = accountViewModel.studentId, keyboardOptions = KeyboardOptions.Default.copy(
keyboardType = KeyboardType.Number,
imeAction = ImeAction.Done
- ),
- singleLine = true,
- isError = !isValidStudentId
+ ), isError = !isValidStudentId
)
if (isValidStudentId) {
if (checkRepeat) {
val isRepeat: Boolean? by accountViewModel.isRepeat.observeAsState(null)
+ Logger.i("isRepeat=$isRepeat")
when (isRepeat) {
null -> AnimationText(text = accountViewModel.checkRegTip)
true ->
Text(buildAnnotatedString {
- append(accountViewModel.studentIdDesc)
+ append(accountViewModel.studentId.formDesc)
withStyle(
style = MaterialTheme.typography.body1.toSpanStyle().copy(
color = MaterialTheme.colors.error
)
) {
- append(studentId)
+ append(accountViewModel.studentId.formValue.value ?: "")
}
append(accountViewModel.registered)
})
false ->
Text(buildAnnotatedString {
- append(accountViewModel.studentIdDesc)
+ append(accountViewModel.studentId.formDesc)
withStyle(
style = MaterialTheme.typography.body1.toSpanStyle().copy(
color = MaterialTheme.colors.primary
)
) {
- append(studentId)
+ append(accountViewModel.studentId.formValue.value ?: "")
}
append(accountViewModel.canRegister)
})
@@ -323,26 +314,14 @@ private fun PasswordDialog(accountViewModel: AccountViewModel = viewModel(), mes
/**
* 姓名文本框
- * TODO 需要把逻辑封装到[com.gyf.csams.uikit.BaseTextField]
- * @param name 姓名
* @param accountViewModel
*/
@Composable
-private fun Name(name: String, accountViewModel: AccountViewModel = viewModel()) {
+private fun Name(accountViewModel: AccountViewModel = viewModel()) {
Column {
val isValidName: Boolean by accountViewModel.isValidName.observeAsState(false)
- val focusManager = LocalFocusManager.current
- OutlinedTextField(
- value = name,
- onValueChange = { accountViewModel.onNameChange(it) },
- label = { Text(text = accountViewModel.nameDesc) },
- placeholder = { Text(text = accountViewModel.namePlaceholder) },
- singleLine = true,
- isError = !isValidName,
- keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
- keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Done)
- )
+ BaseTextField(form = accountViewModel.name, isError = !isValidName)
if (!isValidName) {
Text(
@@ -356,30 +335,22 @@ private fun Name(name: String, accountViewModel: AccountViewModel = viewModel())
/**
* 密码框
- *TODO 需要把逻辑封装到[com.gyf.csams.uikit.BaseTextField]
* @param accountViewModel
*/
@Composable
private fun Password(accountViewModel: AccountViewModel = viewModel()) {
Column {
val isValidPwd: Boolean by accountViewModel.isValidPwd.observeAsState(false)
- val focusManager = LocalFocusManager.current
- val password: String by accountViewModel.password.observeAsState("")
- OutlinedTextField(
- value = password,
- visualTransformation = PasswordVisualTransformation(),
- onValueChange = { accountViewModel.onPasswordChange(it) },
- label = { Text(text = accountViewModel.passwordDesc) },
- placeholder = { Text(text = accountViewModel.passwordPlaceholder) },
- singleLine = true,
- isError = !isValidPwd,
- keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
+
+ BaseTextField(
+ form = accountViewModel.password, isError = !isValidPwd,
keyboardOptions = KeyboardOptions.Default.copy(
imeAction = ImeAction.Done,
- keyboardType = KeyboardType.Number
- )
+ keyboardType = KeyboardType.Number,
+ ), visualTransformation = PasswordVisualTransformation()
)
+
if (!isValidPwd) {
Text(
text = accountViewModel.passwordFormat,
diff --git a/app/src/main/java/com/gyf/csams/activity/model/ActivityDetailViewModel.kt b/foreground/src/main/java/com/gyf/csams/activity/model/ActivityDetailViewModel.kt
similarity index 100%
rename from app/src/main/java/com/gyf/csams/activity/model/ActivityDetailViewModel.kt
rename to foreground/src/main/java/com/gyf/csams/activity/model/ActivityDetailViewModel.kt
diff --git a/app/src/main/java/com/gyf/csams/activity/ui/ActivityDetailActivity.kt b/foreground/src/main/java/com/gyf/csams/activity/ui/ActivityDetailActivity.kt
similarity index 99%
rename from app/src/main/java/com/gyf/csams/activity/ui/ActivityDetailActivity.kt
rename to foreground/src/main/java/com/gyf/csams/activity/ui/ActivityDetailActivity.kt
index 2f03c58..3ebe398 100644
--- a/app/src/main/java/com/gyf/csams/activity/ui/ActivityDetailActivity.kt
+++ b/foreground/src/main/java/com/gyf/csams/activity/ui/ActivityDetailActivity.kt
@@ -24,6 +24,7 @@ import com.gyf.csams.R
import com.gyf.csams.activity.model.*
import com.gyf.csams.uikit.*
import com.gyf.csams.util.format
+import com.orhanobut.logger.Logger
/**
* 活动详情
@@ -32,7 +33,6 @@ import com.gyf.csams.util.format
class ActivityDetailActivity : ComponentActivity() {
- @ExperimentalMaterialApi
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -249,6 +249,8 @@ class ActivityDetailActivity : ComponentActivity() {
@Composable
private fun PhotoItem(modifier: Modifier = Modifier, vo: ActivityPhotoVo) {
+ // TODO 解决Build Warnning
+ Logger.i("$vo")
Box(
modifier = modifier.border(width = 1.dp, color = MaterialTheme.colors.background),
contentAlignment = Alignment.Center
@@ -358,7 +360,6 @@ class ActivityDetailActivity : ComponentActivity() {
* 交流区
*
*/
- @ExperimentalMaterialApi
@Composable
private fun BBS(model: BBSViewModel = viewModel(), scaffoldModel: ScaffoldModel = viewModel()) {
MainFrame(background = { Background(image = BackgroundImage.ActivityBBS, alpha = 0.7F) }) {
diff --git a/app/src/main/java/com/gyf/csams/association/model/AssociationViewModel.kt b/foreground/src/main/java/com/gyf/csams/association/model/AssociationViewModel.kt
similarity index 100%
rename from app/src/main/java/com/gyf/csams/association/model/AssociationViewModel.kt
rename to foreground/src/main/java/com/gyf/csams/association/model/AssociationViewModel.kt
diff --git a/app/src/main/java/com/gyf/csams/association/model/ExamViewModel.kt b/foreground/src/main/java/com/gyf/csams/association/model/ExamViewModel.kt
similarity index 100%
rename from app/src/main/java/com/gyf/csams/association/model/ExamViewModel.kt
rename to foreground/src/main/java/com/gyf/csams/association/model/ExamViewModel.kt
diff --git a/app/src/main/java/com/gyf/csams/association/model/RegAssociationViewModel.kt b/foreground/src/main/java/com/gyf/csams/association/model/RegAssociationViewModel.kt
similarity index 100%
rename from app/src/main/java/com/gyf/csams/association/model/RegAssociationViewModel.kt
rename to foreground/src/main/java/com/gyf/csams/association/model/RegAssociationViewModel.kt
diff --git a/app/src/main/java/com/gyf/csams/association/model/RenameViewModel.kt b/foreground/src/main/java/com/gyf/csams/association/model/RenameViewModel.kt
similarity index 100%
rename from app/src/main/java/com/gyf/csams/association/model/RenameViewModel.kt
rename to foreground/src/main/java/com/gyf/csams/association/model/RenameViewModel.kt
diff --git a/app/src/main/java/com/gyf/csams/association/ui/AssociationActivity.kt b/foreground/src/main/java/com/gyf/csams/association/ui/AssociationActivity.kt
similarity index 99%
rename from app/src/main/java/com/gyf/csams/association/ui/AssociationActivity.kt
rename to foreground/src/main/java/com/gyf/csams/association/ui/AssociationActivity.kt
index 6b3c093..101aa2a 100644
--- a/app/src/main/java/com/gyf/csams/association/ui/AssociationActivity.kt
+++ b/foreground/src/main/java/com/gyf/csams/association/ui/AssociationActivity.kt
@@ -424,6 +424,8 @@ class AssociationActivity : ComponentActivity() {
) {
val context = LocalContext.current
val act by model.act.observeAsState()
+ // TODO 解决Build Warnning
+ Logger.i("$act")
Row(modifier = modifier.clickable(onClick = {
context.startActivity(Intent(context, ActivityDetailActivity::class.java))
}), horizontalArrangement = Arrangement.Center) {
diff --git a/app/src/main/java/com/gyf/csams/association/ui/ExamActivity.kt b/foreground/src/main/java/com/gyf/csams/association/ui/ExamActivity.kt
similarity index 100%
rename from app/src/main/java/com/gyf/csams/association/ui/ExamActivity.kt
rename to foreground/src/main/java/com/gyf/csams/association/ui/ExamActivity.kt
diff --git a/app/src/main/java/com/gyf/csams/association/ui/ReNameActivity.kt b/foreground/src/main/java/com/gyf/csams/association/ui/ReNameActivity.kt
similarity index 100%
rename from app/src/main/java/com/gyf/csams/association/ui/ReNameActivity.kt
rename to foreground/src/main/java/com/gyf/csams/association/ui/ReNameActivity.kt
diff --git a/app/src/main/java/com/gyf/csams/association/ui/RegAssociationActivity.kt b/foreground/src/main/java/com/gyf/csams/association/ui/RegAssociationActivity.kt
similarity index 100%
rename from app/src/main/java/com/gyf/csams/association/ui/RegAssociationActivity.kt
rename to foreground/src/main/java/com/gyf/csams/association/ui/RegAssociationActivity.kt
diff --git a/app/src/main/java/com/gyf/csams/main/model/MainViewModel.kt b/foreground/src/main/java/com/gyf/csams/main/model/MainViewModel.kt
similarity index 100%
rename from app/src/main/java/com/gyf/csams/main/model/MainViewModel.kt
rename to foreground/src/main/java/com/gyf/csams/main/model/MainViewModel.kt
diff --git a/app/src/main/java/com/gyf/csams/main/ui/MainActivity.kt b/foreground/src/main/java/com/gyf/csams/main/ui/MainActivity.kt
similarity index 99%
rename from app/src/main/java/com/gyf/csams/main/ui/MainActivity.kt
rename to foreground/src/main/java/com/gyf/csams/main/ui/MainActivity.kt
index 3848965..faffe03 100644
--- a/app/src/main/java/com/gyf/csams/main/ui/MainActivity.kt
+++ b/foreground/src/main/java/com/gyf/csams/main/ui/MainActivity.kt
@@ -76,7 +76,6 @@ class MainActivity : ComponentActivity() {
@Composable
private fun Center(
model: CenterViewModel = viewModel(),
- scaffoldModel: ScaffoldModel = viewModel(),
navController: NavHostController
) {
MainFrame(
diff --git a/app/src/main/java/com/gyf/csams/message/model/MessageViewModel.kt b/foreground/src/main/java/com/gyf/csams/message/model/MessageViewModel.kt
similarity index 100%
rename from app/src/main/java/com/gyf/csams/message/model/MessageViewModel.kt
rename to foreground/src/main/java/com/gyf/csams/message/model/MessageViewModel.kt
diff --git a/app/src/main/java/com/gyf/csams/message/model/SysMessageViewModel.kt b/foreground/src/main/java/com/gyf/csams/message/model/SysMessageViewModel.kt
similarity index 100%
rename from app/src/main/java/com/gyf/csams/message/model/SysMessageViewModel.kt
rename to foreground/src/main/java/com/gyf/csams/message/model/SysMessageViewModel.kt
diff --git a/app/src/main/java/com/gyf/csams/message/ui/MessageActivity.kt b/foreground/src/main/java/com/gyf/csams/message/ui/MessageActivity.kt
similarity index 98%
rename from app/src/main/java/com/gyf/csams/message/ui/MessageActivity.kt
rename to foreground/src/main/java/com/gyf/csams/message/ui/MessageActivity.kt
index 0d2f384..352e361 100644
--- a/app/src/main/java/com/gyf/csams/message/ui/MessageActivity.kt
+++ b/foreground/src/main/java/com/gyf/csams/message/ui/MessageActivity.kt
@@ -30,7 +30,7 @@ class MessageActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
setContent {
- Body { scaffoldState ->
+ Body { _ ->
val model: MessageViewModel = viewModel()
val context = LocalContext.current
MainFrame(background = {
diff --git a/app/src/main/java/com/gyf/csams/message/ui/SysMessageActivity.kt b/foreground/src/main/java/com/gyf/csams/message/ui/SysMessageActivity.kt
similarity index 99%
rename from app/src/main/java/com/gyf/csams/message/ui/SysMessageActivity.kt
rename to foreground/src/main/java/com/gyf/csams/message/ui/SysMessageActivity.kt
index 10d3a62..21bdd4a 100644
--- a/app/src/main/java/com/gyf/csams/message/ui/SysMessageActivity.kt
+++ b/foreground/src/main/java/com/gyf/csams/message/ui/SysMessageActivity.kt
@@ -31,7 +31,7 @@ class SysMessageActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
setContent {
- Body { scaffoldState ->
+ Body { _ ->
MainFrame(background = {
Background(
image = BackgroundImage.ActivityMessage,
diff --git a/app/src/main/java/com/gyf/csams/uikit/BaseView.kt b/foreground/src/main/java/com/gyf/csams/uikit/BaseView.kt
similarity index 97%
rename from app/src/main/java/com/gyf/csams/uikit/BaseView.kt
rename to foreground/src/main/java/com/gyf/csams/uikit/BaseView.kt
index b13cbce..2d46753 100644
--- a/app/src/main/java/com/gyf/csams/uikit/BaseView.kt
+++ b/foreground/src/main/java/com/gyf/csams/uikit/BaseView.kt
@@ -23,6 +23,7 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.input.ImeAction
+import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.lifecycle.LiveData
@@ -483,7 +484,10 @@ fun Carousel(
fun BaseTextField(
modifier: Modifier = Modifier,
form: T,
- singeLine: Boolean = false
+ singeLine: Boolean = false,
+ keyboardOptions: KeyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Done),
+ isError: Boolean = false,
+ visualTransformation: VisualTransformation = VisualTransformation.None
) {
val name: String by form.formValue.observeAsState("")
val focusManager = LocalFocusManager.current
@@ -495,8 +499,11 @@ fun BaseTextField(
placeholder = { Text(text = form.formPlaceholder) },
singleLine = singeLine,
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
- keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Done),
- trailingIcon = { Text(text = "${name.length}/${form.textLength}") })
+ keyboardOptions = keyboardOptions,
+ trailingIcon = { Text(text = "${name.length}/${form.textLength}") },
+ isError = isError,
+ visualTransformation = visualTransformation
+ )
}
/**
diff --git a/app/src/main/java/com/gyf/csams/uikit/ViewModel.kt b/foreground/src/main/java/com/gyf/csams/uikit/ViewModel.kt
similarity index 100%
rename from app/src/main/java/com/gyf/csams/uikit/ViewModel.kt
rename to foreground/src/main/java/com/gyf/csams/uikit/ViewModel.kt
diff --git a/foreground/src/main/java/com/gyf/csams/uikit/theme/Color.kt b/foreground/src/main/java/com/gyf/csams/uikit/theme/Color.kt
new file mode 100644
index 0000000..cbec799
--- /dev/null
+++ b/foreground/src/main/java/com/gyf/csams/uikit/theme/Color.kt
@@ -0,0 +1,8 @@
+package com.gyf.csams.uikit.theme
+
+import androidx.compose.ui.graphics.Color
+
+val Purple200 = Color(0xFFBB86FC)
+val Purple500 = Color(0xFF6200EE)
+val Purple700 = Color(0xFF3700B3)
+val Teal200 = Color(0xFF03DAC5)
\ No newline at end of file
diff --git a/foreground/src/main/java/com/gyf/csams/uikit/theme/Shape.kt b/foreground/src/main/java/com/gyf/csams/uikit/theme/Shape.kt
new file mode 100644
index 0000000..e2f4bfb
--- /dev/null
+++ b/foreground/src/main/java/com/gyf/csams/uikit/theme/Shape.kt
@@ -0,0 +1,11 @@
+package com.gyf.csams.uikit.theme
+
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material.Shapes
+import androidx.compose.ui.unit.dp
+
+val Shapes = Shapes(
+ small = RoundedCornerShape(4.dp),
+ medium = RoundedCornerShape(4.dp),
+ large = RoundedCornerShape(0.dp)
+)
\ No newline at end of file
diff --git a/app/src/main/java/com/gyf/csams/uikit/theme/Theme.kt b/foreground/src/main/java/com/gyf/csams/uikit/theme/Theme.kt
similarity index 100%
rename from app/src/main/java/com/gyf/csams/uikit/theme/Theme.kt
rename to foreground/src/main/java/com/gyf/csams/uikit/theme/Theme.kt
diff --git a/foreground/src/main/java/com/gyf/csams/uikit/theme/Type.kt b/foreground/src/main/java/com/gyf/csams/uikit/theme/Type.kt
new file mode 100644
index 0000000..5dcc466
--- /dev/null
+++ b/foreground/src/main/java/com/gyf/csams/uikit/theme/Type.kt
@@ -0,0 +1,28 @@
+package com.gyf.csams.uikit.theme
+
+import androidx.compose.material.Typography
+import androidx.compose.ui.text.TextStyle
+import androidx.compose.ui.text.font.FontFamily
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.sp
+
+// Set of Material typography styles to start with
+val Typography = Typography(
+ body1 = TextStyle(
+ fontFamily = FontFamily.Default,
+ fontWeight = FontWeight.Normal,
+ fontSize = 16.sp
+ )
+ /* Other default text styles to override
+ button = TextStyle(
+ fontFamily = FontFamily.Default,
+ fontWeight = FontWeight.W500,
+ fontSize = 14.sp
+ ),
+ caption = TextStyle(
+ fontFamily = FontFamily.Default,
+ fontWeight = FontWeight.Normal,
+ fontSize = 12.sp
+ )
+ */
+)
\ No newline at end of file
diff --git a/app/src/main/java/com/gyf/csams/util/GsonUtil.kt b/foreground/src/main/java/com/gyf/csams/util/GsonUtil.kt
similarity index 100%
rename from app/src/main/java/com/gyf/csams/util/GsonUtil.kt
rename to foreground/src/main/java/com/gyf/csams/util/GsonUtil.kt
diff --git a/app/src/main/java/com/gyf/csams/util/HttpUtil.kt b/foreground/src/main/java/com/gyf/csams/util/HttpUtil.kt
similarity index 100%
rename from app/src/main/java/com/gyf/csams/util/HttpUtil.kt
rename to foreground/src/main/java/com/gyf/csams/util/HttpUtil.kt
diff --git a/app/src/main/java/com/gyf/csams/util/RandomUtil.kt b/foreground/src/main/java/com/gyf/csams/util/RandomUtil.kt
similarity index 90%
rename from app/src/main/java/com/gyf/csams/util/RandomUtil.kt
rename to foreground/src/main/java/com/gyf/csams/util/RandomUtil.kt
index 97b9d20..e372a95 100644
--- a/app/src/main/java/com/gyf/csams/util/RandomUtil.kt
+++ b/foreground/src/main/java/com/gyf/csams/util/RandomUtil.kt
@@ -11,10 +11,6 @@ fun randomNum(length: Int = 8): String {
fun encode(char: Char) = "\\u${char.toInt().toHexString()}"
-//String ->unicode
-fun String.encodeUnicode(text: String) = text
- .toCharArray().joinToString(separator = "", truncated = "") { encode(it) }
-
//unicode ->String
fun String.decodeUnicode(): String {
fun decode1(unicode: String) = unicode.toInt(16).toChar()
diff --git a/app/src/main/java/com/gyf/csams/util/TokenUtil.kt b/foreground/src/main/java/com/gyf/csams/util/TokenUtil.kt
similarity index 91%
rename from app/src/main/java/com/gyf/csams/util/TokenUtil.kt
rename to foreground/src/main/java/com/gyf/csams/util/TokenUtil.kt
index 9d5f773..ad80808 100644
--- a/app/src/main/java/com/gyf/csams/util/TokenUtil.kt
+++ b/foreground/src/main/java/com/gyf/csams/util/TokenUtil.kt
@@ -91,11 +91,7 @@ abstract class AppDatabase : RoomDatabase() {
return sInstance
}
- /**
- * Build the database. [Builder.build] only sets up the database configuration and
- * creates a new instance of the database.
- * The SQLite database is only created when it's accessed for the first time.
- */
+
private fun buildDatabase(appContext: Context): AppDatabase {
return Room.databaseBuilder(appContext, AppDatabase::class.java, DATABASE_NAME)
.build()
diff --git a/foreground/src/main/res/drawable-v24/ic_launcher_foreground.xml b/foreground/src/main/res/drawable-v24/ic_launcher_foreground.xml
new file mode 100644
index 0000000..2b068d1
--- /dev/null
+++ b/foreground/src/main/res/drawable-v24/ic_launcher_foreground.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_account.xml b/foreground/src/main/res/drawable/ic_account.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_account.xml
rename to foreground/src/main/res/drawable/ic_account.xml
diff --git a/app/src/main/res/drawable/ic_account_fill.xml b/foreground/src/main/res/drawable/ic_account_fill.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_account_fill.xml
rename to foreground/src/main/res/drawable/ic_account_fill.xml
diff --git a/app/src/main/res/drawable/ic_add_account.xml b/foreground/src/main/res/drawable/ic_add_account.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_add_account.xml
rename to foreground/src/main/res/drawable/ic_add_account.xml
diff --git a/app/src/main/res/drawable/ic_add_fill.xml b/foreground/src/main/res/drawable/ic_add_fill.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_add_fill.xml
rename to foreground/src/main/res/drawable/ic_add_fill.xml
diff --git a/app/src/main/res/drawable/ic_add_select.xml b/foreground/src/main/res/drawable/ic_add_select.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_add_select.xml
rename to foreground/src/main/res/drawable/ic_add_select.xml
diff --git a/app/src/main/res/drawable/ic_all.xml b/foreground/src/main/res/drawable/ic_all.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_all.xml
rename to foreground/src/main/res/drawable/ic_all.xml
diff --git a/app/src/main/res/drawable/ic_all_fill.xml b/foreground/src/main/res/drawable/ic_all_fill.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_all_fill.xml
rename to foreground/src/main/res/drawable/ic_all_fill.xml
diff --git a/app/src/main/res/drawable/ic_arrow_down.xml b/foreground/src/main/res/drawable/ic_arrow_down.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_arrow_down.xml
rename to foreground/src/main/res/drawable/ic_arrow_down.xml
diff --git a/app/src/main/res/drawable/ic_arrow_left.xml b/foreground/src/main/res/drawable/ic_arrow_left.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_arrow_left.xml
rename to foreground/src/main/res/drawable/ic_arrow_left.xml
diff --git a/app/src/main/res/drawable/ic_arrow_right.xml b/foreground/src/main/res/drawable/ic_arrow_right.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_arrow_right.xml
rename to foreground/src/main/res/drawable/ic_arrow_right.xml
diff --git a/app/src/main/res/drawable/ic_arrow_up.xml b/foreground/src/main/res/drawable/ic_arrow_up.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_arrow_up.xml
rename to foreground/src/main/res/drawable/ic_arrow_up.xml
diff --git a/app/src/main/res/drawable/ic_comments.xml b/foreground/src/main/res/drawable/ic_comments.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_comments.xml
rename to foreground/src/main/res/drawable/ic_comments.xml
diff --git a/app/src/main/res/drawable/ic_configuration.xml b/foreground/src/main/res/drawable/ic_configuration.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_configuration.xml
rename to foreground/src/main/res/drawable/ic_configuration.xml
diff --git a/app/src/main/res/drawable/ic_editor.xml b/foreground/src/main/res/drawable/ic_editor.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_editor.xml
rename to foreground/src/main/res/drawable/ic_editor.xml
diff --git a/app/src/main/res/drawable/ic_exchange_rate.xml b/foreground/src/main/res/drawable/ic_exchange_rate.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_exchange_rate.xml
rename to foreground/src/main/res/drawable/ic_exchange_rate.xml
diff --git a/app/src/main/res/drawable/ic_home.xml b/foreground/src/main/res/drawable/ic_home.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_home.xml
rename to foreground/src/main/res/drawable/ic_home.xml
diff --git a/app/src/main/res/drawable/ic_home_fill.xml b/foreground/src/main/res/drawable/ic_home_fill.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_home_fill.xml
rename to foreground/src/main/res/drawable/ic_home_fill.xml
diff --git a/foreground/src/main/res/drawable/ic_launcher_background.xml b/foreground/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 0000000..07d5da9
--- /dev/null
+++ b/foreground/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/ic_notice.xml b/foreground/src/main/res/drawable/ic_notice.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_notice.xml
rename to foreground/src/main/res/drawable/ic_notice.xml
diff --git a/app/src/main/res/drawable/ic_notification.xml b/foreground/src/main/res/drawable/ic_notification.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_notification.xml
rename to foreground/src/main/res/drawable/ic_notification.xml
diff --git a/app/src/main/res/drawable/ic_sami_select.xml b/foreground/src/main/res/drawable/ic_sami_select.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_sami_select.xml
rename to foreground/src/main/res/drawable/ic_sami_select.xml
diff --git a/app/src/main/res/drawable/ic_upload.xml b/foreground/src/main/res/drawable/ic_upload.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_upload.xml
rename to foreground/src/main/res/drawable/ic_upload.xml
diff --git a/foreground/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/foreground/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/foreground/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/foreground/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/foreground/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/foreground/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/foreground/src/main/res/mipmap-hdpi/ic_launcher.webp b/foreground/src/main/res/mipmap-hdpi/ic_launcher.webp
new file mode 100644
index 0000000..c209e78
Binary files /dev/null and b/foreground/src/main/res/mipmap-hdpi/ic_launcher.webp differ
diff --git a/foreground/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/foreground/src/main/res/mipmap-hdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..b2dfe3d
Binary files /dev/null and b/foreground/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ
diff --git a/foreground/src/main/res/mipmap-mdpi/ic_launcher.webp b/foreground/src/main/res/mipmap-mdpi/ic_launcher.webp
new file mode 100644
index 0000000..4f0f1d6
Binary files /dev/null and b/foreground/src/main/res/mipmap-mdpi/ic_launcher.webp differ
diff --git a/foreground/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/foreground/src/main/res/mipmap-mdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..62b611d
Binary files /dev/null and b/foreground/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ
diff --git a/foreground/src/main/res/mipmap-xhdpi/ic_launcher.webp b/foreground/src/main/res/mipmap-xhdpi/ic_launcher.webp
new file mode 100644
index 0000000..948a307
Binary files /dev/null and b/foreground/src/main/res/mipmap-xhdpi/ic_launcher.webp differ
diff --git a/foreground/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/foreground/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..1b9a695
Binary files /dev/null and b/foreground/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ
diff --git a/foreground/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/foreground/src/main/res/mipmap-xxhdpi/ic_launcher.webp
new file mode 100644
index 0000000..28d4b77
Binary files /dev/null and b/foreground/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ
diff --git a/foreground/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/foreground/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..9287f50
Binary files /dev/null and b/foreground/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ
diff --git a/foreground/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/foreground/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
new file mode 100644
index 0000000..aa7d642
Binary files /dev/null and b/foreground/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ
diff --git a/foreground/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/foreground/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..9126ae3
Binary files /dev/null and b/foreground/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ
diff --git a/foreground/src/main/res/values-night/themes.xml b/foreground/src/main/res/values-night/themes.xml
new file mode 100644
index 0000000..1ff666e
--- /dev/null
+++ b/foreground/src/main/res/values-night/themes.xml
@@ -0,0 +1,16 @@
+
+
+
+
\ No newline at end of file
diff --git a/foreground/src/main/res/values/colors.xml b/foreground/src/main/res/values/colors.xml
new file mode 100644
index 0000000..f8c6127
--- /dev/null
+++ b/foreground/src/main/res/values/colors.xml
@@ -0,0 +1,10 @@
+
+
+ #FFBB86FC
+ #FF6200EE
+ #FF3700B3
+ #FF03DAC5
+ #FF018786
+ #FF000000
+ #FFFFFFFF
+
\ No newline at end of file
diff --git a/foreground/src/main/res/values/strings.xml b/foreground/src/main/res/values/strings.xml
new file mode 100644
index 0000000..6b30d8d
--- /dev/null
+++ b/foreground/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/foreground/src/main/res/values/themes.xml b/foreground/src/main/res/values/themes.xml
new file mode 100644
index 0000000..8ad1ac7
--- /dev/null
+++ b/foreground/src/main/res/values/themes.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/test/java/com/gyf/csams/ExampleUnitTest.kt b/foreground/src/test/java/com/gyf/csams/ExampleUnitTest.kt
similarity index 100%
rename from app/src/test/java/com/gyf/csams/ExampleUnitTest.kt
rename to foreground/src/test/java/com/gyf/csams/ExampleUnitTest.kt
diff --git a/gradlew b/gradlew
index cccdd3d..153015f 100644
--- a/gradlew
+++ b/gradlew
@@ -24,7 +24,7 @@ cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
-APP_NAME="Gradle"
+foreground_app_name="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
@@ -106,7 +106,7 @@ fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$foreground_app_name\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 15cd416..c857320 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -7,5 +7,5 @@ dependencyResolutionManagement {
}
}
rootProject.name = "CSAMS"
-include(":app")
-
\ No newline at end of file
+include(":foreground")
+include(":background")