mirror of
				https://github.com/SimpleMobileTools/Simple-Voice-Recorder.git
				synced 2025-06-05 21:59:31 +02:00 
			
		
		
		
	toggle the recording button icon as appropriate
This commit is contained in:
		| @@ -1,6 +1,7 @@ | |||||||
| package com.simplemobiletools.voicerecorder.activities | package com.simplemobiletools.voicerecorder.activities | ||||||
|  |  | ||||||
| import android.content.Intent | import android.content.Intent | ||||||
|  | import android.graphics.drawable.Drawable | ||||||
| import android.os.Bundle | import android.os.Bundle | ||||||
| import android.view.Menu | import android.view.Menu | ||||||
| import android.view.MenuItem | import android.view.MenuItem | ||||||
| @@ -12,6 +13,8 @@ import com.simplemobiletools.voicerecorder.R | |||||||
| import kotlinx.android.synthetic.main.activity_main.* | import kotlinx.android.synthetic.main.activity_main.* | ||||||
|  |  | ||||||
| class MainActivity : SimpleActivity() { | class MainActivity : SimpleActivity() { | ||||||
|  |     private var isRecording = false | ||||||
|  |  | ||||||
|     override fun onCreate(savedInstanceState: Bundle?) { |     override fun onCreate(savedInstanceState: Bundle?) { | ||||||
|         super.onCreate(savedInstanceState) |         super.onCreate(savedInstanceState) | ||||||
|         setContentView(R.layout.activity_main) |         setContentView(R.layout.activity_main) | ||||||
| @@ -32,9 +35,8 @@ class MainActivity : SimpleActivity() { | |||||||
|  |  | ||||||
|     override fun onResume() { |     override fun onResume() { | ||||||
|         super.onResume() |         super.onResume() | ||||||
|         val micIcon = resources.getColoredDrawableWithColor(R.drawable.ic_mic_vector, getFABIconColor()) |  | ||||||
|         toggle_recording_button.apply { |         toggle_recording_button.apply { | ||||||
|             setImageDrawable(micIcon) |             setImageDrawable(getToggleButtonIcon()) | ||||||
|             background.applyColorFilter(getAdjustedPrimaryColor()) |             background.applyColorFilter(getAdjustedPrimaryColor()) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -56,10 +58,34 @@ class MainActivity : SimpleActivity() { | |||||||
|     private fun initVoiceRecorder() { |     private fun initVoiceRecorder() { | ||||||
|         val filename = "${getCurrentFormattedDateTime()}.mp3" |         val filename = "${getCurrentFormattedDateTime()}.mp3" | ||||||
|         toggle_recording_button.setOnClickListener { |         toggle_recording_button.setOnClickListener { | ||||||
|  |             toggleRecording() | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     private fun toggleRecording() { | ||||||
|  |         isRecording = !isRecording | ||||||
|  |         toggle_recording_button.setImageDrawable(getToggleButtonIcon()) | ||||||
|  |  | ||||||
|  |         if (isRecording) { | ||||||
|  |             startRecording() | ||||||
|  |         } else { | ||||||
|  |             stopRecording() | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private fun startRecording() { | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private fun stopRecording() { | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private fun getToggleButtonIcon(): Drawable { | ||||||
|  |         val drawable = if (isRecording) R.drawable.ic_stop_vector else R.drawable.ic_mic_vector | ||||||
|  |         return resources.getColoredDrawableWithColor(drawable, getFABIconColor()) | ||||||
|  |     } | ||||||
|  |  | ||||||
|     private fun launchSettings() { |     private fun launchSettings() { | ||||||
|         startActivity(Intent(applicationContext, SettingsActivity::class.java)) |         startActivity(Intent(applicationContext, SettingsActivity::class.java)) | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user