Skip to content

Commit

Permalink
* Fixed an issue where messages in chats were being read twice.
Browse files Browse the repository at this point in the history
* Fixed an issue where the shortcut to navigate to an open profile was not correctly functioning.
* Fixed an issue where the keyboard shortcut to open the navigation menu didn't work.
* Resolved all issues with the button for enabling/disabling the microphone in voice chats.
* Fixed an issue in the Polish language where inputting a character was blocked by the ALT+C combination.
* Corrected the pronunciation of the phrases "Owner" and "Administrator" in messages.
* Addressed several other minor issues
  • Loading branch information
unknown committed Oct 3, 2023
1 parent 6e6f423 commit ba77290
Show file tree
Hide file tree
Showing 21 changed files with 496 additions and 446 deletions.
29 changes: 29 additions & 0 deletions 5.0.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"addonId": "unigramPlus",
"displayName": "UnigramPlus",
"URL": "",
"description": "This add-on adds a lot of hotkeys for quick navigation through the main elements of the Unigram application, convenient interaction with Chat messages, and also adds many small improvements that make working in Unigram much easier",
"sha256": "0e0c89443fb8f67be20a7a96d9406ede52a5d84624e94b9d1f692a1ae168c0d5",
"homepage": "https://github.com/Kostya-Gladkiy/UnigramPlus",
"addonVersionName": "5.0.0",
"addonVersionNumber": {
"major": 5,
"minor": 0,
"patch": 0
},
"minNVDAVersion": {
"major": 2021,
"minor": 2,
"patch": 0
},
"lastTestedVersion": {
"major": 2023,
"minor": 3,
"patch": 0
},
"channel": "stable",
"publisher": "",
"sourceURL": "https://github.com/Kostya-Gladkiy/UnigramPlus",
"license": "GPL 2",
"licenseURL": "https://www.gnu.org/licenses/gpl-2.0.html"
}
2 changes: 2 additions & 0 deletions addon/GlobalPlugins/UnigramPlus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def script_open_settings_dialog(self, gesture, arg = False):
# Call answer
@script(description=_("Accept call"), gesture="kb:ALT+Y")
def script_answeringCall(self, gesture):
gesture.send()
desctop = api.getDesktopObject()
# notification = next((item.firstChild.firstChild for item in desctop.children if item.firstChild and hasattr(item.firstChild, "UIAAutomationId") and item.firstChild.UIAAutomationId == "PriorityToastView"), False)
notification = next((item.firstChild.firstChild for item in desctop.children if item.firstChild and hasattr(item.firstChild, "UIAAutomationId") and item.firstChild.UIAAutomationId == "ToastCenterScrollViewer"), False)
Expand All @@ -147,6 +148,7 @@ def script_answeringCall(self, gesture):
# End a call, decline call, or leave a voice chat
@script(description=_("Press \"Decline call\" button if there is an incoming call, \"End call\" button if a call is in progress or leave voice chat if it is active."), gesture="kb:ALT+N")
def script_callCancellation(self, gesture):
gesture.send()
desctop = api.getDesktopObject()
# notification = next((item.firstChild for item in desctop.children if item.firstChild and hasattr(item.firstChild, "UIAAutomationId") and item.firstChild.UIAAutomationId == "PriorityToastView"), False)
notification = next((item.firstChild.firstChild for item in desctop.children if item.firstChild and hasattr(item.firstChild, "UIAAutomationId") and item.firstChild.UIAAutomationId == "ToastCenterScrollViewer"), False)
Expand Down
50 changes: 34 additions & 16 deletions addon/appModules/unigram.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@
class Audio_and_video_button:
def script_enter(self, gesture):
gesture.send()
if self.UIAAutomationId == "Audio": new_name = self.next.next.name if self.next.next else self.name
if self.UIAAutomationId == "Audio": new_name = self.next.name if self.next else self.name
elif self.UIAAutomationId == "Video": new_name = _("Camera on") if self.firstChild.name == "\ue964" else _("Camera off") if self.firstChild.name == "\ue963" else self.name
def spechState(): message(new_name)
thr = Timer(.1, spechState).start()
# if self.UIAAutomationId == "Audio": self.action_audio_button()
# elif self.UIAAutomationId == "Video": self.action_video_button()

def initOverlayClass(self):
self.bindGesture("kb:Enter", "enter")
# self.bindGesture("kb:space", "enter")
Expand All @@ -60,6 +59,20 @@ def script_voice_answer(self, gesture):
answer = answer.firstChild
if answer: message(answer.name)

@script(description=_("Show message text in popup window"), gesture="kb:ALT+C")
def script_show_text_message(self, gesture):
textMessage = next((item.name for item in self.children if item.UIAAutomationId in ("TextBlock", "Message", "Question")), None)
if textMessage: TextWindow(textMessage.strip(), _("message text"), readOnly=False)
else: message(_("This message does not contain text"))

@script(description=_("Open comments"), gesture="kb:control+ALT+C")
def script_openComentars(self, gesture):
targetButton = next((item for item in reversed(self.children) if item.role == Role.LINK and item.UIAAutomationId == "Thread"), False)
if targetButton:
# self.isSkipName = 1
targetButton.doAction()
else: message(_("Button to open comments not found"))

@script(description=_("Edit message"), gesture="kb:backspace")
def script_edit_message(self, gesture):
self.appModule.activate_option_for_menu((icons_from_context_menu["edit"]), "Messages")
Expand Down Expand Up @@ -89,6 +102,10 @@ def script_activate_reaction(self, gesture):
def initOverlayClass(self):
self.positionInfo = self.parent.positionInfo
self.states.discard(State.CHECKABLE)
self.bindGesture("kb:ALT+C", "show_text_message")
self.bindGesture("kb:backspace", "edit_message")
self.bindGesture("kb:enter", "reply_to_message")
self.bindGesture("kb:control+ALT+C", "openComentars")
if conf.get("action_when_pressing_up_arrow_in_text_field") == "to_messages":
self.bindGesture("kb:downArrow", "next_message")

Expand Down Expand Up @@ -343,7 +360,7 @@ def get_settings_panel(self):
def get_contacts_list(self):
a = next((item for item in self.getElements() if item.role == Role.TABCONTROL and item.UIAAutomationId == "rpMasterTitlebar"), None)
if not a: return False
try:b = a.firstChild.next.lastChild.firstChild.next.next.next
try:b = a.firstChild.next.lastChild.firstChild.next.next.next.next
except: b = False
if b: return b
else: return False
Expand Down Expand Up @@ -522,7 +539,7 @@ def script_move_focus_to_list_threads(self, gesture):
def get_profile_panel(self):
list = self.profile_panel_element
if not list or not list.location.width:
list = next((item for item in self.getElements() if (item.role == Role.LIST and item.UIAAutomationId == "ScrollingHost" and item.firstChild.UIAAutomationId == "Photo") or (item.role == Role.LINK and item.UIAAutomationId == "Photo" and item.next.UIAAutomationId == "Title")), None)
list = next((item for item in self.getElements() if (item.role == Role.LIST and item.UIAAutomationId == "ScrollingHost" and item.firstChild and item.firstChild.UIAAutomationId in ("Photo", "Segments")) or (item.role == Role.LINK and item.UIAAutomationId == "Photo" and item.next.UIAAutomationId == "Title")), None)
if not list:
return False
if list.UIAAutomationId == "Photo":
Expand Down Expand Up @@ -638,7 +655,7 @@ def script_callCancellation(self, gesture):
# The first check concerns the situation when the call is already ongoing
# The second check concerns the situation when the user wants to leave the voice chat while in the voice chat window
# The fourth check concerns the situation when an incoming call is received
targetButton = next((item for item in self.getElements(self)[1:] if (item.UIAAutomationId == "Accept" and item.previous.UIAAutomationId == "Audio") or (item.UIAAutomationId == "Leave" and item.firstChild.name == "\ue711") or (item.previous.UIAAutomationId == "Audio" and item.firstChild.name == "\ue711")), False)
targetButton = next((item for item in self.getElements(self)[1:] if (item.UIAAutomationId == "Accept" and item.previous.UIAAutomationId == "Audio") or (item.UIAAutomationId == "Leave" and item.firstChild and item.firstChild.name == "\ue711") or (item.previous.UIAAutomationId == "Audio" and item.firstChild and item.firstChild.name == "\ue711")), False)
if targetButton:
lastFocus = api.getFocusObject()
message(targetButton.name)
Expand All @@ -655,15 +672,15 @@ def script_microphone(self, gesture):
if item.UIAAutomationId == "Audio" and item.previous.UIAAutomationId == "Video" and item.next.UIAAutomationId == "Accept":
targetButton = item
break
elif item.UIAAutomationId == "Audio" and item.next.next.UIAAutomationId == "AudioInfo":
elif item.UIAAutomationId == "Audio" and item.next.UIAAutomationId == "AudioInfo":
targetButton = item
isVoiceChat = True
break
if targetButton:
if isVoiceChat:
targetButton.doAction()
obj.setFocus()
def spechState(): message(targetButton.next.next.name)
def spechState(): message(targetButton.next.name)
thr = Timer(.1, spechState).start()
return True
self.fixedDoAction(targetButton)
Expand Down Expand Up @@ -722,8 +739,8 @@ def script_copy(self, gesture):
self.activate_option_for_menu((icons_from_context_menu["copy"]), "Messages")

# Show message text in popup window
@script(description=_("Show message text in popup window"), gesture="kb:ALT+C")
def script_show_text_message(self, gesture):
# @script(description=_("Show message text in popup window"), gesture="kb:ALT+C")
def _script_show_text_message(self, gesture):
obj = api.getFocusObject()
if not self.is_message_object(obj): return False
textMessage = next((item.name for item in obj.children if item.UIAAutomationId in ("TextBlock", "Message", "Question")), False)
Expand Down Expand Up @@ -776,13 +793,13 @@ def script_showMoreOptions(self, gesture):
@script(description=_("Open navigation menu"), gesture="kb:ALT+M")
def script_showMenu(self, gesture):
try:
targetButton = next((item for item in self.getElements() if item.UIAAutomationId == "Photo" and item.previous and item.previous.UIAAutomationId == "StateLabel"), False)
targetButton = next((item for item in self.getElements() if item.UIAAutomationId == "Photo" and item.role == Role.TOGGLEBUTTON), False)
except: targetButton = False
if targetButton: targetButton.doAction()
else: message(_("Navigation menu not available"))

# Function to open comments
@script(description=_("Open comments"), gesture="kb:control+ALT+C")
# @script(description=_("Open comments"), gesture="kb:control+ALT+C")
def script_openComentars(self, gesture):
obj = api.getFocusObject()
if not self.is_message_object(obj): return
Expand Down Expand Up @@ -888,8 +905,9 @@ def action_message_focus(self, obj):
reactions = []
# Determine the message was sent or received
sender_message = "received" if keywords[3] in obj.name[-80:] else "send" if keywords[2] in obj.name[-80:] else ""
cleaned_message_element = re.sub(r"\W+", "", obj.name)
for item in obj.children:
if (item.UIAAutomationId in ("TextBlock", "Message") and item.name.strip() not in obj.name) or item.UIAAutomationId == "RecognizedText":
if (item.UIAAutomationId in ("TextBlock", "Message") and re.sub(r"\W+", "", item.name) not in cleaned_message_element) or item.UIAAutomationId == "RecognizedText":
# Processing the message description containing multiple embedded media
try: obj.name =re.sub(r"[\.,]?{}|{}".format(keywords[3], keywords[2]), fr". {item.name}\g<0>", obj.name)
except: pass
Expand Down Expand Up @@ -952,8 +970,7 @@ def action_message_focus(self, obj):
list_text = obj.name.split("\n")
key_phrases = phrase_administrator_in_message.get(conf.get("lang"), phrase_administrator_in_message["en"])
en_key_phrases = phrase_administrator_in_message["en"]
# if not conf.get("notify administrators in messages") and len(list_text) > 1 and ((admin_label and list_text[1] == ". "+admin_label+". \r") or list_text[1] in (". "+key_phrases[0]+". \r", ". "+key_phrases[1]+". \r")):
if not conf.get("notify administrators in messages") and len(list_text) > 1 and list_text[1] in (". "+key_phrases[0]+". \r", ". "+key_phrases[1]+". \r", ". "+en_key_phrases[0]+". \r", ". "+en_key_phrases[1]+". \r"):
if not conf.get("notify administrators in messages") and len(list_text) > 1 and list_text[1] in (", "+key_phrases[0]+". \r", ", "+key_phrases[1]+". \r", ", "+en_key_phrases[0]+". \r", ", "+en_key_phrases[1]+". \r"):
del list_text[1]
obj.name = "\n".join(list_text)
else:
Expand Down Expand Up @@ -1146,7 +1163,7 @@ def action(title, subtitle):
try:
# Add a label to unmute the microphone on a voice call
# Add a label to turn on the camera on a voice call
if obj.UIAAutomationId == "Audio" and obj.firstChild.name == "\ue720": obj.name = obj.next.next.name
if obj.UIAAutomationId == "Audio" and obj.firstChild.name == "\ue720": obj.name = obj.next.name
elif obj.UIAAutomationId == "Video" and obj.firstChild.name == "\ue963": obj.name = _("Enable video")
elif obj.UIAAutomationId == "Video" and obj.firstChild.name == "\ue964": obj.name = _("Disable video")
except: pass
Expand Down Expand Up @@ -1406,6 +1423,7 @@ def processing_of_answer_options_in_surveys(self, obj):
_("Right answer") # This is necessary for this phrase to appear in the translation dictionary
return f'{_("Right answer")+": " if processing_of_answer_options_in_surveys else ""}{obj.name}, '


# A timer that checks if the voice message has been converted to text
def waiting_for_recognition(self, obj):
interval = .5
Expand Down
10 changes: 10 additions & 0 deletions addon/doc/ar/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@

## قائمة التغييرات:

### الإصدار 5.0.0

* تم إصلاح مشكلة قراءة الرسائل في الدردشات مرتين.
* تم إصلاح مشكلة عدم عمل اختصار الانتقال إلى ملف تعريف الدردشة المفتوحة بشكل صحيح.
* تم إصلاح مشكلة عدم عمل اختصار فتح قائمة التنقل.
* تم حل جميع المشكلات المتعلقة بزر تفعيل/تعطيل الميكروفون في المحادثات الصوتية.
* تم إصلاح مشكلة في اللغة البولندية حيث تم حظر إدخال حرف بواسطة مجموعة ALT+C.
* تصحيح نطق عبارتي "المالك" و"المسؤول" في الرسائل.
* معالجة العديد من المشكلات البسيطة الأخرى.

### الإصدار 4.9.0

* تمت إضافة خيار لتغيير السلوك عند الضغط على السهم لأعلى في حقل تحرير رسالة فارغ. يمكنك الاختيار من بين الخيارات التالية: تنشيط وظيفة تحرير آخر رسالة مرسلة، أو نقل التركيز إلى الرسالة الأخيرة في الدردشة, أو عدم القيام بأي شيء.
Expand Down
Loading

0 comments on commit ba77290

Please sign in to comment.