Skip to content

Commit

Permalink
fix: refactoring the code for signing
Browse files Browse the repository at this point in the history
  • Loading branch information
cofbro committed Dec 23, 2023
1 parent 76d5ea6 commit caf4ee0
Show file tree
Hide file tree
Showing 7 changed files with 381 additions and 299 deletions.
4 changes: 4 additions & 0 deletions app/src/main/java/com/cofbro/qian/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
AutoUpdater(this).checkUpdate()
}

private fun saveBottomBarHeight(virtualHeight: Int) {
CacheUtils.cache[Constants.Cache.BOTTOM_BAR_HEIGHT] = (binding?.navigationBar?.height?.plus(virtualHeight)).toString()
}


private fun initView() {
Expand Down Expand Up @@ -100,6 +103,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
val windowInsects = ViewCompat.getRootWindowInsets(window.decorView)
val height = windowInsects?.getInsetsIgnoringVisibility(WindowInsetsCompat.Type.navigationBars())?.bottom ?: 0
updateLayoutParams(height)
saveBottomBarHeight(height)
}
}

Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/com/cofbro/qian/profile/ProfileFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import android.os.Bundle
import android.view.ViewGroup.MarginLayoutParams
import android.widget.Toast
import androidx.appcompat.widget.SwitchCompat
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.lifecycle.lifecycleScope
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.CenterCrop
Expand Down Expand Up @@ -46,10 +48,23 @@ class ProfileFragment : BaseFragment<ProfileViewModel, FragmentProfileBinding>()

private fun initView() {
adjustMarginOfView()
adjustContainerHeight()
profileMessageInfo()
checkSignWithStatus()
}

private fun adjustContainerHeight() {
binding?.tvLogin?.post {
val bottomHeight = CacheUtils.cache[Constants.Cache.BOTTOM_BAR_HEIGHT]?.toInt() ?: 0
val layout = binding?.tvLogin?.layoutParams as? MarginLayoutParams
layout?.bottomMargin = bottomHeight
binding?.tvLogin?.layoutParams = layout
// val layout = binding?.profileContainer?.layoutParams
// layout?.height = (binding?.profileContainer?.height ?: 0) + bottomHeight * 3
// binding?.profileContainer?.layoutParams = layout
}
}

private fun checkSignWithStatus() {
val switch = requireActivity().getBySp("signWith")?.toBoolean() ?: false
binding?.signWithButton?.isChecked = switch
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/java/com/cofbro/qian/profile/ProfileViewModel.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package com.cofbro.qian.profile

import com.cofbro.hymvvmutils.base.BaseViewModel
import com.cofbro.hymvvmutils.base.ResponseMutableLiveData
import com.cofbro.qian.utils.CacheUtils
import com.cofbro.qian.utils.DefaultRepository
import com.cofbro.qian.utils.NetworkUtils
import okhttp3.Response

class ProfileViewModel : BaseViewModel<DefaultRepository>() {
val uid = CacheUtils.cache["uid"] ?: ""
var logoutDialog:LogoutDialog? = null


}
1 change: 1 addition & 0 deletions app/src/main/java/com/cofbro/qian/utils/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ object Constants {
const val LOGIN_ACTIVITY = "LoginActivity"
const val MAIN_ACTIVITY = "MainActivity"
const val CONV = "conv"
const val BOTTOM_BAR_HEIGHT = "bottomBarHeight"
}

object Login {
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/com/cofbro/qian/utils/HtmlParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ import com.cofbro.qian.mapsetting.util.PreWeb
import org.jsoup.Jsoup

object HtmlParser {
fun parseImToken(html: String): JSONObject {
val data = JSONObject()
val doc = Jsoup.parse(html)
data["imToken"] = doc.getElementById("myToken") ?: ""
data["tid"] = doc.getElementById("myTuid") ?: ""
return data
}


fun parseHomeworkHTML(html: String): List<JSONObject> {
val jsonObject = arrayListOf<JSONObject>()
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<vector android:height="24dp" android:viewportHeight="1024"
android:viewportWidth="1024" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#4e8cee" android:pathData="M512,512m-512,0a512,512 0,1 0,1024 0,512 512,0 1,0 -1024,0Z"/>
<path android:fillColor="#FFFFFF" android:pathData="M245.2,512m-71.7,0a71.7,71.7 0,1 0,143.4 0,71.7 71.7,0 1,0 -143.4,0Z"/>
<path android:fillColor="#FFFFFF" android:pathData="M512,512m-71.7,0a71.7,71.7 0,1 0,143.4 0,71.7 71.7,0 1,0 -143.4,0Z"/>
<path android:fillColor="#FFFFFF" android:pathData="M778.8,512m-71.7,0a71.7,71.7 0,1 0,143.4 0,71.7 71.7,0 1,0 -143.4,0Z"/>
</vector>
Loading

0 comments on commit caf4ee0

Please sign in to comment.