Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Diveboard.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
3CF3378318BD48FE001D2DF0 /* DiveCountlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3CF3378218BD48FE001D2DF0 /* DiveCountlineView.m */; };
3CF3378518BD591F001D2DF0 /* DiveCountlineView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3CF3378418BD591F001D2DF0 /* DiveCountlineView.xib */; };
3CF3780718DD22CD00D832B3 /* DiveEditViewController-ipad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3CF3780618DD22CD00D832B3 /* DiveEditViewController-ipad.xib */; };
6AB050AD213F672F00DC40BB /* btn_youtube.png in Resources */ = {isa = PBXBuildFile; fileRef = 6AB050AC213F672E00DC40BB /* btn_youtube.png */; };
C313798519DEDC2600F4B3DD /* libsqlite3.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C313798419DEDC2600F4B3DD /* libsqlite3.0.dylib */; };
C31B7AA019DE465700BE6239 /* GZIP.m in Sources */ = {isa = PBXBuildFile; fileRef = C31B7A9F19DE465700BE6239 /* GZIP.m */; };
C31CC26B19E5903B001CA1F7 /* progress_mask.png in Resources */ = {isa = PBXBuildFile; fileRef = C31CC26A19E5903B001CA1F7 /* progress_mask.png */; };
Expand Down Expand Up @@ -432,6 +433,7 @@
3CF3378218BD48FE001D2DF0 /* DiveCountlineView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DiveCountlineView.m; sourceTree = "<group>"; };
3CF3378418BD591F001D2DF0 /* DiveCountlineView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DiveCountlineView.xib; sourceTree = "<group>"; };
3CF3780618DD22CD00D832B3 /* DiveEditViewController-ipad.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = "DiveEditViewController-ipad.xib"; sourceTree = "<group>"; };
6AB050AC213F672E00DC40BB /* btn_youtube.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = btn_youtube.png; sourceTree = "<group>"; };
C313798419DEDC2600F4B3DD /* libsqlite3.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.0.dylib; path = usr/lib/libsqlite3.0.dylib; sourceTree = SDKROOT; };
C31B7A9B19DE42FB00BE6239 /* libz.1.2.5.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.1.2.5.dylib; path = usr/lib/libz.1.2.5.dylib; sourceTree = SDKROOT; };
C31B7A9E19DE465700BE6239 /* GZIP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GZIP.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1042,10 +1044,10 @@
3C13084618F3E1DC00D51AC7 /* DataRequestManager.m */,
3CE7FA4E1933731700D72A34 /* DiveBoardNavigationController.h */,
3CE7FA4F1933731700D72A34 /* DiveBoardNavigationController.m */,
E0B1D5AC19C9BE150007C481 /* DiveDatePicker.m */,
3C66AB0118F538C7000AB0D6 /* DiveOfflineModeManager.h */,
3C66AB0218F538C7000AB0D6 /* DiveOfflineModeManager.m */,
E0B1D5AB19C9BE150007C481 /* DiveDatePicker.h */,
E0B1D5AC19C9BE150007C481 /* DiveDatePicker.m */,
E0B1D5B219C9EE740007C481 /* DiveDatePicker.xib */,
E035C3C819D0D17700FE5266 /* MKMapView+ZoomLevel.h */,
E035C3C919D0D17700FE5266 /* MKMapView+ZoomLevel.m */,
Expand Down Expand Up @@ -1128,6 +1130,7 @@
3CE047BA18BCBB4C00FA47FF /* button */ = {
isa = PBXGroup;
children = (
6AB050AC213F672E00DC40BB /* btn_youtube.png */,
C36D415119DB04B8003CBFE5 /* no_picture.png */,
C3A1675719D9BEB300D29509 /* btn_checked.png */,
C3A1675819D9BEB300D29509 /* btn_unchecked.png */,
Expand Down Expand Up @@ -1919,6 +1922,7 @@
C3A92DBE19E098C9003C9B58 /* WalletViewController.xib in Resources */,
3C539E2018EA46C200470897 /* icon58.png in Resources */,
3C539E2218EA46C200470897 /* icon76.png in Resources */,
6AB050AD213F672F00DC40BB /* btn_youtube.png in Resources */,
C5B7350619F6C1F7005FA191 /* uv_idea.png in Resources */,
E0A25C9119C62C300043A849 /* full_diveboard_grey.png in Resources */,
E0A25C9819C716FE0043A849 /* btn_back_black.png in Resources */,
Expand Down
4 changes: 2 additions & 2 deletions Diveboard/Classes/DiveDetail/DiveDetailPhotosViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@property (nonatomic, strong) id<DiveDetailPhotosViewDelegate> delegate;

- (id)initWithDiveInformation:(DiveInformation *) diveInfo;
- (void)setDiveInformation:(DiveInformation *)diveInfo;

- (void)setDiveInformation:(DiveInformation *) diveInfo;
- (void)didClickedYoutubeButton:(NSIndexPath *) indexPath :(NSString*)youtubeVideoId;

@end
13 changes: 10 additions & 3 deletions Diveboard/Classes/DiveDetail/DiveDetailPhotosViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import "DiveDetailPhotosViewController.h"
#import "DiveEditPhotoCell.h"
#import "Global.h"
@interface DiveDetailPhotosViewController ()
@interface DiveDetailPhotosViewController () <DiveEditPhotoCellDelegate>
{
DiveInformation* m_DiveInformation;
}
Expand Down Expand Up @@ -127,10 +127,12 @@ -(DiveEditPhotoCell *)collectionView:(UICollectionView *)collectionView cellForI
{
DiveEditPhotoCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"PhotoCell" forIndexPath:indexPath];


DivePicture* divePicture = [m_DiveInformation.divePictures objectAtIndex:indexPath.row];
[cell setDivePicture:indexPath:divePicture];

if (divePicture.isYoutube) {
[cell setYoutubeButton:indexPath:divePicture.youtubeVideoId];
cell.delegate = self;
}
return cell;


Expand Down Expand Up @@ -163,4 +165,9 @@ - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollection
return size;
}

-(void)didClickedYoutubeButton:(NSIndexPath *)indexPath :(NSString*)youtubeVideoId
{
[GlobalMethods launchYoutubeVideo:youtubeVideoId];
}

@end
26 changes: 12 additions & 14 deletions Diveboard/Classes/DiveDetail/DiveDetailPhotosViewController.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="DiveDetailPhotosViewController">
Expand All @@ -14,20 +18,20 @@
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="No Picture in your album" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="LdW-3W-kzf">
<rect key="frame" x="26" y="274" width="268" height="21"/>
<rect key="frame" x="26" y="323" width="323" height="21"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="HelveticaNeue-Light" family="Helvetica Neue" pointSize="14"/>
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<color key="textColor" red="0.66666668653488159" green="0.66666668653488159" blue="0.66666668653488159" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<collectionView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" minimumZoomScale="0.0" maximumZoomScale="0.0" dataMode="none" id="DXk-4X-vKm">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="0.0" minimumInteritemSpacing="0.0" id="XHy-6T-IDP">
<size key="itemSize" width="106" height="106"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
Expand All @@ -41,13 +45,7 @@
</connections>
</collectionView>
</subviews>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
<point key="canvasLocation" x="330" y="233"/>
</view>
</objects>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@optional
- (void)didLongPressedPhoto:(UIGestureRecognizer*) gestureRecognizer :(NSIndexPath*)indexPath :(UIImage*)image;
- (void)didClickedAddPhotoButton:(NSIndexPath*)indexPath;
- (void)didClickedYoutubeButton:(NSIndexPath*)indexPath :(NSString *)youtubeVideoId;
@end


Expand All @@ -22,11 +23,15 @@
IBOutlet UIImageView* m_imgDivePicture;

IBOutlet UIButton* m_btnAdd;
IBOutlet UIButton* m_btnYoutube;
}
@property (nonatomic, strong) id<DiveEditPhotoCellDelegate> delegate;
@property (nonatomic, copy) NSString* youtubeVideoId;

- (void)setAddButton:(NSIndexPath*)indexPath;
- (void)setYoutubeButton:(NSIndexPath*)indexPath :(NSString *)youtubeVideoId;
- (void)setDivePicture:(NSIndexPath*)indexPath :(DivePicture*)divePicture;
- (IBAction)onAddButton:(id)sender;
- (IBAction)onYoutubeButton:(id)sender;

@end
24 changes: 24 additions & 0 deletions Diveboard/Classes/DiveEdit/DiveEditPhotosVC/DiveEditPhotoCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ - (void)setDivePicture:(NSIndexPath*)indexPath :(DivePicture*)divePicture{

m_indexPath = indexPath;
[m_btnAdd setHidden:YES];
[m_btnYoutube setHidden:YES];

_longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressDetected:)];
[self addGestureRecognizer:_longPressRecognizer];
Expand All @@ -65,6 +66,21 @@ -(void)setAddButton:(NSIndexPath *)indexPath
[self removeGestureRecognizer:_longPressRecognizer];


}

-(void)setYoutubeButton:(NSIndexPath *)indexPath :(NSString *)youtubeVideoId
{

m_indexPath = indexPath;
self.youtubeVideoId = youtubeVideoId;

[m_btnYoutube setBackgroundImage:[UIImage imageNamed:@"btn_youtube.png"] forState:UIControlStateNormal];

[m_btnYoutube setHidden:NO];

[self removeGestureRecognizer:_longPressRecognizer];


}

-(void) longPressDetected:(UIGestureRecognizer*) gestureRecognizer{
Expand All @@ -83,4 +99,12 @@ - (void)onAddButton:(id)sender{
[self.delegate didClickedAddPhotoButton:m_indexPath];
}
}
- (void)onYoutubeButton:(id)sender {

if (self.delegate && [self.delegate respondsToSelector:@selector(didClickedYoutubeButton::)]) {

[self.delegate didClickedYoutubeButton:m_indexPath :self.youtubeVideoId];
}
}

@end
32 changes: 21 additions & 11 deletions Diveboard/Classes/DiveEdit/DiveEditPhotosVC/DiveEditPhotoCell.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6250" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
Expand All @@ -17,32 +21,38 @@
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" id="6AN-Ft-2CY">
<rect key="frame" x="0.0" y="0.0" width="106" height="106"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="fc6-U5-XEC">
<rect key="frame" x="0.0" y="0.0" width="106" height="106"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="onAddButton:" destination="X9j-Mr-iKP" eventType="touchUpInside" id="kO1-6v-kqZ"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="4DS-zn-lK6" userLabel="Mbtn Youtube">
<rect key="frame" x="0.0" y="0.0" width="106" height="106"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="onYoutubeButton:" destination="X9j-Mr-iKP" eventType="touchUpInside" id="mcC-sM-o47"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<size key="customSize" width="141" height="121"/>
<connections>
<outlet property="m_btnAdd" destination="fc6-U5-XEC" id="yxu-qg-REy"/>
<outlet property="m_btnYoutube" destination="4DS-zn-lK6" id="rmr-St-gEB"/>
<outlet property="m_imgDivePicture" destination="6AN-Ft-2CY" id="Yko-Kp-Azx"/>
</connections>
</collectionViewCell>
</objects>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>
2 changes: 2 additions & 0 deletions Diveboard/Classes/Global/DiveInformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
@property (nonatomic, strong) NSString *permaLink;
@property (nonatomic, strong) NSString *player;
@property (nonatomic, strong) NSString *thumbnail;
@property (nonatomic) BOOL isYoutube;
@property (nonatomic, strong) NSString *youtubeVideoId;

@property (nonatomic, strong) NSString *urlString;
@property (nonatomic) BOOL isLocal;
Expand Down
16 changes: 16 additions & 0 deletions Diveboard/Classes/Global/DiveInformation.m
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,22 @@ - (id)initWithDictionary:(NSDictionary *)data
}

}
//Check if Youtube Video
if ([self.media rangeOfString:@"video"].location != NSNotFound && [self.player rangeOfString:@"youtube.com"].location != NSNotFound) {
NSError *error = NULL;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"src\\=\\'http\\:\\/\\/www\\.youtube\\.com\\/embed\\/([a-zA-Z0-9]+)\\?wmode\\=opaque\\&autoplay\\=0\\'"
options:NSRegularExpressionCaseInsensitive
error:&error];
NSArray *matches = [regex matchesInString:self.player options:0 range:NSMakeRange(0, [self.player length])];
NSString *youtubeVideoId = NULL;
if (matches.count>0) {
//NSRange matchRange = [match range];
NSRange matchRange = [matches[0] rangeAtIndex:1];
self.youtubeVideoId = [self.player substringWithRange:matchRange];
self.isYoutube = true;
}
}

return self;
}

Expand Down
2 changes: 1 addition & 1 deletion Diveboard/Classes/Global/Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ typedef NSUInteger UserSettingDownloadType;

+ (NSString *) encodeValueToFloat:(NSString *)value;
+ (void)setBorderView:(UIView*)view borderColor:(UIColor *)color borderWidth:(float)borderWidth position:(NSString*)position;

+ (void)launchYoutubeVideo:(NSString*)youtubeVideoId;

@end

Expand Down
12 changes: 12 additions & 0 deletions Diveboard/Classes/Global/Global.m
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,18 @@ + (void)setBorderView:(UIView*)view borderColor:(UIColor *)color borderWidth:(fl

}

+(void)launchYoutubeVideo:(NSString*)youtubeVideoId {
NSURL *linkToApp = [NSURL URLWithString:[NSString stringWithFormat:@"youtube://watch?v=%@",youtubeVideoId]];
NSURL *linkToWeb = [NSURL URLWithString:[NSString stringWithFormat:@"https://www.youtube.com/watch?v=%@",youtubeVideoId]];

if ([[UIApplication sharedApplication] canOpenURL:linkToApp]) {
[[UIApplication sharedApplication] openURL:linkToApp];
}
else{
[[UIApplication sharedApplication] openURL:linkToWeb];
}
return;
}

@end

Expand Down
Loading