Merge branch 'feature/4802_personal_notes_redesign' into 'develop'

MESSENGER-4802 personal notes in favorites

See merge request bwmessenger/bundesmessenger/bundesmessenger-ios!203
This commit is contained in:
Frank Rotermund
2023-09-07 12:53:46 +00:00
13 changed files with 60 additions and 71 deletions

View File

@@ -136,7 +136,6 @@ class BWIBuildSettings: NSObject {
var bwiAutoCreateAliasOnRoomCreation = true
var bwiLocationShareButtonVisible = false
var bwiUseCustomPersonalNotesAvatar = true
var bwiBetterIgnoredUsers = true
var bwiSettingsShowInAppNotifications = false
var bwiFilteredContextMenu = true
@@ -530,6 +529,9 @@ class BWIBuildSettings: NSObject {
var bwiPersonalNotesRoom = false
var bwiPersonalNotesRoomLeavable = false
var bwiResetPersonalNotesAccountData = false
var bwiUseCustomPersonalNotesAvatar = true
var bwiPersonalNotesRoomAsFavorite = true
var bwiShowTimelineSettings = false
// MARK BWI personal state

Binary file not shown.

Before

Width:  |  Height:  |  Size: 213 KiB

View File

@@ -9,7 +9,7 @@
"scale" : "2x"
},
{
"filename" : "BWI-noticeboard.png",
"filename" : "Notizen-Avatar.svg",
"idiom" : "universal",
"scale" : "3x"
}

View File

@@ -0,0 +1,4 @@
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="16" cy="16" r="16" fill="#DEBB6B"/>
<path d="M13.5 20.7913H18.5C18.6771 20.7913 18.8255 20.7314 18.9453 20.6116C19.0651 20.4917 19.125 20.3432 19.125 20.166C19.125 19.9889 19.0651 19.8405 18.9453 19.7208C18.8255 19.6012 18.6771 19.5413 18.5 19.5413H13.5C13.3229 19.5413 13.1745 19.6013 13.0547 19.7211C12.9349 19.8409 12.875 19.9894 12.875 20.1666C12.875 20.3438 12.9349 20.4922 13.0547 20.6118C13.1745 20.7315 13.3229 20.7913 13.5 20.7913ZM13.5 17.458H18.5C18.6771 17.458 18.8255 17.3981 18.9453 17.2782C19.0651 17.1584 19.125 17.0099 19.125 16.8327C19.125 16.6556 19.0651 16.5071 18.9453 16.3875C18.8255 16.2678 18.6771 16.208 18.5 16.208H13.5C13.3229 16.208 13.1745 16.2679 13.0547 16.3878C12.9349 16.5076 12.875 16.6561 12.875 16.8333C12.875 17.0104 12.9349 17.1588 13.0547 17.2785C13.1745 17.3981 13.3229 17.458 13.5 17.458ZM11.2564 23.9163C10.8355 23.9163 10.4792 23.7705 10.1875 23.4788C9.89583 23.1871 9.75 22.8308 9.75 22.4099V9.58942C9.75 9.16848 9.89583 8.81217 10.1875 8.52051C10.4792 8.22884 10.8355 8.08301 11.2564 8.08301H17.2516C17.4548 8.08301 17.6485 8.12201 17.8327 8.20001C18.0169 8.27799 18.1773 8.38536 18.3141 8.52211L21.8109 12.0189C21.9476 12.1556 22.055 12.3161 22.133 12.5003C22.211 12.6844 22.25 12.8781 22.25 13.0814V22.4099C22.25 22.8308 22.1041 23.1871 21.8125 23.4788C21.5208 23.7705 21.1645 23.9163 20.7435 23.9163H11.2564ZM17.25 12.333V9.33299H11.2564C11.1923 9.33299 11.1335 9.3597 11.0801 9.41311C11.0267 9.46654 11 9.52531 11 9.58942V22.4099C11 22.474 11.0267 22.5328 11.0801 22.5862C11.1335 22.6396 11.1923 22.6663 11.2564 22.6663H20.7435C20.8077 22.6663 20.8664 22.6396 20.9199 22.5862C20.9733 22.5328 21 22.474 21 22.4099V13.083H17.9999C17.7874 13.083 17.6093 13.0111 17.4656 12.8673C17.3219 12.7236 17.25 12.5455 17.25 12.333Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -429,6 +429,7 @@
"bwi_settings_enable_notes_room_title" = "Zeige meine Notizen";
"bwi_settings_enable_notes_room_summary" = "Einen Raum für private Notizen anzeigen";
"bwi_notes_room_title" = "Meine Notizen";
"home_context_menu_personal_notes" = "Notizen ausblenden";
// MARK: - Personal State

View File

@@ -342,6 +342,7 @@
"bwi_settings_enable_notes_room_title" = "My notes";
"bwi_settings_enable_notes_room_summary" = "how personal notes room.";
"bwi_notes_room_title" = "My notes";
"home_context_menu_personal_notes" = "Hide notes";
// MARK: - Personal State

View File

@@ -129,23 +129,8 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
}
- (NSArray<id<MXRoomSummaryProtocol>> *)favoriteCellDataArray
{
// bwi: for personal notes room
NSMutableArray<id<MXRoomSummaryProtocol>> *filteredArray = [NSMutableArray arrayWithArray:self.recentsListService.favoritedRoomListData.rooms];
if( _recentsDataSourceMode == RecentsDataSourceModeFavourites) {
PersonalNotesDefaultService *service = [[PersonalNotesDefaultService alloc] initWithMxSession:self.mxSession];
PersonalNotesSettings *settings = [[PersonalNotesSettings alloc] init];
if ([service personalNotesRoomId] && settings.personalNotesVisible) {
MXRoom* room = [self.mxSession roomWithRoomId:[service personalNotesRoomId]];
if (room) {
MXRoomSummary *summary = [self.mxSession roomSummaryWithRoomId:[service personalNotesRoomId]];
[filteredArray insertObject:summary atIndex:0];
}
}
}
return filteredArray;
// bwi #4802: for personal notes room
return [self filteredRoomCellDataArray:self.recentsListService.favoritedRoomListData.rooms];
}
- (NSArray<id<MXRoomSummaryProtocol>> *)peopleCellDataArray
{
@@ -153,17 +138,8 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
}
- (NSArray<id<MXRoomSummaryProtocol>> *)conversationCellDataArray
{
// bwi: for personal notes room
NSMutableArray<id<MXRoomSummaryProtocol>> *filteredArray = [NSMutableArray arrayWithCapacity:self.recentsListService.conversationRoomListData.rooms.count];
for ( id<MXRoomSummaryProtocol> object in self.recentsListService.conversationRoomListData.rooms) {
MXRoom* room = [self.mxSession roomWithRoomId:object.roomId];
if (!room.isPersonalNotesRoom) {
[filteredArray addObject:object];
}
}
return filteredArray;
// bwi #4802: for personal notes room
return [self filteredRoomCellDataArray:self.recentsListService.conversationRoomListData.rooms];
}
- (NSArray<id<MXRoomSummaryProtocol>> *)lowPriorityCellDataArray
{
@@ -179,26 +155,28 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
}
- (NSArray<id<MXRoomSummaryProtocol>> *)breadcrumbsRoomCellDataArray
{
// bwi: for personal notes room
NSMutableArray<id<MXRoomSummaryProtocol>> *filteredArray = [NSMutableArray arrayWithCapacity:self.recentsListService.breadcrumbsRoomListData.rooms.count];
for ( id<MXRoomSummaryProtocol> object in self.recentsListService.breadcrumbsRoomListData.rooms) {
MXRoom* room = [self.mxSession roomWithRoomId:object.roomId];
if (!room.isPersonalNotesRoom) {
[filteredArray addObject:object];
}
}
return filteredArray;
// bwi #4802: for personal notes room
return [self filteredRoomCellDataArray:self.recentsListService.breadcrumbsRoomListData.rooms];
}
- (NSArray<id<MXRoomSummaryProtocol>> *)allChatsRoomCellDataArray
{
// bwi: for personal notes room
NSMutableArray<id<MXRoomSummaryProtocol>> *filteredArray = [NSMutableArray arrayWithCapacity:self.recentsListService.allChatsRoomListData.rooms.count];
// bwi #4802: for personal notes room
return [self filteredRoomCellDataArray:self.recentsListService.allChatsRoomListData.rooms];
}
- (NSArray<id<MXRoomSummaryProtocol>> *)filteredRoomCellDataArray:(NSArray<id<MXRoomSummaryProtocol>> *)arrayToFilter {
// bwi: #4802 for personal notes room
NSMutableArray<id<MXRoomSummaryProtocol>> *filteredArray = [NSMutableArray arrayWithCapacity:arrayToFilter.count];
for ( id<MXRoomSummaryProtocol> object in self.recentsListService.allChatsRoomListData.rooms) {
PersonalNotesSettings *settings = [[PersonalNotesSettings alloc] init];
for ( id<MXRoomSummaryProtocol> object in arrayToFilter) {
MXRoom* room = [self.mxSession roomWithRoomId:object.roomId];
if (!room.isPersonalNotesRoom) {
if (room.isPersonalNotesRoom ) {
if (settings.personalNotesVisible && BWIBuildSettings.shared.bwiPersonalNotesRoom) {
[filteredArray addObject:object];
}
} else {
[filteredArray addObject:object];
}
}
@@ -265,9 +243,6 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
}
}
if (self.recentsListService.shouldShowBWIPersonalNotes) {
[types addObject:@(RecentsDataSourceSectionTypePersonalNotes)];
}
if (self.favoriteCellDataArray.count > 0 || _recentsDataSourceMode == RecentsDataSourceModeFavourites)
{
@@ -716,10 +691,6 @@ 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])
@@ -744,7 +715,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
(sectionType == RecentsDataSourceSectionTypeInvites && self.recentsDataSourceMode == RecentsDataSourceModeAllChats) ||
(sectionType == RecentsDataSourceSectionTypeAllChats && !self.allChatsFilterOptions.optionsCount) ||
(sectionType == RecentsDataSourceSectionTypeAllChats && self.currentSpace != nil && self.currentSpace.childRoomIds.count == 0) ||
sectionType == RecentsDataSourceSectionTypePersonalNotes || sectionType == RecentsDataSourceSectionTypeFeatureBanner)
sectionType == RecentsDataSourceSectionTypeFeatureBanner)
{
return 0.0;
}
@@ -1284,11 +1255,6 @@ 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)
{

View File

@@ -28,7 +28,6 @@ import Foundation
case serverNotice
case suggestedRooms
case breadcrumbs
case personalNotes
case searchedRoom
case allChats
case unknown

View File

@@ -148,6 +148,10 @@ class AllChatsCoordinator: NSObject, SplitViewMasterCoordinatorProtocol {
self.bwiCheckForMatomoPromt()
BWIAnalytics.sharedTracker.readUserConfig()
if BWIBuildSettings.shared.bwiPersonalNotesRoom {
self.bwiCheckForPersonalNotesRoom()
}
}
func bwiOnUnlockedByPin() {
@@ -301,10 +305,6 @@ class AllChatsCoordinator: NSObject, SplitViewMasterCoordinatorProtocol {
private func addMatrixSessionToAllChatsController(_ matrixSession: MXSession) {
MXLog.debug("[TabBarCoordinator] masterTabBarController.addMatrixSession")
self.allChatsViewController.addMatrixSession(matrixSession)
if BWIBuildSettings.shared.bwiPersonalNotesRoom {
self.bwiCheckForPersonalNotesRoom()
}
}
// TODO: Remove Matrix session handling from the view controller
@@ -712,6 +712,7 @@ class AllChatsCoordinator: NSObject, SplitViewMasterCoordinatorProtocol {
}
service.createPersonalNotesRoomIfNeeded()
service.setAsFavoriteIfNeeded()
}
}
@@ -783,6 +784,10 @@ extension AllChatsCoordinator: AllChatsViewControllerDelegate {
self.bwiCheckForMatomoPromt()
BWIAnalytics.sharedTracker.resetMatomo()
if BWIBuildSettings.shared.bwiPersonalNotesRoom {
self.bwiCheckForPersonalNotesRoom()
}
}
func allChatsViewController(_ allChatsViewController: AllChatsViewController, didSelectRoomWithParameters roomNavigationParameters: RoomNavigationParameters, completion: @escaping () -> Void) {

View File

@@ -405,7 +405,6 @@ class AllChatsViewController: HomeViewController {
RecentsDataSourceSectionType.serverNotice.rawValue,
RecentsDataSourceSectionType.suggestedRooms.rawValue,
RecentsDataSourceSectionType.breadcrumbs.rawValue,
RecentsDataSourceSectionType.personalNotes.rawValue,
RecentsDataSourceSectionType.featureBanner.rawValue
]
}

View File

@@ -398,7 +398,6 @@
|| (sectionType == RecentsDataSourceSectionTypePeople && !recentsDataSource.recentsListService.peopleRoomListData.counts.numberOfRooms)
|| (sectionType == RecentsDataSourceSectionTypeSecureBackupBanner)
|| (sectionType == RecentsDataSourceSectionTypeCrossSigningBanner)
|| (sectionType == RecentsDataSourceSectionTypePersonalNotes)
)
{
return [recentsDataSource tableView:tableView cellForRowAtIndexPath:indexPath];
@@ -502,8 +501,7 @@
RecentsDataSourceSectionType sectionType = [recentsDataSource.sections sectionTypeForSectionIndex:indexPath.section];
if ((sectionType == RecentsDataSourceSectionTypeConversation && !recentsDataSource.recentsListService.conversationRoomListData.counts.numberOfRooms)
|| (sectionType == RecentsDataSourceSectionTypePeople && !recentsDataSource.recentsListService.peopleRoomListData.counts.numberOfRooms)
|| (sectionType == RecentsDataSourceSectionTypePersonalNotes))
|| (sectionType == RecentsDataSourceSectionTypePeople && !recentsDataSource.recentsListService.peopleRoomListData.counts.numberOfRooms))
{
return [recentsDataSource cellHeightAtIndexPath:indexPath];
}
@@ -582,7 +580,7 @@
{
[self showCrossSigningSetup];
}
else if (sectionType == RecentsDataSourceSectionTypeAllChats || sectionType == RecentsDataSourceSectionTypePersonalNotes)
else if (sectionType == RecentsDataSourceSectionTypeAllChats)
{
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
}

View File

@@ -90,7 +90,7 @@ import MatrixSDK
}
extension PersonalNotesDefaultService : PersonalNotesService {
func personalNotesRoomId() -> String? {
guard let personalNotesRoom = self.personalNotesRoom() else {
return nil
@@ -123,8 +123,8 @@ extension PersonalNotesDefaultService : PersonalNotesService {
room.replaceTag(PersonalNotesDefaultService.roomTag, with: PersonalNotesDefaultService.roomTag, withOrder: tagOrder) { (response) in
}
case .failure(let error):
MXLog.error("**BWI** Personal Notes creation failure:")
case .failure(_ ):
MXLog.error("**BWI** Personal Notes creation failure")
}
}
}
@@ -138,4 +138,16 @@ extension PersonalNotesDefaultService : PersonalNotesService {
func avatarImageUrl() -> String {
return self.defaultAvatar
}
func setAsFavoriteIfNeeded() {
if let room = self.session.room(withRoomId: self.personalNotesRoomId()) {
if room.accountData.tags[kMXRoomTagFavourite] == nil {
let tagOrder = self.session.tagOrderToBe(at: 0, from: UInt(NSNotFound), withTag: kMXRoomTagFavourite) ?? ""
room.replaceTag(kMXRoomTagFavourite, with: kMXRoomTagFavourite, withOrder: tagOrder) { (response) in
let tags = room.accountData.tags
print(tags)
}
}
}
}
}

View File

@@ -24,4 +24,6 @@ protocol PersonalNotesService {
func resetPersonalNotesRoom()
func avatarImageUrl() -> String
func setAsFavoriteIfNeeded()
}