启动图标替换;Api接口更新

main
chenglifeng 8 months ago
parent 196f7d08b4
commit 91b8db4795
  1. 2
      app/build.gradle
  2. 2
      app/src/main/AndroidManifest.xml
  3. 2
      app/src/main/java/com/project/survey/constants/Constants.kt
  4. 6
      app/src/main/java/com/project/survey/logic/bean/LoginBean.kt
  5. 47
      app/src/main/java/com/project/survey/logic/viewmodel/LoginViewModel.kt
  6. 13
      app/src/main/java/com/project/survey/network/Api.kt
  7. 38
      app/src/main/java/com/project/survey/ui/home/MeFragment.kt
  8. 2
      app/src/main/res/layout/widget_section_item.xml
  9. 6
      app/src/main/res/mipmap-anydpi/ic_launcher.xml
  10. 6
      app/src/main/res/mipmap-anydpi/ic_launcher_round.xml
  11. BIN
      app/src/main/res/mipmap-hdpi/ic_launcher.webp
  12. BIN
      app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
  13. BIN
      app/src/main/res/mipmap-hdpi/icon_launcher.webp
  14. BIN
      app/src/main/res/mipmap-mdpi/ic_launcher.webp
  15. BIN
      app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
  16. BIN
      app/src/main/res/mipmap-mdpi/icon_launcher.webp
  17. BIN
      app/src/main/res/mipmap-xhdpi/ic_launcher.webp
  18. BIN
      app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
  19. BIN
      app/src/main/res/mipmap-xhdpi/icon_launcher.webp
  20. BIN
      app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
  21. BIN
      app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
  22. BIN
      app/src/main/res/mipmap-xxhdpi/icon_launcher.webp
  23. BIN
      app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
  24. BIN
      app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
  25. BIN
      app/src/main/res/mipmap-xxxhdpi/icon_launcher.webp

@ -28,7 +28,7 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
buildConfigField "String", "BASE_URL", "\"http://10.190.183.37\""
buildConfigField "String", "BASE_URL", "\"http://10.190.183.37:80\""
javaCompileOptions {
annotationProcessorOptions {

@ -34,7 +34,7 @@
android:name="com.project.survey.App"
android:allowBackup="false"
android:extractNativeLibs="true"
android:icon="@mipmap/ic_launcher"
android:icon="@mipmap/icon_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:requestLegacyExternalStorage="true"

@ -7,7 +7,7 @@ object Constants {
object SPConstants {
const val TOKEN = "token"
const val ACCOUNT = "account"
const val LOGIN = "login" //登录状态
const val MOBILE_PHONE = "mobilePhone"
}
object EventConstants{

@ -0,0 +1,6 @@
package com.project.survey.logic.bean
data class LoginBean(
val token: String,
val mobilePhone: String
)

@ -4,39 +4,48 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.project.survey.constants.EventConstants
import com.project.survey.constants.SPConstants
import com.project.survey.logic.bean.LoginBean
import com.project.survey.logic.event.Message
import com.project.survey.network.RetrofitClient
import com.project.survey.util.SPUtils
class LoginViewModel : BaseViewModel(){
class LoginViewModel : BaseViewModel() {
val api = RetrofitClient.createApiService()
val loginResponse: LiveData<String>
val loginResponse: LiveData<LoginBean>
get() = _loginResponse
private val _loginResponse = MutableLiveData<String>()
private val _loginResponse = MutableLiveData<LoginBean>()
/**
* 登录
*/
fun login(account: String, password: String){
fun login(account: String, password: String) {
launch {
// TODO:
// val res = api.login(account, password)
// if (res.success){
// _loginResponse.postValue(res.data)
// SPUtils.put(SPConstants.TOKEN, res.data)
// SPUtils.put(SPConstants.LOGIN, true)
// SPUtils.put(SPConstants.ACCOUNT, account)
// msgEvent.postValue(Message(EventConstants.LOGIN_STATUS))
// }
_loginResponse.postValue("res.data")
SPUtils.put(SPConstants.TOKEN, "res.data")
SPUtils.put(SPConstants.LOGIN, true)
SPUtils.put(SPConstants.ACCOUNT, account)
msgEvent.postValue(Message(EventConstants.LOGIN_STATUS))
val res = api.login(account, password)
if (res.success) {
_loginResponse.postValue(res.data)
SPUtils.put(SPConstants.TOKEN, res.data.token)
SPUtils.put(SPConstants.ACCOUNT, account)
SPUtils.put(SPConstants.MOBILE_PHONE, res.data.mobilePhone)
msgEvent.postValue(Message(EventConstants.LOGIN_STATUS))
}
// _loginResponse.postValue("res.data")
// SPUtils.put(SPConstants.TOKEN, "res.data")
// SPUtils.put(SPConstants.LOGIN, true)
// SPUtils.put(SPConstants.ACCOUNT, account)
// msgEvent.postValue(Message(EventConstants.LOGIN_STATUS))
}
}
fun sendSMS(mobile: String) {
launch {
val res = api.sendSMS(mobile)
if (res.success) {
}
}
}
}

@ -1,5 +1,6 @@
package com.project.survey.network
import com.project.survey.logic.bean.LoginBean
import com.project.survey.model.ProjectBean
import retrofit2.http.GET
import retrofit2.http.Query
@ -9,11 +10,11 @@ interface Api {
/**
* 登录
*/
@GET("/je/project/login")
@GET("/je/personInfo/externalEntry")
suspend fun login(
@Query("account") account: String,
@Query("password") password: String
): HttpResult<String>
): HttpResult<LoginBean>
/**
* 获取用户可访问的所有项目的信息
@ -22,4 +23,12 @@ interface Api {
suspend fun getAllProjectIDByAccount(
@Query("account") account: String
): HttpResult<List<ProjectBean>>
/**
*
*/
@GET("/Api/Mas/sendSms")
suspend fun sendSMS(
@Query("mobile") mobile: String
): HttpResult<Any>
}

@ -25,33 +25,39 @@ class MeFragment : BaseBindingFragment<FragmentMeBinding>() {
private val viewModel: LoginViewModel by viewModels()
private val account by lazy { SPUtils.getString(SPConstants.ACCOUNT) }
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentMeBinding {
return FragmentMeBinding.inflate(inflater, container, false)
}
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentMeBinding =
FragmentMeBinding.inflate(inflater, container, false)
override fun initView() {
}
override fun initData() {
viewModel.msgEvent.observe(this) {
binding.tvLoginOrOut.text =
if (SPUtils.getBoolean(SPConstants.LOGIN) == true) getString(R.string.login_out) else getString(
R.string.login
)
binding.tvName.text =
if (SPUtils.getBoolean(SPConstants.LOGIN) == true) account else "请登录"
updateUIByData()
}
updateUIByData()
if (BuildConfig.DEBUG) {
binding.tvVersion.text = BuildConfig.VERSION_NAME
}
}
private fun updateUIByData(){
val token = SPUtils.getString(SPConstants.TOKEN) ?: ""
binding.tvLoginOrOut.text =
if (token.isBlank())
getString(R.string.login)
else
getString(R.string.login_out)
binding.tvName.text =
if (token.isBlank()) "请登录" else SPUtils.getString(SPConstants.ACCOUNT) ?: ""
}
override fun initListener() {
binding.tvLoginOrOut.setOnClickNoRepeatListener {
if (SPUtils.getBoolean(SPConstants.LOGIN) == true) {
if (SPUtils.getString(SPConstants.TOKEN).isNullOrBlank()) {
// 登录
LoginActivity.start()
} else {
// 退出登录
MaterialDialog.Builder(mContext)
.title("确定退出吗?")
@ -59,14 +65,10 @@ class MeFragment : BaseBindingFragment<FragmentMeBinding>() {
.positiveText("退出")
.onPositive { _, _ ->
SPUtils.removeKey(SPConstants.TOKEN)
SPUtils.put(SPConstants.LOGIN, false)
SPUtils.removeKey(SPConstants.ACCOUNT)
viewModel.msgEvent.postValue(Message(EventConstants.LOGIN_STATUS))
}
.show()
} else {
// 登录
LoginActivity.start()
}
}
binding.llSwitchProject.setOnClickNoRepeatListener {
@ -74,7 +76,7 @@ class MeFragment : BaseBindingFragment<FragmentMeBinding>() {
}
// TODO:
binding.llAbout.setOnClickNoRepeatListener {
SPUtils.put(SPConstants.LOGIN, false)
// viewModel.sendSMS("17379748209")
}
}
}

@ -13,7 +13,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@mipmap/ic_launcher" />
tools:src="@mipmap/icon_launcher" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tvBadge"

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

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Loading…
Cancel
Save