diff --git a/app/src/main/java/com/gh/gamecenter/qa/editor/FullScreenVideoView.kt b/app/src/main/java/com/gh/gamecenter/qa/editor/FullScreenVideoView.kt index dbe8acdfda..fbe3a44668 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/editor/FullScreenVideoView.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/editor/FullScreenVideoView.kt @@ -1,24 +1,23 @@ package com.gh.gamecenter.qa.editor +import android.annotation.SuppressLint import android.app.Activity import android.app.Application import android.content.Context +import android.graphics.Typeface import android.os.Build import android.os.Bundle import android.provider.Settings import android.util.AttributeSet -import android.view.GestureDetector -import android.view.MotionEvent -import android.view.Surface -import android.view.View -import android.widget.ImageView -import android.widget.SeekBar +import android.view.* +import android.widget.* import androidx.core.content.ContextCompat import com.gh.gamecenter.R import com.gh.gamecenter.common.constant.Constants import com.gh.gamecenter.common.observer.MuteCallback import com.gh.gamecenter.common.observer.VolumeObserver import com.gh.gamecenter.common.utils.* +import com.gh.gamecenter.common.view.BugFixedPopupWindow import com.gh.gamecenter.core.utils.MD5Utils import com.gh.gamecenter.core.utils.SPUtils import com.gh.gamecenter.databinding.LayoutFullScreenDetailVideoPortraitBinding @@ -39,6 +38,7 @@ class FullScreenVideoView @JvmOverloads constructor(context: Context, attrs: Att private var mVolumeObserver: VolumeObserver private var mMuteDisposable: Disposable? = null private var mVideoIsMuted = SPUtils.getBoolean(Constants.SP_VIDEO_PLAY_MUTE, true) + private var mSpeedPopupWindow: PopupWindow? = null private lateinit var mBinding: LayoutFullScreenDetailVideoPortraitBinding val backBtn: View = findViewById(R.id.back) var uuid = UUID.randomUUID().toString() @@ -59,6 +59,14 @@ class FullScreenVideoView @JvmOverloads constructor(context: Context, attrs: Att showBackBtn() mBinding.layoutBottom.volume.setOnClickListener { toggleMute() } + mBinding.layoutBottom.speedTv.visibility = View.VISIBLE + mBinding.layoutBottom.speedTv.setOnClickListener { + cancelDismissControlViewTimer() + mSpeedPopupWindow = showPlaySpeedPopupWindow(mContext, speed, mBinding.layoutBottom.root) + mSpeedPopupWindow?.setOnDismissListener { + startDismissControlViewTimer() + } + } } mFullscreenButton.visibility = View.GONE @@ -239,6 +247,12 @@ class FullScreenVideoView @JvmOverloads constructor(context: Context, attrs: Att return CustomManager.getCustomManager(getKey()) } + override fun hideAllWidget() { + super.hideAllWidget() + + mSpeedPopupWindow?.dismiss() + } + fun getKey(): String { return uuid } @@ -446,4 +460,55 @@ class FullScreenVideoView @JvmOverloads constructor(context: Context, attrs: Att // onLossAudio 回调的时候再决定是否需要暂停 } + @SuppressLint("SetTextI18n") + private fun showPlaySpeedPopupWindow(context: Context, + currentSpeed: Float, + anchorView: View): PopupWindow { + val availableVideoSpeed = arrayListOf(2.0F, 1.5F, 1.0F, 0.75F, 0.5F) + + val inflater = LayoutInflater.from(context) + val layout = inflater.inflate(R.layout.popup_video_play_speed, null) + val popupWindow = BugFixedPopupWindow( + layout, + LinearLayout.LayoutParams.WRAP_CONTENT, + LinearLayout.LayoutParams.WRAP_CONTENT + ) + + val container = layout.findViewById(R.id.container) + for (videoSpeed in availableVideoSpeed) { + val item = inflater.inflate(R.layout.item_video_play_speed, container, false) + container.addView(item) + + val tv = item.findViewById(R.id.titleTv) + tv.text = "${videoSpeed}X" + if (videoSpeed == currentSpeed) { + tv.setTextColor(R.color.text_aw_primary.toColor(context)) + tv.setTypeface(Typeface.DEFAULT, Typeface.BOLD) + } else { + tv.setTextColor(R.color.text_aw_secondary.toColor(context)) + tv.setTypeface(Typeface.DEFAULT, Typeface.NORMAL) + } + + item.setOnClickListener { + speed = videoSpeed + if (videoSpeed != 1.0F) { + mBinding.layoutBottom.speedTv.text = tv.text + mBinding.layoutBottom.speedTv.setTypeface(Typeface.DEFAULT, Typeface.BOLD) + } else { + mBinding.layoutBottom.speedTv.text = resources.getString(R.string.video_speed) + mBinding.layoutBottom.speedTv.setTypeface(Typeface.DEFAULT, Typeface.NORMAL) + } + popupWindow.dismiss() + } + } + + popupWindow.run { + isTouchable = true + isFocusable = true + showAutoOrientation(anchorView = anchorView) + } + + return popupWindow + } + } \ No newline at end of file diff --git a/app/src/main/res/drawable/divider_video_play_speed.xml b/app/src/main/res/drawable/divider_video_play_speed.xml new file mode 100644 index 0000000000..c3c961ce56 --- /dev/null +++ b/app/src/main/res/drawable/divider_video_play_speed.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_video_play_speed.xml b/app/src/main/res/layout/item_video_play_speed.xml new file mode 100644 index 0000000000..1524ed32e9 --- /dev/null +++ b/app/src/main/res/layout/item_video_play_speed.xml @@ -0,0 +1,12 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/piece_full_screen_video_control.xml b/app/src/main/res/layout/piece_full_screen_video_control.xml index 512820639f..a468a3055c 100644 --- a/app/src/main/res/layout/piece_full_screen_video_control.xml +++ b/app/src/main/res/layout/piece_full_screen_video_control.xml @@ -38,6 +38,21 @@ app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8eff71c5ff..b3ec9c8da4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -164,6 +164,8 @@ 版本:V%1$s | %2$s + 倍速 + 了解更多 小助手邀你共建良好的社区氛围,请通过“光环助手礼仪测试”后发言。 diff --git a/module_common/src/main/res/drawable/background_shape_black_90_radius_4.xml b/module_common/src/main/res/drawable/background_shape_black_90_radius_4.xml new file mode 100644 index 0000000000..c96773a0ea --- /dev/null +++ b/module_common/src/main/res/drawable/background_shape_black_90_radius_4.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/module_common/src/main/res/values/colors.xml b/module_common/src/main/res/values/colors.xml index 197c9fb8e3..06fa46d8d6 100644 --- a/module_common/src/main/res/values/colors.xml +++ b/module_common/src/main/res/values/colors.xml @@ -207,6 +207,8 @@ #66000000 #80000000 #99000000 + #CC000000 + #E6000000 - #CC000000 + #0DFFFFFF #1AFFFFFF #33FFFFFF #66FFFFFF