mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-22 13:30:36 +01:00
Added multilingual text rendering
This commit is contained in:
parent
f51796a184
commit
22be3b6067
@ -5,12 +5,12 @@ package.domain = io.unsigned
|
|||||||
|
|
||||||
source.dir = .
|
source.dir = .
|
||||||
source.include_exts = py,png,jpg,jpeg,webp,ttf,kv,pyi,typed,so,0,1,2,3,atlas,frag,html,css,js,whl,zip,gz,woff2,pdf,epub
|
source.include_exts = py,png,jpg,jpeg,webp,ttf,kv,pyi,typed,so,0,1,2,3,atlas,frag,html,css,js,whl,zip,gz,woff2,pdf,epub
|
||||||
source.include_patterns = assets/*,share/*
|
source.include_patterns = assets/*,assets/fonts/*,share/*
|
||||||
source.exclude_patterns = app_storage/*,venv/*,Makefile,./Makefil*,requirements,precompiled/*,parked/*,./setup.py,Makef*,./Makefile,Makefile
|
source.exclude_patterns = app_storage/*,venv/*,Makefile,./Makefil*,requirements,precompiled/*,parked/*,./setup.py,Makef*,./Makefile,Makefile
|
||||||
|
|
||||||
version.regex = __version__ = ['"](.*)['"]
|
version.regex = __version__ = ['"](.*)['"]
|
||||||
version.filename = %(source.dir)s/main.py
|
version.filename = %(source.dir)s/main.py
|
||||||
android.numeric_version = 20231207
|
android.numeric_version = 20240103
|
||||||
|
|
||||||
# Cryptography recipe is currently broken, using RNS-internal crypto for now
|
# Cryptography recipe is currently broken, using RNS-internal crypto for now
|
||||||
requirements = kivy==2.2.1,libbz2,pillow,qrcode==7.3.1,usb4a,usbserial4a
|
requirements = kivy==2.2.1,libbz2,pillow,qrcode==7.3.1,usb4a,usbserial4a
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
__debug_build__ = False
|
__debug_build__ = False
|
||||||
__disable_shaders__ = False
|
__disable_shaders__ = False
|
||||||
__version__ = "0.7.7"
|
__version__ = "0.7.8"
|
||||||
__variant__ = "beta"
|
__variant__ = "beta"
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
@ -179,6 +179,7 @@ class SidebandApp(MDApp):
|
|||||||
self.sideband = SidebandCore(self, is_client=False, verbose=(args.verbose or __debug_build__))
|
self.sideband = SidebandCore(self, is_client=False, verbose=(args.verbose or __debug_build__))
|
||||||
|
|
||||||
self.set_ui_theme()
|
self.set_ui_theme()
|
||||||
|
self.font_config()
|
||||||
self.dark_theme_text_color = dark_theme_text_color
|
self.dark_theme_text_color = dark_theme_text_color
|
||||||
|
|
||||||
self.conversations_view = None
|
self.conversations_view = None
|
||||||
@ -347,6 +348,27 @@ class SidebandApp(MDApp):
|
|||||||
|
|
||||||
self.update_ui_colors()
|
self.update_ui_colors()
|
||||||
|
|
||||||
|
def font_config(self):
|
||||||
|
from kivy.core.text import LabelBase, DEFAULT_FONT
|
||||||
|
fb_path = "assets/fonts/"
|
||||||
|
LabelBase.register(name="hebrew",
|
||||||
|
fn_regular=fb_path+"NotoSansHebrew-Regular.ttf",
|
||||||
|
fn_bold=fb_path+"NotoSansHebrew-Bold.ttf",)
|
||||||
|
|
||||||
|
LabelBase.register(name="japanese",
|
||||||
|
fn_regular=fb_path+"NotoSansJP-Regular.ttf")
|
||||||
|
|
||||||
|
LabelBase.register(name="chinese",
|
||||||
|
fn_regular=fb_path+"NotoSansSC-Regular.ttf")
|
||||||
|
|
||||||
|
LabelBase.register(name="korean",
|
||||||
|
fn_regular=fb_path+"NotoSansKR-Regular.ttf")
|
||||||
|
|
||||||
|
LabelBase.register(name="emoji",
|
||||||
|
fn_regular=fb_path+"NotoEmoji-Regular.ttf")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def update_ui_colors(self):
|
def update_ui_colors(self):
|
||||||
if self.sideband.config["dark_ui"]:
|
if self.sideband.config["dark_ui"]:
|
||||||
self.color_reject = colors["DeepOrange"]["900"]
|
self.color_reject = colors["DeepOrange"]["900"]
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
<!-- Allow writing to external storage -->
|
<!-- Allow writing to external storage -->
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
|
<!-- Legacy permissions for bluetooth access (Android < 12) -->
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
|
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
|
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -12,10 +12,16 @@ from kivy.properties import StringProperty, BooleanProperty
|
|||||||
from kivy.uix.gridlayout import GridLayout
|
from kivy.uix.gridlayout import GridLayout
|
||||||
from kivy.uix.boxlayout import BoxLayout
|
from kivy.uix.boxlayout import BoxLayout
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
|
from kivy.utils import escape_markup
|
||||||
|
|
||||||
from kivymd.uix.button import MDRectangleFlatButton, MDRectangleFlatIconButton
|
from kivymd.uix.button import MDRectangleFlatButton, MDRectangleFlatIconButton
|
||||||
from kivymd.uix.dialog import MDDialog
|
from kivymd.uix.dialog import MDDialog
|
||||||
|
|
||||||
|
if RNS.vendor.platformutils.get_platform() == "android":
|
||||||
|
from ui.helpers import multilingual_markup
|
||||||
|
else:
|
||||||
|
from .helpers import multilingual_markup
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import plyer
|
import plyer
|
||||||
import subprocess
|
import subprocess
|
||||||
@ -175,6 +181,13 @@ class Messages():
|
|||||||
|
|
||||||
for m in self.new_messages:
|
for m in self.new_messages:
|
||||||
if not m["hash"] in self.added_item_hashes:
|
if not m["hash"] in self.added_item_hashes:
|
||||||
|
if not self.is_trusted:
|
||||||
|
message_input = str( escape_markup(m["content"].decode("utf-8")) ).encode("utf-8")
|
||||||
|
else:
|
||||||
|
message_input = m["content"]
|
||||||
|
|
||||||
|
message_markup = multilingual_markup(message_input)
|
||||||
|
|
||||||
txstr = time.strftime(ts_format, time.localtime(m["sent"]))
|
txstr = time.strftime(ts_format, time.localtime(m["sent"]))
|
||||||
rxstr = time.strftime(ts_format, time.localtime(m["received"]))
|
rxstr = time.strftime(ts_format, time.localtime(m["received"]))
|
||||||
titlestr = ""
|
titlestr = ""
|
||||||
@ -305,7 +318,7 @@ class Messages():
|
|||||||
force_markup = True
|
force_markup = True
|
||||||
|
|
||||||
item = ListLXMessageCard(
|
item = ListLXMessageCard(
|
||||||
text=pre_content+m["content"].decode("utf-8")+extra_content,
|
text=pre_content+message_markup.decode("utf-8")+extra_content,
|
||||||
heading=heading_str,
|
heading=heading_str,
|
||||||
md_bg_color=msg_color,
|
md_bg_color=msg_color,
|
||||||
)
|
)
|
||||||
@ -320,7 +333,6 @@ class Messages():
|
|||||||
item.ids.content_text.text_color = mt_color
|
item.ids.content_text.text_color = mt_color
|
||||||
item.ids.msg_submenu.theme_text_color = "Custom"
|
item.ids.msg_submenu.theme_text_color = "Custom"
|
||||||
item.ids.msg_submenu.text_color = mt_color
|
item.ids.msg_submenu.text_color = mt_color
|
||||||
item.ids.content_text.markup = self.is_trusted or force_markup
|
|
||||||
|
|
||||||
def gen_del(mhash, item):
|
def gen_del(mhash, item):
|
||||||
def x():
|
def x():
|
||||||
@ -759,7 +771,7 @@ Builder.load_string("""
|
|||||||
MDLabel:
|
MDLabel:
|
||||||
id: content_text
|
id: content_text
|
||||||
text: root.text
|
text: root.text
|
||||||
markup: False
|
markup: True
|
||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
text_size: self.width, None
|
text_size: self.width, None
|
||||||
height: self.texture_size[1]
|
height: self.texture_size[1]
|
||||||
|
Loading…
Reference in New Issue
Block a user