Skip to content

Commit

Permalink
6.0.2rc2 (#980)
Browse files Browse the repository at this point in the history
Features:
- Improve login error messages
- Blacklist cheogram.com for omemo

Fixes:
- Fix several crashes
- Fix log export
  • Loading branch information
tmolitor-stud-tu authored Dec 15, 2023
2 parents 7cec7a6 + 22b3898 commit 05f2e17
Show file tree
Hide file tree
Showing 32 changed files with 716 additions and 483 deletions.
3 changes: 3 additions & 0 deletions Monal/Classes/ActiveChatsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ -(void) configureComposeButton
buttonWithNotificationBadgeForImage:composeImage
hasNotification:[[DataLayer sharedInstance] allContactRequests].count > 0
withTapHandler:composeTapRecoginzer];
[self.composeButton.customView setIsAccessibilityElement:YES];
[self.composeButton.customView setAccessibilityLabel:@"Open contacts list"];
}

-(void) viewDidLoad
Expand Down Expand Up @@ -119,6 +121,7 @@ -(void) viewDidLoad
[self configureComposeButton];

UIBarButtonItem* spinnerButton = [[UIBarButtonItem alloc] initWithCustomView:self.spinner];
[spinnerButton setIsAccessibilityElement:NO];
[self.navigationItem setRightBarButtonItems:@[self.composeButton, spinnerButton] animated:NO];

self.chatListTable.emptyDataSetSource = self;
Expand Down
18 changes: 10 additions & 8 deletions Monal/Classes/ContactDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct ContactDetails: View {
//.buttonStyle(BorderlessButtonStyle())

#if !DISABLE_OMEMO
if(!contact.isGroup || (contact.isGroup && contact.mucType == "group")) {
if((!contact.isGroup || (contact.isGroup && contact.mucType == "group")) && !HelperTools.isContactBlacklisted(forEncryption:contact.obj)) {
Button(action: {
if(contact.isEncrypted) {
showingShouldDisableEncryptionAlert = true
Expand Down Expand Up @@ -127,13 +127,15 @@ struct ContactDetails: View {
}
}
#if !DISABLE_OMEMO
if(!contact.isGroup) {
NavigationLink(destination: LazyClosureView(OmemoKeys(contact: contact))) {
contact.isSelfChat ? Text("Own Encryption Keys") : Text("Encryption Keys")
}
} else if(contact.mucType == "group") {
NavigationLink(destination: LazyClosureView(OmemoKeys(contact: contact))) {
Text("Encryption Keys")
if(!HelperTools.isContactBlacklisted(forEncryption:contact.obj)) {
if(!contact.isGroup) {
NavigationLink(destination: LazyClosureView(OmemoKeys(contact: contact))) {
contact.isSelfChat ? Text("Own Encryption Keys") : Text("Encryption Keys")
}
} else if(contact.mucType == "group") {
NavigationLink(destination: LazyClosureView(OmemoKeys(contact: contact))) {
Text("Encryption Keys")
}
}
}
#endif
Expand Down
83 changes: 0 additions & 83 deletions Monal/Classes/ContactList.swift

This file was deleted.

113 changes: 113 additions & 0 deletions Monal/Classes/ContactPicker.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
//
// ContactList.swift
// Monal
//
// Created by Jan on 15.12.22.
// Copyright © 2022 monal-im.org. All rights reserved.
//

import SwiftUI
import monalxmpp
import OrderedCollections

struct ContactEntry: View { // TODO move
let contact : MLContact

var body:some View {
ZStack(alignment: .topLeading) {
HStack(alignment: .center) {
Image(uiImage: contact.avatar)
.resizable()
.frame(width: 40, height: 40, alignment: .center)
VStack(alignment: .leading) {
Text(contact.contactDisplayName as String)
Text(contact.contactJid as String).font(.footnote).opacity(0.6)
}
}
}
}
}

struct ContactPickerEntry: View {
let contact : MLContact
let isPicked: Bool

var body:some View {
ZStack(alignment: .topLeading) {
HStack(alignment: .center) {
if(isPicked) {
Image(systemName: "checkmark.circle")
.foregroundColor(.blue)
} else {
Image(systemName: "circle")
}
Image(uiImage: contact.avatar)
.resizable()
.frame(width: 40, height: 40, alignment: .center)
VStack(alignment: .leading) {
Text(contact.contactDisplayName as String)
Text(contact.contactJid as String).font(.footnote).opacity(0.6)
}
}
}
}
}

struct ContactPicker: View {
@Environment(\.presentationMode) private var presentationMode

let contacts : [MLContact]
@Binding var selectedContacts : OrderedSet<MLContact> // already selected when going into the view
@State var searchFieldInput = ""

func matchesSearch(contact : MLContact) -> Bool {
// TODO better lookup
if searchFieldInput.isEmpty == true {
return true
} else {
return contact.contactDisplayName.lowercased().contains(searchFieldInput.lowercased()) ||
contact.contactJid.contains(searchFieldInput.lowercased())
}
}

var body: some View {
if(contacts.isEmpty) {
Text("No contacts to show :(")
.navigationTitle("Contact Lists")
} else {
List {
Section {
TextField("Search contacts", text: $searchFieldInput)
}
ForEach(Array(contacts.enumerated()), id: \.element) { idx, contact in
if matchesSearch(contact: contact) {
let contactIsSelected = self.selectedContacts.contains(contact);
ContactPickerEntry(contact: contact, isPicked: contactIsSelected)
.onTapGesture(perform: {
if(contactIsSelected) {
self.selectedContacts.remove(contact)
} else {
self.selectedContacts.append(contact)
}
})
}
}
}
.listStyle(.inset)
.navigationBarTitle("Contact Selection", displayMode: .inline)
.navigationBarBackButtonHidden(true)
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
Button("Back", action: {
self.presentationMode.wrappedValue.dismiss()
})
}
}
}
}

init(selectedContacts: Binding<OrderedSet<MLContact>>) {
self._selectedContacts = selectedContacts
self.contacts = DataLayer.sharedInstance().contactList() as! [MLContact]
}
}
3 changes: 3 additions & 0 deletions Monal/Classes/ContactsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ -(void) configureContactRequestsImage
buttonWithNotificationBadgeForImage:requestsImage
hasNotification:[[DataLayer sharedInstance] allContactRequests].count > 0
withTapHandler:requestsTapRecoginzer];
[self.navigationItem.rightBarButtonItems[1] setIsAccessibilityElement:YES];
[self.navigationItem.rightBarButtonItems[1] setAccessibilityLabel:@"Open contacts list"];

}

#pragma mark view life cycle
Expand Down
25 changes: 19 additions & 6 deletions Monal/Classes/CreateGroupMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import MobileCoreServices
import UniformTypeIdentifiers
import SwiftUI
import monalxmpp
import OrderedCollections

struct CreateGroupMenu: View {
var delegate: SheetDismisserProtocol
Expand All @@ -21,10 +22,10 @@ struct CreateGroupMenu: View {
@State private var showAlert = false
// note: dismissLabel is not accessed but defined at the .alert() section
@State private var alertPrompt = AlertPrompt(dismissLabel: Text("Close"))
@State private var selectedContacts : OrderedSet<MLContact> = []

@ObservedObject private var overlay = LoadingOverlayState()

@State private var showQRCodeScanner = false
@State private var success = false

private let dismissWithNewGroup: (MLContact) -> ()
Expand Down Expand Up @@ -82,14 +83,26 @@ struct CreateGroupMenu: View {
.autocapitalization(.none)
.addClearButton(text:$groupName)

NavigationLink(destination: LazyClosureView(ContactList(contacts: DataLayer.sharedInstance().contactList() as! [MLContact])), label: {
NavigationLink(destination: LazyClosureView(ContactPicker(selectedContacts: $selectedContacts)), label: {
Text("Group Members")
})
}
Section {
Button(action: {}, label: {
Text("Create new group")
})
if(self.selectedContacts.count > 0) {
Section(header: Text("Selected Group Members")) {
ForEach(self.selectedContacts, id: \.contactJid) { contact in
ContactEntry(contact: contact)
}
.onDelete(perform: { indexSet in
self.selectedContacts.remove(at: indexSet.first!)
})
}
Section {
Button(action: {

}, label: {
Text("Create new group")
})
}
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions Monal/Classes/HelperTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
@class XMPPStanza;
@class UNNotificationRequest;
@class DDLogMessage;
@class MLFileLogger;
@class DDFileLogger;
@class UIView;
@class UITapGestureRecognizer;

Expand All @@ -37,7 +37,7 @@ void swizzle(Class c, SEL orig, SEL new);

@interface HelperTools : NSObject

@property (class, nonatomic, strong) MLFileLogger* fileLogger;
@property (class, nonatomic, strong) DDFileLogger* fileLogger;

+(NSData* _Nullable) convertLogmessageToJsonData:(DDLogMessage*) logMessage counter:(uint64_t*) counter andError:(NSError** _Nullable) error;
+(void) initSystem;
Expand Down Expand Up @@ -84,6 +84,7 @@ void swizzle(Class c, SEL orig, SEL new);
+(NSString*) stringFromToken:(NSData*) tokenIn;
+(void) configureFileProtection:(NSString*) protectionLevel forFile:(NSString*) file;
+(void) configureFileProtectionFor:(NSString*) file;
+(BOOL) isContactBlacklistedForEncryption:(MLContact*) contact;
+(NSDictionary<NSString*, NSString*>*) splitJid:(NSString*) jid;

+(void) scheduleBackgroundTask:(BOOL) force;
Expand Down
Loading

0 comments on commit 05f2e17

Please sign in to comment.