diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/FaceManager.java b/FaceUnity/src/main/java/com/yunbao/faceunity/FaceManager.java index b73b3e256..9462122c8 100644 --- a/FaceUnity/src/main/java/com/yunbao/faceunity/FaceManager.java +++ b/FaceUnity/src/main/java/com/yunbao/faceunity/FaceManager.java @@ -19,11 +19,15 @@ import com.faceunity.core.enumeration.FUInputTextureEnum; import com.faceunity.core.enumeration.FUTransformMatrixEnum; import com.faceunity.core.faceunity.FUAIKit; import com.faceunity.core.utils.CameraUtils; +import com.yunbao.faceunity.data.FaceBeautyDataFactory; import com.yunbao.faceunity.data.FaceUnityDataFactory; +import com.yunbao.faceunity.entity.FaceBeautyBean; +import com.yunbao.faceunity.entity.FaceBeautyFilterBean; import com.yunbao.faceunity.listener.FURendererListener; import com.yunbao.faceunity.ui.FaceUnityView; import com.yunbao.faceunity.utils.CSVUtils; import com.yunbao.faceunity.utils.FURenderer; +import com.yunbao.faceunity.utils.FaceSPUtils; import com.yunbao.faceunity.utils.FaceUnityData; import com.yunbao.faceunity.utils.net.OkHttpUtils; @@ -31,6 +35,8 @@ import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; +import java.util.Map; +import java.util.Objects; import cn.rongcloud.rtc.api.RCRTCEngine; import cn.rongcloud.rtc.api.callback.IRCRTCVideoOutputFrameListener; @@ -83,6 +89,7 @@ public class FaceManager implements SensorEventListener { /** * 注册长按对比键事件 + * * @param faceUnityView */ public void setFaceUnityView(FaceUnityView faceUnityView) { @@ -98,6 +105,44 @@ public class FaceManager implements SensorEventListener { } }); } + public void loadConfig(){ + initFaceBeauty(); + } + public void initFaceBeauty() { + FaceBeautyDataFactory faceBeautyDataFactory; + faceBeautyDataFactory = new FaceBeautyDataFactory(); + Map configMap = FaceSPUtils.getInstance().getAll(); + for (String key : configMap.keySet()) { + if ("FilterViewHolder_".equals(key)) { + for (FaceBeautyFilterBean filter : faceBeautyDataFactory.getBeautyFilters()) { + if (filter.getKey().equals(configMap.get(key))&&!"origin".equals(configMap.get(key))) { + faceBeautyDataFactory.onFilterSelected(filter.getKey(), Double.parseDouble((String) Objects.requireNonNull(configMap.get("FilterViewHolder_" + configMap.get(key) + "_val")))/100, filter.getDesRes()); + Log.i(TAG, "test: 设置滤镜 ="+filter.getKey()+" val = "+configMap.get("FilterViewHolder_" + configMap.get(key) + "_val")); + break; + } + } + } else if (key.startsWith("BeautySkinViewHolder_")) { + String name = key.replace("BeautySkinViewHolder_", ""); + for (FaceBeautyBean bean : faceBeautyDataFactory.getShapeBeauty()) { + if (bean.getKey().equals(name)) { + faceBeautyDataFactory.updateParamIntensity(bean.getKey(),Double.parseDouble((String) Objects.requireNonNull(configMap.get(key)))); + Log.i(TAG, "test: 设置美颜 = "+bean.getKey()+" val = "+configMap.get(key)); + break; + } + } + }else if(key.startsWith("BeautyShapeViewHolder")){ + String name = key.replace("BeautyShapeViewHolder_", ""); + for (FaceBeautyBean bean : faceBeautyDataFactory.getShapeBeauty()) { + if (bean.getKey().equals(name)) { + faceBeautyDataFactory.updateParamIntensity(bean.getKey(),Double.parseDouble((String) Objects.requireNonNull(configMap.get(key)))); + Log.i(TAG, "test: 设置美肤 = "+bean.getKey()+" val = "+configMap.get(key)); + break; + } + } + } + + } + } /** * 监听人脸识别个数 diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/data/FaceBeautyDataFactory.java b/FaceUnity/src/main/java/com/yunbao/faceunity/data/FaceBeautyDataFactory.java index 823aedd07..a56b53cce 100644 --- a/FaceUnity/src/main/java/com/yunbao/faceunity/data/FaceBeautyDataFactory.java +++ b/FaceUnity/src/main/java/com/yunbao/faceunity/data/FaceBeautyDataFactory.java @@ -85,6 +85,19 @@ public class FaceBeautyDataFactory extends AbstractFaceBeautyDataFactory { public FaceBeautyDataFactory(FaceBeautyListener listener) { mFaceBeautyListener = listener; } + public FaceBeautyDataFactory(){ + mFaceBeautyListener=new FaceBeautyListener() { + @Override + public void onFilterSelected(int res) { + + } + + @Override + public void onFaceBeautyEnable(boolean enable) { + + } + }; + } /** 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 b8ae46f8d..2264afcf1 100644 --- a/FaceUnity/src/main/java/com/yunbao/faceunity/ui/FaceUnityView.java +++ b/FaceUnity/src/main/java/com/yunbao/faceunity/ui/FaceUnityView.java @@ -2,7 +2,6 @@ package com.yunbao.faceunity.ui; import android.content.Context; import android.util.AttributeSet; -import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; import android.widget.ImageView; @@ -311,7 +310,7 @@ public class FaceUnityView extends LinearLayout implements StickerDownloadHelper tabLayout.removeAllTabs(); for (TabLayout.Tab tab : tabs) { tabLayout.addTab(tab); - if(tab.getTag() instanceof Integer) { + if (tab.getTag() instanceof Integer) { if (FaceSPUtils.getInstance().getString(StyleViewHolder.class.getSimpleName() + "_") != null && (int) tab.getTag() == FaceParam.FACE_BEAUTY_STYLE) { ToastUtil.show("请先重置风格推荐"); tab.select(); @@ -446,7 +445,7 @@ public class FaceUnityView extends LinearLayout implements StickerDownloadHelper containerRecycler.setAdapter(containerAdapter); } // titleLayout.setVisibility(title.getVisibility()==GONE?INVISIBLE:VISIBLE); - // Log.i(TAG, "setContainerRecycler: " + list.size()); + // Log.i(TAG, "setContainerRecycler: " + list.size()); containerAdapter.setList(list); containerAdapter.notifyDataSetChanged(); } diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/utils/FURenderer.java b/FaceUnity/src/main/java/com/yunbao/faceunity/utils/FURenderer.java index 63ed91659..2c5855435 100644 --- a/FaceUnity/src/main/java/com/yunbao/faceunity/utils/FURenderer.java +++ b/FaceUnity/src/main/java/com/yunbao/faceunity/utils/FURenderer.java @@ -55,7 +55,7 @@ public class FURenderer extends IFURenderer { private FURenderKit mFURenderKit; /* AI道具*/ - private String BUNDLE_AI_FACE = "model" + File.separator + "ai_face_processor.bundle"; + private String BUNDLE_AI_FACE = "model" + File.separator + "ai_face_processor_lite.bundle"; private String BUNDLE_AI_HUMAN = "model" + File.separator + "ai_human_processor.bundle"; /* GL 线程 ID */ diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/utils/FaceSPUtils.java b/FaceUnity/src/main/java/com/yunbao/faceunity/utils/FaceSPUtils.java index f4ba6d5b0..4eb1ab1d4 100644 --- a/FaceUnity/src/main/java/com/yunbao/faceunity/utils/FaceSPUtils.java +++ b/FaceUnity/src/main/java/com/yunbao/faceunity/utils/FaceSPUtils.java @@ -5,6 +5,8 @@ import android.content.SharedPreferences; import com.yunbao.common.CommonAppContext; +import java.util.Map; + public class FaceSPUtils { private static FaceSPUtils utils; private SharedPreferences mSharedPreferences; @@ -38,4 +40,7 @@ public class FaceSPUtils { } } } + public Map getAll(){ + return mSharedPreferences.getAll(); + } } 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 39f59c1e7..ebd661c0b 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveFaceUnityDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveFaceUnityDialogFragment.java @@ -65,6 +65,7 @@ public class LiveFaceUnityDialogFragment extends AbsDialogFragment { public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); manager.setFaceUnityView(faceView); + manager.loadConfig(); } @Override diff --git a/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java index dbfba8e4e..22d94a17b 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java @@ -209,6 +209,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl //新美颜 manager.initFURender(mContext); manager.drawRongFrame(mContext); + setFaceUnity(true); } @@ -229,7 +230,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl chooseLiveClass(); } else if (i == R.id.btn_beauty) { //beauty();//momo美颜 - setFaceUnity(); //新娱美颜 + setFaceUnity(false); //新娱美颜 } else if (i == R.id.btn_wishlist) { //点击心愿单 openWishListWindow(); @@ -249,13 +250,16 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl /** * 新娱美颜 */ - public void setFaceUnity() { + public void setFaceUnity(boolean init) { LiveFaceUnityDialogFragment fragment = new LiveFaceUnityDialogFragment(mContext); fragment.setManager(manager); fragment.setDismissShowUi(mRootView); if (mContext instanceof LiveRyAnchorActivity) { fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "FaceUnity"); mRootView.setVisibility(View.INVISIBLE); + if(init){ + fragment.dismiss(); + } } }