Ver código fonte

增加老师端直播间美颜

Pq 2 anos atrás
pai
commit
b1dd6eb350
24 arquivos alterados com 75 adições e 4 exclusões
  1. 57 1
      teacher/src/main/java/com/cooleshow/teacher/ui/live/LiveBeautyOptionsFragment.java
  2. 7 0
      teacher/src/main/java/com/cooleshow/teacher/widgets/dialog/LiveBeautyOptionsDialog.java
  3. 10 3
      teacher/src/main/java/com/cooleshow/teacher/widgets/helper/LiveRoomBeautyHelper.java
  4. BIN
      teacher/src/main/res/drawable-xhdpi/icon_live_beauty_off.png
  5. BIN
      teacher/src/main/res/drawable-xhdpi/icon_live_beauty_on.png
  6. BIN
      teacher/src/main/res/drawable-xhdpi/icon_live_beauty_options1_off.png
  7. BIN
      teacher/src/main/res/drawable-xhdpi/icon_live_beauty_options1_on.png
  8. BIN
      teacher/src/main/res/drawable-xhdpi/icon_live_beauty_options2_off.png
  9. BIN
      teacher/src/main/res/drawable-xhdpi/icon_live_beauty_options2_on.png
  10. BIN
      teacher/src/main/res/drawable-xhdpi/icon_live_beauty_options3_off.png
  11. BIN
      teacher/src/main/res/drawable-xhdpi/icon_live_beauty_options3_on.png
  12. BIN
      teacher/src/main/res/drawable-xhdpi/icon_live_beauty_options4_off.png
  13. BIN
      teacher/src/main/res/drawable-xhdpi/icon_live_beauty_options4_on.png
  14. BIN
      teacher/src/main/res/drawable-xxhdpi/icon_live_beauty_off.png
  15. BIN
      teacher/src/main/res/drawable-xxhdpi/icon_live_beauty_on.png
  16. BIN
      teacher/src/main/res/drawable-xxhdpi/icon_live_beauty_options1_off.png
  17. BIN
      teacher/src/main/res/drawable-xxhdpi/icon_live_beauty_options1_on.png
  18. BIN
      teacher/src/main/res/drawable-xxhdpi/icon_live_beauty_options2_off.png
  19. BIN
      teacher/src/main/res/drawable-xxhdpi/icon_live_beauty_options2_on.png
  20. BIN
      teacher/src/main/res/drawable-xxhdpi/icon_live_beauty_options3_off.png
  21. BIN
      teacher/src/main/res/drawable-xxhdpi/icon_live_beauty_options3_on.png
  22. BIN
      teacher/src/main/res/drawable-xxhdpi/icon_live_beauty_options4_off.png
  23. BIN
      teacher/src/main/res/drawable-xxhdpi/icon_live_beauty_options4_on.png
  24. 1 0
      teacher/src/main/res/layout/fragment_live_beauty_layout.xml

+ 57 - 1
teacher/src/main/java/com/cooleshow/teacher/ui/live/LiveBeautyOptionsFragment.java

@@ -1,5 +1,6 @@
 package com.cooleshow.teacher.ui.live;
 
+import android.graphics.drawable.Drawable;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.RadioGroup;
@@ -9,6 +10,8 @@ import com.cooleshow.teacher.R;
 import com.cooleshow.teacher.databinding.FragmentLiveBeautyLayoutBinding;
 import com.cooleshow.teacher.widgets.helper.LiveRoomBeautyHelper;
 
+import androidx.annotation.DrawableRes;
+
 /**
  * Author by pq, Date on 2022/6/13.
  */
@@ -30,12 +33,22 @@ public class LiveBeautyOptionsFragment extends BaseFragment<FragmentLiveBeautyLa
                 } else if (checkedId == R.id.rb_options4) {
                     type = LiveRoomBeautyHelper.OPTIONS_TYPE4;
                 }
+                updateCheckStyle(checkedId);
                 if (mEventListener != null) {
                     mEventListener.onChangeOptions(type);
                 }
             }
         });
-
+        mViewBinding.ivSwitchLiveBeauty.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                LiveRoomBeautyHelper.getInstance().switchBeauty();
+                updateUI();
+                if (mEventListener != null) {
+                    mEventListener.onSwitchBeautyMode(LiveRoomBeautyHelper.getInstance().isOpenBeauty());
+                }
+            }
+        });
     }
 
     @Override
@@ -44,6 +57,41 @@ public class LiveBeautyOptionsFragment extends BaseFragment<FragmentLiveBeautyLa
     }
 
 
+    private void updateUI() {
+        if (LiveRoomBeautyHelper.getInstance().isOpenBeauty()) {
+            mViewBinding.rbOptions1.setClickable(true);
+            mViewBinding.rbOptions2.setClickable(true);
+            mViewBinding.rbOptions3.setClickable(true);
+            mViewBinding.rbOptions4.setClickable(true);
+            mViewBinding.rgOptions.clearCheck();
+            mViewBinding.ivSwitchLiveBeauty.setImageResource(R.drawable.icon_live_beauty_on);
+            mViewBinding.tvSwitchLiveBeauty.setText("已开启");
+            mViewBinding.rbOptions1.setCompoundDrawables(null, getTopDrawable(R.drawable.icon_live_beauty_options1_on), null, null);
+            mViewBinding.rbOptions2.setCompoundDrawables(null, getTopDrawable(R.drawable.icon_live_beauty_options2_on), null, null);
+            mViewBinding.rbOptions3.setCompoundDrawables(null, getTopDrawable(R.drawable.icon_live_beauty_options3_on), null, null);
+            mViewBinding.rbOptions4.setCompoundDrawables(null, getTopDrawable(R.drawable.icon_live_beauty_options4_on), null, null);
+        } else {
+            mViewBinding.ivSwitchLiveBeauty.setImageResource(R.drawable.icon_live_beauty_off);
+            mViewBinding.tvSwitchLiveBeauty.setText("已关闭");
+            mViewBinding.rbOptions1.setClickable(false);
+            mViewBinding.rbOptions2.setClickable(false);
+            mViewBinding.rbOptions3.setClickable(false);
+            mViewBinding.rbOptions4.setClickable(false);
+            mViewBinding.rgOptions.clearCheck();
+            mViewBinding.rbOptions1.setCompoundDrawables(null, getTopDrawable(R.drawable.icon_live_beauty_options1_off), null, null);
+            mViewBinding.rbOptions2.setCompoundDrawables(null, getTopDrawable(R.drawable.icon_live_beauty_options2_off), null, null);
+            mViewBinding.rbOptions3.setCompoundDrawables(null, getTopDrawable(R.drawable.icon_live_beauty_options3_off), null, null);
+            mViewBinding.rbOptions4.setCompoundDrawables(null, getTopDrawable(R.drawable.icon_live_beauty_options4_off), null, null);
+        }
+    }
+
+    private void updateCheckStyle(int viewId) {
+        mViewBinding.rbOptions1.setCompoundDrawables(null, getTopDrawable(viewId == mViewBinding.rbOptions1.getId() ? R.drawable.icon_live_beauty_options1 : R.drawable.icon_live_beauty_options1_on), null, null);
+        mViewBinding.rbOptions2.setCompoundDrawables(null, getTopDrawable(viewId == mViewBinding.rbOptions2.getId() ? R.drawable.icon_live_beauty_options2 : R.drawable.icon_live_beauty_options2_on), null, null);
+        mViewBinding.rbOptions3.setCompoundDrawables(null, getTopDrawable(viewId == mViewBinding.rbOptions3.getId() ? R.drawable.icon_live_beauty_options3 : R.drawable.icon_live_beauty_options3_on), null, null);
+        mViewBinding.rbOptions4.setCompoundDrawables(null, getTopDrawable(viewId == mViewBinding.rbOptions4.getId() ? R.drawable.icon_live_beauty_options4 : R.drawable.icon_live_beauty_options4_on), null, null);
+    }
+
     @Override
     protected FragmentLiveBeautyLayoutBinding getLayoutView() {
         return FragmentLiveBeautyLayoutBinding.inflate(getLayoutInflater());
@@ -55,5 +103,13 @@ public class LiveBeautyOptionsFragment extends BaseFragment<FragmentLiveBeautyLa
 
     public interface OnEventListener {
         void onChangeOptions(int type);
+
+        void onSwitchBeautyMode(boolean isOpen);
+    }
+
+    private Drawable getTopDrawable(@DrawableRes int id) {
+        Drawable drawableTop = getResources().getDrawable(id);
+        drawableTop.setBounds(0, 0, drawableTop.getMinimumWidth(), drawableTop.getMinimumHeight());
+        return drawableTop;
     }
 }

+ 7 - 0
teacher/src/main/java/com/cooleshow/teacher/widgets/dialog/LiveBeautyOptionsDialog.java

@@ -157,6 +157,13 @@ public class LiveBeautyOptionsDialog extends Dialog implements LiveBeautyOptions
     }
 
     @Override
+    public void onSwitchBeautyMode(boolean isOpen) {
+        if (mSeekBar != null) {
+            mSeekBar.setVisibility(isOpen ? View.VISIBLE : View.INVISIBLE);
+        }
+    }
+
+    @Override
     public void onClick(View v) {
         int id = v.getId();
         if (id == R.id.tv_reset) {

+ 10 - 3
teacher/src/main/java/com/cooleshow/teacher/widgets/helper/LiveRoomBeautyHelper.java

@@ -30,7 +30,6 @@ public class LiveRoomBeautyHelper {
     private LiveRoomBeautyHelper() {
     }
 
-
     public static LiveRoomBeautyHelper getInstance() {
         if (mHelper == null) {
             synchronized (LiveRoomBeautyHelper.class) {
@@ -42,6 +41,10 @@ public class LiveRoomBeautyHelper {
         return mHelper;
     }
 
+    public boolean isOpenBeauty() {
+        return isOpenBeauty;
+    }
+
     public void update(int progress) {
         RCRTCBeautyOption beautyOption = RCRTCBeautyEngine.getInstance().getCurrentBeautyOption();
         if (currentType == OPTIONS_TYPE1) {
@@ -77,8 +80,12 @@ public class LiveRoomBeautyHelper {
     }
 
 
-    public void switchBeauty(boolean isOpen) {
-        this.isOpenBeauty = isOpen;
+    public void switchBeauty() {
+        if (isOpenBeauty) {
+            this.isOpenBeauty = false;
+        } else {
+            this.isOpenBeauty = true;
+        }
         RCRTCBeautyOption beautyOption = RCRTCBeautyEngine.getInstance().getCurrentBeautyOption();
         RCRTCBeautyEngine.getInstance().setBeautyOption(isOpenBeauty, beautyOption);  // true 是使用美颜,false 不使用美颜
     }

BIN
teacher/src/main/res/drawable-xhdpi/icon_live_beauty_off.png


BIN
teacher/src/main/res/drawable-xhdpi/icon_live_beauty_on.png


BIN
teacher/src/main/res/drawable-xhdpi/icon_live_beauty_options1_off.png


BIN
teacher/src/main/res/drawable-xhdpi/icon_live_beauty_options1_on.png


BIN
teacher/src/main/res/drawable-xhdpi/icon_live_beauty_options2_off.png


BIN
teacher/src/main/res/drawable-xhdpi/icon_live_beauty_options2_on.png


BIN
teacher/src/main/res/drawable-xhdpi/icon_live_beauty_options3_off.png


BIN
teacher/src/main/res/drawable-xhdpi/icon_live_beauty_options3_on.png


BIN
teacher/src/main/res/drawable-xhdpi/icon_live_beauty_options4_off.png


BIN
teacher/src/main/res/drawable-xhdpi/icon_live_beauty_options4_on.png


BIN
teacher/src/main/res/drawable-xxhdpi/icon_live_beauty_off.png


BIN
teacher/src/main/res/drawable-xxhdpi/icon_live_beauty_on.png


BIN
teacher/src/main/res/drawable-xxhdpi/icon_live_beauty_options1_off.png


BIN
teacher/src/main/res/drawable-xxhdpi/icon_live_beauty_options1_on.png


BIN
teacher/src/main/res/drawable-xxhdpi/icon_live_beauty_options2_off.png


BIN
teacher/src/main/res/drawable-xxhdpi/icon_live_beauty_options2_on.png


BIN
teacher/src/main/res/drawable-xxhdpi/icon_live_beauty_options3_off.png


BIN
teacher/src/main/res/drawable-xxhdpi/icon_live_beauty_options3_on.png


BIN
teacher/src/main/res/drawable-xxhdpi/icon_live_beauty_options4_off.png


BIN
teacher/src/main/res/drawable-xxhdpi/icon_live_beauty_options4_on.png


+ 1 - 0
teacher/src/main/res/layout/fragment_live_beauty_layout.xml

@@ -17,6 +17,7 @@
         app:layout_constraintTop_toTopOf="parent" />
 
     <TextView
+        android:id="@+id/tv_switch_live_beauty"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:paddingTop="23dp"