mirror of
https://github.com/SimpleMobileTools/Simple-Voice-Recorder.git
synced 2025-06-05 21:59:31 +02:00
moving the main view in a separate fragment
This commit is contained in:
@ -15,7 +15,7 @@ import com.simplemobiletools.voicerecorder.helpers.GET_RECORDER_INFO
|
|||||||
import com.simplemobiletools.voicerecorder.helpers.STOP_AMPLITUDE_UPDATE
|
import com.simplemobiletools.voicerecorder.helpers.STOP_AMPLITUDE_UPDATE
|
||||||
import com.simplemobiletools.voicerecorder.models.Events
|
import com.simplemobiletools.voicerecorder.models.Events
|
||||||
import com.simplemobiletools.voicerecorder.services.RecorderService
|
import com.simplemobiletools.voicerecorder.services.RecorderService
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
import kotlinx.android.synthetic.main.fragment_recorder.*
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
import org.greenrobot.eventbus.Subscribe
|
import org.greenrobot.eventbus.Subscribe
|
||||||
import org.greenrobot.eventbus.ThreadMode
|
import org.greenrobot.eventbus.ThreadMode
|
||||||
@ -50,7 +50,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
background.applyColorFilter(adjustedPrimaryColor)
|
background.applyColorFilter(adjustedPrimaryColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
visualizer.chunkColor = adjustedPrimaryColor
|
recorder_visualizer.chunkColor = adjustedPrimaryColor
|
||||||
recording_duration.setTextColor(config.textColor)
|
recording_duration.setTextColor(config.textColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun initVoiceRecorder() {
|
private fun initVoiceRecorder() {
|
||||||
visualizer.recreate()
|
recorder_visualizer.recreate()
|
||||||
bus = EventBus.getDefault()
|
bus = EventBus.getDefault()
|
||||||
bus!!.register(this)
|
bus!!.register(this)
|
||||||
|
|
||||||
@ -145,14 +145,14 @@ class MainActivity : SimpleActivity() {
|
|||||||
isRecording = event.isRecording
|
isRecording = event.isRecording
|
||||||
toggle_recording_button.setImageDrawable(getToggleButtonIcon())
|
toggle_recording_button.setImageDrawable(getToggleButtonIcon())
|
||||||
if (isRecording) {
|
if (isRecording) {
|
||||||
visualizer.recreate()
|
recorder_visualizer.recreate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
fun gotAmplitudeEvent(event: Events.RecordingAmplitude) {
|
fun gotAmplitudeEvent(event: Events.RecordingAmplitude) {
|
||||||
val amplitude = event.amplitude
|
val amplitude = event.amplitude
|
||||||
visualizer.update(amplitude)
|
recorder_visualizer.update(amplitude)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getToggleButtonIcon(): Drawable {
|
private fun getToggleButtonIcon(): Drawable {
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.simplemobiletools.voicerecorder.fragments
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.widget.RelativeLayout
|
||||||
|
|
||||||
|
class RecorderFragment(context: Context, attributeSet: AttributeSet) : RelativeLayout(context, attributeSet)
|
@ -1,46 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
android:id="@+id/main_holder"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:id="@+id/recorder_holder"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<com.visualizer.amplitude.AudioRecordView
|
<include layout="@layout/fragment_recorder" />
|
||||||
android:id="@+id/visualizer"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_above="@+id/recording_duration"
|
|
||||||
android:layout_margin="@dimen/big_margin"
|
|
||||||
android:background="@drawable/frame_background"
|
|
||||||
app:chunkAlignTo="center"
|
|
||||||
app:chunkMaxHeight="200dp"
|
|
||||||
app:chunkMinHeight="2dp"
|
|
||||||
app:chunkRoundedCorners="true"
|
|
||||||
app:chunkSoftTransition="true"
|
|
||||||
app:chunkSpace="1dp"
|
|
||||||
app:chunkWidth="3dp" />
|
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
|
||||||
android:id="@+id/recording_duration"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_above="@+id/toggle_recording_button"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_marginBottom="@dimen/bigger_margin"
|
|
||||||
android:textSize="@dimen/extra_big_text_size"
|
|
||||||
tools:text="00:00" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/toggle_recording_button"
|
|
||||||
android:layout_width="@dimen/toggle_recording_button_size"
|
|
||||||
android:layout_height="@dimen/toggle_recording_button_size"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_marginBottom="@dimen/big_margin"
|
|
||||||
android:background="@drawable/circle_background"
|
|
||||||
android:elevation="@dimen/medium_margin"
|
|
||||||
android:padding="@dimen/normal_margin"
|
|
||||||
android:src="@drawable/ic_microphone_vector" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
46
app/src/main/res/layout/fragment_recorder.xml
Normal file
46
app/src/main/res/layout/fragment_recorder.xml
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<com.simplemobiletools.voicerecorder.fragments.RecorderFragment xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/recorder_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<com.visualizer.amplitude.AudioRecordView
|
||||||
|
android:id="@+id/recorder_visualizer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_above="@+id/recording_duration"
|
||||||
|
android:layout_margin="@dimen/big_margin"
|
||||||
|
android:background="@drawable/frame_background"
|
||||||
|
app:chunkAlignTo="center"
|
||||||
|
app:chunkMaxHeight="200dp"
|
||||||
|
app:chunkMinHeight="2dp"
|
||||||
|
app:chunkRoundedCorners="true"
|
||||||
|
app:chunkSoftTransition="true"
|
||||||
|
app:chunkSpace="1dp"
|
||||||
|
app:chunkWidth="3dp" />
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
|
android:id="@+id/recording_duration"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_above="@+id/toggle_recording_button"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginBottom="@dimen/bigger_margin"
|
||||||
|
android:textSize="@dimen/extra_big_text_size"
|
||||||
|
tools:text="00:00" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/toggle_recording_button"
|
||||||
|
android:layout_width="@dimen/toggle_recording_button_size"
|
||||||
|
android:layout_height="@dimen/toggle_recording_button_size"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginBottom="@dimen/big_margin"
|
||||||
|
android:background="@drawable/circle_background"
|
||||||
|
android:elevation="@dimen/medium_margin"
|
||||||
|
android:padding="@dimen/normal_margin"
|
||||||
|
android:src="@drawable/ic_microphone_vector" />
|
||||||
|
|
||||||
|
</com.simplemobiletools.voicerecorder.fragments.RecorderFragment>
|
Reference in New Issue
Block a user