From 04f0953cfa22396c06228fcd06542a34214f5bd0 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Fri, 23 Sep 2022 10:43:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BE=8E=E9=A2=9C=E8=A1=A5=E5=85=85=E5=AF=B9?= =?UTF-8?q?=E6=AF=94=E9=94=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/faceunity/FaceManager.java | 30 ++++++-- .../yunbao/faceunity/ui/FaceUnityView.java | 40 +++++++++-- .../src/main/res/layout/layout_faceunity.xml | 64 ++++++++++++------ .../main/res/mipmap-xxhdpi/icon_contrast.png | Bin 0 -> 1090 bytes .../java/com/shayu/phonelive/AppContext.java | 2 +- .../com/yunbao/common/utils/VersionUtil.java | 4 +- .../dialog/LiveFaceUnityDialogFragment.java | 3 +- 7 files changed, 104 insertions(+), 39 deletions(-) create mode 100644 FaceUnity/src/main/res/mipmap-xxhdpi/icon_contrast.png 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"> - + + + + + + + H#M1Uu4P!q91(H4s&siggPZ5R%u+++@c4~$ z)hgFzaTw2Le<0Mb*tBM+Ymv>${|XKKDt{SMvu`@gzNy4u9xE%kXEpOLo|BtrI_$pR z&S=B1!LqmVsJxKp{KVosOULzWA6OcWr{}Lbp!PVtwQtj+-A(g~4&`51zVhZ=7nC|d&6{dAcMZw_ciK~`>vhdaJhE2&s#0ma;CXwFEU)H z{Tja@n!9VJ!}5sR8gAF;K3BVt$^H4eomF|yv_;J#d)3}fn6@;mP zS$x~@R-_DLfl;g#{{y3wMJKY3#4hl@aYH-ItbDYp(uo+P;Z(7jG4d!%y97#vM<$I4QqlS}Q(n=Anz)6%&+zsUrJm&e0bN z3putpwClH>DrHffI^}f-!`)f-r%JzA%FmTsCOQ?aX_3biKUvn_! zrkyHvY3ZxCy}s~Lmx*$5-ut#i5hu>c1MXR{zG1Ke~>emHgM=n;XwqRrTjf<;MDrDew0lmOu7sd!u;Ctedw= z>dviB+r4#V)5R+X&)+V6^`2esc=23~vtm}4noKVUJ?&Yr_rZULlehQoIadC9wrEL{ z?S@6ac@`et-y~iTr}Fauf(dI=+2=4}1SS`xV ys~3)3TO8O0IgFHDxl05Z6^w((;<7jXW7g1+?Jzy6yAD_=FnGH9xvX!G literal 0 HcmV?d00001 diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java index f1a7fa8bf..4c2699943 100644 --- a/app/src/main/java/com/shayu/phonelive/AppContext.java +++ b/app/src/main/java/com/shayu/phonelive/AppContext.java @@ -115,7 +115,7 @@ public class AppContext extends CommonAppContext { public void onCreate() { super.onCreate(); //注册全局异常捕获 - registerError(); + // registerError(); sInstance = this; L.setDeBug(BuildConfig.DEBUG); AppEventsLogger.activateApp(this); diff --git a/common/src/main/java/com/yunbao/common/utils/VersionUtil.java b/common/src/main/java/com/yunbao/common/utils/VersionUtil.java index 96bcdce19..6eace2b38 100644 --- a/common/src/main/java/com/yunbao/common/utils/VersionUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/VersionUtil.java @@ -81,7 +81,7 @@ public class VersionUtil { //谷歌更新 } else if (CommonAppConfig.IS_GOOGLE_PLAY == true) { - if (configBean.getGoogle_isup().equals("0")) { + if ("0".equals(configBean.getGoogle_isup())) { DialogUitl.Builder builder = new DialogUitl.Builder(context); builder.setTitle(WordUtil.getString(R.string.version_update)) .setContent(configBean.getUpdateDes()) @@ -159,7 +159,7 @@ public class VersionUtil { ToastUtil.show(R.string.version_download_url_error); } } else if (CommonAppConfig.IS_GOOGLE_PLAY) { - if (configBean.getGoogle_isup() != null && configBean.getGoogle_isup().equals("0")) { + if ( "0".equals(configBean.getGoogle_isup())) { Log.e("tagg", "111111"); DialogUitl.Builder builder = new DialogUitl.Builder(context); builder.setTitle(WordUtil.getString(R.string.version_update)) diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveFaceUnityDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveFaceUnityDialogFragment.java index 317f76535..922c523b3 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveFaceUnityDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveFaceUnityDialogFragment.java @@ -51,7 +51,7 @@ public class LiveFaceUnityDialogFragment extends AbsDialogFragment { WindowManager.LayoutParams params = window.getAttributes(); params.width = ActionBar.LayoutParams.MATCH_PARENT; - params.height = ActionBar.LayoutParams.WRAP_CONTENT; + params.height = ActionBar.LayoutParams.WRAP_CONTENT; params.gravity = Gravity.BOTTOM; window.setAttributes(params); @@ -60,6 +60,7 @@ public class LiveFaceUnityDialogFragment extends AbsDialogFragment { @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); + manager.setFaceUnityView(faceView); } public void setManager(FaceManager manager) {