mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 17:12:45 +02:00
Merge branch 'master' into develop
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
#import "NSBundle+MXKLanguage.h"
|
||||
#import "GeneratedInterface-Swift.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
@@ -55,37 +56,37 @@ static const char _fallbackLanguage = 0;
|
||||
[self setupMXKLanguageBundle];
|
||||
|
||||
// [NSBundle localizedStringForKey] calls will be redirected to the bundle corresponding
|
||||
// to "language"
|
||||
objc_setAssociatedObject([NSBundle mainBundle],
|
||||
&_bundle, language ? [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:language ofType:@"lproj"]] : nil,
|
||||
// to "language". `lprojBundleFor` loads this from the main app bundle as we might be running in an extension.
|
||||
objc_setAssociatedObject(NSBundle.app,
|
||||
&_bundle, language ? [NSBundle lprojBundleFor:language] : nil,
|
||||
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
|
||||
objc_setAssociatedObject([NSBundle mainBundle],
|
||||
objc_setAssociatedObject(NSBundle.app,
|
||||
&_language, language,
|
||||
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
|
||||
+ (NSString *)mxk_language
|
||||
{
|
||||
return objc_getAssociatedObject([NSBundle mainBundle], &_language);
|
||||
return objc_getAssociatedObject(NSBundle.app, &_language);
|
||||
}
|
||||
|
||||
+ (void)mxk_setFallbackLanguage:(NSString *)language
|
||||
{
|
||||
[self setupMXKLanguageBundle];
|
||||
|
||||
objc_setAssociatedObject([NSBundle mainBundle],
|
||||
&_fallbackBundle, language ? [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:language ofType:@"lproj"]] : nil,
|
||||
objc_setAssociatedObject(NSBundle.app,
|
||||
&_fallbackBundle, language ? [NSBundle lprojBundleFor:language] : nil,
|
||||
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
|
||||
objc_setAssociatedObject([NSBundle mainBundle],
|
||||
objc_setAssociatedObject(NSBundle.app,
|
||||
&_fallbackLanguage, language,
|
||||
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
|
||||
+ (NSString *)mxk_fallbackLanguage
|
||||
{
|
||||
return objc_getAssociatedObject([NSBundle mainBundle], &_fallbackLanguage);
|
||||
return objc_getAssociatedObject(NSBundle.app, &_fallbackLanguage);
|
||||
}
|
||||
|
||||
#pragma mark - Private methods
|
||||
@@ -96,7 +97,7 @@ static const char _fallbackLanguage = 0;
|
||||
dispatch_once(&onceToken, ^{
|
||||
|
||||
// Use MXKLanguageBundle as the [NSBundle mainBundle] class
|
||||
object_setClass([NSBundle mainBundle], [MXKLanguageBundle class]);
|
||||
object_setClass(NSBundle.app, MXKLanguageBundle.class);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,12 @@ limitations under the License.
|
||||
The fake top view displayed in case of vertical bounce.
|
||||
*/
|
||||
__weak UIView *topview;
|
||||
|
||||
/**
|
||||
`isRefreshNeeded` is set to `YES` if an update of the datasource has been triggered but the UI has not been updated.
|
||||
It's set to `NO` after a refresh of the UI.
|
||||
*/
|
||||
BOOL isRefreshNeeded;
|
||||
}
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UISearchBar *recentsSearchBar;
|
||||
@@ -83,6 +89,11 @@ limitations under the License.
|
||||
*/
|
||||
@property (nonatomic) BOOL enableBarButtonSearch;
|
||||
|
||||
/**
|
||||
Enabled or disabled the UI update after recents syncs. Default YES.
|
||||
*/
|
||||
@property (nonatomic, getter=isRecentsUpdateEnabled) BOOL recentsUpdateEnabled;
|
||||
|
||||
#pragma mark - Class methods
|
||||
|
||||
/**
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
{
|
||||
[super finalizeInit];
|
||||
|
||||
_recentsUpdateEnabled = YES;
|
||||
_enableBarButtonSearch = YES;
|
||||
}
|
||||
|
||||
@@ -169,6 +170,8 @@
|
||||
|
||||
// Observe the server sync
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onSyncNotification) name:kMXSessionDidSyncNotification object:nil];
|
||||
|
||||
self.recentsUpdateEnabled = YES;
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
@@ -319,6 +322,10 @@
|
||||
|
||||
- (void)refreshRecentsTable
|
||||
{
|
||||
if (!self.recentsUpdateEnabled) return;
|
||||
|
||||
isRefreshNeeded = NO;
|
||||
|
||||
// For now, do a simple full reload
|
||||
[self.recentsTableView reloadData];
|
||||
}
|
||||
@@ -330,6 +337,16 @@
|
||||
[self.view setNeedsUpdateConstraints];
|
||||
}
|
||||
|
||||
- (void)setRecentsUpdateEnabled:(BOOL)activeUpdate
|
||||
{
|
||||
_recentsUpdateEnabled = activeUpdate;
|
||||
|
||||
if (_recentsUpdateEnabled && isRefreshNeeded)
|
||||
{
|
||||
[self refreshRecentsTable];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Action
|
||||
|
||||
- (IBAction)search:(id)sender
|
||||
@@ -385,6 +402,12 @@
|
||||
|
||||
- (void)dataSource:(MXKDataSource *)dataSource didCellChange:(id)changes
|
||||
{
|
||||
if (!_recentsUpdateEnabled)
|
||||
{
|
||||
isRefreshNeeded = YES;
|
||||
return;
|
||||
}
|
||||
|
||||
// For now, do a simple full reload
|
||||
[self refreshRecentsTable];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user