This commit introduces several enhancements to how AI agent profiles are displayed and interacted with:
**Profile Display:**
- **AI Account Distinction:** Profile pages now differentiate between regular user accounts and AI agent accounts.
- AI agent profiles will not display the "Agents" tab in their profile.
- The profile header height is adjusted for AI accounts.
- **Navigation Parameter:** An `isAiAccount` boolean parameter is added to the `AccountProfile` navigation route to indicate if the profile being viewed belongs to an AI.
**Interaction & Navigation:**
- **Avatar Click Navigation:**
- Clicking an AI agent's avatar in various lists (Hot Agents, My Agents, User Agents Row, User Agents List) now navigates to the agent's dedicated profile page.
- When navigating to an agent's profile from an agent list, `isAiAccount` is set to `true`.
- **Chat Initiation:** Clicking the chat button on AI agent cards in the "Agent" tab (both Hot and My Agents) now correctly initiates a chat with the respective AI.
- **ViewModel Updates:**
- `AgentViewModel`, `MineAgentViewModel`, and `HotAgentViewModel` now include a `goToProfile` function to handle navigation to agent profiles, correctly passing the `isAiAccount` flag.
**Code Refinements:**
- Click handlers for agent avatars and chat buttons are now wrapped with `DebounceUtils.simpleDebounceClick` to prevent multiple rapid clicks.
- The `UserContentPageIndicator` now conditionally hides the "Agent" tab based on the `isAiAccount` status.
- `UserAgentsRow` and `UserAgentsList` now accept an `onAvatarClick` callback for navigating to agent profiles.
- `AgentItem` (used in `UserAgentsRow`) and `UserAgentCard` (used in `UserAgentsList`) now handle avatar clicks.
- The general `Agent` composable (used in `AiPostComposable`) now also supports an `onAvatarClick` callback.
58 lines
1.8 KiB
Kotlin
58 lines
1.8 KiB
Kotlin
package com.aiosman.ravenow
|
|
|
|
import android.content.Context
|
|
import android.content.SharedPreferences
|
|
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
|
|
|
|
/**
|
|
* 持久化本地数据
|
|
*/
|
|
object AppStore {
|
|
private const val STORE_VERSION = 1
|
|
private const val PREFS_NAME = "app_prefs_$STORE_VERSION"
|
|
var token: String? = null
|
|
var rememberMe: Boolean = false
|
|
var isGuest: Boolean = false
|
|
private lateinit var sharedPreferences: SharedPreferences
|
|
lateinit var googleSignInOptions: GoogleSignInOptions
|
|
fun init(context: Context) {
|
|
sharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
|
|
this.loadData()
|
|
|
|
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
|
|
.requestIdToken("754277015802-uarf8br8k8gkpbj0t9g65bvkvit630q5.apps.googleusercontent.com") // Replace with your server's client ID
|
|
.requestEmail()
|
|
.build()
|
|
googleSignInOptions = gso
|
|
// apply dark mode
|
|
if (sharedPreferences.getBoolean("darkMode", false)) {
|
|
AppState.darkMode = true
|
|
AppState.appTheme = DarkThemeColors()
|
|
}
|
|
|
|
}
|
|
|
|
suspend fun saveData() {
|
|
// shared preferences
|
|
sharedPreferences.edit().apply {
|
|
putString("token", token)
|
|
putBoolean("rememberMe", rememberMe)
|
|
putBoolean("isGuest", isGuest)
|
|
}.apply()
|
|
}
|
|
|
|
fun loadData() {
|
|
// shared preferences
|
|
token = sharedPreferences.getString("token", null)
|
|
rememberMe = sharedPreferences.getBoolean("rememberMe", false)
|
|
isGuest = sharedPreferences.getBoolean("isGuest", false)
|
|
}
|
|
|
|
fun saveDarkMode(darkMode: Boolean) {
|
|
sharedPreferences.edit().apply {
|
|
putBoolean("darkMode", darkMode)
|
|
}.apply()
|
|
}
|
|
|
|
|
|
} |