This commit is contained in:
2026-06-04 10:50:24 +08:00
parent 8f9f3a9779
commit 250f21a2b8
67 changed files with 1192 additions and 159 deletions

View File

@@ -5,8 +5,10 @@ plugins {
id("dev.flutter.flutter-gradle-plugin")
}
val appPackageName = "com.gdfw.fxjk"
android {
namespace = "com.example.flutter_template"
namespace = appPackageName
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
@@ -20,8 +22,7 @@ android {
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.example.flutter_template"
applicationId = appPackageName
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion

View File

@@ -0,0 +1,9 @@
package com.gdfw.fxjk
object AppConstants {
const val PACKAGE_NAME = "com.gdfw.fxjk"
const val RECORDING_METHOD_CHANNEL = "$PACKAGE_NAME/recording"
const val RECORDING_EVENT_CHANNEL = "$PACKAGE_NAME/recording_events"
const val RECORDING_ACTION_START = "$PACKAGE_NAME.recording.START"
const val RECORDING_ACTION_STOP = "$PACKAGE_NAME.recording.STOP"
}

View File

@@ -1,8 +1,8 @@
package com.example.flutter_template
package com.gdfw.fxjk
import androidx.camera.view.PreviewView
import com.example.flutter_template.recording.RecordingPlatformHandler
import com.example.flutter_template.recording.RecordingPreviewFactory
import com.gdfw.fxjk.recording.RecordingPlatformHandler
import com.gdfw.fxjk.recording.RecordingPreviewFactory
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine

View File

@@ -1,4 +1,4 @@
package com.example.flutter_template.recording
package com.gdfw.fxjk.recording
import android.content.Context
import android.content.Intent

View File

@@ -1,4 +1,4 @@
package com.example.flutter_template.recording
package com.gdfw.fxjk.recording
import android.app.NotificationManager
import android.content.Context

View File

@@ -1,4 +1,4 @@
package com.example.flutter_template.recording
package com.gdfw.fxjk.recording
import android.content.Context
import android.util.Log

View File

@@ -1,4 +1,4 @@
package com.example.flutter_template.recording
package com.gdfw.fxjk.recording
import android.app.Notification
import android.app.NotificationChannel
@@ -15,7 +15,8 @@ import android.os.IBinder
import android.os.PowerManager
import androidx.core.app.NotificationCompat
import androidx.lifecycle.LifecycleService
import com.example.flutter_template.MainActivity
import com.gdfw.fxjk.AppConstants
import com.gdfw.fxjk.MainActivity
class RecordingForegroundService : LifecycleService() {
private var wakeLock: PowerManager.WakeLock? = null
@@ -29,7 +30,7 @@ class RecordingForegroundService : LifecycleService() {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
super.onStartCommand(intent, flags, startId)
when (intent?.action) {
ACTION_START -> {
AppConstants.RECORDING_ACTION_START -> {
acquireWakeLock()
val notification = buildNotification("正在录制")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
@@ -43,7 +44,7 @@ class RecordingForegroundService : LifecycleService() {
}
isRunning = true
}
ACTION_STOP -> {
AppConstants.RECORDING_ACTION_STOP -> {
releaseWakeLock()
stopForeground(STOP_FOREGROUND_REMOVE)
isRunning = false
@@ -143,8 +144,6 @@ class RecordingForegroundService : LifecycleService() {
companion object {
const val CHANNEL_ID = "recording_foreground"
const val NOTIFICATION_ID = 1001
const val ACTION_START = "com.example.flutter_template.recording.START"
const val ACTION_STOP = "com.example.flutter_template.recording.STOP"
private const val WAKE_LOCK_TAG = "record_tool:recording_wake_lock"
@Volatile
@@ -156,7 +155,7 @@ class RecordingForegroundService : LifecycleService() {
fun start(context: Context) {
val intent =
Intent(context, RecordingForegroundService::class.java).apply {
action = ACTION_START
action = AppConstants.RECORDING_ACTION_START
}
ContextCompatStart.startForegroundService(context, intent)
}
@@ -164,7 +163,7 @@ class RecordingForegroundService : LifecycleService() {
fun stop(context: Context) {
val intent =
Intent(context, RecordingForegroundService::class.java).apply {
action = ACTION_STOP
action = AppConstants.RECORDING_ACTION_STOP
}
context.startService(intent)
}

View File

@@ -1,4 +1,4 @@
package com.example.flutter_template.recording
package com.gdfw.fxjk.recording
import android.app.Activity
import android.os.Build
@@ -7,7 +7,8 @@ import android.os.Looper
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
import com.example.flutter_template.MainActivity
import com.gdfw.fxjk.AppConstants
import com.gdfw.fxjk.MainActivity
import io.flutter.plugin.common.BinaryMessenger
import io.flutter.plugin.common.EventChannel
import io.flutter.plugin.common.MethodCall
@@ -18,9 +19,9 @@ class RecordingPlatformHandler(
messenger: BinaryMessenger,
) : MethodChannel.MethodCallHandler, EventChannel.StreamHandler {
private val methodChannel =
MethodChannel(messenger, "com.example.flutter_template/recording")
MethodChannel(messenger, AppConstants.RECORDING_METHOD_CHANNEL)
private val eventChannel =
EventChannel(messenger, "com.example.flutter_template/recording_events")
EventChannel(messenger, AppConstants.RECORDING_EVENT_CHANNEL)
private val mainHandler = Handler(Looper.getMainLooper())
private var eventSink: EventChannel.EventSink? = null

View File

@@ -1,9 +1,9 @@
package com.example.flutter_template.recording
package com.gdfw.fxjk.recording
import android.content.Context
import android.view.View
import androidx.camera.view.PreviewView
import com.example.flutter_template.MainActivity
import com.gdfw.fxjk.MainActivity
import io.flutter.plugin.common.StandardMessageCodec
import io.flutter.plugin.platform.PlatformView
import io.flutter.plugin.platform.PlatformViewFactory

View File

@@ -1,4 +1,4 @@
package com.example.flutter_template.recording
package com.gdfw.fxjk.recording
import android.content.Context
import androidx.lifecycle.LifecycleService

View File

@@ -1,4 +1,4 @@
package com.example.flutter_template.recording
package com.gdfw.fxjk.recording
enum class RecordingState {
IDLE,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 544 B

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 442 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 721 B

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

File diff suppressed because one or more lines are too long