Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

Commit

Permalink
rearrange files in folders, added ability to check for new versions
Browse files Browse the repository at this point in the history
  • Loading branch information
hollanderbart committed Nov 10, 2017
1 parent 56b587a commit e5d8182
Show file tree
Hide file tree
Showing 72 changed files with 149 additions and 126 deletions.
82 changes: 41 additions & 41 deletions NPO Live.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
511C0F571C06388D00B15BDA /* SmallChannelCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 511C0F541C06388D00B15BDA /* SmallChannelCell.swift */; };
511C0F5A1C06389D00B15BDA /* TVCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 511C0F581C06389D00B15BDA /* TVCollectionViewController.swift */; };
511C0F5B1C06389D00B15BDA /* PlayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 511C0F591C06389D00B15BDA /* PlayerViewController.swift */; };
93026D061FB258E000BC01F8 /* ChannelStreamController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93026D051FB258E000BC01F8 /* ChannelStreamController.swift */; };
932C01991FB34EDD0028D251 /* VersionUtility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 932C01981FB34EDD0028D251 /* VersionUtility.swift */; };
93AF11B91F18BA05005043DB /* Pods_NPO_Live.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DAF4D1674025305B1531E95D /* Pods_NPO_Live.framework */; };
/* End PBXBuildFile section */

Expand All @@ -31,7 +31,7 @@
511C0F591C06389D00B15BDA /* PlayerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerViewController.swift; sourceTree = "<group>"; };
5123DB861C008A1A00F86B26 /* NPO Live.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "NPO Live.app"; sourceTree = BUILT_PRODUCTS_DIR; };
5123DB921C008A1A00F86B26 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
93026D051FB258E000BC01F8 /* ChannelStreamController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelStreamController.swift; sourceTree = "<group>"; };
932C01981FB34EDD0028D251 /* VersionUtility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionUtility.swift; sourceTree = "<group>"; };
98E26ADFA6C6F60733EC205D /* Pods-NPO Live.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NPO Live.debug.xcconfig"; path = "Pods/Target Support Files/Pods-NPO Live/Pods-NPO Live.debug.xcconfig"; sourceTree = "<group>"; };
DAF4D1674025305B1531E95D /* Pods_NPO_Live.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NPO_Live.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
Expand All @@ -48,80 +48,80 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
49F08DDD1C00ED2E00AF0C36 /* Supporting Files */ = {
5123DB7D1C008A1A00F86B26 = {
isa = PBXGroup;
children = (
511C0F4E1C06387700B15BDA /* AppDelegate.swift */,
511C0F4F1C06387700B15BDA /* Assets.xcassets */,
511C0F521C06388D00B15BDA /* Main.storyboard */,
5123DB921C008A1A00F86B26 /* Info.plist */,
5123DB881C008A1A00F86B26 /* NPO Live */,
5123DB871C008A1A00F86B26 /* Products */,
7B0DBED132F02AE30031C0B2 /* Pods */,
947374420EE0AC472B9668D5 /* Frameworks */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
511C0F4A1C06384C00B15BDA /* Model */ = {
5123DB871C008A1A00F86B26 /* Products */ = {
isa = PBXGroup;
children = (
511C0F471C06384900B15BDA /* ChannelProvider.swift */,
5123DB861C008A1A00F86B26 /* NPO Live.app */,
);
name = Model;
name = Products;
sourceTree = "<group>";
};
511C0F4B1C06385500B15BDA /* View */ = {
5123DB881C008A1A00F86B26 /* NPO Live */ = {
isa = PBXGroup;
children = (
511C0F531C06388D00B15BDA /* BigChannelCell.swift */,
511C0F541C06388D00B15BDA /* SmallChannelCell.swift */,
932FC16A1FB4454E00FDACBF /* Control */,
932FC1681FB4453500FDACBF /* Model */,
932FC1691FB4453F00FDACBF /* View */,
932FC16B1FB4458600FDACBF /* Supporting Files */,
);
name = View;
path = "NPO Live";
sourceTree = "<group>";
};
511C0F4C1C06385900B15BDA /* Control */ = {
7B0DBED132F02AE30031C0B2 /* Pods */ = {
isa = PBXGroup;
children = (
93026D051FB258E000BC01F8 /* ChannelStreamController.swift */,
511C0F581C06389D00B15BDA /* TVCollectionViewController.swift */,
511C0F591C06389D00B15BDA /* PlayerViewController.swift */,
98E26ADFA6C6F60733EC205D /* Pods-NPO Live.debug.xcconfig */,
4D473A8CFCE3B5A086B71258 /* Pods-NPO Live.release.xcconfig */,
);
name = Control;
name = Pods;
sourceTree = "<group>";
};
5123DB7D1C008A1A00F86B26 = {
932FC1681FB4453500FDACBF /* Model */ = {
isa = PBXGroup;
children = (
5123DB881C008A1A00F86B26 /* NPO Live */,
5123DB871C008A1A00F86B26 /* Products */,
7B0DBED132F02AE30031C0B2 /* Pods */,
947374420EE0AC472B9668D5 /* Frameworks */,
511C0F471C06384900B15BDA /* ChannelProvider.swift */,
);
path = Model;
sourceTree = "<group>";
};
5123DB871C008A1A00F86B26 /* Products */ = {
932FC1691FB4453F00FDACBF /* View */ = {
isa = PBXGroup;
children = (
5123DB861C008A1A00F86B26 /* NPO Live.app */,
511C0F531C06388D00B15BDA /* BigChannelCell.swift */,
511C0F541C06388D00B15BDA /* SmallChannelCell.swift */,
);
name = Products;
path = View;
sourceTree = "<group>";
};
5123DB881C008A1A00F86B26 /* NPO Live */ = {
932FC16A1FB4454E00FDACBF /* Control */ = {
isa = PBXGroup;
children = (
511C0F4A1C06384C00B15BDA /* Model */,
511C0F4B1C06385500B15BDA /* View */,
511C0F4C1C06385900B15BDA /* Control */,
49F08DDD1C00ED2E00AF0C36 /* Supporting Files */,
511C0F581C06389D00B15BDA /* TVCollectionViewController.swift */,
511C0F591C06389D00B15BDA /* PlayerViewController.swift */,
932C01981FB34EDD0028D251 /* VersionUtility.swift */,
);
path = "NPO Live";
path = Control;
sourceTree = "<group>";
};
7B0DBED132F02AE30031C0B2 /* Pods */ = {
932FC16B1FB4458600FDACBF /* Supporting Files */ = {
isa = PBXGroup;
children = (
98E26ADFA6C6F60733EC205D /* Pods-NPO Live.debug.xcconfig */,
4D473A8CFCE3B5A086B71258 /* Pods-NPO Live.release.xcconfig */,
511C0F4E1C06387700B15BDA /* AppDelegate.swift */,
511C0F4F1C06387700B15BDA /* Assets.xcassets */,
511C0F521C06388D00B15BDA /* Main.storyboard */,
5123DB921C008A1A00F86B26 /* Info.plist */,
);
name = Pods;
path = "Supporting Files";
sourceTree = "<group>";
};
947374420EE0AC472B9668D5 /* Frameworks */ = {
Expand Down Expand Up @@ -257,10 +257,10 @@
files = (
511C0F5A1C06389D00B15BDA /* TVCollectionViewController.swift in Sources */,
511C0F501C06387700B15BDA /* AppDelegate.swift in Sources */,
93026D061FB258E000BC01F8 /* ChannelStreamController.swift in Sources */,
511C0F571C06388D00B15BDA /* SmallChannelCell.swift in Sources */,
511C0F5B1C06389D00B15BDA /* PlayerViewController.swift in Sources */,
511C0F491C06384900B15BDA /* ChannelProvider.swift in Sources */,
932C01991FB34EDD0028D251 /* VersionUtility.swift in Sources */,
511C0F561C06388D00B15BDA /* BigChannelCell.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -379,7 +379,7 @@
"$(inherited)",
"\"$(PROJECT_DIR)/NPO Live\"",
);
INFOPLIST_FILE = "NPO Live/Info.plist";
INFOPLIST_FILE = "NPO Live/Supporting Files/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "bdh.NPO-Live";
Expand All @@ -400,7 +400,7 @@
"$(inherited)",
"\"$(PROJECT_DIR)/NPO Live\"",
);
INFOPLIST_FILE = "NPO Live/Info.plist";
INFOPLIST_FILE = "NPO Live/Supporting Files/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "bdh.NPO-Live";
Expand Down
58 changes: 0 additions & 58 deletions NPO Live/AppDelegate.swift

This file was deleted.

19 changes: 0 additions & 19 deletions NPO Live/ChannelStreamController.swift

This file was deleted.

65 changes: 65 additions & 0 deletions NPO Live/Control/VersionUtility.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// AppVersionController.swift
// NPO Live
//
// Created by Bart den Hollander on 08/11/2017.
// Copyright © 2017 Bart den Hollander. All rights reserved.
//

import Foundation
import NPOStream

enum VersionControllerResult {
case newVersion(String)
case noNewVersion
}

struct Release: Codable {
var tag_name: String
var name: String
}

class VersionUtility {

static let gitHubLatestReleaseURLString = "https://api.github.com/repos/hollanderbart/NPO-Live/releases/latest"

func checkForNewVersion(_ currentVersion: String, onCompletion: @escaping (VersionControllerResult) -> Void) {
guard let gitHubLatestReleaseURL = URL(string: VersionUtility.gitHubLatestReleaseURLString) else { return }

getVersionTagFromLatestRelease(gitHubLatestReleaseURL) { (result) in
switch result {
case .success(let version):
if version > currentVersion {
onCompletion(.newVersion(version))
} else {
onCompletion(.noNewVersion)
}
case .error(let error):
print(error)
}
}
}

private func getVersionTagFromLatestRelease(_ url: URL, onCompletion: @escaping (Result<String>) -> Void) {
let decoder = JSONDecoder()
let request = NSMutableURLRequest(url: url)
request.httpMethod = "GET"
request.addValue("application/vnd.github.v3+json", forHTTPHeaderField: "Accept")

let task = URLSession.shared.dataTask(with: request as URLRequest) { (data, _, error) in
if let responseData = data {
do {
let response = try decoder.decode(Release.self, from: responseData)
onCompletion(.success(response.tag_name))
} catch {
onCompletion(.error(error))
}
} else {
if let error = error {
onCompletion(.error(error))
}
}
}
task.resume()
}
}
File renamed without changes.
39 changes: 39 additions & 0 deletions NPO Live/Supporting Files/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// AppDelegate.swift
// NPO Live
//
// Created by Maurice van Breukelen on 21-11-15.
// Copyright © 2015 Maurice van Breukelen. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?
let versionUtility = VersionUtility()

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

if let currentVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String {
versionUtility.checkForNewVersion(currentVersion) { result in
switch result {
case .newVersion(let newVersion):
let alert = UIAlertController(title: "Update available", message: "Version \(newVersion) is available. Your version is \(currentVersion).", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))

DispatchQueue.main.async {
if let rootViewController = self.window?.rootViewController {
rootViewController.present(alert, animated: true, completion: nil)
}
}
case .noNewVersion:
break
}

}
}
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.1</string>
<string>1.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SmallChannelCell: UICollectionViewCell {
let channel = channel,
let image = UIImage(named: channel.title) else { return }
logoView.image = image
logoView.center = contentView.center
logoView.contentMode = .scaleAspectFill
logoView.adjustsImageWhenAncestorFocused = true
logoView.layer.cornerRadius = 10
logoView.layer.masksToBounds = true
Expand Down
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,10 @@ The following channels are available to watch.
![Top Shelf](images/top_shelf.png)
![Playing](images/playing.png)

## Changelog
* v1.0.1: Build fixed
* v1.0.0: Initial release

## Next releases
- Check for updates automatically
- ~~Check for updates automatically~~
- Active show information per channel
- Support for light / dark theme
- ~~Support for light / dark theme~~
- While watching a channel, go directly to the next or previous channel
- Subtitle support
- Automatic refresh token after one hour of watching a show (known issue)
Expand Down

0 comments on commit e5d8182

Please sign in to comment.