Unverified Commit 15f98301 authored by manuroe's avatar manuroe Committed by GitHub
Browse files

Merge branch 'develop' into MadLittleMods/gitter.im-room-directory

parents 55ffff26 cafed69c
......@@ -6,6 +6,9 @@ Changes to be released in next version
🙌 Improvements
* Add `gitter.im` to list of default room directories
* MasterTabBarController: Show/Hide Home Screen tabs (#4234).
* RoomVC: Enable / Disable VoIP feature in Rooms (#4236).
* UnifiedSearchRecentsDataSource: Show/Hide public directory (#4242).
🐛 Bugfix
*
......
......@@ -215,6 +215,13 @@ final class BuildSettings: NSObject {
/// Indicates should the app log out the user when number of biometrics failures reaches `maxAllowedNumberOfBiometricsFailures`. Defaults to `false`
static let logOutUserWhenBiometricsFailuresExceeded: Bool = false
// MARK: - Main Tabs
static let homeScreenShowFavouritesTab: Bool = true
static let homeScreenShowPeopleTab: Bool = true
static let homeScreenShowRoomsTab: Bool = true
static let homeScreenShowCommunitiesTab: Bool = true
// MARK: - General Settings Screen
static let settingsScreenShowUserFirstName: Bool = false
......@@ -250,6 +257,11 @@ final class BuildSettings: NSObject {
static let roomCreationScreenRoomIsEncrypted: Bool = true
static let roomCreationScreenAllowRoomTypeConfiguration: Bool = true
static let roomCreationScreenRoomIsPublic: Bool = false
// MARK: - Room Screen
static let roomScreenAllowVoIPForDirectRoom: Bool = true
static let roomScreenAllowVoIPForNonDirectRoom: Bool = true
// MARK: - Room Settings Screen
......@@ -280,4 +292,7 @@ final class BuildSettings: NSObject {
static let authScreenShowPhoneNumber = true
static let authScreenShowForgotPassword = true
static let authScreenShowCustomServerOptions = true
// Mark: - Unified Search
static let unifiedSearchScreenShowPublicDirectory = true
}
......@@ -52,6 +52,13 @@ final class RiotSettings: NSObject {
static let roomCreationScreenAllowRoomTypeConfiguration = "roomCreationScreenAllowRoomTypeConfiguration"
static let roomCreationScreenRoomIsPublic = "roomCreationScreenRoomIsPublic"
static let allowInviteExernalUsers = "allowInviteExernalUsers"
static let homeScreenShowFavouritesTab = "homeScreenShowFavouritesTab"
static let homeScreenShowPeopleTab = "homeScreenShowPeopleTab"
static let homeScreenShowRoomsTab = "homeScreenShowRoomsTab"
static let homeScreenShowCommunitiesTab = "homeScreenShowCommunitiesTab"
static let roomScreenAllowVoIPForDirectRoom = "roomScreenAllowVoIPForDirectRoom"
static let roomScreenAllowVoIPForNonDirectRoom = "roomScreenAllowVoIPForNonDirectRoom"
static let unifiedSearchScreenShowPublicDirectory = "unifiedSearchScreenShowPublicDirectory"
}
static let shared = RiotSettings()
......@@ -242,6 +249,29 @@ final class RiotSettings: NSObject {
}
}
// MARK: - Room Screen
var roomScreenAllowVoIPForDirectRoom: Bool {
get {
guard defaults.object(forKey: UserDefaultsKeys.roomScreenAllowVoIPForDirectRoom) != nil else {
return BuildSettings.roomScreenAllowVoIPForDirectRoom
}
return defaults.bool(forKey: UserDefaultsKeys.roomScreenAllowVoIPForDirectRoom)
} set {
defaults.set(newValue, forKey: UserDefaultsKeys.roomScreenAllowVoIPForDirectRoom)
}
}
var roomScreenAllowVoIPForNonDirectRoom: Bool {
get {
guard defaults.object(forKey: UserDefaultsKeys.roomScreenAllowVoIPForNonDirectRoom) != nil else {
return BuildSettings.roomScreenAllowVoIPForNonDirectRoom
}
return defaults.bool(forKey: UserDefaultsKeys.roomScreenAllowVoIPForNonDirectRoom)
} set {
defaults.set(newValue, forKey: UserDefaultsKeys.roomScreenAllowVoIPForNonDirectRoom)
}
}
// MARK: - Room Creation Screen
var roomCreationScreenAllowEncryptionConfiguration: Bool {
......@@ -297,6 +327,49 @@ final class RiotSettings: NSObject {
defaults.set(newValue, forKey: UserDefaultsKeys.allowInviteExernalUsers)
}
}
// MARK: - Main Tabs
var homeScreenShowFavouritesTab: Bool {
get {
guard defaults.object(forKey: UserDefaultsKeys.homeScreenShowFavouritesTab) != nil else {
return BuildSettings.homeScreenShowFavouritesTab
}
return defaults.bool(forKey: UserDefaultsKeys.homeScreenShowFavouritesTab)
} set {
defaults.set(newValue, forKey: UserDefaultsKeys.homeScreenShowFavouritesTab)
}
}
var homeScreenShowPeopleTab: Bool {
get {
guard defaults.object(forKey: UserDefaultsKeys.homeScreenShowPeopleTab) != nil else {
return BuildSettings.homeScreenShowPeopleTab
}
return defaults.bool(forKey: UserDefaultsKeys.homeScreenShowPeopleTab)
} set {
defaults.set(newValue, forKey: UserDefaultsKeys.homeScreenShowPeopleTab)
}
}
var homeScreenShowRoomsTab: Bool {
get {
guard defaults.object(forKey: UserDefaultsKeys.homeScreenShowRoomsTab) != nil else {
return BuildSettings.homeScreenShowRoomsTab
}
return defaults.bool(forKey: UserDefaultsKeys.homeScreenShowRoomsTab)
} set {
defaults.set(newValue, forKey: UserDefaultsKeys.homeScreenShowRoomsTab)
}
}
var homeScreenShowCommunitiesTab: Bool {
get {
guard defaults.object(forKey: UserDefaultsKeys.homeScreenShowCommunitiesTab) != nil else {
return BuildSettings.homeScreenShowCommunitiesTab
}
return defaults.bool(forKey: UserDefaultsKeys.homeScreenShowCommunitiesTab)
} set {
defaults.set(newValue, forKey: UserDefaultsKeys.homeScreenShowCommunitiesTab)
}
}
// MARK: General Settings
......@@ -400,4 +473,18 @@ final class RiotSettings: NSObject {
defaults.set(newValue, forKey: UserDefaultsKeys.settingsSecurityScreenShowAdvancedUnverifiedDevices)
}
}
// Mark: - Unified Search
var unifiedSearchScreenShowPublicDirectory: Bool {
get {
guard defaults.object(forKey: UserDefaultsKeys.unifiedSearchScreenShowPublicDirectory) != nil else {
return BuildSettings.unifiedSearchScreenShowPublicDirectory
}
return defaults.bool(forKey: UserDefaultsKeys.unifiedSearchScreenShowPublicDirectory)
} set {
defaults.set(newValue, forKey: UserDefaultsKeys.unifiedSearchScreenShowPublicDirectory)
}
}
}
......@@ -22,6 +22,7 @@
#import "DirectoryRecentTableViewCell.h"
#import "MXRoom+Riot.h"
#import "Riot-Swift.h"
@interface UnifiedSearchRecentsDataSource()
{
......@@ -85,7 +86,10 @@
}
// The public rooms directory cell is then visible whatever the search activity.
self.directorySection = sectionsOffset++;
if (RiotSettings.shared.unifiedSearchScreenShowPublicDirectory)
{
self.directorySection = sectionsOffset++;
}
if (_hideRecents)
{
......
......@@ -1400,7 +1400,8 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
- (BOOL)supportCallOption
{
return BuildSettings.allowVoIPUsage && self.roomDataSource.mxSession.callManager && self.roomDataSource.room.summary.membersCount.joined >= 2;
BOOL callOptionAllowed = (self.roomDataSource.room.isDirect && RiotSettings.shared.roomScreenAllowVoIPForDirectRoom) || (!self.roomDataSource.room.isDirect && RiotSettings.shared.roomScreenAllowVoIPForNonDirectRoom);
return callOptionAllowed && BuildSettings.allowVoIPUsage && self.roomDataSource.mxSession.callManager && self.roomDataSource.room.summary.membersCount.joined >= 2;
}
- (BOOL)isCallActive
......
......@@ -130,6 +130,8 @@
}];
[self userInterfaceThemeDidChange];
[self updateTabs];
}
- (void)userInterfaceThemeDidChange
......@@ -880,38 +882,75 @@
#pragma mark -
- (void)refreshTabBarBadges
- (void)updateTabs
{
// Use a middle dot to signal missed notif in favourites
[self setMissedDiscussionsMark:(recentsDataSource.missedFavouriteDiscussionsCount? @"\u00B7": nil)
onTabBarItem:TABBAR_FAVOURITES_INDEX
withBadgeColor:(recentsDataSource.missedHighlightFavouriteDiscussionsCount ? ThemeService.shared.theme.noticeColor : ThemeService.shared.theme.noticeSecondaryColor)];
if (RiotSettings.shared.homeScreenShowCommunitiesTab && RiotSettings.shared.homeScreenShowRoomsTab
&& RiotSettings.shared.homeScreenShowPeopleTab && RiotSettings.shared.homeScreenShowFavouritesTab)
{
return;
}
// Update the badge on People and Rooms tabs
if (recentsDataSource.unsentMessagesDirectDiscussionsCount)
NSMutableArray *newTabs = [NSMutableArray arrayWithArray:self.viewControllers];
if (!RiotSettings.shared.homeScreenShowCommunitiesTab)
{
[self setBadgeValue:@"!"
onTabBarItem:TABBAR_PEOPLE_INDEX
withBadgeColor:ThemeService.shared.theme.noticeColor];
[newTabs removeObjectAtIndex:TABBAR_GROUPS_INDEX];
}
else
if (!RiotSettings.shared.homeScreenShowRoomsTab)
{
[newTabs removeObjectAtIndex:TABBAR_ROOMS_INDEX];
}
if (!RiotSettings.shared.homeScreenShowPeopleTab)
{
[newTabs removeObjectAtIndex:TABBAR_PEOPLE_INDEX];
}
if (!RiotSettings.shared.homeScreenShowFavouritesTab)
{
[newTabs removeObjectAtIndex:TABBAR_FAVOURITES_INDEX];
}
self.viewControllers = newTabs;
}
- (void)refreshTabBarBadges
{
// Use a middle dot to signal missed notif in favourites
if (RiotSettings.shared.homeScreenShowFavouritesTab)
{
[self setMissedDiscussionsCount:recentsDataSource.missedDirectDiscussionsCount
onTabBarItem:TABBAR_PEOPLE_INDEX
withBadgeColor:(recentsDataSource.missedHighlightDirectDiscussionsCount ? ThemeService.shared.theme.noticeColor : ThemeService.shared.theme.noticeSecondaryColor)];
[self setMissedDiscussionsMark:(recentsDataSource.missedFavouriteDiscussionsCount? @"\u00B7": nil)
onTabBarItem:TABBAR_FAVOURITES_INDEX
withBadgeColor:(recentsDataSource.missedHighlightFavouriteDiscussionsCount ? ThemeService.shared.theme.noticeColor : ThemeService.shared.theme.noticeSecondaryColor)];
}
if (recentsDataSource.unsentMessagesGroupDiscussionsCount)
// Update the badge on People and Rooms tabs
if (RiotSettings.shared.homeScreenShowPeopleTab)
{
[self setMissedDiscussionsCount:recentsDataSource.unsentMessagesGroupDiscussionsCount
onTabBarItem:TABBAR_ROOMS_INDEX
withBadgeColor:ThemeService.shared.theme.noticeColor];
if (recentsDataSource.unsentMessagesDirectDiscussionsCount)
{
[self setBadgeValue:@"!"
onTabBarItem:TABBAR_PEOPLE_INDEX
withBadgeColor:ThemeService.shared.theme.noticeColor];
}
else
{
[self setMissedDiscussionsCount:recentsDataSource.missedDirectDiscussionsCount
onTabBarItem:TABBAR_PEOPLE_INDEX
withBadgeColor:(recentsDataSource.missedHighlightDirectDiscussionsCount ? ThemeService.shared.theme.noticeColor : ThemeService.shared.theme.noticeSecondaryColor)];
}
}
else
if (RiotSettings.shared.homeScreenShowRoomsTab)
{
[self setMissedDiscussionsCount:recentsDataSource.missedGroupDiscussionsCount
onTabBarItem:TABBAR_ROOMS_INDEX
withBadgeColor:(recentsDataSource.missedHighlightGroupDiscussionsCount ? ThemeService.shared.theme.noticeColor : ThemeService.shared.theme.noticeSecondaryColor)];
if (recentsDataSource.unsentMessagesGroupDiscussionsCount)
{
[self setMissedDiscussionsCount:recentsDataSource.unsentMessagesGroupDiscussionsCount
onTabBarItem:TABBAR_ROOMS_INDEX
withBadgeColor:ThemeService.shared.theme.noticeColor];
}
else
{
[self setMissedDiscussionsCount:recentsDataSource.missedGroupDiscussionsCount
onTabBarItem:TABBAR_ROOMS_INDEX
withBadgeColor:(recentsDataSource.missedHighlightGroupDiscussionsCount ? ThemeService.shared.theme.noticeColor : ThemeService.shared.theme.noticeSecondaryColor)];
}
}
}
......@@ -922,39 +961,47 @@
- (void)setBadgeValue:(NSString *)value onTabBarItem:(NSUInteger)index withBadgeColor:(UIColor*)badgeColor
{
if (value)
NSInteger itemIndex = [self indexOfTabItemWithTag:index];
if (itemIndex != NSNotFound)
{
self.tabBar.items[index].badgeValue = value;
self.tabBar.items[index].badgeColor = badgeColor;
[self.tabBar.items[index] setBadgeTextAttributes:@{
NSForegroundColorAttributeName: ThemeService.shared.theme.baseTextPrimaryColor
}
forState:UIControlStateNormal];
}
else
{
self.tabBar.items[index].badgeValue = nil;
if (value)
{
self.tabBar.items[itemIndex].badgeValue = value;
self.tabBar.items[itemIndex].badgeColor = badgeColor;
[self.tabBar.items[itemIndex] setBadgeTextAttributes:@{
NSForegroundColorAttributeName: ThemeService.shared.theme.baseTextPrimaryColor
}
forState:UIControlStateNormal];
}
else
{
self.tabBar.items[itemIndex].badgeValue = nil;
}
}
}
- (void)setMissedDiscussionsMark:(NSString*)mark onTabBarItem:(NSUInteger)index withBadgeColor:(UIColor*)badgeColor
{
if (mark)
NSInteger itemIndex = [self indexOfTabItemWithTag:index];
if (itemIndex != NSNotFound)
{
self.tabBar.items[index].badgeValue = mark;
self.tabBar.items[index].badgeColor = badgeColor;
[self.tabBar.items[index] setBadgeTextAttributes:@{
NSForegroundColorAttributeName: ThemeService.shared.theme.baseTextPrimaryColor
}
forState:UIControlStateNormal];
}
else
{
self.tabBar.items[index].badgeValue = nil;
if (mark)
{
self.tabBar.items[itemIndex].badgeValue = mark;
self.tabBar.items[itemIndex].badgeColor = badgeColor;
[self.tabBar.items[itemIndex] setBadgeTextAttributes:@{
NSForegroundColorAttributeName: ThemeService.shared.theme.baseTextPrimaryColor
}
forState:UIControlStateNormal];
}
else
{
self.tabBar.items[itemIndex].badgeValue = nil;
}
}
}
......@@ -975,6 +1022,19 @@
return badgeValue;
}
- (NSInteger)indexOfTabItemWithTag:(NSUInteger)tag
{
for (int i = 0 ; i < self.tabBar.items.count ; i++)
{
if (self.tabBar.items[i].tag == tag)
{
return i;
}
}
return NSNotFound;
}
#pragma mark -
- (void)promptUserBeforeUsingAnalytics
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment