我的智能体

This commit is contained in:
weber
2025-08-05 17:01:23 +08:00
parent a944bd0fa3
commit b837c704e5
12 changed files with 177 additions and 95 deletions

View File

@@ -40,6 +40,7 @@
android:exported="true" android:exported="true"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/Theme.App.Starting" android:theme="@style/Theme.App.Starting"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"> android:windowSoftInputMode="adjustResize">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

View File

@@ -5,6 +5,7 @@ import android.app.NotificationChannel
import android.app.NotificationManager import android.app.NotificationManager
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.ActivityInfo
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.net.Uri import android.net.Uri
import android.os.Build import android.os.Build
@@ -78,6 +79,10 @@ class MainActivity : ComponentActivity() {
@RequiresApi(Build.VERSION_CODES.P) @RequiresApi(Build.VERSION_CODES.P)
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
// 设置屏幕方向为竖屏
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
// 监听应用生命周期 // 监听应用生命周期
ProcessLifecycleOwner.get().lifecycle.addObserver(MainActivityLifecycleObserver()) ProcessLifecycleOwner.get().lifecycle.addObserver(MainActivityLifecycleObserver())
// 创建通知渠道 // 创建通知渠道

View File

@@ -55,7 +55,7 @@ fun AccountEditScreen2() {
fun onNicknameChange(value: String) { fun onNicknameChange(value: String) {
model.name = value model.name = value
usernameError = when { usernameError = when {
value.isEmpty() -> "昵称不能为空" value.trim().isEmpty() -> "昵称不能为空"
value.length < 3 -> "昵称长度不能小于3" value.length < 3 -> "昵称长度不能小于3"
value.length > 20 -> "昵称长度不能大于20" value.length > 20 -> "昵称长度不能大于20"
else -> null else -> null

View File

@@ -487,9 +487,7 @@ fun MomentBottomOperateRowGroup(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.fillMaxHeight() .fillMaxHeight()
.noRippleClickable { ,
onFavoriteClick()
},
contentAlignment = Alignment.CenterEnd contentAlignment = Alignment.CenterEnd
) { ) {
MomentOperateBtn(count = momentEntity.favoriteCount.toString()) { MomentOperateBtn(count = momentEntity.favoriteCount.toString()) {

View File

@@ -19,6 +19,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.paging.compose.collectAsLazyPagingItems import androidx.paging.compose.collectAsLazyPagingItems
import com.aiosman.ravenow.AppState
import com.aiosman.ravenow.LocalAppTheme import com.aiosman.ravenow.LocalAppTheme
import com.aiosman.ravenow.R import com.aiosman.ravenow.R
import com.aiosman.ravenow.exp.viewModelFactory import com.aiosman.ravenow.exp.viewModelFactory
@@ -41,9 +42,9 @@ fun FollowerListScreen(userId: Int) {
model.loadData(userId) model.loadData(userId)
} }
StatusBarMaskLayout( StatusBarMaskLayout(
modifier = Modifier modifier = Modifier.background(color = appColors.background).padding(horizontal = 16.dp),
.background(color = appColors.background) darkIcons = !AppState.darkMode,
.padding(horizontal = 16.dp), maskBoxBackgroundColor = appColors.background
) { ) {
var dataFlow = model.usersFlow var dataFlow = model.usersFlow
var users = dataFlow.collectAsLazyPagingItems() var users = dataFlow.collectAsLazyPagingItems()

View File

@@ -26,6 +26,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import androidx.lifecycle.viewmodel.compose.viewModel import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.paging.compose.collectAsLazyPagingItems import androidx.paging.compose.collectAsLazyPagingItems
import com.aiosman.ravenow.AppState
import com.aiosman.ravenow.LocalAppTheme import com.aiosman.ravenow.LocalAppTheme
import com.aiosman.ravenow.R import com.aiosman.ravenow.R
import com.aiosman.ravenow.exp.viewModelFactory import com.aiosman.ravenow.exp.viewModelFactory
@@ -48,9 +49,9 @@ fun FollowingListScreen(userId: Int) {
model.loadData(userId) model.loadData(userId)
} }
StatusBarMaskLayout( StatusBarMaskLayout(
modifier = Modifier modifier = Modifier.background(color = appColors.background).padding(horizontal = 16.dp),
.background(color = appColors.background) darkIcons = !AppState.darkMode,
.padding(horizontal = 16.dp), maskBoxBackgroundColor = appColors.background
) { ) {
var dataFlow = model.usersFlow var dataFlow = model.usersFlow
var users = dataFlow.collectAsLazyPagingItems() var users = dataFlow.collectAsLazyPagingItems()

View File

@@ -107,6 +107,7 @@ fun ProfileV3(
onChatClick: () -> Unit = {}, onChatClick: () -> Unit = {},
moments: List<MomentEntity>, moments: List<MomentEntity>,
isSelf: Boolean = true, isSelf: Boolean = true,
isMain:Boolean = false,
onLoadMore: () -> Unit = {}, onLoadMore: () -> Unit = {},
onLike: (MomentEntity) -> Unit = {}, onLike: (MomentEntity) -> Unit = {},
onComment: (MomentEntity) -> Unit = {}, onComment: (MomentEntity) -> Unit = {},
@@ -274,7 +275,7 @@ fun ProfileV3(
) )
} }
} }
if (isSelf) { if (isSelf&&isMain) {
Box( Box(
modifier = Modifier modifier = Modifier
.align(Alignment.TopEnd) .align(Alignment.TopEnd)
@@ -386,6 +387,7 @@ fun ProfileV3(
), ),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
) { ) {
if (!isMain) {
Image( Image(
painter = painterResource(id = R.drawable.rider_pro_back_icon), // Replace with your image resource painter = painterResource(id = R.drawable.rider_pro_back_icon), // Replace with your image resource
contentDescription = "Back", contentDescription = "Back",
@@ -413,8 +415,10 @@ fun ProfileV3(
fontWeight = FontWeight.W600, fontWeight = FontWeight.W600,
color = AppColors.text color = AppColors.text
) )
}
Spacer(modifier = Modifier.weight(1f)) Spacer(modifier = Modifier.weight(1f))
if (isSelf) { if (isSelf&&isMain) {
Box( Box(
modifier = Modifier.noRippleClickable { modifier = Modifier.noRippleClickable {
IndexViewModel.openDrawer = true IndexViewModel.openDrawer = true

View File

@@ -16,6 +16,7 @@ fun ProfileWrap(
MyProfileViewModel.loadProfile() MyProfileViewModel.loadProfile()
} }
ProfileV3( ProfileV3(
isMain = true,
onUpdateBanner = { uri, file, context -> onUpdateBanner = { uri, file, context ->
MyProfileViewModel.updateUserProfileBanner(uri, file, context) MyProfileViewModel.updateUserProfileBanner(uri, file, context)
}, },

View File

@@ -85,7 +85,9 @@ import com.google.accompanist.systemuicontroller.rememberSystemUiController
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import java.io.File import java.io.File
/**
* 发布动态
*/
@Preview @Preview
@Composable @Composable
fun NewPostScreen() { fun NewPostScreen() {

View File

@@ -123,6 +123,9 @@ import kotlinx.coroutines.launch
import net.engawapg.lib.zoomable.rememberZoomState import net.engawapg.lib.zoomable.rememberZoomState
import net.engawapg.lib.zoomable.zoomable import net.engawapg.lib.zoomable.zoomable
/**
* 动态详情
*/
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
fun PostScreen( fun PostScreen(
@@ -689,6 +692,7 @@ fun Header(
windowInsets = WindowInsets(0) windowInsets = WindowInsets(0)
) { ) {
PostMenuModal( PostMenuModal(
onDeleteClick = { onDeleteClick = {
onDeleteClick() onDeleteClick()
expanded = false expanded = false
@@ -696,7 +700,8 @@ fun Header(
onReportClick = { onReportClick = {
onReportClick() onReportClick()
expanded = false expanded = false
} },
userId = userId
) )
} }
} }
@@ -1214,7 +1219,7 @@ fun CommentItem(
color = AppColors.nonActiveText, color = AppColors.nonActiveText,
) )
Spacer(modifier = Modifier.width(27.dp)) Spacer(modifier = Modifier.width(27.dp))
if (AppState.UserId?.toLong() != commentEntity.author) {
Icon( Icon(
painter = painterResource(id = R.drawable.rider_pro_comment), painter = painterResource(id = R.drawable.rider_pro_comment),
contentDescription = "", contentDescription = "",
@@ -1236,7 +1241,7 @@ fun CommentItem(
) )
}, },
) )
}
} }
@@ -1375,11 +1380,11 @@ fun PostBottomBar(
fun PostMenuModal( fun PostMenuModal(
onDeleteClick: () -> Unit = {}, onDeleteClick: () -> Unit = {},
onReportClick: () -> Unit = {}, onReportClick: () -> Unit = {},
momentEntity: MomentEntity? = null userId: Int? = 0
) { ) {
val AppColors = LocalAppTheme.current val AppColors = LocalAppTheme.current
Column( Row(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.height(160.dp) .height(160.dp)
@@ -1388,10 +1393,10 @@ fun PostMenuModal(
) { ) {
Row( Row(
modifier = Modifier modifier = Modifier
.fillMaxWidth(), .size(60.dp),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
) { ) {
momentEntity?.let { if(AppState.UserId == userId){
Column( Column(
modifier = Modifier.padding(end = 16.dp), modifier = Modifier.padding(end = 16.dp),
verticalArrangement = Arrangement.Center, verticalArrangement = Arrangement.Center,
@@ -1417,13 +1422,20 @@ fun PostMenuModal(
Spacer(modifier = Modifier.height(8.dp)) Spacer(modifier = Modifier.height(8.dp))
Text( Text(
text = stringResource(R.string.delete), text = stringResource(R.string.delete),
fontSize = 11.sp, fontSize = 12.sp,
fontWeight = FontWeight.Bold, fontWeight = FontWeight.Bold,
color = AppColors.text color = AppColors.text
) )
} }
} }
} }
Row(
modifier = Modifier
.size(60.dp),
verticalAlignment = Alignment.CenterVertically
) {
if(AppState.UserId == userId){
Column( Column(
modifier = Modifier.padding(end = 16.dp), modifier = Modifier.padding(end = 16.dp),
verticalArrangement = Arrangement.Center, verticalArrangement = Arrangement.Center,
@@ -1437,11 +1449,11 @@ fun PostMenuModal(
} }
) { ) {
Image( Image(
painter = painterResource(id = R.drawable.rider_pro_moment_delete), painter = painterResource(id = R.drawable.rider_pro_moment_report),
contentDescription = "", contentDescription = "",
modifier = Modifier.size(24.dp), modifier = Modifier.size(24.dp),
colorFilter = ColorFilter.tint( colorFilter = ColorFilter.tint(
AppColors.text AppColors.error
) )
) )
} }
@@ -1449,12 +1461,13 @@ fun PostMenuModal(
Spacer(modifier = Modifier.height(8.dp)) Spacer(modifier = Modifier.height(8.dp))
Text( Text(
text = stringResource(R.string.report), text = stringResource(R.string.report),
fontSize = 11.sp, fontSize = 12.sp,
fontWeight = FontWeight.Bold, fontWeight = FontWeight.Bold,
color = AppColors.text color = AppColors.error
) )
} }
}
}
} }
} }
@@ -1621,7 +1634,7 @@ fun CommentMenuModal(
onCloseClick() onCloseClick()
} }
} }
if (!isSelf) { //自己也可以回复自己
Spacer(modifier = Modifier.width(48.dp)) Spacer(modifier = Modifier.width(48.dp))
MenuActionItem( MenuActionItem(
icon = R.drawable.rider_pro_comment, icon = R.drawable.rider_pro_comment,
@@ -1629,7 +1642,7 @@ fun CommentMenuModal(
) { ) {
onReplyClick() onReplyClick()
} }
}
} }
Spacer(modifier = Modifier.height(48.dp)) Spacer(modifier = Modifier.height(48.dp))
} }

View File

@@ -42,7 +42,12 @@ class AccountProfileViewModel : ViewModel() {
if (profileId == profile?.id) { if (profileId == profile?.id) {
return@launch return@launch
} }
try {
profile = userService.getUserProfile(id) profile = userService.getUserProfile(id)
} catch (e: Exception) {
e.printStackTrace()
}
refreshing = false refreshing = false
profile?.let { profile?.let {
try { try {

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group
android:translateX="-337"
android:translateY="-702">
<group
android:translateX="159"
android:translateY="686">
<group
android:translateY="16">
<group
android:translateX="178">
<path
android:fillType="evenOdd"
android:strokeWidth="1"
android:pathData="M 0 0 L 24 0 L 24 24 L 0 24 Z" />
<path
android:fillType="evenOdd"
android:strokeColor="#ED1C24"
android:strokeWidth="2"
android:strokeLineJoin="round"
android:strokeLineCap="round"
android:pathData="M5,19 L19,19 C19.6625348,18.9953523 20.2797678,18.6628968 20.6482087,18.1122378 C21.0166496,17.5615789 21.088473,16.8641947 20.84,16.25 L13.74,4 C13.3877623,3.36336836 12.717579,2.96824584 11.99,2.96824584 C11.262421,2.96824584 10.5922377,3.36336836 10.24,4 L3.14,16.25 C2.89639597,16.8497348 2.95812047,17.5302837 3.30565137,18.0764037 C3.65318227,18.6225237 4.24353735,18.9666713 4.89,19" />
<path
android:fillType="evenOdd"
android:strokeWidth="1"
android:pathData="M 0 0 L 24 0 L 24 24 L 0 24 Z" />
<path
android:fillType="evenOdd"
android:strokeColor="#ED1C24"
android:strokeWidth="2"
android:strokeLineJoin="round"
android:strokeLineCap="round"
android:pathData="M 12 8 L 12 12" />
<path
android:fillType="evenOdd"
android:strokeColor="#ED1C24"
android:strokeWidth="2"
android:strokeLineJoin="round"
android:strokeLineCap="round"
android:pathData="M 12 16 L 12.01 16" />
</group>
</group>
</group>
</group>
</vector>