Skip to content

Commit

Permalink
Update progress/recording indicator for Live TV and Radio
Browse files Browse the repository at this point in the history
Update the indicators for progress and recording to a progress bar. The progress bar is located on the left side, uses dark gray background and Kodi blue for the progress. Total runtime is located right aligned and under the bar. The recording indicator is located in a reserved area left of the runtime.
In the EPG the highlighting is done by changing the cell background and letting the start time label use a bigger font size and label color.
  • Loading branch information
wutschel committed Dec 27, 2024
1 parent 947f573 commit 3002cad
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 39 deletions.
6 changes: 6 additions & 0 deletions Kodi Remote.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
C76594B62C5E885B00B93A2A /* Roboto-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 0FE6087E164B3094009CA3A9 /* Roboto-Regular.ttf */; };
C76594B72C5E8A5B00B93A2A /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = C70F41D02BA4D98E00847C75 /* PrivacyInfo.xcprivacy */; };
C78C30F528F877870055CD95 /* VersionCheck.m in Sources */ = {isa = PBXBuildFile; fileRef = C78C30F428F877870055CD95 /* VersionCheck.m */; };
C7E176482D1ECD6C0060AE86 /* ProgressBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = C7E176472D1ECD6C0060AE86 /* ProgressBarView.m */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -313,6 +314,8 @@
C7A030F428B60EB900B27764 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Localizable.strings"; sourceTree = "<group>"; };
C7A1381F296AF0B500D84A72 /* hr-HR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "hr-HR"; path = "hr-HR.lproj/InfoPlist.strings"; sourceTree = "<group>"; };
C7A13820296AF0B500D84A72 /* hr-HR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "hr-HR"; path = "hr-HR.lproj/Localizable.strings"; sourceTree = "<group>"; };
C7E176472D1ECD6C0060AE86 /* ProgressBarView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ProgressBarView.m; sourceTree = "<group>"; };
C7E176492D1ECD7D0060AE86 /* ProgressBarView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ProgressBarView.h; sourceTree = "<group>"; };
C7F28D4826961FE50004B112 /* ConvenienceMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ConvenienceMacros.h; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -357,6 +360,8 @@
0F554910151D1187007E633F /* DetailViewController.m */,
0F089AA318EC4E3300F32430 /* SettingsValuesViewController.h */,
0F089AA418EC4E3300F32430 /* SettingsValuesViewController.m */,
C7E176492D1ECD7D0060AE86 /* ProgressBarView.h */,
C7E176472D1ECD6C0060AE86 /* ProgressBarView.m */,
0F44EC4F18A6672100BE44BD /* ProgressPieView.h */,
0F44EC5018A6672100BE44BD /* ProgressPieView.m */,
0FEE08141704819A00EC9BC7 /* FloatingHeaderFlowLayout.h */,
Expand Down Expand Up @@ -849,6 +854,7 @@
C78C30F528F877870055CD95 /* VersionCheck.m in Sources */,
C76451D629C51221000AE949 /* UIView+WebCacheOperation.m in Sources */,
0F4019B318F415A50064E4DC /* MessagesView.m in Sources */,
C7E176482D1ECD6C0060AE86 /* ProgressBarView.m in Sources */,
0F7F0DCC1703490A0098FF75 /* BDKCollectionIndexView.m in Sources */,
0FEE08161704819A00EC9BC7 /* FloatingHeaderFlowLayout.m in Sources */,
0F7B951A1708975500880F33 /* UIImage+Resize.m in Sources */,
Expand Down
85 changes: 46 additions & 39 deletions XBMC Remote/DetailViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#import "RecentlyAddedCell.h"
#import "NSString+MD5.h"
#import "UIScrollView+SVPullToRefresh.h"
#import "ProgressPieView.h"
#import "ProgressBarView.h"
#import "SettingsValuesViewController.h"
#import "customButton.h"
#import "VersionCheck.h"
Expand Down Expand Up @@ -67,9 +67,8 @@ @implementation DetailViewController
#define GENRE_HEIGHT 18
#define EPGCHANNELTIME_WIDTH 40
#define EPGCHANNELTIME_HEIGHT 12
#define EPG_RECORDING_DOT_SIZE 12
#define CHANNELLIST_DOT_SIZE 6
#define CHANNELLIST_PIE_SIZE 28
#define EPGCHANNELBAR_HEIGHT 30
#define RECORDING_DOT_SIZE 12
#define TRACKCOUNT_WIDTH 26
#define LABEL_PADDING 8
#define VERTICAL_PADDING 8
Expand Down Expand Up @@ -265,18 +264,18 @@ - (void)updateEpgTableInfo:(NSDictionary*)parameters {
if (channelEPG[@"current_details"] != nil) {
item[@"genre"] = channelEPG[@"current_details"];
}
ProgressPieView *progressView = (ProgressPieView*)[cell viewWithTag:EPG_VIEW_CELL_PROGRESSVIEW];
ProgressBarView *progressView = (ProgressBarView*)[cell viewWithTag:EPG_VIEW_CELL_PROGRESSVIEW];
if (![current.text isEqualToString:LOCALIZED_STR(@"Not Available")] && [channelEPG[@"starttime"] isKindOfClass:[NSDate class]] && [channelEPG[@"endtime"] isKindOfClass:[NSDate class]]) {
float percent_elapsed = [Utilities getPercentElapsed:channelEPG[@"starttime"] EndDate:channelEPG[@"endtime"]];
[progressView updateProgressPercentage:percent_elapsed];
[progressView setProgressBarPercentage:percent_elapsed];
progressView.hidden = NO;
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSUInteger unitFlags = NSCalendarUnitMinute;
NSDateComponents *components = [gregorian components:unitFlags
fromDate:channelEPG[@"starttime"]
toDate:channelEPG[@"endtime"] options:0];
NSInteger minutes = [components minute];
progressView.pieLabel.text = [NSString stringWithFormat:@" %ld'", (long)minutes];
progressView.barLabel.text = [NSString stringWithFormat:@"%ld'", (long)minutes];
}
else {
progressView.hidden = YES;
Expand Down Expand Up @@ -2481,14 +2480,10 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI
programTimeLabel.textColor = [Utilities get2ndLabelColor];
[cell.contentView addSubview:programTimeLabel];

CGFloat pieSize = EPGCHANNELTIME_WIDTH;
CGRect pieFrame = CGRectMake(SMALL_PADDING, (cellHeight + CGRectGetMaxY(programTimeLabel.frame) - pieSize) / 2, pieSize, pieSize);
[self layoutProgressPie:pieFrame pieSize:pieSize dotSize:EPG_RECORDING_DOT_SIZE color:[Utilities getSystemBlue] cell:cell];
[self addProgressBar:cell recDotSize:RECORDING_DOT_SIZE];
}
else if (channelListView) {
CGFloat pieSize = CHANNELLIST_PIE_SIZE;
CGRect pieFrame = CGRectMake(viewWidth - pieSize - SMALL_PADDING, LABEL_PADDING, pieSize, pieSize);
[self layoutProgressPie:pieFrame pieSize:pieSize dotSize:CHANNELLIST_DOT_SIZE color:[Utilities get1stLabelColor] cell:cell];
[self addProgressBar:cell recDotSize:RECORDING_DOT_SIZE];
}
UILabel *title = (UILabel*)[cell viewWithTag:XIB_JSON_DATA_CELL_TITLE];
UILabel *genre = (UILabel*)[cell viewWithTag:XIB_JSON_DATA_CELL_GENRE];
Expand Down Expand Up @@ -2614,6 +2609,12 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI
frame.size.height = ceil(thumbWidth * 0.7);
cell.urlImageView.frame = frame;
cell.urlImageView.autoresizingMask = UIViewAutoresizingNone;

CGFloat originY = CGRectGetMaxY(frame) + SMALL_PADDING;
CGFloat height = cell.frame.size.height - originY - SMALL_PADDING;
CGRect barFrame = CGRectMake(SMALL_PADDING, originY, CGRectGetWidth(frame), height);
ProgressBarView *progressView = (ProgressBarView*)[cell viewWithTag:EPG_VIEW_CELL_PROGRESSVIEW];
[progressView setProgressBarFrame:barFrame];
}
if (channelListView) {
runtime.hidden = NO;
Expand All @@ -2623,7 +2624,7 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI
genre.frame = frame;
genre.textColor = [Utilities get1stLabelColor];
genre.font = [UIFont boldSystemFontOfSize:14];
ProgressPieView *progressView = (ProgressPieView*)[cell viewWithTag:EPG_VIEW_CELL_PROGRESSVIEW];
ProgressBarView *progressView = (ProgressBarView*)[cell viewWithTag:EPG_VIEW_CELL_PROGRESSVIEW];
progressView.hidden = YES;
UIImageView *isRecordingImageView = (UIImageView*)[cell viewWithTag:EPG_VIEW_CELL_RECORDING_ICON];
isRecordingImageView.hidden = ![item[@"isrecording"] boolValue];
Expand Down Expand Up @@ -2764,23 +2765,31 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI
genre.minimumScaleFactor = FONT_SCALING_DEFAULT;
[genre sizeToFit];
UILabel *programStartTime = (UILabel*)[cell viewWithTag:EPG_VIEW_CELL_STARTTIME];
ProgressPieView *progressView = (ProgressPieView*)[cell viewWithTag:EPG_VIEW_CELL_PROGRESSVIEW];
ProgressBarView *progressView = (ProgressBarView*)[cell viewWithTag:EPG_VIEW_CELL_PROGRESSVIEW];
NSDate *starttime = [xbmcDateFormatter dateFromString:item[@"starttime"]];
NSDate *endtime = [xbmcDateFormatter dateFromString:item[@"endtime"]];
programStartTime.text = [localHourMinuteFormatter stringFromDate:starttime];
float percent_elapsed = [Utilities getPercentElapsed:starttime EndDate:endtime];

CGRect progressFrame = CGRectMake(SMALL_PADDING,
CGRectGetMinY(genre.frame) + VERTICAL_PADDING,
CGRectGetWidth(programStartTime.frame),
EPGCHANNELBAR_HEIGHT);
[progressView setProgressBarFrame:progressFrame];

title.textColor = [Utilities get1stLabelColor];
genre.textColor = [Utilities get2ndLabelColor];
title.highlightedTextColor = [Utilities get1stLabelColor];
genre.highlightedTextColor = [Utilities get2ndLabelColor];

if (percent_elapsed > 0 && percent_elapsed < 100) {
title.textColor = [Utilities getSystemBlue];
genre.textColor = [Utilities getSystemBlue];
programStartTime.textColor = [Utilities getSystemBlue];

title.highlightedTextColor = [Utilities getSystemBlue];
genre.highlightedTextColor = [Utilities getSystemBlue];
programStartTime.highlightedTextColor = [Utilities getSystemBlue];

[progressView updateProgressPercentage:percent_elapsed];
progressView.pieLabel.hidden = NO;
programStartTime.textColor = [Utilities get1stLabelColor];
programStartTime.highlightedTextColor = [Utilities get1stLabelColor];
programStartTime.font = [UIFont systemFontOfSize:14];
cell.backgroundColor = [Utilities getSystemGray4];

[progressView setProgressBarPercentage:percent_elapsed];
progressView.barLabel.hidden = NO;
NSCalendar *gregorian = [[NSCalendar alloc]
initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSUInteger unitFlags = NSCalendarUnitMinute;
Expand All @@ -2789,18 +2798,17 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI
toDate:endtime
options:0];
NSInteger minutes = [components minute];
progressView.pieLabel.text = [NSString stringWithFormat:@" %ld'", (long)minutes];
progressView.barLabel.text = [NSString stringWithFormat:@"%ld'", (long)minutes];
progressView.hidden = NO;
}
else {
progressView.hidden = YES;
progressView.pieLabel.hidden = YES;
title.textColor = [Utilities get1stLabelColor];
genre.textColor = [Utilities get2ndLabelColor];
programStartTime.textColor = [Utilities get2ndLabelColor];
title.highlightedTextColor = [Utilities get1stLabelColor];
genre.highlightedTextColor = [Utilities get2ndLabelColor];
programStartTime.highlightedTextColor = [Utilities get2ndLabelColor];
programStartTime.font = [UIFont systemFontOfSize:13];
cell.backgroundColor = [Utilities getSystemGray6];

progressView.hidden = YES;
progressView.barLabel.hidden = YES;
}
UIImageView *hasTimer = (UIImageView*)[cell viewWithTag:EPG_VIEW_CELL_RECORDING_ICON];
if ([item[@"hastimer"] boolValue]) {
Expand Down Expand Up @@ -3151,22 +3159,21 @@ - (void)layoutSectionView:(UIView*)albumDetailView thumbView:(UIImageView*)thumb
[albumDetailView addSubview:released];
}

- (void)layoutProgressPie:(CGRect)pieFrame pieSize:(CGFloat)pieSize dotSize:(CGFloat)dotSize color:(UIColor*)color cell:(UITableViewCell*)cell {
ProgressPieView *progressView = [[ProgressPieView alloc] initWithFrame:pieFrame color:color];
- (void)addProgressBar:(UITableViewCell*)cell recDotSize:(CGFloat)dotSize {
ProgressBarView *progressView = [ProgressBarView new];
progressView.tag = EPG_VIEW_CELL_PROGRESSVIEW;
progressView.hidden = YES;
[cell.contentView addSubview:progressView];

CGPoint timerOrigin = progressView.frame.origin;
timerOrigin.x += pieSize / 2 - dotSize / 2;
timerOrigin.y += [progressView getPieRadius] + 2 * [progressView getLineWidth] - dotSize / 2;
UIImageView *timerView = [[UIImageView alloc] initWithFrame:(CGRect){timerOrigin, CGSizeMake(dotSize, dotSize)}];
UIImageView *timerView = [[UIImageView alloc] initWithFrame:(CGRect){CGPointZero, CGSizeMake(dotSize, dotSize)}];
timerView.image = [UIImage imageNamed:@"button_timer"];
timerView.contentMode = UIViewContentModeScaleToFill;
timerView.tag = EPG_VIEW_CELL_RECORDING_ICON;
timerView.hidden = YES;
timerView.backgroundColor = UIColor.clearColor;
[cell.contentView addSubview:timerView];
timerView.center = progressView.reservedArea.center;
timerView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
[progressView.reservedArea addSubview:timerView];
}

- (CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section {
Expand Down
25 changes: 25 additions & 0 deletions XBMC Remote/ProgressBarView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// ProgressBarView.h
// Kodi Remote
//
// Created by Buschmann on 27.12.24.
// Copyright © 2024 Team Kodi. All rights reserved.
//

#ifndef ProgressBarView_h
#define ProgressBarView_h

@interface ProgressBarView : UIView {
UIView *progressBarMask;
UIView *progressBar;
}

- (void)setProgressBarFrame:(CGRect)frame;
- (void)setProgressBarPercentage:(CGFloat)progressPercentage;

@property (nonatomic, readonly) UILabel *barLabel;
@property (nonatomic, readonly) UIView *reservedArea;

@end

#endif /* ProgressBarView_h */
70 changes: 70 additions & 0 deletions XBMC Remote/ProgressBarView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//
// ProgressBarView.m
// Kodi Remote
//
// Created by Buschmann on 27.12.24.
// Copyright © 2024 Team Kodi. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "ProgressBarView.h"
#import "Utilities.h"

#define RESERVED_WIDTH 14
#define PROGRESSBAR_HEIGHT 8
#define PROGRESSBAR_RADIUS 2
#define FONT_SIZE 10

@implementation ProgressBarView

@synthesize barLabel;
@synthesize reservedArea;

- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self createProgressBar];
}
return self;
}

- (void)createProgressBar {
progressBarMask = [UIView new];
progressBarMask.backgroundColor = UIColor.darkGrayColor;
progressBarMask.layer.cornerRadius = PROGRESSBAR_RADIUS;
progressBarMask.clipsToBounds = YES;
[self addSubview:progressBarMask];

progressBar = [UIView new];
progressBar.backgroundColor = KODI_BLUE_COLOR;
[progressBarMask addSubview:progressBar];

reservedArea = [UILabel new];
[self addSubview:reservedArea];

barLabel = [UILabel new];
barLabel.font = [UIFont systemFontOfSize:FONT_SIZE];
barLabel.adjustsFontSizeToFitWidth = YES;
barLabel.minimumScaleFactor = FONT_SCALING_MIN;
barLabel.textAlignment = NSTextAlignmentRight;
barLabel.textColor = [Utilities get1stLabelColor];
[self addSubview:barLabel];
}

- (void)setProgressBarFrame:(CGRect)frame {
self.frame = frame;
CGFloat labelHeight = CGRectGetHeight(frame) - PROGRESSBAR_HEIGHT;
CGFloat labelWidth = CGRectGetWidth(frame) - RESERVED_WIDTH;
barLabel.frame = CGRectMake(RESERVED_WIDTH, PROGRESSBAR_HEIGHT, labelWidth, labelHeight);
reservedArea.frame = CGRectMake(0, PROGRESSBAR_HEIGHT, RESERVED_WIDTH, labelHeight);
progressBarMask.frame = CGRectMake(0, 0, CGRectGetWidth(frame), PROGRESSBAR_HEIGHT);
progressBar.frame = CGRectMake(0, 0, 0, PROGRESSBAR_HEIGHT);
}

- (void)setProgressBarPercentage:(CGFloat)progressPercentage {
CGRect frame = progressBar.frame;
frame.size.width = ceil(progressPercentage / 100.0 * CGRectGetWidth(self.frame));
progressBar.frame = frame;
}

@end

0 comments on commit 3002cad

Please sign in to comment.