Merge branch 'feature/4014_new_layout_notes_room' into 'develop'

Feature/4014 new layout notes room

See merge request bwmessenger/bundesmessenger/bundesmessenger-ios!80
This commit is contained in:
JanNiklas Grabowski
2023-01-27 10:18:50 +00:00
17 changed files with 169 additions and 67 deletions
+20 -5
View File
@@ -38,6 +38,7 @@ PODS:
- DTFoundation/Core
- DTFoundation/UIKit (1.7.18):
- DTFoundation/Core
- DTTJailbreakDetection (0.4.0)
- FLEX (4.5.0)
- FlowCommoniOS (1.12.2)
- GBDeviceInfo (7.1.0):
@@ -55,6 +56,9 @@ PODS:
- LoggerAPI (1.9.200):
- Logging (~> 1.1)
- Logging (1.4.0)
- MatomoTracker (7.4.1):
- MatomoTracker/Core (= 7.4.1)
- MatomoTracker/Core (7.4.1)
- MatrixSDK (0.24.7):
- MatrixSDK/Core (= 0.24.7)
- MatrixSDK/Core (0.24.7):
@@ -115,6 +119,7 @@ DEPENDENCIES:
- DSBottomSheet (~> 0.3)
- DSWaveformImage (~> 6.1.1)
- DTCoreText (~> 1.6.25)
- DTTJailbreakDetection (~> 0.4.0)
- FLEX (~> 4.5.0)
- FlowCommoniOS (~> 1.12.0)
- GBDeviceInfo (~> 7.1.0)
@@ -122,8 +127,9 @@ DEPENDENCIES:
- KeychainAccess (~> 4.2.2)
- KTCenterFlowLayout (~> 1.3.1)
- libPhoneNumber-iOS (~> 0.9.13)
- MatrixSDK (= 0.24.7)
- MatrixSDK/JingleCallStack (= 0.24.7)
- MatomoTracker (~> 7.4.1)
- MatrixSDK (from `https://dl-gitlab.example.com/bwmessenger/bundesmessenger/bundesmessenger-ios-sdk`, tag `v0.24.7_bwi_beta`)
- MatrixSDK/JingleCallStack (from `https://dl-gitlab.example.com/bwmessenger/bundesmessenger/bundesmessenger-ios-sdk`, tag `v0.24.7_bwi_beta`)
- OLMKit
- PostHog (~> 1.4.4)
- ReadMoreTextView (~> 3.0.1)
@@ -152,6 +158,7 @@ SPEC REPOS:
- DSWaveformImage
- DTCoreText
- DTFoundation
- DTTJailbreakDetection
- FLEX
- FlowCommoniOS
- GBDeviceInfo
@@ -165,7 +172,7 @@ SPEC REPOS:
- libPhoneNumber-iOS
- LoggerAPI
- Logging
- MatrixSDK
- MatomoTracker
- MatrixSDKCrypto
- OLMKit
- PostHog
@@ -190,14 +197,20 @@ EXTERNAL SOURCES:
AnalyticsEvents:
:branch: release/swift
:git: https://github.com/matrix-org/matrix-analytics-events.git
MatrixSDK:
:git: https://dl-gitlab.example.com/bwmessenger/bundesmessenger/bundesmessenger-ios-sdk
:tag: v0.24.7_bwi_beta
CHECKOUT OPTIONS:
AnalyticsEvents:
:commit: 53ad46ba1ea1ee8f21139dda3c351890846a202f
:git: https://github.com/matrix-org/matrix-analytics-events.git
MatrixSDK:
:git: https://dl-gitlab.example.com/bwmessenger/bundesmessenger/bundesmessenger-ios-sdk
:tag: v0.24.7_bwi_beta
SPEC CHECKSUMS:
AFNetworking: 7864c38297c79aaca1500c33288e429c3451fdce
AFNetworking: 3bd23d814e976cd148d7d44c3ab78017b744cd58
AnalyticsEvents: 0cc8cf52da2fd464a2f39b788a295988151116ce
BlueCryptor: b0aee3d9b8f367b49b30de11cda90e1735571c24
BlueECC: 0d18e93347d3ec6d41416de21c1ffa4d4cd3c2cc
@@ -207,6 +220,7 @@ SPEC CHECKSUMS:
DSWaveformImage: 3c718a0cf99291887ee70d1d0c18d80101d3d9ce
DTCoreText: ac297b565abd3b12390d33cd6e076d875f0c0a5e
DTFoundation: a53f8cda2489208cbc71c648be177f902ee17536
DTTJailbreakDetection: 5e356c5badc17995f65a83ed9483f787a0057b71
FLEX: e51461dd6f0bfb00643c262acdfea5d5d12c596b
FlowCommoniOS: ca92071ab526dc89905495a37844fd7e78d1a7f2
GBDeviceInfo: 5d62fa85bdcce3ed288d83c28789adf1173e4376
@@ -220,6 +234,7 @@ SPEC CHECKSUMS:
libPhoneNumber-iOS: 0a32a9525cf8744fe02c5206eb30d571e38f7d75
LoggerAPI: ad9c4a6f1e32f518fdb43a1347ac14d765ab5e3d
Logging: beeb016c9c80cf77042d62e83495816847ef108b
MatomoTracker: 24a846c9d3aa76933183fe9d47fd62c9efa863fb
MatrixSDK: 895929fad10b7ec9aa96d557403b44c5e3522211
MatrixSDKCrypto: 2bd9ca41b2c644839f4e680a64897d56b3f95392
OLMKit: da115f16582e47626616874e20f7bb92222c7a51
@@ -241,6 +256,6 @@ SPEC CHECKSUMS:
zxcvbn-ios: fef98b7c80f1512ff0eec47ac1fa399fc00f7e3c
ZXingObjC: fdbb269f25dd2032da343e06f10224d62f537bdb
PODFILE CHECKSUM: 56782e2abd382278b3c5b23824ca74994fd0a97e
PODFILE CHECKSUM: 869221f53222bc657fc29068c97625ccb2b82cb5
COCOAPODS: 1.11.3
+3
View File
@@ -560,3 +560,6 @@
// MARK: - Netiquette Menu
"bwi_settings_netiquette" = "Netiquette";
// MARK: - New Layout
"all_chats_edit_layout_show_personal_notes" = "Notizenraum anzeigen";
+3
View File
@@ -437,3 +437,6 @@
// MARK: - Netiquette Menu
"bwi_settings_netiquette" = "Rules of Communication";
// MARK: - New Layout
"all_chats_edit_layout_show_personal_notes" = "Show personal notes";
+4
View File
@@ -11,6 +11,10 @@ import Foundation
// swiftlint:disable function_parameter_count identifier_name line_length type_body_length
@objcMembers
public class BWIL10n: NSObject {
/// Notizenraum anzeigen
public static var allChatsEditLayoutShowPersonalNotes: String {
return BWIL10n.tr("Bwi", "all_chats_edit_layout_show_personal_notes")
}
/// Passwort vergessen?
public static var authForgotPassword: String {
return BWIL10n.tr("Bwi", "auth_forgot_password")
@@ -173,7 +173,17 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
}
- (NSArray<id<MXRoomSummaryProtocol>> *)allChatsRoomCellDataArray
{
return self.recentsListService.allChatsRoomListData.rooms;
// bwi: for personal notes room
NSMutableArray<id<MXRoomSummaryProtocol>> *filteredArray = [NSMutableArray arrayWithCapacity:self.recentsListService.allChatsRoomListData.rooms.count];
for ( id<MXRoomSummaryProtocol> object in self.recentsListService.allChatsRoomListData.rooms) {
MXRoom* room = [self.mxSession roomWithRoomId:object.roomId];
if (!room.isPersonalNotesRoom) {
[filteredArray addObject:object];
}
}
return filteredArray;
}
- (NSInteger)totalVisibleItemCount
@@ -229,6 +239,10 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
[types addObject:@(RecentsDataSourceSectionTypeBreadcrumbs)];
}
}
if (self.recentsListService.shouldShowBWIPersonalNotes) {
[types addObject:@(RecentsDataSourceSectionTypePersonalNotes)];
}
if (self.favoriteCellDataArray.count > 0 || _recentsDataSourceMode == RecentsDataSourceModeFavourites)
{
@@ -673,6 +687,10 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
{
count = self.allChatsRoomCellDataArray.count ?: 1;
}
else if (sectionType == RecentsDataSourceSectionTypePersonalNotes)
{
count = 1;
}
// Adjust this count according to the potential dragged cell.
if ([self isMovingCellSection:section])
@@ -696,7 +714,8 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
sectionType == RecentsDataSourceSectionTypeBreadcrumbs ||
(sectionType == RecentsDataSourceSectionTypeInvites && self.recentsDataSourceMode == RecentsDataSourceModeAllChats) ||
(sectionType == RecentsDataSourceSectionTypeAllChats && !self.allChatsFilterOptions.optionsCount) ||
(sectionType == RecentsDataSourceSectionTypeAllChats && self.currentSpace != nil && self.currentSpace.childRoomIds.count == 0))
(sectionType == RecentsDataSourceSectionTypeAllChats && self.currentSpace != nil && self.currentSpace.childRoomIds.count == 0) ||
sectionType == RecentsDataSourceSectionTypePersonalNotes )
{
return 0.0;
}
@@ -1236,6 +1255,11 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
summary = self.allChatsRoomCellDataArray[cellDataIndex];
}
}
else if (sectionType == RecentsDataSourceSectionTypePersonalNotes) {
PersonalNotesDefaultService* service = [[PersonalNotesDefaultService alloc] initWithMxSession:self.mxSession];
summary = [self.mxSession roomWithRoomId:[service personalNotesRoomId]].summary;
}
if (summary)
{
@@ -28,6 +28,7 @@ import Foundation
case serverNotice
case suggestedRooms
case breadcrumbs
case personalNotes
case searchedRoom
case allChats
case unknown
@@ -393,6 +393,10 @@ public class RecentsListService: NSObject, RecentsListServiceProtocol {
multicastDelegate.removeAllDelegates()
}
public var shouldShowBWIPersonalNotes: Bool {
return AllChatsLayoutSettingsManager.shared.allChatLayoutSettings.sections.contains(.bwiPersonalNotes)
}
// MARK: - Riot Settings Observer
private func addRiotSettingsObserver() {
@@ -232,4 +232,8 @@ public class MockRecentsListService: NSObject, RecentsListServiceProtocol {
public func stopUncompletedVoiceBroadcastIfNeeded(for listData: MatrixSDK.MXRoomListData?) {
// nothing here
}
public var shouldShowBWIPersonalNotes: Bool {
return true
}
}
@@ -110,4 +110,7 @@ public protocol RecentsListServiceProtocol {
/// Remove all delegates
func removeAllDelegates()
// bwi: should personal notes room be shown
var shouldShowBWIPersonalNotes: Bool { get }
}
@@ -28,14 +28,27 @@ class AllChatsActionProvider {
// MARK: - RoomActionProviderProtocol
var menu: UIMenu {
return UIMenu(title: "", children: [
self.recentsAction,
self.filtersAction,
UIMenu(title: "", options: .displayInline, children: [
activityOrderAction,
alphabeticalOrderAction
if BWIBuildSettings.shared.bwiPersonalNotesRoom {
return UIMenu(title: "", children: [
self.recentsAction,
self.bwiPersonalNotesAction,
self.filtersAction,
UIMenu(title: "", options: .displayInline, children: [
activityOrderAction,
alphabeticalOrderAction
])
])
])
} else {
return UIMenu(title: "", children: [
self.recentsAction,
self.filtersAction,
UIMenu(title: "", options: .displayInline, children: [
activityOrderAction,
alphabeticalOrderAction
])
])
}
}
// MARK: - Private
@@ -46,7 +59,7 @@ class AllChatsActionProvider {
discoverabilityTitle: VectorL10n.allChatsEditLayoutShowRecents,
state: AllChatsLayoutSettingsManager.shared.allChatLayoutSettings.sections.contains(.recents) ? .on : .off) { action in
let settings = AllChatsLayoutSettingsManager.shared.allChatLayoutSettings
let newSettings = AllChatsLayoutSettings(sections: action.state == .on ? [] : .recents,
let newSettings = AllChatsLayoutSettings(sections: AllChatsLayoutSettingsManager.shared.sectionsFor(recents: action.state != .on, personalNotes: settings.sections.contains(.bwiPersonalNotes)),
filters: settings.filters,
sorting: settings.sorting)
AllChatsLayoutSettingsManager.shared.allChatLayoutSettings = newSettings
@@ -54,6 +67,19 @@ class AllChatsActionProvider {
}
}
private var bwiPersonalNotesAction: UIAction {
return UIAction(title: BWIL10n.allChatsEditLayoutShowPersonalNotes,
image: UIImage(systemName: "square.and.pencil")?.withRenderingMode(.alwaysTemplate),
discoverabilityTitle: BWIL10n.allChatsEditLayoutShowPersonalNotes,
state: AllChatsLayoutSettingsManager.shared.allChatLayoutSettings.sections.contains(.bwiPersonalNotes) ? .on : .off) { action in
let settings = AllChatsLayoutSettingsManager.shared.allChatLayoutSettings
let newSettings = AllChatsLayoutSettings(sections: AllChatsLayoutSettingsManager.shared.sectionsFor(recents: settings.sections.contains(.recents), personalNotes: action.state != .on),
filters: settings.filters,
sorting: settings.sorting)
AllChatsLayoutSettingsManager.shared.allChatLayoutSettings = newSettings
}
}
private var filtersAction: UIAction {
return UIAction(title: VectorL10n.allChatsEditLayoutShowFilters,
image: UIImage(systemName: "bubble.right")?.withRenderingMode(.alwaysTemplate),
@@ -141,7 +141,7 @@ class AllChatsEditActionProvider {
private var createRoomAction: UIAction {
UIAction(title: parentSpace == nil ? VectorL10n.roomRecentsCreateEmptyRoom : VectorL10n.spacesAddRoom,
image: UIImage(systemName: "number"),
image: UIImage(systemName: "person.3"),
attributes: isAddRoomAvailable ? [] : .disabled) { [weak self] action in
guard let self = self else { return }
@@ -19,7 +19,8 @@
typedef NS_OPTIONS(NSUInteger, AllChatsLayoutSectionType) {
AllChatsLayoutSectionTypeRecents = 1 << 0,
AllChatsLayoutSectionTypeFavourites = 1 << 1
AllChatsLayoutSectionTypeFavourites = 1 << 1,
AllChatsLayoutSectionTypeBWIPersonalNotes = 1 << 2
};
typedef NS_OPTIONS(NSUInteger, AllChatsLayoutFilterType) {
@@ -16,6 +16,8 @@
import Foundation
// bwi: we use an additional section and have specific settings we want to apply on first start of the app
@objcMembers
class AllChatsLayoutSettings: NSObject, NSCoding {
@@ -31,10 +33,21 @@ class AllChatsLayoutSettings: NSObject, NSCoding {
init(sections: AllChatsLayoutSectionType = [],
filters: AllChatsLayoutFilterType = [],
sorting: AllChatsLayoutSortingType = .activity) {
self.sections = sections
self.filters = filters
self.sorting = sorting
sorting: AllChatsLayoutSortingType = .activity) {
if !UserDefaults.standard.bool(forKey: "FirstStartWithNewSettings") {
if PersonalNotesSettings().personalNotesVisible && BWIBuildSettings.shared.bwiPersonalNotesRoom {
self.sections = [.bwiPersonalNotes]
} else {
self.sections = []
}
self.filters = [.unreads, .favourites, .people]
self.sorting = .activity
UserDefaults.standard.set(true, forKey: "FirstStartWithNewSettings")
} else {
self.sections = sections
self.filters = filters
self.sorting = sorting
}
}
func encode(with coder: NSCoder) {
@@ -44,18 +57,20 @@ class AllChatsLayoutSettings: NSObject, NSCoding {
}
required init?(coder: NSCoder) {
self.sections = AllChatsLayoutSectionType(rawValue: UInt(coder.decodeInteger(forKey: Constants.sectionsKey)))
// bwi: per default filters should be on in our environments -> If there is no key
if BWIBuildSettings.shared.filtersActiveByDefault {
if coder.containsValue(forKey: Constants.filtersKey) {
self.filters = AllChatsLayoutFilterType(rawValue: UInt(coder.decodeInteger(forKey: Constants.filtersKey)))
// bwi: there are cases when only init with coder is called, so use our first start settings here, too
if !UserDefaults.standard.bool(forKey: "FirstStartWithNewSettings") {
if PersonalNotesSettings().personalNotesVisible && BWIBuildSettings.shared.bwiPersonalNotesRoom {
self.sections = [.bwiPersonalNotes]
} else {
self.filters = [.unreads, .favourites, .people]
self.sections = []
}
self.filters = [.unreads, .favourites, .people]
self.sorting = .activity
UserDefaults.standard.set(true, forKey: "FirstStartWithNewSettings")
} else {
self.sections = AllChatsLayoutSectionType(rawValue: UInt(coder.decodeInteger(forKey: Constants.sectionsKey)))
self.filters = AllChatsLayoutFilterType(rawValue: UInt(coder.decodeInteger(forKey: Constants.filtersKey)))
self.sorting = AllChatsLayoutSortingType(rawValue: UInt(coder.decodeInteger(forKey: Constants.sortingKey))) ?? .activity
}
self.sorting = AllChatsLayoutSortingType(rawValue: UInt(coder.decodeInteger(forKey: Constants.sortingKey))) ?? .activity
}
}
@@ -72,7 +72,15 @@ final class AllChatsLayoutSettingsManager: NSObject {
var allChatLayoutSettings: AllChatsLayoutSettings {
get {
guard let data = RiotSettings.defaults.data(forKey: Constants.settingsKey) else {
return AllChatsLayoutSettings()
// bwi: setup AllChatsLayout and save it in UserDefaults if not already saved
let newSettings = AllChatsLayoutSettings()
guard let data = try? NSKeyedArchiver.archivedData(withRootObject: newSettings, requiringSecureCoding: false) else {
MXLog.warning("[AllChatsLayoutSettingsManager] set allChatLayoutSettings: failed to archive settings")
return newSettings
}
RiotSettings.defaults.set(data, forKey: Constants.settingsKey)
return newSettings
}
do {
@@ -110,6 +118,18 @@ final class AllChatsLayoutSettingsManager: NSObject {
return !allChatLayoutSettings.filters.isEmpty && !activeFilters.isEmpty && activeFilters != .all
}
func sectionsFor( recents: Bool, personalNotes: Bool) -> AllChatsLayoutSectionType {
if recents && personalNotes {
return [.recents, .bwiPersonalNotes]
} else if recents {
return [.recents]
} else if personalNotes {
return [.bwiPersonalNotes]
} else {
return []
}
}
// MARK: - Private
private func track(activeFilters: AllChatsLayoutFilterType?) {
@@ -283,7 +283,8 @@ class AllChatsViewController: HomeViewController {
RecentsDataSourceSectionType.lowPriority.rawValue,
RecentsDataSourceSectionType.serverNotice.rawValue,
RecentsDataSourceSectionType.suggestedRooms.rawValue,
RecentsDataSourceSectionType.breadcrumbs.rawValue
RecentsDataSourceSectionType.breadcrumbs.rawValue,
RecentsDataSourceSectionType.personalNotes.rawValue
]
}
@@ -141,10 +141,15 @@
self.accessibilityLabel = accessibilityLabel;
[self.roomAvatar vc_setRoomAvatarImageWith:roomCellData.avatarUrl
roomId:roomCellData.roomIdentifier
displayName:roomCellData.roomDisplayname
mediaManager:roomCellData.mxSession.mediaManager];
PersonalNotesDefaultService *service = [[PersonalNotesDefaultService alloc] initWithMxSession:roomCellData.mxSession];
if (BWIBuildSettings.shared.bwiUseCustomPersonalNotesAvatar && [roomCellData.roomIdentifier isEqualToString:[service personalNotesRoomId]]) {
self.roomAvatar.image = [UIImage imageNamed:[service avatarImageUrl]];
} else {
[self.roomAvatar vc_setRoomAvatarImageWith:roomCellData.avatarUrl
roomId:roomCellData.roomIdentifier
displayName:roomCellData.roomDisplayname
mediaManager:roomCellData.mxSession.mediaManager];
}
if (roomCellData.directUserId)
{
+5 -32
View File
@@ -159,7 +159,6 @@ typedef NS_ENUM(NSUInteger, USER_INTERFACE)
{
//USER_INTERFACE_LANGUAGE_INDEX = 0,
USER_INTERFACE_THEME_INDEX = 0,
USER_INTERFACE_PERSONAL_NOTES,
TIMELINE_SIMPLE_INDEX,
TIMELINE_TIMESTAMP_INDEX,
TIMELINE_DELETED_MESSAGES_INDEX,
@@ -626,10 +625,6 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
[sectionUserInterface addRowWithTag:USER_INTERFACE_THEME_INDEX];
sectionUserInterface = [self updateTimeLine:sectionUserInterface];
[tmpSections addObject: sectionUserInterface];
if (BWIBuildSettings.shared.bwiPersonalNotesRoom) {
[sectionUserInterface addRowWithTag:USER_INTERFACE_PERSONAL_NOTES];
}
if (BWIBuildSettings.shared.bwiShowTimelineSettings) {
Section *sectionTimeline = [Section sectionWithTag:SECTION_TAG_TIMELINE];
@@ -2454,26 +2449,24 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kSettingsViewControllerPhoneBookCountryCellId];
}
NSString *theme = RiotSettings.shared.userInterfaceTheme;
if (!theme)
{
theme = @"auto";
}
theme = [NSString stringWithFormat:@"settings_ui_theme_%@", theme];
NSString *i18nTheme = NSLocalizedStringFromTable(theme, @"Vector", nil);
cell.textLabel.textColor = ThemeService.shared.theme.textPrimaryColor;
cell.textLabel.text = [VectorL10n settingsUiTheme];
cell.detailTextLabel.text = i18nTheme;
[cell vc_setAccessoryDisclosureIndicatorWithCurrentTheme];
cell.selectionStyle = UITableViewCellSelectionStyleDefault;
} else if (row == USER_INTERFACE_PERSONAL_NOTES) {
cell = [self cellForPersonalNotes:tableView indexPath:indexPath];
} else if (row == USER_INTERFACE_TIMELINE_STYLE_INDEX)
{
cell = [self buildMessageBubblesCellForTableView:tableView atIndexPath:indexPath];
@@ -5149,26 +5142,6 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
#pragma mark - bwi Messenger Additions
- (UITableViewCell*) cellForPersonalNotes:(UITableView*)tableView indexPath:(NSIndexPath*)indexPath {
MXKTableViewCellWithLabelAndSwitch* labelAndSwitchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath];
PersonalNotesSettings *settings = [[PersonalNotesSettings alloc] init];
labelAndSwitchCell.mxkLabel.text = BWIL10n.bwiSettingsEnableNotesRoomTitle;
labelAndSwitchCell.mxkSwitch.on = settings.personalNotesVisible;
labelAndSwitchCell.mxkSwitch.onTintColor = ThemeService.shared.theme.tintColor;
labelAndSwitchCell.mxkSwitch.enabled = YES;
[labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(togglePersonalNotesService:) forControlEvents:UIControlEventTouchUpInside];
return labelAndSwitchCell;
}
- (void)togglePersonalNotesService:(UISwitch*)theSwitch
{
PersonalNotesSettings *settings = [[PersonalNotesSettings alloc] init];
settings.personalNotesVisible = theSwitch.isOn;
}
- (NSString*) bwiDowntimeCellText {
NSString *downtimeText = [NSString stringWithFormat:@"\n%@\n\n", [[[ServerDowntimeDefaultService alloc] init] downtimeText]];
return downtimeText;