Skip to content

Commit

Permalink
Always present message from topmost view
Browse files Browse the repository at this point in the history
Move existing helper method topMostController to Utilities and re-use also for placing the messagesView.
  • Loading branch information
wutschel committed Sep 14, 2024
1 parent 1143017 commit b332902
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
16 changes: 3 additions & 13 deletions XBMC Remote/DetailViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -481,16 +481,6 @@ - (void)addExtraProperties:(NSMutableArray*)mutableProperties newParams:(NSMutab
}
}

- (UIViewController*)topMostController {
UIViewController *topController = UIApplication.sharedApplication.keyWindow.rootViewController;

while (topController.presentedViewController) {
topController = topController.presentedViewController;
}

return topController;
}

- (void)setFilternameLabel:(NSString*)labelText runFullscreenButtonCheck:(BOOL)check forceHide:(BOOL)forceHide {
self.navigationItem.title = [Utilities stripBBandHTML:labelText];
if (IS_IPHONE) {
Expand Down Expand Up @@ -3254,7 +3244,7 @@ - (void)showActionSheet:(NSIndexPath*)indexPath sheetActions:(NSArray*)sheetActi
UIImageView *isRecordingImageView = (UIImageView*)[cell viewWithTag:EPG_VIEW_CELL_RECORDING_ICON];
BOOL isRecording = isRecordingImageView == nil ? NO : !isRecordingImageView.hidden;
CGPoint sheetOrigin = CGPointMake(rectOriginX, rectOriginY);
UIViewController *showFromCtrl = [self topMostController];
UIViewController *showFromCtrl = [Utilities topMostController];
[self showActionSheetOptions:title options:sheetActions recording:isRecording origin:sheetOrigin fromcontroller:showFromCtrl fromview:self.view];
}
else if (indexPath != nil) { // No actions found, revert back to standard play action
Expand Down Expand Up @@ -3284,7 +3274,7 @@ - (void)longPressSeason:(UILongPressGestureRecognizer*)sender {
title = [NSString stringWithFormat:@"%@\n%@", title, season];
}

UIViewController *showFromCtrl = [self topMostController];
UIViewController *showFromCtrl = [Utilities topMostController];
UIView *showFromView = nil;
if (IS_IPHONE) {
showFromView = self.view;
Expand Down Expand Up @@ -3366,7 +3356,7 @@ - (void)handleLongPress:(UILongPressGestureRecognizer*)activeRecognizer {
}
UIImageView *isRecordingImageView = (UIImageView*)[cell viewWithTag:EPG_VIEW_CELL_RECORDING_ICON];
BOOL isRecording = isRecordingImageView == nil ? NO : !isRecordingImageView.hidden;
UIViewController *showFromCtrl = [self topMostController];
UIViewController *showFromCtrl = [Utilities topMostController];
UIView *showFromView = nil;
if (IS_IPHONE) {
showFromView = self.view;
Expand Down
2 changes: 1 addition & 1 deletion XBMC Remote/MasterViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ - (CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPat

- (void)addMessagesToRootView {
// Add MessagesView to root view to be able to show messages on top
UIView *rootView = UIApplication.sharedApplication.keyWindow.rootViewController.view;
UIView *rootView = [Utilities topMostController].view;
[rootView addSubview:messagesView];
}

Expand Down
1 change: 1 addition & 0 deletions XBMC Remote/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,6 @@ typedef enum {
+ (void)wakeUp:(NSString*)macAddress;
+ (NSString*)getUrlStyleAddress:(NSString*)address;
+ (int)getActivePlayerID:(NSArray*)activePlayerList;
+ (UIViewController*)topMostController;

@end
8 changes: 8 additions & 0 deletions XBMC Remote/Utilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -1435,4 +1435,12 @@ + (int)getActivePlayerID:(NSArray*)activePlayerList {
return activePlayerID;
}

+ (UIViewController*)topMostController {
UIViewController *topController = UIApplication.sharedApplication.keyWindow.rootViewController;
while (topController.presentedViewController) {
topController = topController.presentedViewController;
}
return topController;
}

@end

0 comments on commit b332902

Please sign in to comment.