From 1e86b266a94307b87c5b199617f5079a3c63d736 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 10 Mar 2024 16:36:41 +0100 Subject: [PATCH] Display warning on very large messages --- sbapp/ui/messages.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sbapp/ui/messages.py b/sbapp/ui/messages.py index 6e7d2d0..7ea8cfc 100644 --- a/sbapp/ui/messages.py +++ b/sbapp/ui/messages.py @@ -27,6 +27,8 @@ import plyer import subprocess import shlex +from kivy.graphics.opengl import glGetIntegerv, GL_MAX_TEXTURE_SIZE + if RNS.vendor.platformutils.get_platform() == "android": from sideband.sense import Telemeter, Commands from ui.helpers import ts_format, file_ts_format, mdc @@ -53,6 +55,7 @@ class Messages(): self.screen = self.app.root.ids.screen_manager.get_screen("messages_screen") self.ids = self.screen.ids + self.max_texture_size = glGetIntegerv(GL_MAX_TEXTURE_SIZE)[0] self.new_messages = [] self.added_item_hashes = [] self.added_messages = 0 @@ -324,6 +327,16 @@ class Messages(): heading=heading_str, md_bg_color=msg_color, ) + + def check_texture(w, val): + try: + if w.texture_size[1] > 360 and w.texture_size[1] >= self.max_texture_size: + w.text = "[i]The content of this message is too large to display in the message stream. You can copy the message content into another program by using the context menu of this message, and selecting [b]Copy[/b].[/i]" + except: + pass + + item.ids.content_text.bind(texture_size=check_texture) + if not RNS.vendor.platformutils.is_android(): item.radius = dp(5)