feat: Add StartRecordingActivity

This commit is contained in:
Myzel394 2023-08-27 22:26:25 +02:00
parent b5272e8d1c
commit 4688766c14
No known key found for this signature in database
GPG Key ID: 79CC92F37B3E1A2B
4 changed files with 35 additions and 0 deletions

View File

@ -127,4 +127,6 @@ dependencies {
implementation 'com.maxkeppeler.sheets-compose-dialogs:duration:1.2.0' implementation 'com.maxkeppeler.sheets-compose-dialogs:duration:1.2.0'
implementation 'com.maxkeppeler.sheets-compose-dialogs:list:1.2.0' implementation 'com.maxkeppeler.sheets-compose-dialogs:list:1.2.0'
implementation 'com.maxkeppeler.sheets-compose-dialogs:input:1.2.0' implementation 'com.maxkeppeler.sheets-compose-dialogs:input:1.2.0'
implementation 'com.joaomgcd:taskerpluginlibrary:0.4.4'
} }

View File

@ -29,6 +29,13 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity
android:name=".StartRecordingActivity"
android:exported="true"
android:noHistory="true"
/>
<receiver <receiver
android:name=".receivers.LocalChangeReceiver" android:name=".receivers.LocalChangeReceiver"
android:exported="false"> android:exported="false">

View File

@ -0,0 +1,20 @@
package app.myzel394.alibi
import android.app.Activity
import android.content.Intent
import androidx.core.content.ContextCompat
import app.myzel394.alibi.services.AudioRecorderService
class StartRecordingActivity : Activity() {
override fun onStart() {
super.onStart()
val context = this
val intent = Intent(context, AudioRecorderService::class.java).apply {
putExtra("startNow", true)
}
ContextCompat.startForegroundService(context, intent)
finish()
}
}

View File

@ -5,6 +5,7 @@ import android.app.Notification
import android.app.PendingIntent import android.app.PendingIntent
import android.app.Service import android.app.Service
import android.content.Intent import android.content.Intent
import android.content.Intent.getIntent
import android.os.Binder import android.os.Binder
import android.os.IBinder import android.os.IBinder
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
@ -14,6 +15,7 @@ import app.myzel394.alibi.NotificationHelper
import app.myzel394.alibi.R import app.myzel394.alibi.R
import app.myzel394.alibi.enums.RecorderState import app.myzel394.alibi.enums.RecorderState
import app.myzel394.alibi.ui.utils.PermissionHelper import app.myzel394.alibi.ui.utils.PermissionHelper
import kotlinx.coroutines.runBlocking
import java.time.LocalDateTime import java.time.LocalDateTime
import java.time.ZoneId import java.time.ZoneId
import java.util.Calendar import java.util.Calendar
@ -58,6 +60,10 @@ abstract class RecorderService: Service() {
} }
} }
if (intent?.getBooleanExtra("startNow", false) == true) {
startRecording()
}
return super.onStartCommand(intent, flags, startId) return super.onStartCommand(intent, flags, startId)
} }