解决build warning

更新compose ui库版本
增加后台模块foreground
更改app应用名和id,和后台区分
重命名模块名为foreground,和后台区分
登陆注册表单更新
master
pan 4 years ago
parent 6f85668740
commit 169a6973f2
  1. 3
      app/src/main/res/values/strings.xml
  2. 0
      background/.gitignore
  3. 62
      background/build.gradle.kts
  4. 0
      background/proguard-rules.pro
  5. 0
      background/src/androidTest/java/com/gyf/csams/ExampleInstrumentedTest.kt
  6. 26
      background/src/main/AndroidManifest.xml
  7. 38
      background/src/main/java/com/gyf/csams/MainActivity.kt
  8. 0
      background/src/main/java/com/gyf/csams/uikit/theme/Color.kt
  9. 0
      background/src/main/java/com/gyf/csams/uikit/theme/Shape.kt
  10. 44
      background/src/main/java/com/gyf/csams/uikit/theme/Theme.kt
  11. 0
      background/src/main/java/com/gyf/csams/uikit/theme/Type.kt
  12. 0
      background/src/main/res/drawable-v24/ic_launcher_foreground.xml
  13. 0
      background/src/main/res/drawable/ic_launcher_background.xml
  14. 0
      background/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
  15. 0
      background/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
  16. 0
      background/src/main/res/mipmap-hdpi/ic_launcher.webp
  17. 0
      background/src/main/res/mipmap-hdpi/ic_launcher_round.webp
  18. 0
      background/src/main/res/mipmap-mdpi/ic_launcher.webp
  19. 0
      background/src/main/res/mipmap-mdpi/ic_launcher_round.webp
  20. 0
      background/src/main/res/mipmap-xhdpi/ic_launcher.webp
  21. 0
      background/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
  22. 0
      background/src/main/res/mipmap-xxhdpi/ic_launcher.webp
  23. 0
      background/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
  24. 0
      background/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
  25. 0
      background/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
  26. 0
      background/src/main/res/values-night/themes.xml
  27. 0
      background/src/main/res/values/colors.xml
  28. 3
      background/src/main/res/values/strings.xml
  29. 0
      background/src/main/res/values/themes.xml
  30. 16
      background/src/test/java/com/gyf/csams/ExampleUnitTest.kt
  31. 5
      build.gradle.kts
  32. 1
      foreground/.gitignore
  33. 18
      foreground/build.gradle.kts
  34. 21
      foreground/proguard-rules.pro
  35. 22
      foreground/src/androidTest/java/com/gyf/csams/ExampleInstrumentedTest.kt
  36. 0
      foreground/src/androidTest/java/com/gyf/csams/MainActivityTest.kt
  37. 0
      foreground/src/androidTest/java/com/gyf/csams/TestPreview.kt
  38. 6
      foreground/src/main/AndroidManifest.xml
  39. 2
      foreground/src/main/java/com/gyf/csams/APP.kt
  40. 0
      foreground/src/main/java/com/gyf/csams/Api.kt
  41. 0
      foreground/src/main/java/com/gyf/csams/InitActivity.kt
  42. 0
      foreground/src/main/java/com/gyf/csams/InitViewModel.kt
  43. 97
      foreground/src/main/java/com/gyf/csams/account/model/AccountViewModel.kt
  44. 73
      foreground/src/main/java/com/gyf/csams/account/ui/AccountActivity.kt
  45. 0
      foreground/src/main/java/com/gyf/csams/activity/model/ActivityDetailViewModel.kt
  46. 5
      foreground/src/main/java/com/gyf/csams/activity/ui/ActivityDetailActivity.kt
  47. 0
      foreground/src/main/java/com/gyf/csams/association/model/AssociationViewModel.kt
  48. 0
      foreground/src/main/java/com/gyf/csams/association/model/ExamViewModel.kt
  49. 0
      foreground/src/main/java/com/gyf/csams/association/model/RegAssociationViewModel.kt
  50. 0
      foreground/src/main/java/com/gyf/csams/association/model/RenameViewModel.kt
  51. 2
      foreground/src/main/java/com/gyf/csams/association/ui/AssociationActivity.kt
  52. 0
      foreground/src/main/java/com/gyf/csams/association/ui/ExamActivity.kt
  53. 0
      foreground/src/main/java/com/gyf/csams/association/ui/ReNameActivity.kt
  54. 0
      foreground/src/main/java/com/gyf/csams/association/ui/RegAssociationActivity.kt
  55. 0
      foreground/src/main/java/com/gyf/csams/main/model/MainViewModel.kt
  56. 1
      foreground/src/main/java/com/gyf/csams/main/ui/MainActivity.kt
  57. 0
      foreground/src/main/java/com/gyf/csams/message/model/MessageViewModel.kt
  58. 0
      foreground/src/main/java/com/gyf/csams/message/model/SysMessageViewModel.kt
  59. 2
      foreground/src/main/java/com/gyf/csams/message/ui/MessageActivity.kt
  60. 2
      foreground/src/main/java/com/gyf/csams/message/ui/SysMessageActivity.kt
  61. 13
      foreground/src/main/java/com/gyf/csams/uikit/BaseView.kt
  62. 0
      foreground/src/main/java/com/gyf/csams/uikit/ViewModel.kt
  63. 8
      foreground/src/main/java/com/gyf/csams/uikit/theme/Color.kt
  64. 11
      foreground/src/main/java/com/gyf/csams/uikit/theme/Shape.kt
  65. 0
      foreground/src/main/java/com/gyf/csams/uikit/theme/Theme.kt
  66. 28
      foreground/src/main/java/com/gyf/csams/uikit/theme/Type.kt
  67. 0
      foreground/src/main/java/com/gyf/csams/util/GsonUtil.kt
  68. 0
      foreground/src/main/java/com/gyf/csams/util/HttpUtil.kt
  69. 4
      foreground/src/main/java/com/gyf/csams/util/RandomUtil.kt
  70. 6
      foreground/src/main/java/com/gyf/csams/util/TokenUtil.kt
  71. 30
      foreground/src/main/res/drawable-v24/ic_launcher_foreground.xml
  72. 0
      foreground/src/main/res/drawable/ic_account.xml
  73. 0
      foreground/src/main/res/drawable/ic_account_fill.xml
  74. 0
      foreground/src/main/res/drawable/ic_add_account.xml
  75. 0
      foreground/src/main/res/drawable/ic_add_fill.xml
  76. 0
      foreground/src/main/res/drawable/ic_add_select.xml
  77. 0
      foreground/src/main/res/drawable/ic_all.xml
  78. 0
      foreground/src/main/res/drawable/ic_all_fill.xml
  79. 0
      foreground/src/main/res/drawable/ic_arrow_down.xml
  80. 0
      foreground/src/main/res/drawable/ic_arrow_left.xml
  81. 0
      foreground/src/main/res/drawable/ic_arrow_right.xml
  82. 0
      foreground/src/main/res/drawable/ic_arrow_up.xml
  83. 0
      foreground/src/main/res/drawable/ic_comments.xml
  84. 0
      foreground/src/main/res/drawable/ic_configuration.xml
  85. 0
      foreground/src/main/res/drawable/ic_editor.xml
  86. 0
      foreground/src/main/res/drawable/ic_exchange_rate.xml
  87. 0
      foreground/src/main/res/drawable/ic_home.xml
  88. 0
      foreground/src/main/res/drawable/ic_home_fill.xml
  89. 170
      foreground/src/main/res/drawable/ic_launcher_background.xml
  90. 0
      foreground/src/main/res/drawable/ic_notice.xml
  91. 0
      foreground/src/main/res/drawable/ic_notification.xml
  92. 0
      foreground/src/main/res/drawable/ic_sami_select.xml
  93. 0
      foreground/src/main/res/drawable/ic_upload.xml
  94. 5
      foreground/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
  95. 5
      foreground/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
  96. BIN
      foreground/src/main/res/mipmap-hdpi/ic_launcher.webp
  97. BIN
      foreground/src/main/res/mipmap-hdpi/ic_launcher_round.webp
  98. BIN
      foreground/src/main/res/mipmap-mdpi/ic_launcher.webp
  99. BIN
      foreground/src/main/res/mipmap-mdpi/ic_launcher_round.webp
  100. BIN
      foreground/src/main/res/mipmap-xhdpi/ic_launcher.webp
  101. Some files were not shown because too many files have changed in this diff Show More

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

@ -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"]}")
}

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gyf.csams">
<application
android:allowBackup="true"
android:fullBackupOnly="true"
android:icon="@mipmap/ic_launcher"
android:label="${background_app_name}"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.CSAMS">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="${background_app_name}"
android:theme="@style/Theme.CSAMS.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

@ -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")
}
}

@ -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
)
}

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Before

Width:  |  Height:  |  Size: 982 B

After

Width:  |  Height:  |  Size: 982 B

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

@ -0,0 +1,3 @@
<resources>
</resources>

@ -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)
}
}

@ -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")

@ -0,0 +1 @@
/build

@ -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 {

@ -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

@ -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)
}
}

@ -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 @@
<!--社团主界面-->
<activity
android:name=".association.ui.AssociationActivity"
android:exported="true"></activity>
android:exported="true" />
<!--社团重命名主界面-->
<activity
android:name=".association.ui.ReNameActivity"
android:exported="true"></activity>
android:exported="true" />
<!--题库界面-->
<activity

@ -105,7 +105,7 @@ class APP : Application() {
Logger.addLogAdapter(AndroidLogAdapter())
Logger.addLogAdapter(DiskLogAdapter())
Logger.i("${BuildConfig.APP_NAME}启动")
Logger.i("${BuildConfig.foreground_app_name}启动")
}

@ -13,6 +13,7 @@ import com.gyf.csams.AccountApi
import com.gyf.csams.Api
import com.gyf.csams.InitActivity
import com.gyf.csams.account.ui.AccountRoute
import com.gyf.csams.uikit.StringForm
import com.gyf.csams.util.*
import com.orhanobut.logger.Logger
import kotlinx.coroutines.Job
@ -65,16 +66,22 @@ class AccountViewModel(application: Application) : AndroidViewModel(application)
val welcomeEnd = "欢迎使用"
//学号
private val _studentId = MutableLiveData<String>()
val studentId: LiveData<String> = _studentId
val studentId = object : StringForm(formDesc = "学号", textLength = 8) {
override fun onChange(value: String) {
super.onChange(value)
viewModelScope.launch {
checkRepeat()
}
}
}
private val _isValidStudentId = MutableLiveData<Boolean>()
val isValidStudentId: LiveData<Boolean> = _isValidStudentId
val studentIdDesc = "学号"
val studentIdPlaceholder = "请输入$studentIdDesc"
val studentIdFormat = "入学年份(四位)+班级代码(两位)+学生代码(两位)"
//学号已存在
private val _isRepeat = MutableLiveData<Boolean?>()
val isRepeat: LiveData<Boolean?> = _isRepeat
val regBtnDesc = "注册"
@ -86,23 +93,27 @@ class AccountViewModel(application: Application) : AndroidViewModel(application)
//提示信息
val checkRegTip = "检测学号是否已${regBtnDesc}。。。"
val isRepeat: LiveData<Boolean?> = _isRepeat
private var checkJob: Job? = null
//姓名
private val _name = MutableLiveData<String>()
val name: LiveData<String> = _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<Boolean>()
val isValidName: LiveData<Boolean> = _isValidName
val nameFormat = "姓名不能为空"
//密码
private val _password = MutableLiveData<String>()
val password: LiveData<String> = _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<Boolean>()
val isValidPwd: LiveData<Boolean> = _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<Boolean>(
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<ApiResponse<Boolean>>() {}.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}"
)
)

@ -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,

@ -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) }) {

@ -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) {

@ -76,7 +76,6 @@ class MainActivity : ComponentActivity() {
@Composable
private fun Center(
model: CenterViewModel = viewModel(),
scaffoldModel: ScaffoldModel = viewModel(),
navController: NavHostController
) {
MainFrame(

@ -30,7 +30,7 @@ class MessageActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
setContent {
Body { scaffoldState ->
Body { _ ->
val model: MessageViewModel = viewModel()
val context = LocalContext.current
MainFrame(background = {

@ -31,7 +31,7 @@ class SysMessageActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
setContent {
Body { scaffoldState ->
Body { _ ->
MainFrame(background = {
Background(
image = BackgroundImage.ActivityMessage,

@ -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 <T : StringForm> 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 <T : StringForm> 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
)
}
/**

@ -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)

@ -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)
)

@ -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
)
*/
)

@ -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()

@ -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()

@ -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>

@ -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>

@ -0,0 +1,5 @@
<?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" />
</adaptive-icon>

@ -0,0 +1,5 @@
<?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" />
</adaptive-icon>

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: 982 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save