diff --git a/common/src/main/java/com/yunbao/common/fragment/ProcessFragment.java b/common/src/main/java/com/yunbao/common/fragment/ProcessFragment.java index 328fbe9fb..2519b3016 100644 --- a/common/src/main/java/com/yunbao/common/fragment/ProcessFragment.java +++ b/common/src/main/java/com/yunbao/common/fragment/ProcessFragment.java @@ -41,7 +41,7 @@ public class ProcessFragment extends Fragment { * @param permissions * @return true 有权限 false无权限 */ - private boolean checkPermissions(String[] permissions) { + public boolean checkPermissions(String[] permissions) { for (String permission : permissions) { if (ContextCompat.checkSelfPermission(mContext, permission) != PackageManager.PERMISSION_GRANTED) { return false; diff --git a/common/src/main/java/com/yunbao/common/utils/ProcessResultUtil.java b/common/src/main/java/com/yunbao/common/utils/ProcessResultUtil.java index 06e4b384b..b3f59ada9 100644 --- a/common/src/main/java/com/yunbao/common/utils/ProcessResultUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/ProcessResultUtil.java @@ -1,6 +1,7 @@ package com.yunbao.common.utils; import android.content.Intent; + import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; @@ -28,14 +29,17 @@ public class ProcessResultUtil { mFragment.requestPermissions(permissions, runnable); } + public boolean checkPermissions(String[] permissions) { + return mFragment.checkPermissions(permissions); + } - public void startActivityForResult(Intent intent, ActivityResultCallback callback){ - mFragment.startActivityForResult(intent,callback); + public void startActivityForResult(Intent intent, ActivityResultCallback callback) { + mFragment.startActivityForResult(intent, callback); } - public void release(){ - if(mFragment!=null){ + public void release() { + if (mFragment != null) { mFragment.release(); } } diff --git a/live/src/main/AndroidManifest.xml b/live/src/main/AndroidManifest.xml index 58c8d2033..c6fc69564 100644 --- a/live/src/main/AndroidManifest.xml +++ b/live/src/main/AndroidManifest.xml @@ -3,6 +3,7 @@ xmlns:tools="http://schemas.android.com/tools" package="com.yunbao.live"> + 20) { + if (volume > 10) { gifView.setVisibility(View.VISIBLE); voiceFluctuations.setVisibility(View.GONE); } @@ -138,14 +143,12 @@ public class VoiceDialog extends AbsDialogFragment { @Override public void onBeginOfSpeech() { Log.e(TAG, "onBeginOfSpeech 开始讲话"); - voiceFluctuations.setVisibility(View.GONE); - gifView.setVisibility(View.VISIBLE); + } @Override public void onEndOfSpeech() { Log.e(TAG, "onBeginOfSpeech 结束讲话"); - ImgLoader.displayGif(mContext, R.mipmap.img_p, voiceFluctuations); if (TextUtils.isEmpty(voiceChat.getText())) { dismiss(); TextHintDialog textHintDialog = new TextHintDialog(); diff --git a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java index affaa6ea0..a50d3cf22 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java @@ -1,5 +1,6 @@ package com.yunbao.live.views; +import android.Manifest; import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; @@ -8,6 +9,7 @@ import android.graphics.Canvas; import android.graphics.Color; import android.os.Bundle; import android.os.Handler; +import android.os.Vibrator; import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.Log; @@ -22,6 +24,8 @@ import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.ViewFlipper; +import androidx.fragment.app.FragmentActivity; + import com.opensource.svgaplayer.SVGADrawable; import com.opensource.svgaplayer.SVGAImageView; import com.opensource.svgaplayer.SVGAParser; @@ -36,6 +40,7 @@ import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.ProcessResultUtil; import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.SpUtil; import com.yunbao.common.utils.ToastUtil; @@ -129,6 +134,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { SVGADrawable drawable = new SVGADrawable(videoItem); svga_new_user_gif.setImageDrawable(drawable); SVGAViewUtils.playEndClear(svga_new_user_gif); + } @Override @@ -269,15 +275,27 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { voiceButton.setOnTouchListener((v, event) -> { if (event.getAction() == MotionEvent.ACTION_DOWN) { downY = event.getY(); - //按下 - handler.postDelayed(mLongPressed, 500); + if (mProcessResultUtil.checkPermissions(new String[]{Manifest.permission.RECORD_AUDIO})) { + //按下 + handler.postDelayed(mLongPressed, 500); + } else { + mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() { + @Override + public void run() { + + } + }); + } + } else if (event.getAction() == MotionEvent.ACTION_MOVE) { float moveY = event.getY(); if (downY - moveY > 120) { - voiceDialog.withdraw(); + if (voiceDialog != null) + voiceDialog.withdraw(); } if ((downY - moveY < 100) && (downY - moveY > 30)) { - voiceDialog.notWithdraw(); + if (voiceDialog != null) + voiceDialog.notWithdraw(); } } else if (event.getAction() == MotionEvent.ACTION_UP) { //松开 @@ -297,15 +315,18 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { } return true; }); - + mProcessResultUtil = new ProcessResultUtil((FragmentActivity) mContext); } private float downY = 0; - + private ProcessResultUtil mProcessResultUtil; private VoiceDialog voiceDialog = null; private Runnable mLongPressed = new Runnable() { @Override public void run() { + + Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); + vibrator.vibrate(30);//震动时间(ms) if (voiceDialog == null) { voiceDialog = new VoiceDialog(); } diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index 69c9b7eb5..96ddb899e 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -14,6 +14,7 @@ import android.os.Handler; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; @@ -61,7 +62,6 @@ import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.formatBigNum; import com.yunbao.common.views.weight.LiveFloatView; import com.yunbao.live.R; -import com.yunbao.live.activity.FALiveRoomInOneActivity; import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveAudienceActivity; import com.yunbao.live.bean.LiveBuyGuardMsgBean; @@ -408,7 +408,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe @Override public void onStop() { boolean isForeground = LifecycleUtils.INSTANCE.isForeground(); - if (mLiveBean != null && !isQuitF && !isForeground) { + boolean floatPermission = PermissionUtils.checkPermission(mContext); + if (mLiveBean != null && !isQuitF && !isForeground && floatPermission) { LiveFloatView.getInstance() .cacheLiveData(mLiveBean, mLiveType, mLiveSDK, mLiveTypeVal) .builderSystemFloat(mContext, mLiveBean.getPull()); @@ -1626,4 +1627,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRoomViewHolder.chatScrollToBottom(); } } + + public void setSecondPageEnableScroll(boolean enableScroll) { + mViewPager.setCanScroll(enableScroll); + } } diff --git a/live/src/main/res/drawable/bg_voice_chat.xml b/live/src/main/res/drawable/bg_voice_chat.xml index ef4188aec..edb9bf37b 100644 --- a/live/src/main/res/drawable/bg_voice_chat.xml +++ b/live/src/main/res/drawable/bg_voice_chat.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/live/src/main/res/layout/activity_live_detail.xml b/live/src/main/res/layout/activity_live_detail.xml index 9cb9f4e07..997e1794d 100644 --- a/live/src/main/res/layout/activity_live_detail.xml +++ b/live/src/main/res/layout/activity_live_detail.xml @@ -11,8 +11,8 @@ - + @@ -25,31 +29,31 @@ android:id="@+id/gif_view" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_centerHorizontal="true" - android:layout_marginTop="30dp" + android:layout_marginTop="23dp" + android:layout_marginStart="20dp" + android:layout_marginEnd="20dp" android:background="@mipmap/voice_fluctuations" android:visibility="gone" /> - - - \ No newline at end of file + + + + + \ No newline at end of file diff --git a/main/src/main/res/layout/view_homemain.xml b/main/src/main/res/layout/view_homemain.xml index 544448e95..1d47d4685 100644 --- a/main/src/main/res/layout/view_homemain.xml +++ b/main/src/main/res/layout/view_homemain.xml @@ -93,7 +93,7 @@ @@ -138,8 +138,7 @@ android:id="@+id/btn_start" android:layout_width="60dp" android:layout_height="60dp" - android:layout_centerHorizontal="true" - android:layout_centerVertical="true" + android:layout_centerInParent="true" android:onClick="mainClick" android:src="@mipmap/icon_main_start" />