fix: все фото в пикере

This commit is contained in:
Jganenokk
2026-08-26 21:34:17 +07:00
parent 5d115e0f9e
commit 9b37565887
14 changed files with 423 additions and 151 deletions
@@ -8,7 +8,9 @@ import android.os.Build
import android.os.IBinder
import android.util.Log
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.app.Person
import androidx.core.app.ServiceCompat
object CallState {
@Volatile
@@ -27,6 +29,9 @@ class CallForegroundService : Service() {
@Volatile
var screenShare = false
@Volatile
private var running: CallForegroundService? = null
fun setScreenShare(ctx: Context, enabled: Boolean, caller: String) {
screenShare = enabled
val intent = Intent(ctx, CallForegroundService::class.java).apply {
@@ -65,6 +70,12 @@ class CallForegroundService : Service() {
fun stop(ctx: Context) {
CallState.inCall = false
screenShare = false
val service = running
if (service != null) {
service.shutdown()
return
}
NotificationManagerCompat.from(ctx).cancel(ONGOING_ID)
try {
ctx.startService(
Intent(ctx, CallForegroundService::class.java).apply {
@@ -78,18 +89,25 @@ class CallForegroundService : Service() {
override fun onBind(intent: Intent?): IBinder? = null
override fun onCreate() {
super.onCreate()
running = this
}
override fun onDestroy() {
if (running === this) running = null
CallState.inCall = false
super.onDestroy()
}
private fun shutdown() {
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE)
stopSelf()
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
when (intent?.action) {
ACTION_STOP -> {
@Suppress("DEPRECATION")
stopForeground(true)
stopSelf()
}
ACTION_STOP -> shutdown()
ACTION_SCREEN_SHARE -> {
screenShare = intent.getBooleanExtra(EXTRA_SCREEN_SHARE, false)
val caller = intent.getStringExtra(CallConst.EXTRA_CALLER) ?: "Звонок"
@@ -83,6 +83,9 @@ class MainActivity : FlutterActivity() {
private val shareHandler = Handler(Looper.getMainLooper())
private companion object {
@Volatile
var keepAwake = false
const val LOG_TAG = "VpnBypass"
const val SHARE_TAG = "ShareIntake"
const val NFC_TAG = "NfcExchange"
@@ -359,6 +362,10 @@ class MainActivity : FlutterActivity() {
)
result.success(null)
}
"dropOngoing" -> {
CallForegroundService.stop(applicationContext)
result.success(null)
}
"notifyEnded" -> {
CallRinger.stop()
NotificationManagerCompat.from(this).cancel(CallConst.NOTIF_ID)
@@ -395,6 +402,19 @@ class MainActivity : FlutterActivity() {
}
}
MethodChannel(
flutterEngine.dartExecutor.binaryMessenger,
"ru.komet.app/screen",
).setMethodCallHandler { call, result ->
when (call.method) {
"setKeepAwake" -> {
setKeepAwake(call.argument<Boolean>("enabled") == true)
result.success(null)
}
else -> result.notImplemented()
}
}
EventChannel(
flutterEngine.dartExecutor.binaryMessenger,
"ru.komet.app/calls_events",
@@ -498,6 +518,7 @@ class MainActivity : FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
if (intent?.hasExtra(CallConst.EXTRA_CALL) == true) applyCallWindowFlags()
super.onCreate(savedInstanceState)
applyKeepAwake()
intent?.let { if (it.hasExtra(CallConst.EXTRA_CALL)) stashCall(it, emit = false) }
stashChatOpen(intent, emit = false)
stashShare(intent, emit = false)
@@ -557,6 +578,9 @@ class MainActivity : FlutterActivity() {
private fun stashCall(intent: Intent, emit: Boolean) {
val json = intent.getStringExtra(CallConst.EXTRA_CALL) ?: return
val action = intent.getStringExtra(CallConst.EXTRA_ACTION) ?: CallConst.ACTION_RING
intent.removeExtra(CallConst.EXTRA_CALL)
intent.removeExtra(CallConst.EXTRA_ACTION)
intent.removeExtra(CallConst.EXTRA_CALLER)
if (action == CallConst.ACTION_ANSWER) CallRinger.stop()
val map = mapOf<String, Any?>("data" to json, "action" to action)
val sink = CallEvents.sink
@@ -575,8 +599,7 @@ class MainActivity : FlutterActivity() {
@Suppress("DEPRECATION")
window.addFlags(
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON,
)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
@@ -593,12 +616,24 @@ class MainActivity : FlutterActivity() {
@Suppress("DEPRECATION")
window.clearFlags(
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON,
)
}
}
private fun setKeepAwake(enabled: Boolean) {
keepAwake = enabled
runOnUiThread { applyKeepAwake() }
}
private fun applyKeepAwake() {
if (keepAwake) {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
} else {
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
}
}
// Центр-кроп видео в квадрат size×size (без искажений) через media3
// Transformer: LAYOUT_SCALE_TO_FIT_WITH_CROP заполняет квадрат и обрезает
// лишнее по бокам.