Selaa lähdekoodia

修改IM部分样式机构端

Pq 1 vuosi sitten
vanhempi
commit
e70b2757f1

+ 5 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/ui/ChatFragment.java

@@ -45,6 +45,7 @@ public class ChatFragment extends BaseFragment<TcFragmentChatLayoutBinding> impl
     protected void initView(View rootView) {
         Utils.setHeadView(mViewBinding.viewStatusBar, requireContext(), 0);
         IMThemManager.getInstance().init(getContext());
+        setViewStyles();
         IMCenter.getInstance().addUnReadMessageObserver(mUnReadMessageObserver);
         if (BaseApplication.Companion.isTeacherClient()) {
             mViewBinding.imCreateGroup.setVisibility(View.VISIBLE);
@@ -54,6 +55,10 @@ public class ChatFragment extends BaseFragment<TcFragmentChatLayoutBinding> impl
         }
     }
 
+    private void setViewStyles() {
+        IMThemManager.getInstance().setTabViewStyles(mViewBinding.tabLayout);
+    }
+
     private void initListener() {
         mViewBinding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
             @Override

+ 3 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/ui/ContactPersonListFragment.java

@@ -28,6 +28,7 @@ import com.cooleshow.chatmodule.contract.ContactListFragmentContract;
 import com.cooleshow.chatmodule.databinding.TcFragmentContactListLayoutBinding;
 import com.cooleshow.chatmodule.presenter.ContactListPresenter;
 import com.cooleshow.chatmodule.utils.helper.ChatHelper;
+import com.cooleshow.chatmodule.utils.helper.IMThemManager;
 import com.cooleshow.chatmodule.widget.CustomIndexBarDataHelperImpl;
 import com.mcxtzhang.indexlib.suspension.SuspensionDecoration;
 import com.scwang.smart.refresh.layout.api.RefreshLayout;
@@ -77,6 +78,8 @@ public class ContactPersonListFragment extends BaseMVPFragment<TcFragmentContact
         if (getArguments() != null) {
             isSelectContact = getArguments().getBoolean(IMConstants.IS_SELECT_CONTACT, false);
         }
+        IMThemManager.getInstance().setSearchIconStyles(mViewBinding.ivSearchIcon);
+        IMThemManager.getInstance().setSearchButtonStyles(mViewBinding.tvSearch);
         mViewBinding.etTargetName.setHint("请输入联系人名称");
         CustomIndexBarDataHelperImpl indexBarDataHelper = new CustomIndexBarDataHelperImpl();
         mViewBinding.livLetters.setDataHelper(indexBarDataHelper);

+ 3 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/ui/ContactRoomListFragment.java

@@ -23,6 +23,7 @@ import com.cooleshow.chatmodule.databinding.TcFragmentContactRoomListBinding;
 import com.cooleshow.chatmodule.presenter.ContactRoomListPresenter;
 import com.cooleshow.chatmodule.utils.helper.ChatGroupHelper;
 import com.cooleshow.chatmodule.utils.helper.ChatHelper;
+import com.cooleshow.chatmodule.utils.helper.IMThemManager;
 import com.cooleshow.chatmodule.widget.CustomIndexBarDataHelperImpl;
 import com.mcxtzhang.indexlib.suspension.SuspensionDecoration;
 import com.scwang.smart.refresh.layout.api.RefreshLayout;
@@ -63,6 +64,8 @@ public class ContactRoomListFragment extends BaseMVPFragment<TcFragmentContactRo
         if (getArguments() != null) {
             isSelectContact = getArguments().getBoolean(IMConstants.IS_SELECT_CONTACT, false);
         }
+        IMThemManager.getInstance().setSearchIconStyles(mViewBinding.ivSearchIcon);
+        IMThemManager.getInstance().setSearchButtonStyles(mViewBinding.tvSearch);
         mViewBinding.etTargetName.setHint("请输入群聊名称");
         mViewBinding.tvSearch.setOnClickListener(this);
         mListAdapter = new ContactRoomListAdapter();

+ 4 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/ui/ConversationListFragment.java

@@ -6,6 +6,7 @@ import android.view.View;
 import com.cooleshow.base.ui.fragment.BaseFragment;
 import com.cooleshow.chatmodule.R;
 import com.cooleshow.chatmodule.databinding.TcFragmentConversationListLayoutBinding;
+import com.cooleshow.chatmodule.utils.helper.IMThemManager;
 import com.tencent.qcloud.tuicore.TUIConstants;
 import com.tencent.qcloud.tuicore.TUICore;
 import com.tencent.qcloud.tuicore.interfaces.ITUINotification;
@@ -28,6 +29,9 @@ public class ConversationListFragment extends BaseFragment<TcFragmentConversatio
 
     @Override
     protected void initView(View rootView) {
+        IMThemManager.getInstance().setSearchIconStyles(mViewBinding.ivSearchIcon);
+        IMThemManager.getInstance().setSearchButtonStyles(mViewBinding.tvSearch);
+
         TUICore.registerEvent(TUIConstants.TUILogin.EVENT_LOGIN_STATE_CHANGED, TUIConstants.TUILogin.EVENT_SUB_KEY_USER_LOGIN_SUCCESS, this);
         TUICore.registerEvent(TUIConstants.TUILogin.EVENT_LOGIN_STATE_CHANGED, TUIConstants.TUILogin.EVENT_SUB_KEY_USER_LOGOUT_SUCCESS, this);
         mTuiConversationFragment = new TUIConversationFragment();

+ 64 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/utils/helper/IMThemManager.java

@@ -1,7 +1,14 @@
 package com.cooleshow.chatmodule.utils.helper;
 
 import android.content.Context;
+import android.graphics.Color;
+import android.graphics.PorterDuff;
 import android.graphics.drawable.Drawable;
+import android.graphics.drawable.GradientDrawable;
+import android.graphics.drawable.LayerDrawable;
+import android.widget.ImageView;
+import android.widget.TableLayout;
+import android.widget.TextView;
 
 import com.cooleshow.base.common.BaseApplication;
 import com.cooleshow.base.utils.SizeUtils;
@@ -12,6 +19,7 @@ import com.cooleshow.chatmodule.message.bean.TUIChatShareMusicMessageBean;
 import com.cooleshow.chatmodule.message.holder.TUIChatShareLiveMessageHolder;
 import com.cooleshow.chatmodule.message.holder.TUIChatShareMusicMessageHolder;
 import com.cooleshow.chatmodule.widget.CustomChatInputMusicExtension;
+import com.google.android.material.tabs.TabLayout;
 import com.tencent.qcloud.tuicore.TUIConfig;
 import com.tencent.qcloud.tuicore.TUIConstants;
 import com.tencent.qcloud.tuicore.TUICore;
@@ -25,6 +33,12 @@ import com.tencent.qcloud.tuikit.tuichat.config.TUIChatConfigs;
  * Author by pq, Date on 2023/7/3.
  */
 public class IMThemManager {
+    private Drawable tabIndicatorDrawable = null;
+    private int tabIndicatorColor = -1;
+    private int searchIconRes = -1;
+    private int searchBtBackgroundRes = -1;
+
+
     private IMThemManager() {
     }
 
@@ -63,8 +77,58 @@ public class IMThemManager {
         }
     }
 
+    public void setTabViewStyles(TabLayout tableLayout) {
+        if (tableLayout == null) {
+            return;
+        }
+        Drawable tabSelectedIndicator = tableLayout.getTabSelectedIndicator();
+        if (tabIndicatorDrawable != null && tabIndicatorColor != -1) {
+            tabSelectedIndicator.setTint(tabIndicatorColor);
+        } else {
+            tabSelectedIndicator.setTintList(null);
+        }
+    }
+
+    public void setSearchIconStyles(ImageView imageView) {
+        if (imageView == null) {
+            return;
+        }
+        if (searchIconRes != -1) {
+            imageView.setImageResource(searchIconRes);
+        }
+    }
+
+    public void setSearchButtonStyles(TextView textView) {
+        if (textView == null) {
+            return;
+        }
+        if (searchBtBackgroundRes != -1) {
+            textView.setBackgroundResource(searchBtBackgroundRes);
+        }
+    }
+
     public void setEmptyDrawable(Drawable emptyDrawable) {
         MessageProperties instance = MessageProperties.getInstance();
         instance.setConversationListEmptyDrawable(emptyDrawable);
     }
+
+    public void setTabIndicatorDrawable(Drawable tabIndicatorDrawable, int tabIndicatorColor) {
+        this.tabIndicatorDrawable = tabIndicatorDrawable;
+        this.tabIndicatorColor = tabIndicatorColor;
+    }
+
+    public void setSearchIconRes(int searchIconRes) {
+        this.searchIconRes = searchIconRes;
+    }
+
+    public void setSearchBtBackgroundRes(int searchBtBackgroundRes) {
+        this.searchBtBackgroundRes = searchBtBackgroundRes;
+    }
+
+    public void resetStyleValue() {
+        this.tabIndicatorDrawable = null;
+        this.tabIndicatorColor = -1;
+        this.searchIconRes = -1;
+        this.searchBtBackgroundRes = -1;
+    }
 }

+ 1 - 1
chatModule/src/main/res/layout/tc_fragment_chat_layout.xml

@@ -27,7 +27,7 @@
         app:tabBackground="@color/transparent"
         app:tabGravity="center"
         app:tabIndicator="@drawable/custom_indicator_drawable"
-        app:tabIndicatorColor="@color/colorAccent"
+        app:tabIndicatorColor="@color/transparent"
         app:tabIndicatorFullWidth="false"
         app:tabIndicatorHeight="4dp"
         app:tabMaxWidth="0dp"

+ 3 - 0
institution/src/main/java/com/cooleshow/institution/stu/ui/main/MainActivity.java

@@ -93,6 +93,9 @@ public class MainActivity extends BaseMVPActivity<ActivityInstitutionMainLayoutB
     private void setStyleConfig() {
         StyleConfig.isStudentStyle = false;
         IMThemManager.getInstance().setEmptyDrawable(getResources().getDrawable(R.drawable.jg_icon_empty_content));
+        IMThemManager.getInstance().setTabIndicatorDrawable(getResources().getDrawable(R.drawable.jg_custom_indicator_drawable),getResources().getColor(R.color.color_fe2451));
+        IMThemManager.getInstance().setSearchBtBackgroundRes(R.drawable.shape_ff3c81_toff76a6_14dp);
+        IMThemManager.getInstance().setSearchIconRes(R.drawable.jg_icon_search);
     }
 
     public void onTabClick(View view) {

+ 15 - 0
institution/src/main/res/drawable/jg_custom_indicator_drawable.xml

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:opacity="opaque"
+    tools:targetApi="23">
+
+    <item
+        android:width="16dp"
+        android:gravity="center_horizontal">
+        <shape android:shape="rectangle">
+            <corners android:radius="2dp"/>
+            <solid android:color="@color/color_fe2451" />
+        </shape>
+    </item>
+</layer-list>

+ 6 - 0
institution/src/main/res/drawable/shape_ff3c81_toff76a6_14dp.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <gradient android:startColor="#FF76A6"
+        android:endColor="#FF3C81"/>
+    <corners android:radius="14dp"/>
+</shape>

+ 1 - 0
institution/src/main/res/values/colors.xml

@@ -7,4 +7,5 @@
     <color name="color_66000000">#66000000</color>
     <color name="color_fe2451">#FE2451</color>
     <color name="color_777777">#777777</color>
+    <color name="color_fe2c57">#FE2C57</color>
 </resources>

+ 1 - 0
student/src/main/java/com/cooleshow/student/ui/main/MainActivity.java

@@ -254,6 +254,7 @@ public class MainActivity extends BaseMVPActivity<ActivityMainBinding, MainPrese
     private void setStyleConfig() {
         StyleConfig.isStudentStyle = true;
         IMThemManager.getInstance().setEmptyDrawable(null);
+        IMThemManager.getInstance().resetStyleValue();
     }
 
     /**