diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/FaceManager.java b/FaceUnity/src/main/java/com/yunbao/faceunity/FaceManager.java index 9c31a0e86..b73b3e256 100644 --- a/FaceUnity/src/main/java/com/yunbao/faceunity/FaceManager.java +++ b/FaceUnity/src/main/java/com/yunbao/faceunity/FaceManager.java @@ -11,9 +11,6 @@ import android.hardware.SensorManager; import android.os.Environment; import android.util.Log; -import androidx.annotation.NonNull; - -import com.faceunity.core.callback.OperateCallback; import com.faceunity.core.entity.FURenderOutputData; import com.faceunity.core.enumeration.CameraFacingEnum; import com.faceunity.core.enumeration.FUAIProcessorEnum; @@ -21,13 +18,10 @@ import com.faceunity.core.enumeration.FUAITypeEnum; import com.faceunity.core.enumeration.FUInputTextureEnum; import com.faceunity.core.enumeration.FUTransformMatrixEnum; import com.faceunity.core.faceunity.FUAIKit; -import com.faceunity.core.faceunity.FURenderManager; import com.faceunity.core.utils.CameraUtils; -import com.faceunity.core.utils.FULogger; import com.yunbao.faceunity.data.FaceUnityDataFactory; import com.yunbao.faceunity.listener.FURendererListener; import com.yunbao.faceunity.ui.FaceUnityView; -import com.yunbao.faceunity.utils.Authpack; import com.yunbao.faceunity.utils.CSVUtils; import com.yunbao.faceunity.utils.FURenderer; import com.yunbao.faceunity.utils.FaceUnityData; @@ -50,6 +44,7 @@ public class FaceManager implements SensorEventListener { private static final String TAG = FaceManager.class.getSimpleName(); private FaceUnityDataFactory mFaceUnityDataFactory; private FaceManager.FaceStatusChanged faceStatusChanged; + private boolean pauseFace = false; /** * 初始化美颜模块,在AppContext中调用 @@ -61,7 +56,7 @@ public class FaceManager implements SensorEventListener { FaceUnityData.mApplication = context; OkHttpUtils.getInstance().init(context, false); FURenderer.getInstance().setup(context); - isInit=true; + isInit = true; } private FURenderer mFURenderer; @@ -86,6 +81,24 @@ public class FaceManager implements SensorEventListener { mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_NORMAL); } + /** + * 注册长按对比键事件 + * @param faceUnityView + */ + public void setFaceUnityView(FaceUnityView faceUnityView) { + faceUnityView.setIFaceUnityInter(new FaceUnityView.IFaceUnityInter() { + @Override + public void onPause() { + pauseFace = true; + } + + @Override + public void onStart() { + pauseFace = false; + } + }); + } + /** * 监听人脸识别个数 */ @@ -108,6 +121,9 @@ public class FaceManager implements SensorEventListener { @Override public RCRTCVideoFrame processVideoFrame(RCRTCVideoFrame callVideoFrame) { //Log.i(TAG, "processVideoFrame: egl context " + EGL14.eglGetCurrentContext()); + if (pauseFace) { + return callVideoFrame; + } int width = callVideoFrame.getWidth(); int height = callVideoFrame.getHeight(); diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/ui/FaceUnityView.java b/FaceUnity/src/main/java/com/yunbao/faceunity/ui/FaceUnityView.java index 064872467..33dc80941 100644 --- a/FaceUnity/src/main/java/com/yunbao/faceunity/ui/FaceUnityView.java +++ b/FaceUnity/src/main/java/com/yunbao/faceunity/ui/FaceUnityView.java @@ -2,8 +2,8 @@ package com.yunbao.faceunity.ui; import android.content.Context; import android.util.AttributeSet; +import android.view.KeyEvent; import android.view.LayoutInflater; -import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -18,9 +18,8 @@ import com.yunbao.faceunity.R; import com.yunbao.faceunity.adapters.ContainerRecyclerAdapter; import com.yunbao.faceunity.adapters.MenuGroupRecyclerAdapter; import com.yunbao.faceunity.data.FaceParam; -import com.yunbao.faceunity.data.FaceUnityDataFactory; -import com.yunbao.faceunity.entity.BaseBean; import com.yunbao.faceunity.data.FineStickerDataFactory; +import com.yunbao.faceunity.entity.BaseBean; import com.yunbao.faceunity.entity.FunctionEnum; import com.yunbao.faceunity.entity.MakeupCustomClassBean; import com.yunbao.faceunity.entity.MenuGroupBean; @@ -52,8 +51,9 @@ public class FaceUnityView extends LinearLayout implements StickerDownloadHelper private TabLayout tabLayout; private TextView title; private LinearLayout menu2, menuDiy, reset, menu2Reset; - private ImageView menu2Back, back, close; + private ImageView menu2Back, back, close, contrast; private DiscreteSeekBar seekBar; + private IFaceUnityInter iFaceUnityInter; public FaceUnityView(Context context) { super(context); @@ -96,6 +96,7 @@ public class FaceUnityView extends LinearLayout implements StickerDownloadHelper menu2Reset = findViewById(R.id.menu2_reset); menuDiy = findViewById(R.id.menu_diy); seekBar = findViewById(R.id.item_seekBar); + contrast = findViewById(R.id.item_contrast); initMenuGroup(); setContainerRecycler(new ArrayList<>()); initViewClick(); @@ -107,9 +108,9 @@ public class FaceUnityView extends LinearLayout implements StickerDownloadHelper private void initViewClick() { menu2Back.setOnClickListener(v -> { Object tag = menu2Back.getTag(); - if(tag==null) { + if (tag == null) { goBackMainMenu(); - }else if(tag.equals("makeup")){ + } else if (tag.equals("makeup")) { title.setText(R.string.home_function_name_makeup); title.setVisibility(VISIBLE); menuDiy.setVisibility(VISIBLE); @@ -129,6 +130,25 @@ public class FaceUnityView extends LinearLayout implements StickerDownloadHelper menu2Reset.setOnClickListener(view -> { containerAdapter.reset(); }); + + contrast.setOnTouchListener((v, event) -> { + if (iFaceUnityInter == null) { + return false; + } + if (event.getAction() == KeyEvent.ACTION_DOWN) { + iFaceUnityInter.onPause(); + } else if (event.getAction() == KeyEvent.ACTION_UP) { + iFaceUnityInter.onStart(); + } + return true; + }); + } + + /** + * 对比接口 + */ + public void setIFaceUnityInter(IFaceUnityInter iFaceUnityInter) { + this.iFaceUnityInter = iFaceUnityInter; } /** @@ -363,6 +383,7 @@ public class FaceUnityView extends LinearLayout implements StickerDownloadHelper /** * 设置美颜选项配置行数,图标为5个,拖动条为2个 + * * @param count */ private void changeRecyclerItemCount(int count) { @@ -371,6 +392,7 @@ public class FaceUnityView extends LinearLayout implements StickerDownloadHelper /** * 设置美颜Recycler内容 + * * @param list */ private void setContainerRecycler(ArrayList list) { @@ -404,4 +426,10 @@ public class FaceUnityView extends LinearLayout implements StickerDownloadHelper public void onDownloadError(FineStickerEntity.DocsBean entity, String msg) { } + + public interface IFaceUnityInter { + void onPause(); + + void onStart(); + } } diff --git a/FaceUnity/src/main/res/layout/layout_faceunity.xml b/FaceUnity/src/main/res/layout/layout_faceunity.xml index f24b8d17c..214756890 100644 --- a/FaceUnity/src/main/res/layout/layout_faceunity.xml +++ b/FaceUnity/src/main/res/layout/layout_faceunity.xml @@ -6,28 +6,48 @@ android:layout_height="wrap_content" android:orientation="vertical"> - + + + + + + +