春节主题:登录、主页面。

This commit is contained in:
2026-01-28 09:29:03 +08:00
parent 3d0fb12565
commit 88ce0205fb
68 changed files with 221 additions and 254 deletions

View File

@@ -315,9 +315,10 @@ open class Application : CommonAppContext() {
private fun initLogUtils() {
LogUtils.getConfig()
.setLogSwitch(true) // 全局开关
.setLogHeadSwitch(false)
.setLog2FileSwitch(true) // 必须设为 true
.setDir(LOGUTILS_SAVE_PATH) // 设置有效路径
.setFileFilter(LogUtils.V); // 允许所有级别
.setDir(LOGUTILS_SAVE_PATH) // 设置有效路径
.setFileFilter(LogUtils.V) // 允许所有级别
}

View File

@@ -9,6 +9,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
@@ -111,37 +112,6 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
private Fragment[] fragments;
private AppUpdateDialog appUpdateDialog;
private boolean isMediaSelected = false;
private int unselectedMediaUrl; // 从服务器获取
private int selectedMediaUrl; // 从服务器获取
// 添加其他 tab 的图标 URL
private int unselectedTrendUrl;
private int selectedTrendUrl;
private int unselectedNewsUrl;
private int selectedNewsUrl;
private int unselectedMeUrl;
private int selectedMeUrl;
// 添加文字颜色变量
private int selectedTextColor = 0; // 选中文字颜色 (从服务器获取)
private int unselectedTextColor = 0; // 未选中文字颜色 (从服务器获取)
// private String unselectedMediaUrl = ""; // 从服务器获取
// private String selectedMediaUrl = ""; // 从服务器获取
//
// // 添加其他 tab 的图标 URL
// private String unselectedTrendUrl = "";
// private String selectedTrendUrl = "";
// private String unselectedNewsUrl = "";
// private String selectedNewsUrl = "";
// private String unselectedMeUrl = "";
// private String selectedMeUrl = "";
//
// // 添加文字颜色变量
// private int selectedTextColor = 0; // 选中文字颜色 (从服务器获取)
// private int unselectedTextColor = 0; // 未选中文字颜色 (从服务器获取)
private InviteDialog inviteDialog;
@Override
protected int getLayoutId() {
@@ -173,6 +143,20 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
LogUtils.e("MainActivity", "onWindowFocusChanged:" + hasFocus);
}
private int getTabBg(){
// 1. 定义需要获取的自定义属性数组
int[] attrs = new int[]{com.xscm.moduleutil.R.attr.app_main_tab_bg};
// 2. 从Context的Theme中获取TypedArray核心绑定当前主题的属性值
TypedArray ta = obtainStyledAttributes(attrs);
// 3. 获取attr对应的资源ID默认值0无有效资源时返回0
int bgResId = ta.getResourceId(0, 0);
// 4. 关键手动回收TypedArray释放系统资源避免内存泄漏
ta.recycle();
// 5. 有有效资源ID时设置背景
return bgResId;
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -356,13 +340,8 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
// 初始化显示派对Tab
reset();
mBinding.rlMedia.setSelected(true);
mBinding.llBottomBar.setBackgroundResource(com.xscm.moduleutil.R.drawable.home_bbar_xz);
mBinding.llBottomBar.setBackgroundResource(getTabBg());
FragmentUtils.showHide(0, fragments);
index = 0;
isMediaSelected = true; // 确保设置为选中状态
selectedTextColor = ColorManager.getInstance().getPrimaryColorInt();
unselectedTextColor = Color.parseColor("#6D6D6D");
updateAllTabUI(); // 这会同时更新图标和文字颜色
}
@Override
@@ -384,7 +363,7 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
public void onClick(View view) {
int id = view.getId();
if (id == R.id.rl_media) {
mBinding.llBottomBar.setBackgroundResource(com.xscm.moduleutil.R.drawable.home_bbar_xz);
mBinding.llBottomBar.setBackgroundResource(getTabBg());
selectShow(0);
} else if (id == R.id.rl_trend) {
mBinding.llBottomBar.setBackgroundResource(com.xscm.moduleutil.R.drawable.home_bbar_yuan);
@@ -395,7 +374,7 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
selectShow(2);
} else if (id == R.id.rl_me) {
mBinding.llBottomBar.setBackgroundResource(com.xscm.moduleutil.R.drawable.home_bbar_xz);
mBinding.llBottomBar.setBackgroundResource(getTabBg());
selectShow(3);
//C0101我的界面
@@ -452,7 +431,6 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
switch (postion) {
case 0:
mBinding.rlMedia.setSelected(true);
isMediaSelected = true;
break;
case 1:
mBinding.rlTrend.setSelected(true);
@@ -465,35 +443,9 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
mBinding.rlMe.setSelected(true);
break;
}
// 更新所有图标状态
updateMediaIcon();
updateTrendIcon();
updateNewsIcon();
updateMeIcon();
// 更新文字颜色
updateTabTextColors();
FragmentUtils.showHide(postion, fragments);
}
private void updateMediaIcon() {
int imageUrl = (index == 0) ? selectedMediaUrl : unselectedMediaUrl;
mBinding.imSy.setImageResource(imageUrl);
// if (!TextUtils.isEmpty(imageUrl)) {
// Glide.with(this)
// .load(imageUrl)
// .placeholder(com.xscm.moduleutil.R.mipmap.tab_main_media_unselected) // 默认图标
// .into(mBinding.imSy);
// } else {
// // 如果没有网络图标,使用默认的选中/未选中状态
// int resId = (index == 0) ?
// com.xscm.moduleutil.R.mipmap.tab_main_media_selected :
// com.xscm.moduleutil.R.mipmap.tab_main_media_unselected;
// mBinding.imTrend.setImageResource(resId);
// }
}
private boolean shouldRestoreRoom() {
// 检查是否应该恢复房间:
@@ -869,43 +821,9 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
@Override
public void getThemeData(ThemeBean themeBean) {
if (themeBean != null) {
// 首页 tab 图标
selectedMediaUrl = themeBean.getHome_sel();
unselectedMediaUrl = themeBean.getHome_nor();
// 语圈 tab 图标
selectedTrendUrl = themeBean.getFind_sel();
unselectedTrendUrl = themeBean.getFind_nor();
// 消息 tab 图标
selectedNewsUrl = themeBean.getMsg_sel();
unselectedNewsUrl = themeBean.getMsg_nor();
// 我的 tab 图标
selectedMeUrl = themeBean.getMine_sel();
unselectedMeUrl = themeBean.getMine_nor();
// 获取文字颜色
try {
if (themeBean.getBtn_text_color() != null && !themeBean.getBtn_text_color().isEmpty()) {
if (CommonAppContext.getInstance().is_open == 1){
selectedTextColor = Color.parseColor("#FF663B");
}else {
selectedTextColor = Color.parseColor(themeBean.getTheme_color());
}
}
unselectedTextColor = Color.parseColor("#898989");
} catch (Exception e) {
// 使用默认颜色
selectedTextColor = ColorManager.getInstance().getPrimaryColorInt();
unselectedTextColor = Color.parseColor("#898989");
}
Map<String, String> colorMap = new HashMap<>();
colorMap.put("theme_color", themeBean.getTheme_color());
colorMap.put("btn_text_color", themeBean.getBtn_text_color());
// 更新 UI
updateAllTabUI();
// if (themeBean.getApp_bg() != null) {
BackgroundManager.getInstance().setBackgroundUrl(themeBean.getApp_bg());
// BackgroundManager.getInstance().setBackgroundUrl(themeBean.getApp_bg());
loadNetworkBackground();
// }
@@ -1136,96 +1054,6 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
});
}
private void updateAllTabUI() {
index = 0;
// 更新图标
updateMediaIcon();
updateTrendIcon();
updateNewsIcon();
updateMeIcon();
// 更新文字
updateTabTextColors();
}
private void updateTrendIcon() {
int imageUrl = (index == 1) ? selectedTrendUrl : unselectedTrendUrl;
mBinding.imTrend.setImageResource(imageUrl);
// if (!TextUtils.isEmpty(imageUrl)) {
// Glide.with(this)
// .load(imageUrl)
// .placeholder(com.xscm.moduleutil.R.mipmap.icon_me_trend_unselect)
// .into(mBinding.imTrend);
// } else {
// // 如果没有网络图标,使用默认的选中/未选中状态
// int resId = (index == 1) ?
// com.xscm.moduleutil.R.mipmap.icon_me_trend_select :
// com.xscm.moduleutil.R.mipmap.icon_me_trend_unselect;
// mBinding.imTrend.setImageResource(resId);
// }
}
private void updateNewsIcon() {
int imageUrl = (index == 2) ? selectedNewsUrl : unselectedNewsUrl;
mBinding.ivNews.setImageResource(imageUrl);
// if (!TextUtils.isEmpty(imageUrl)) {
// Glide.with(this)
// .load(imageUrl)
// .placeholder(com.xscm.moduleutil.R.mipmap.icon_news_un_select)
// .into(mBinding.ivNews);
// } else {
// // 如果没有网络图标,使用默认的选中/未选中状态
// int resId = (index == 2) ?
// com.xscm.moduleutil.R.mipmap.icon_news_select :
// com.xscm.moduleutil.R.mipmap.icon_news_un_select;
// mBinding.ivNews.setImageResource(resId);
// }
}
private void updateMeIcon() {
int imageUrl = (index == 3) ? selectedMeUrl : unselectedMeUrl;
mBinding.imMe.setImageResource(imageUrl);
// if (!TextUtils.isEmpty(imageUrl)) {
// Glide.with(this)
// .load(imageUrl)
// .placeholder(com.xscm.moduleutil.R.mipmap.icon_my_un_select)
// .into(mBinding.imMe);
// } else {
// // 如果没有网络图标,使用默认的选中/未选中状态
// int resId = (index == 3) ?
// com.xscm.moduleutil.R.mipmap.icon_my_select :
// com.xscm.moduleutil.R.mipmap.icon_my_un_select;
// mBinding.imMe.setImageResource(resId);
// }
}
private void updateTabTextColors() {
// 更新声播 tab 文字颜色
if (selectedTextColor != 0 && unselectedTextColor != 0) {
int mediaTextColor = (index == 0) ? selectedTextColor : unselectedTextColor;
mBinding.tvMedia.setTextColor(mediaTextColor);
}
// 更新语圈 tab 文字颜色
if (selectedTextColor != 0 && unselectedTextColor != 0) {
int trendTextColor = (index == 1) ? selectedTextColor : unselectedTextColor;
mBinding.tvTrend.setTextColor(trendTextColor);
}
// 更新消息 tab 文字颜色
if (selectedTextColor != 0 && unselectedTextColor != 0) {
int newsTextColor = (index == 2) ? selectedTextColor : unselectedTextColor;
mBinding.tvNews.setTextColor(newsTextColor);
}
// 更新我的 tab 文字颜色
if (selectedTextColor != 0 && unselectedTextColor != 0) {
int meTextColor = (index == 3) ? selectedTextColor : unselectedTextColor;
mBinding.tvMe.setTextColor(meTextColor);
}
}
@SuppressLint("CheckResult")
public void isShowLoading(boolean isShow) {
if (isShow) {

View File

@@ -120,9 +120,10 @@
android:layout_height="@dimen/dp_30"
android:layout_marginEnd="@dimen/dp_12"
android:background="@drawable/cs"
android:backgroundTint="?attr/app_color_colorPrimary"
android:gravity="center"
android:text="发送"
android:textColor="@color/color_FF333333"
android:textColor="@color/white"
android:textSize="@dimen/sp_12"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"

View File

@@ -10,8 +10,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/log_bj">
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
@@ -146,7 +145,6 @@
android:layout_marginStart="@dimen/dp_40"
android:layout_marginTop="12dp"
android:layout_marginEnd="@dimen/dp_40"
android:background="@drawable/selector_sex_mm"
android:orientation="horizontal">
<RelativeLayout

View File

@@ -9,6 +9,7 @@
</data>
<RelativeLayout
android:background="?attr/app_main_bg"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -49,7 +50,7 @@
android:layout_height="@dimen/dp_24"
android:gravity="center_horizontal"
android:scaleType="fitXY"
android:src="@drawable/main_bottom_bar_icon_media" />
android:src="?attr/app_main_tab_1" />
<TextView
android:id="@+id/tv_media"
@@ -57,7 +58,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_2"
android:text="@string/main_tab1"
android:textColor="@drawable/text_color_two"
android:textColor="?attr/app_main_tab_text_color"
android:textSize="@dimen/sp_10" />
</LinearLayout>
@@ -77,7 +78,7 @@
android:layout_height="@dimen/dp_24"
android:gravity="center_horizontal"
android:scaleType="fitXY"
android:src="@drawable/main_bottom_bar_icon_tend" />
android:src="?attr/app_main_tab_2" />
<TextView
android:id="@+id/tv_trend"
@@ -85,7 +86,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_2"
android:text="@string/main_tab2"
android:textColor="@drawable/text_color_two"
android:textColor="?attr/app_main_tab_text_color"
android:textSize="@dimen/sp_10" />
</LinearLayout>
@@ -113,7 +114,7 @@
android:layout_marginTop="3dp"
android:gravity="center_horizontal"
android:scaleType="fitXY"
android:src="@drawable/main_bottom_bar_icon_news" />
android:src="?attr/app_main_tab_3" />
<TextView
android:id="@+id/tv_message"
@@ -144,7 +145,7 @@
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/dp_2"
android:text="@string/main_tab3"
android:textColor="@drawable/text_color_two"
android:textColor="?attr/app_main_tab_text_color"
android:textSize="@dimen/sp_10" />
</LinearLayout>
@@ -165,7 +166,7 @@
android:layout_centerInParent="true"
android:gravity="center_horizontal"
android:scaleType="fitXY"
android:src="@drawable/main_bottom_bar_icon_me" />
android:src="?attr/app_main_tab_4" />
<TextView
android:id="@+id/tv_me"
@@ -173,7 +174,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_2"
android:text="@string/main_tab4"
android:textColor="@drawable/text_color_two"
android:textColor="?attr/app_main_tab_text_color"
android:textSize="@dimen/sp_10" />
</LinearLayout>
</LinearLayout>

View File

@@ -119,6 +119,7 @@
android:layout_marginTop="@dimen/dp_20"
android:layout_marginEnd="@dimen/dp_38"
android:background="@drawable/cs"
android:backgroundTint="?attr/app_color_colorPrimary"
android:gravity="center"
android:text="立即发布"
android:textColor="@color/color_FF333333"

View File

@@ -273,6 +273,7 @@
android:layout_height="@dimen/dp_40"
android:text="确认"
android:background="@drawable/cs"
android:backgroundTint="?attr/app_color_colorPrimary"
android:gravity="center"
android:textColor="@color/white"
android:textSize="@dimen/sp_14"

View File

@@ -205,7 +205,7 @@
android:layout_height="@dimen/dp_33"
android:layout_marginEnd="@dimen/dp_16"
android:scaleType="fitCenter"
android:src="@mipmap/me_edit"
android:src="?attr/app_user_edit_me"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@@ -403,7 +403,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_16"
android:layout_marginEnd="@dimen/dp_16"
app:cardBackgroundColor="#231F2C"
app:cardBackgroundColor="?attr/app_user_bg_color"
app:cardCornerRadius="@dimen/dp_8">
<LinearLayout
@@ -559,7 +559,7 @@
android:layout_marginStart="@dimen/dp_16"
android:layout_marginTop="@dimen/dp_12"
android:layout_marginEnd="@dimen/dp_16"
app:cardBackgroundColor="#231F2C"
app:cardBackgroundColor="?attr/app_user_bg_color"
app:cardCornerRadius="@dimen/dp_8">
<LinearLayout
@@ -678,7 +678,7 @@
android:layout_marginStart="@dimen/dp_16"
android:layout_marginTop="@dimen/dp_12"
android:layout_marginEnd="@dimen/dp_16"
app:cardBackgroundColor="#231F2C"
app:cardBackgroundColor="?attr/app_user_bg_color"
app:cardCornerRadius="@dimen/dp_8">
<LinearLayout
@@ -818,7 +818,7 @@
android:layout_marginStart="@dimen/dp_16"
android:layout_marginTop="@dimen/dp_12"
android:layout_marginEnd="@dimen/dp_16"
app:cardBackgroundColor="#231F2C"
app:cardBackgroundColor="?attr/app_user_bg_color"
app:cardCornerRadius="@dimen/dp_8">