Skip to content

Commit

Permalink
VLCFavoritesListViewController: Add support for cloud favorites
Browse files Browse the repository at this point in the history
VLCCloudStorageViewController: Reset the path to nil after browsing favorite

VLCCloudStorageTableViewCell: Update Box Cell if favorited

VLCDropBoxController: Create a new instance to prevent conflicts between favorites and normal navigation

`VLCFavoriteListController: Add localization for options and use the provided image assets for menu button

VLCFavoriteService: Remove useless file refrence in Cloud Favorite class

VLCFavoriteListViewController: Enchance Edit Mode

VLCFavoriteService: Remove Code Duplication

VLCFavoriteListViewController: Compilation fix for tvOS

VLCFavoriteViewController: Remove Selectors, additional data sources

VLCFavoriteService: Remove all cloud favorite redudant classes

Files: Remove white spaces

GoogleDriveTableViewController: Correct the fetching of file

VLCFavoriteListViewController: Remove Explicit function calling

CloudViewControllers: Code Cleanup

VLCMovieTVController: Remove Redundant changes

Xcodeproj: Remove unneeded changes

VLCGoogleDriveTableViewController: Revert uneeded changes

VLCDropboxTableViewController: Simplify logic.

VLCDropBoxController: Add back singleton

VLCBoxTableViewController: Fix Typo

VLCCloudStorageTableViewController: Fix Typo

Favorite: Remove Test Code
  • Loading branch information
EshanSingh-ES authored and EshanSingh-ES committed Aug 26, 2024
1 parent 96effb7 commit f3715f7
Show file tree
Hide file tree
Showing 16 changed files with 751 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
@property (nonatomic, strong) IBOutlet UILabel *subtitleLabel;
@property (nonatomic, strong) IBOutlet VLCNetworkImageView *thumbnailView;
@property (nonatomic, strong) IBOutlet UIButton *downloadButton;
@property (nonatomic, strong) IBOutlet UIButton *favouriteButton;

@property (nonatomic, retain) DBFILESMetadata *dropboxFile;
@property (nonatomic, retain) ODItem *oneDriveFile;
Expand All @@ -39,6 +40,9 @@
#endif

@property (nonatomic, readwrite) BOOL isDownloadable;
@property (nonatomic, readwrite) BOOL isFavourite;
// We use this property here to determine folders
@property (nonatomic, readwrite) BOOL isFavourable;

+ (VLCCloudStorageTableViewCell *)cellWithReuseIdentifier:(NSString *)ident;
+ (CGFloat)heightOfCell;
Expand All @@ -50,5 +54,6 @@
@protocol VLCCloudStorageTableViewCell <NSObject>

- (void)triggerDownloadForCell:(VLCCloudStorageTableViewCell *)cell;
- (void)triggerFavoriteForCell:(VLCCloudStorageTableViewCell *)cell;

@end
67 changes: 64 additions & 3 deletions Sources/Cloud/Content List/Cells/VLCCloudStorageTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,23 @@ + (VLCCloudStorageTableViewCell *)cellWithReuseIdentifier:(NSString *)ident
cell.titleLabel.hidden = YES;
cell.subtitleLabel.hidden = YES;
cell.folderTitleLabel.hidden = YES;


cell.isFavourite = NO;
cell.isFavourable = NO;

[[NSNotificationCenter defaultCenter] addObserver:cell selector:@selector(updateAppearanceForColorScheme) name:kVLCThemeDidChangeNotification object:nil];
[cell updateAppearanceForColorScheme];

return cell;
}

- (IBAction)didTapFavorite:(id)sender
{
self.isFavourite = !self.isFavourite;
[self.delegate triggerFavoriteForCell: self];

}

- (void)setDropboxFile:(DBFILESMetadata *)dropboxFile
{
if (dropboxFile != _dropboxFile)
Expand Down Expand Up @@ -149,6 +159,15 @@ - (void)_updatedDisplayedInformation
self.titleLabel.hidden = self.subtitleLabel.hidden = YES;
self.folderTitleLabel.hidden = NO;
self.downloadButton.hidden = YES;
self.isFavourable = YES;

VLCFavoriteService *service = [VLCAppCoordinator sharedInstance].favoriteService;

NSString *selectedFilePath = _dropboxFile.pathLower;
NSString *urlString = [NSString stringWithFormat:@"file://DropBox/%@", selectedFilePath];
NSURL *url = [NSURL URLWithString:urlString];
self.isFavourite = [service isFavoriteURL:url];

self.thumbnailView.image = [UIImage imageNamed:@"folder"];
} else if ([_dropboxFile isKindOfClass:[DBFILESFileMetadata class]]) {
DBFILESFileMetadata *file = (DBFILESFileMetadata *)_dropboxFile;
Expand All @@ -157,22 +176,34 @@ - (void)_updatedDisplayedInformation
self.titleLabel.hidden = self.subtitleLabel.hidden = NO;
self.folderTitleLabel.hidden = YES;
self.downloadButton.hidden = NO;
self.isFavourable = NO;
self.favouriteButton.hidden = YES;
self.thumbnailView.image = [UIImage imageNamed:@"blank"];
}
}
else if(_driveFile != nil){
else if(_driveFile != nil) {
BOOL isDirectory = [self.driveFile.mimeType isEqualToString:@"application/vnd.google-apps.folder"];
if (isDirectory) {
self.folderTitleLabel.text = self.driveFile.name;
self.titleLabel.hidden = self.subtitleLabel.hidden = YES;
self.folderTitleLabel.hidden = NO;
self.isFavourable = YES;

VLCFavoriteService *service = [VLCAppCoordinator sharedInstance].favoriteService;

NSString *selectedFilePath = _driveFile.identifier;
NSString *urlString = [NSString stringWithFormat:@"file://Drive/%@", selectedFilePath];
NSURL *url = [NSURL URLWithString:urlString];

self.isFavourite = [service isFavoriteURL:url];
} else {
NSString *title = self.driveFile.name;
self.titleLabel.text = title;
self.subtitleLabel.text = (self.driveFile.size > 0) ? [NSByteCountFormatter stringFromByteCount:[self.driveFile.size longLongValue] countStyle:NSByteCountFormatterCountStyleFile]: @"";
self.titleLabel.hidden = self.subtitleLabel.hidden = NO;
self.folderTitleLabel.hidden = YES;

self.favouriteButton.hidden = YES;

if (_driveFile.thumbnailLink != nil) {
[self.thumbnailView setImageWithURL:[NSURL URLWithString:_driveFile.thumbnailLink]];
}
Expand All @@ -199,13 +230,23 @@ - (void)_updatedDisplayedInformation
self.titleLabel.hidden = self.subtitleLabel.hidden = YES;
self.folderTitleLabel.hidden = NO;
self.downloadButton.hidden = YES;
self.isFavourable = YES;

VLCFavoriteService *service = [VLCAppCoordinator sharedInstance].favoriteService;

NSString *selectedFilePath = _boxFile.modelID;
NSString *urlString = [NSString stringWithFormat:@"file://Box/%@", selectedFilePath];
NSURL *url = [NSURL URLWithString:urlString];

self.isFavourite = [service isFavoriteURL:url];
} else {
NSString *title = self.boxFile.name;
self.titleLabel.text = title;
self.subtitleLabel.text = (self.boxFile.size > 0) ? [NSByteCountFormatter stringFromByteCount:[self.boxFile.size longLongValue] countStyle:NSByteCountFormatterCountStyleFile]: @"";
self.titleLabel.hidden = self.subtitleLabel.hidden = NO;
self.folderTitleLabel.hidden = YES;
self.downloadButton.hidden = NO;
self.favouriteButton.hidden = YES;
}
//TODO: correct thumbnails
// if (_boxFile.modelID != nil) {
Expand Down Expand Up @@ -233,6 +274,7 @@ - (IBAction)triggerDownload:(id)sender
[self.delegate triggerDownloadForCell:self];
}


+ (CGFloat)heightOfCell
{
return 8. * 4. + [[UIFont preferredFontForTextStyle:UIFontTextStyleBody] lineHeight] + [[UIFont preferredFontForTextStyle:UIFontTextStyleCaption2] lineHeight];
Expand All @@ -243,6 +285,25 @@ - (void)setIsDownloadable:(BOOL)isDownloadable
self.downloadButton.hidden = !isDownloadable;
}

- (void)setIsFavourite:(BOOL)isFavourite
{
if (@available(iOS 13.0, *)) {
_favouriteButton.hidden = !isFavourite;
if (isFavourite) {
[_favouriteButton setImage:[UIImage imageNamed:@"heart.fill"] forState:UIControlStateNormal];
}
} else {
_favouriteButton.hidden = NO;
if (isFavourite) {
[_favouriteButton setImage:[UIImage imageNamed:@"heart"] forState:UIControlStateNormal];
} else {
[_favouriteButton setImage:[UIImage imageNamed:@"heart.fill"] forState:UIControlStateNormal];
}
}

_isFavourite = isFavourite;
}

- (void)prepareForReuse {
[super prepareForReuse];
_thumbnailView.image = nil;
Expand Down
36 changes: 30 additions & 6 deletions Sources/Cloud/Content List/Cells/VLCCloudStorageTableViewCell.xib
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand All @@ -22,14 +23,14 @@
<constraint firstAttribute="width" secondItem="4" secondAttribute="height" multiplier="1:1" id="10D-U5-sbF"/>
</constraints>
</imageView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="File Title" lineBreakMode="tailTruncation" baselineAdjustment="none" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6">
<rect key="frame" x="54" y="10" width="201" height="17"/>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" verticalCompressionResistancePriority="749" text="File Title" lineBreakMode="tailTruncation" baselineAdjustment="none" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6">
<rect key="frame" x="54" y="10" width="201" height="18.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<color key="textColor" red="0.66666666666666663" green="0.66666666666666663" blue="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Folder Title" lineBreakMode="tailTruncation" baselineAdjustment="none" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="23">
<rect key="frame" x="54" y="18.5" width="258" height="17"/>
<rect key="frame" x="54" y="17" width="258" height="20.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
<color key="textColor" red="0.66666666666666663" green="0.66666666666666663" blue="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand Down Expand Up @@ -58,6 +59,21 @@
<action selector="triggerDownload:" destination="3" eventType="touchUpInside" id="vmr-i0-5y5"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="TYG-PY-W9b">
<rect key="frame" x="261" y="8" width="48" height="38"/>
<constraints>
<constraint firstAttribute="width" constant="48" id="7MV-yu-USF"/>
<constraint firstAttribute="height" constant="38" id="9Qh-nG-9qa"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" image="heart">
<color key="titleColor" systemColor="systemOrangeColor"/>
</state>
<connections>
<action selector="didTapFavorite:" destination="3" eventType="touchUpInside" id="ndG-Sf-fBg"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="7" firstAttribute="trailing" secondItem="661-nY-3Tr" secondAttribute="leading" constant="-8" id="3TX-CG-pVW"/>
Expand All @@ -68,10 +84,13 @@
<constraint firstItem="23" firstAttribute="leading" secondItem="4" secondAttribute="trailing" constant="8" id="C3b-pA-uOA"/>
<constraint firstItem="23" firstAttribute="trailing" secondItem="Tip-yB-5Gh" secondAttribute="trailing" constant="-8" id="Fqx-O2-LB5"/>
<constraint firstItem="7" firstAttribute="bottom" secondItem="4" secondAttribute="bottom" constant="-2" id="KGc-0W-IIt"/>
<constraint firstItem="TYG-PY-W9b" firstAttribute="leading" secondItem="6" secondAttribute="trailing" constant="6" id="Xnl-Mi-4el"/>
<constraint firstAttribute="bottom" secondItem="4" secondAttribute="bottom" constant="8" id="acL-xO-d30"/>
<constraint firstItem="TYG-PY-W9b" firstAttribute="top" secondItem="4" secondAttribute="top" id="bOM-e0-C6q"/>
<constraint firstItem="7" firstAttribute="leading" secondItem="4" secondAttribute="trailing" constant="8" id="c7M-0S-tyB"/>
<constraint firstItem="4" firstAttribute="centerY" secondItem="Tip-yB-5Gh" secondAttribute="centerY" id="fyJ-RB-ru7"/>
<constraint firstItem="6" firstAttribute="trailing" secondItem="661-nY-3Tr" secondAttribute="leading" constant="-8" id="hp2-dT-ocj"/>
<constraint firstAttribute="trailing" secondItem="TYG-PY-W9b" secondAttribute="trailing" constant="11" id="lMx-hh-aQL"/>
<constraint firstItem="4" firstAttribute="top" secondItem="Tip-yB-5Gh" secondAttribute="top" constant="8" id="mTr-4f-FSJ"/>
<constraint firstItem="6" firstAttribute="leading" secondItem="4" secondAttribute="trailing" constant="8" id="rrY-Y1-Ttv"/>
<constraint firstItem="4" firstAttribute="leading" secondItem="Tip-yB-5Gh" secondAttribute="leading" constant="8" id="scr-nK-URb"/>
Expand All @@ -80,15 +99,20 @@
</tableViewCellContentView>
<connections>
<outlet property="downloadButton" destination="661-nY-3Tr" id="ehk-e3-y2O"/>
<outlet property="favouriteButton" destination="TYG-PY-W9b" id="bKy-Ua-Geq"/>
<outlet property="folderTitleLabel" destination="23" id="24"/>
<outlet property="subtitleLabel" destination="7" id="8"/>
<outlet property="thumbnailView" destination="4" id="9"/>
<outlet property="titleLabel" destination="6" id="10"/>
</connections>
<point key="canvasLocation" x="139" y="154"/>
<point key="canvasLocation" x="137.59999999999999" y="153.82308845577214"/>
</tableViewCell>
</objects>
<resources>
<image name="download.png" width="32" height="32"/>
<image name="heart" width="24" height="24"/>
<systemColor name="systemOrangeColor">
<color red="1" green="0.58431372550000005" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*****************************************************************************/

#import "VLCCloudStorageController.h"
#import "VLCCloudStorageTableViewCell.h"

@interface VLCCloudStorageTableViewController : UIViewController <VLCCloudStorageDelegate>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ @interface VLCCloudStorageTableViewController()
UIBarButtonItem *_progressBarButtonItem;
UIBarButtonItem *_logoutButton;
UINavigationController *tempNav;
NSString *_initialPath;
}

@end
Expand Down Expand Up @@ -101,6 +102,8 @@ - (void)viewDidLoad

[self updateToolbarWithProgress:nil];
[self updateForTheme];

_initialPath = self.currentPath;
}

- (void)updateForTheme
Expand Down Expand Up @@ -241,11 +244,16 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger

- (void)goBack
{
if ([self.currentPath isEqualToString: _initialPath]) {
[self.navigationController popViewControllerAnimated:YES];
return;
}
if (((![self.currentPath isEqualToString:@""] && ![self.currentPath isEqualToString:@"/"]) && [self.currentPath length] > 0) && [self.controller isAuthorized]){
self.currentPath = [self.currentPath stringByDeletingLastPathComponent];
[self requestInformationForCurrentPath];
} else
} else {
[self.navigationController popViewControllerAnimated:YES];
}
}

- (void)showLoginPanel
Expand Down Expand Up @@ -319,4 +327,37 @@ - (IBAction)playAllAction:(id)sender
{
}

- (UIContextMenuConfiguration *)tableView:(UITableView *)tableView contextMenuConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath point:(CGPoint)point
API_AVAILABLE(ios(13.0)) {
VLCCloudStorageTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

if (cell.isFavourable == false) {
return nil;
}

UIContextMenuConfiguration *menuConfiguration = [UIContextMenuConfiguration configurationWithIdentifier:nil
previewProvider:nil
actionProvider:^UIMenu * _Nullable(NSArray<UIMenuElement *> * _Nonnull suggestedActions) {
NSMutableArray* actions = [[NSMutableArray alloc] init];

NSString *optionTitle = cell.isFavourite ? NSLocalizedString(@"REMOVE_FAVORITE", "") : NSLocalizedString(@"ADD_FAVORITE", "");
UIImage *image = cell.isFavourite ? [UIImage imageNamed:@"heart"] : [UIImage imageNamed:@"heart.fill"];

[actions addObject:[UIAction actionWithTitle:optionTitle image:image identifier:nil handler:^(__kindof UIAction * _Nonnull action) {
cell.isFavourite = !cell.isFavourite;
[self triggerFavoriteForCell: cell];
}]];

UIMenu* menu = [UIMenu menuWithTitle:@"" children:actions];
return menu;
}];

return menuConfiguration;
}

- (void)triggerFavoriteForCell:(VLCCloudStorageTableViewCell *)cell
{
// nop
}

@end
Loading

0 comments on commit f3715f7

Please sign in to comment.