Merge upstream/dev (22 commits) [upstream-sync]
build / ci-image (push) Successful in 11s
build / build (push) Successful in 26m36s

Conflicts resolved by hand, our fork changes carried over:
- MainActivity.kt: keep the unread widget hooks next to upstream's
  scroll capture (attach and detach both).
- app_settings_screen.dart: upstream wrapped the list in
  MeshSettingsTileTheme; image-message and translation sections stay
  gated on kOnDeviceMl (ML-free build).
- channel_chat_screen.dart: upstream split build() into methods; took
  theirs and re-applied the terminal-theme list padding.
- chat_composer.dart: both imports (terminal_theme, radio_guard).
- mesh_nav_tile.dart: upstream's meshTileTitleStyle, with the smaller
  terminal-theme title kept.

flutter analyze clean, flutter test 1522 passed (CI image, local).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5.5 committed 2026-11-10 15:30:43 +01:00
commit 185d2aca53
210 files changed
+52066 -5541

No files matched your search

+5 -1
View File
@@ -29,7 +29,11 @@
android:name="com.pravera.flutter_foreground_task.service.ForegroundService"
android:exported="false"
android:foregroundServiceType="connectedDevice"
android:stopWithTask="false" />
android:stopWithTask="true" />
<!-- Monochrome small icon for the background-connection notification -->
<meta-data
android:name="org.meshcore.open.NOTIFICATION_ICON"
android:resource="@drawable/ic_stat_notification" />
<!-- Handles reply / mark-as-read actions on message notifications -->
<receiver
android:name="com.dexterous.flutterlocalnotifications.ActionBroadcastReceiver"
@@ -0,0 +1,213 @@
package com.meshcore.meshcore_open
import android.app.Activity
import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.PorterDuff
import android.graphics.Rect
import android.os.Build
import android.os.CancellationSignal
import android.os.Handler
import android.os.Looper
import android.view.PixelCopy
import android.view.ScrollCaptureCallback
import android.view.ScrollCaptureSession
import android.view.SurfaceView
import android.view.TextureView
import android.view.View
import android.view.ViewGroup
import androidx.annotation.RequiresApi
import io.flutter.plugin.common.BinaryMessenger
import io.flutter.plugin.common.MethodChannel
import java.util.function.Consumer
import kotlin.math.max
import kotlin.math.min
import kotlin.math.roundToInt
/**
* Lets Android's scrolling screenshot ("Capture more") extend past the
* screen. Flutter draws into one surface, so the system cannot find or
* scroll a list on its own: this callback asks Dart (ScrollCaptureService)
* for the main scrollable's bounds, has it scroll for each requested strip,
* and copies that strip from the Flutter surface into the capture session.
*/
@RequiresApi(Build.VERSION_CODES.S)
class FlutterScrollCapture(
private val activity: Activity,
messenger: BinaryMessenger,
) : ScrollCaptureCallback {
private val channel = MethodChannel(messenger, "meshcore_open/scroll_capture")
private val handler = Handler(Looper.getMainLooper())
private var host: View? = null
/** Scroll bounds in Flutter-surface pixels. */
private var flutterBounds = Rect()
fun attach(view: View) {
host = view
view.scrollCaptureHint = View.SCROLL_CAPTURE_HINT_INCLUDE
view.setScrollCaptureCallback(this)
}
fun detach() {
host?.setScrollCaptureCallback(null)
host = null
}
override fun onScrollCaptureSearch(signal: CancellationSignal, onReady: Consumer<Rect>) {
val view = host
if (view == null) {
onReady.accept(Rect())
return
}
invoke("search", null) { result ->
val map = result as? Map<*, *>
val surface = findFlutterSurface(view)
if (map == null || surface == null) {
onReady.accept(Rect())
return@invoke
}
flutterBounds = Rect(
map.int("left"),
map.int("top"),
map.int("right"),
map.int("bottom"),
)
// Convert to the host view's coordinates.
val hostLoc = IntArray(2).also { view.getLocationInWindow(it) }
val surfLoc = IntArray(2).also { surface.getLocationInWindow(it) }
val bounds = Rect(flutterBounds)
bounds.offset(surfLoc[0] - hostLoc[0], surfLoc[1] - hostLoc[1])
onReady.accept(bounds)
}
}
override fun onScrollCaptureStart(
session: ScrollCaptureSession,
signal: CancellationSignal,
onReady: Runnable,
) {
invoke("start", null) { onReady.run() }
}
override fun onScrollCaptureImageRequest(
session: ScrollCaptureSession,
signal: CancellationSignal,
captureArea: Rect,
onComplete: Consumer<Rect>,
) {
val args = mapOf("top" to captureArea.top, "bottom" to captureArea.bottom)
invoke("scroll", args) { result ->
val scrolled = ((result as? Number)?.toDouble() ?: 0.0).roundToInt()
// The part of the requested strip now on screen, in scroll-bounds
// coordinates relative to the current scroll position.
val visibleTop = max(captureArea.top - scrolled, 0)
val visibleBottom = min(captureArea.bottom - scrolled, flutterBounds.height())
val left = max(captureArea.left, 0)
val right = min(captureArea.right, flutterBounds.width())
if (visibleBottom <= visibleTop || right <= left || signal.isCanceled) {
onComplete.accept(Rect())
return@invoke
}
val source = Rect(
flutterBounds.left + left,
flutterBounds.top + visibleTop,
flutterBounds.left + right,
flutterBounds.top + visibleBottom,
)
val captured = Rect(left, visibleTop + scrolled, right, visibleBottom + scrolled)
// Give the raster thread a moment to present the scrolled frame.
handler.postDelayed({
copyPixels(source) { bitmap ->
if (bitmap == null || signal.isCanceled) {
onComplete.accept(Rect())
return@copyPixels
}
try {
val canvas = session.surface.lockHardwareCanvas()
try {
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR)
canvas.drawBitmap(bitmap, 0f, 0f, null)
} finally {
session.surface.unlockCanvasAndPost(canvas)
}
onComplete.accept(captured)
} catch (e: Exception) {
onComplete.accept(Rect())
} finally {
bitmap.recycle()
}
}
}, FRAME_SETTLE_MS)
}
}
override fun onScrollCaptureEnd(onReady: Runnable) {
invoke("end", null) { onReady.run() }
}
private fun copyPixels(source: Rect, done: (Bitmap?) -> Unit) {
val view = host
val surface = view?.let { findFlutterSurface(it) }
val bitmap = Bitmap.createBitmap(source.width(), source.height(), Bitmap.Config.ARGB_8888)
when (surface) {
is SurfaceView -> PixelCopy.request(surface, source, bitmap, { code ->
if (code == PixelCopy.SUCCESS) {
done(bitmap)
} else {
bitmap.recycle()
done(null)
}
}, handler)
is TextureView -> {
val full = surface.bitmap
if (full == null) {
bitmap.recycle()
done(null)
} else {
android.graphics.Canvas(bitmap).drawBitmap(
full,
source,
Rect(0, 0, source.width(), source.height()),
null,
)
full.recycle()
done(bitmap)
}
}
else -> {
bitmap.recycle()
done(null)
}
}
}
/** The view Flutter renders into (SurfaceView by default). */
private fun findFlutterSurface(view: View): View? {
if (view is SurfaceView || view is TextureView) return view
if (view is ViewGroup) {
for (i in 0 until view.childCount) {
findFlutterSurface(view.getChildAt(i))?.let { return it }
}
}
return null
}
private fun invoke(method: String, args: Any?, onResult: (Any?) -> Unit) {
if (activity.isFinishing) {
onResult(null)
return
}
channel.invokeMethod(method, args, object : MethodChannel.Result {
override fun success(result: Any?) = onResult(result)
override fun error(code: String, message: String?, details: Any?) = onResult(null)
override fun notImplemented() = onResult(null)
})
}
private fun Map<*, *>.int(key: String): Int = (this[key] as? Number)?.toInt() ?: 0
private companion object {
const val FRAME_SETTLE_MS = 48L
}
}
@@ -1,20 +1,42 @@
package com.meshcore.meshcore_open
import io.flutter.embedding.android.FlutterActivity
import android.os.Build
import android.os.Bundle
import android.view.View
import androidx.activity.enableEdgeToEdge
import io.flutter.embedding.android.FlutterFragmentActivity
import io.flutter.embedding.engine.FlutterEngine
class MainActivity : FlutterActivity() {
// FlutterFragmentActivity (a ComponentActivity) so enableEdgeToEdge() works:
// Android 15+ enforces edge-to-edge for apps targeting SDK 35, and the app
// already draws behind the system bars and handles insets in Flutter.
class MainActivity : FlutterFragmentActivity() {
private val usbFunctions by lazy { MeshcoreUsbFunctions(this) }
private var scrollCapture: FlutterScrollCapture? = null
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
}
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
usbFunctions.configureFlutterEngine(flutterEngine)
UnreadWidget.configureFlutterEngine(applicationContext, flutterEngine)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
scrollCapture?.detach()
scrollCapture = FlutterScrollCapture(
this,
flutterEngine.dartExecutor.binaryMessenger,
).also { it.attach(findViewById<View>(android.R.id.content)) }
}
}
override fun onDestroy() {
// A rotation recreates the activity; only a real exit closes the app.
if (!isChangingConfigurations) UnreadWidget.markAppClosed(applicationContext)
scrollCapture?.detach()
scrollCapture = null
usbFunctions.dispose()
super.onDestroy()
}
@@ -14,7 +14,7 @@ import android.hardware.usb.UsbManager
import android.os.Build
import android.os.Handler
import android.os.Looper
import io.flutter.embedding.android.FlutterActivity
import android.app.Activity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.EventChannel
import io.flutter.plugin.common.MethodCall
@@ -24,7 +24,7 @@ import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
class MeshcoreUsbFunctions(
private val activity: FlutterActivity,
private val activity: Activity,
) {
private companion object {
const val usbRecipientInterface = 0x01
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Monochrome status-bar icon (chat bubble with radio tower). Android only
uses the alpha channel for small notification icons, so this must stay
white-on-transparent; the full-colour launcher icon renders as a blob. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#00000000"
android:strokeColor="#FFFFFFFF"
android:strokeWidth="1.8"
android:strokeLineJoin="round"
android:pathData="M12,3C6.75,3 2.5,6.58 2.5,11c0,2.28 1.13,4.34 2.95,5.8L4.5,21l4.36,-2.38C9.84,18.87 10.9,19 12,19c5.25,0 9.5,-3.58 9.5,-8S17.25,3 12,3z" />
<path
android:fillColor="#00000000"
android:strokeColor="#FFFFFFFF"
android:strokeWidth="1.6"
android:strokeLineCap="round"
android:pathData="M8,10A5,5 0,0 1,16 10" />
<path
android:fillColor="#00000000"
android:strokeColor="#FFFFFFFF"
android:strokeWidth="1.6"
android:strokeLineCap="round"
android:pathData="M9.78,11.3A2.8,2.8 0,0 1,14.22 11.3" />
<path
android:fillColor="#FFFFFFFF"
android:pathData="M12,12.4L14.1,17L9.9,17z" />
</vector>