|
|
@ -10,6 +10,7 @@ import android.view.View
|
|
|
|
import android.view.ViewGroup
|
|
|
|
import android.view.ViewGroup
|
|
|
|
import android.widget.EditText
|
|
|
|
import android.widget.EditText
|
|
|
|
import android.widget.ImageButton
|
|
|
|
import android.widget.ImageButton
|
|
|
|
|
|
|
|
import android.widget.ImageView
|
|
|
|
import android.widget.LinearLayout
|
|
|
|
import android.widget.LinearLayout
|
|
|
|
import android.widget.RelativeLayout
|
|
|
|
import android.widget.RelativeLayout
|
|
|
|
import android.widget.SeekBar
|
|
|
|
import android.widget.SeekBar
|
|
|
@ -76,10 +77,27 @@ abstract class BaseActivity : AppCompatActivity() {
|
|
|
|
RecordHelper.stopRecording()
|
|
|
|
RecordHelper.stopRecording()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private val setVoiceAreaRunnable = Runnable {
|
|
|
|
|
|
|
|
volumeUtil.mediaVolume = baseBinding.sbSound.progress
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun initSound() {
|
|
|
|
private fun initSound() {
|
|
|
|
baseBinding.sbSound.max = volumeUtil.mediaMaxVolume
|
|
|
|
baseBinding.sbSound.max = volumeUtil.mediaMaxVolume
|
|
|
|
val mediaVolume = volumeUtil.mediaVolume
|
|
|
|
val mediaVolume = volumeUtil.mediaVolume
|
|
|
|
baseBinding.sbSound.progress = mediaVolume
|
|
|
|
baseBinding.sbSound.progress = mediaVolume
|
|
|
|
|
|
|
|
baseBinding.sbSound.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
|
|
|
|
|
|
|
|
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
|
|
|
|
|
|
|
baseBinding.root.removeCallbacks(setVoiceAreaRunnable)
|
|
|
|
|
|
|
|
baseBinding.root.postDelayed(setVoiceAreaRunnable, 200)
|
|
|
|
|
|
|
|
autoHideVoiceArea(1500)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onStartTrackingTouch(seekBar: SeekBar) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun setChildContent() {
|
|
|
|
private fun setChildContent() {
|
|
|
@ -181,6 +199,7 @@ abstract class BaseActivity : AppCompatActivity() {
|
|
|
|
"SeekBar" -> SeekBar(context, attrs)
|
|
|
|
"SeekBar" -> SeekBar(context, attrs)
|
|
|
|
"EditText" -> EditText(context, attrs)
|
|
|
|
"EditText" -> EditText(context, attrs)
|
|
|
|
"ImageButton" -> ImageButton(context, attrs)
|
|
|
|
"ImageButton" -> ImageButton(context, attrs)
|
|
|
|
|
|
|
|
"ImageView" -> ImageView(context, attrs)
|
|
|
|
else -> {
|
|
|
|
else -> {
|
|
|
|
null
|
|
|
|
null
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -228,11 +247,7 @@ abstract class BaseActivity : AppCompatActivity() {
|
|
|
|
val keyCode = event.keyCode
|
|
|
|
val keyCode = event.keyCode
|
|
|
|
if (KeyEvent.KEYCODE_DPAD_LEFT == keyCode || KeyEvent.KEYCODE_DPAD_RIGHT == keyCode) {
|
|
|
|
if (KeyEvent.KEYCODE_DPAD_LEFT == keyCode || KeyEvent.KEYCODE_DPAD_RIGHT == keyCode) {
|
|
|
|
if (isLeftRightLongPress && baseBinding.areaSound.visibility == View.VISIBLE) {
|
|
|
|
if (isLeftRightLongPress && baseBinding.areaSound.visibility == View.VISIBLE) {
|
|
|
|
baseBinding.areaSound.postDelayed(300) {
|
|
|
|
baseBinding.areaSound.postDelayed(hideVoiceAreaRunnable, 1500)
|
|
|
|
lastFocusView?.requestFocus()
|
|
|
|
|
|
|
|
baseBinding.areaSound.visibility = View.GONE
|
|
|
|
|
|
|
|
volumeUtil.mediaVolume = baseBinding.sbSound.progress
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_ENTER) {
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_ENTER) {
|
|
|
@ -254,25 +269,47 @@ abstract class BaseActivity : AppCompatActivity() {
|
|
|
|
val repeatCount = event.repeatCount
|
|
|
|
val repeatCount = event.repeatCount
|
|
|
|
val keyCode = event.keyCode
|
|
|
|
val keyCode = event.keyCode
|
|
|
|
if (KeyEvent.KEYCODE_DPAD_LEFT == keyCode || KeyEvent.KEYCODE_DPAD_RIGHT == keyCode) {
|
|
|
|
if (KeyEvent.KEYCODE_DPAD_LEFT == keyCode || KeyEvent.KEYCODE_DPAD_RIGHT == keyCode) {
|
|
|
|
isLeftRightLongPress = repeatCount > 10
|
|
|
|
isLeftRightLongPress = repeatCount > 8
|
|
|
|
if (isLeftRightLongPress && currentFocus !is SeekBar) {
|
|
|
|
if (isLeftRightLongPress && currentFocus !is SeekBar) {
|
|
|
|
val visibility = baseBinding.areaSound.visibility
|
|
|
|
showVoiceArea()
|
|
|
|
if (View.GONE == visibility) {
|
|
|
|
|
|
|
|
lastFocusView = currentFocus
|
|
|
|
|
|
|
|
baseBinding.areaSound.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
baseBinding.sbSound.requestFocus()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var mediaVolume = baseBinding.sbSound.progress
|
|
|
|
var mediaVolume = baseBinding.sbSound.progress
|
|
|
|
if (KeyEvent.KEYCODE_DPAD_LEFT == keyCode) mediaVolume-- else mediaVolume++
|
|
|
|
if (KeyEvent.KEYCODE_DPAD_LEFT == keyCode) mediaVolume-- else mediaVolume++
|
|
|
|
baseBinding.sbSound.progress = mediaVolume
|
|
|
|
baseBinding.sbSound.progress = mediaVolume
|
|
|
|
return true
|
|
|
|
return super.dispatchKeyEvent(event)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_ENTER) {
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_ENTER) {
|
|
|
|
isHomeLongPress = repeatCount > 10
|
|
|
|
isHomeLongPress = repeatCount > 8
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_F1) {
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_F1) {
|
|
|
|
LogUtils.w("BaseActivity F1 pressed")
|
|
|
|
LogUtils.w("BaseActivity F1 pressed")
|
|
|
|
SoundUtils.playSoundIo()
|
|
|
|
SoundUtils.playSoundIo()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return super.dispatchKeyEvent(event)
|
|
|
|
return super.dispatchKeyEvent(event)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun showVoiceArea() {
|
|
|
|
|
|
|
|
val visibility = baseBinding.areaSound.visibility
|
|
|
|
|
|
|
|
if (View.GONE == visibility) {
|
|
|
|
|
|
|
|
lastFocusView = currentFocus
|
|
|
|
|
|
|
|
baseBinding.areaSound.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
baseBinding.sbSound.requestFocus()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
autoHideVoiceArea()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun hideVoiceArea() {
|
|
|
|
|
|
|
|
lastFocusView?.requestFocus()
|
|
|
|
|
|
|
|
baseBinding.areaSound.visibility = View.GONE
|
|
|
|
|
|
|
|
volumeUtil.mediaVolume = baseBinding.sbSound.progress
|
|
|
|
|
|
|
|
baseBinding.root.removeCallbacks(hideVoiceAreaRunnable)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private val hideVoiceAreaRunnable = Runnable {
|
|
|
|
|
|
|
|
hideVoiceArea()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun autoHideVoiceArea(delayTime: Long = 2500) {
|
|
|
|
|
|
|
|
baseBinding.root.removeCallbacks(hideVoiceAreaRunnable)
|
|
|
|
|
|
|
|
baseBinding.root.postDelayed(hideVoiceAreaRunnable, delayTime)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|