Skip to content

Commit 1cfe43e

Browse files
cpgiswiftshekcsoni111anubhavpulkit
authored
Merge pull request #245 from Marton-Zeisler/feature/recent-files
* adds recent files database * recents db completed * removes build error * Front end Features for Recent Files Co-authored-by: iswiftshek <[email protected]> Co-authored-by: Chirag Maheshwari <[email protected]> Co-authored-by: Anubhav Singh <[email protected]>
2 parents f83da3b + 9907c3e commit 1cfe43e

36 files changed

+1837
-36
lines changed

AmahiAnywhere/AmahiAnywhere.xcodeproj/project.pbxproj

Lines changed: 61 additions & 5 deletions
Large diffs are not rendered by default.

AmahiAnywhere/AmahiAnywhere.xcworkspace/contents.xcworkspacedata

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AmahiAnywhere/AmahiAnywhere/AppDelegate.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2828
fileprivate var useCastContainerViewController = false
2929

3030
let appID = ApiConfig.appID
31-
let stack = CoreDataStack(modelName: "OfflineFilesModel")!
31+
let stack = CoreDataStack(modelName: "LocalFilesModel")!
3232

3333
var window: UIWindow?
3434
var backgroundSessionCompletionHandler: (() -> Void)?
@@ -214,6 +214,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
214214
NotificationCenter.default.removeObserver(self,
215215
name: NSNotification.Name.gckExpandedMediaControlsTriggered,
216216
object: nil)
217+
RecentsPersistenceService.saveContext()
217218
}
218219

219220
// Mark - Only for debug
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"scale" : "1x"
6+
},
7+
{
8+
"idiom" : "universal",
9+
"filename" : "recentIcon.png",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"filename" : "recentIcon-1.png",
15+
"scale" : "3x"
16+
}
17+
],
18+
"info" : {
19+
"version" : 1,
20+
"author" : "xcode"
21+
}
22+
}
2.73 KB
Loading
1.63 KB
Loading

AmahiAnywhere/AmahiAnywhere/Base/BaseUIViewController.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,20 @@ class BaseUIViewController: UIViewController, GCKSessionManagerListener, GCKRequ
117117
}
118118

119119
@objc func updateTabBarCompleted(){
120-
if var downloadsTabCounter = Int(tabBarController?.tabBar.items?[1].badgeValue ?? "1"){
120+
if var downloadsTabCounter = Int(tabBarController?.tabBar.items?[2].badgeValue ?? "1"){
121121
downloadsTabCounter -= 1
122122
if downloadsTabCounter >= 1{
123-
tabBarController?.tabBar.items?[1].badgeValue = String(downloadsTabCounter)
123+
tabBarController?.tabBar.items?[2].badgeValue = String(downloadsTabCounter)
124124
}else{
125-
tabBarController?.tabBar.items?[1].badgeValue = nil
125+
tabBarController?.tabBar.items?[2].badgeValue = nil
126126
}
127127
}
128128
}
129129

130130
@objc func updateTabBarStarted(){
131-
if var downloadsTabCounter = Int(tabBarController?.tabBar.items?[1].badgeValue ?? "0"){
131+
if var downloadsTabCounter = Int(tabBarController?.tabBar.items?[2].badgeValue ?? "0"){
132132
downloadsTabCounter += 1
133-
tabBarController?.tabBar.items?[1].badgeValue = String(downloadsTabCounter)
133+
tabBarController?.tabBar.items?[2].badgeValue = String(downloadsTabCounter)
134134
}
135135
}
136136

AmahiAnywhere/AmahiAnywhere/Cells/FilesBaseCollectionViewCell.swift

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,59 @@ class FilesBaseCollectionCell: SwipeCollectionViewCell{
2121
selectedBackgroundView = backgroundView
2222
}
2323

24+
func setupArtWork(recentFile: Recent, iconImageView: UIImageView){
25+
let type = recentFile.mimeType
26+
let url = URL(string: recentFile.fileURL)!
27+
28+
switch type {
29+
case "image":
30+
iconImageView.sd_setImage(with: url, placeholderImage: UIImage(named: "image"), options: .refreshCached)
31+
break
32+
case "video":
33+
if let image = VideoThumbnailGenerator.imageFromMemory(for: url) {
34+
iconImageView.image = image
35+
} else {
36+
iconImageView.image = UIImage(named: "video")
37+
DispatchQueue.global(qos: .background).async {
38+
let image = VideoThumbnailGenerator().getThumbnail(url)
39+
DispatchQueue.main.async {
40+
iconImageView.image = image
41+
}
42+
}
43+
}
44+
break
45+
case "audio":
46+
if let image = AudioThumbnailGenerator.imageFromMemory(for: url) {
47+
iconImageView.image = image
48+
} else {
49+
iconImageView.image = UIImage(named: "audio")
50+
DispatchQueue.global(qos: .background).async {
51+
let image = AudioThumbnailGenerator().getThumbnail(url)
52+
DispatchQueue.main.async {
53+
iconImageView.image = image
54+
}
55+
}
56+
}
57+
break
58+
case "presentation", "document", "spreadsheet":
59+
if let image = PDFThumbnailGenerator.imageFromMemory(for: url) {
60+
iconImageView.image = image
61+
} else {
62+
iconImageView.image = UIImage(named: "file")
63+
64+
DispatchQueue.global(qos: .background).async {
65+
let image = PDFThumbnailGenerator().getThumbnail(url)
66+
DispatchQueue.main.async {
67+
iconImageView.image = image
68+
}
69+
}
70+
}
71+
default:
72+
iconImageView.image = UIImage(named: "file")
73+
break
74+
}
75+
}
76+
2477
func setupArtWork(serverFile: ServerFile, iconImageView: UIImageView){
2578
let type = serverFile.mimeType
2679

AmahiAnywhere/AmahiAnywhere/Cells/FilesGridCollectionCell.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ class FilesGridCollectionCell: FilesBaseCollectionCell {
3535
}
3636
}
3737

38+
func setupData(recentFile: Recent){
39+
nameLabel.text = recentFile.fileName
40+
showFile()
41+
42+
setupArtWork(recentFile: recentFile, iconImageView: iconImageView)
43+
}
44+
3845
func showDirectory(){
3946
moreButton.isHidden = true
4047
iconImageView.image = UIImage(named: "folderIcon")

AmahiAnywhere/AmahiAnywhere/Cells/FilesListCollectionViewCell.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ class FilesListCollectionViewCell: FilesBaseCollectionCell {
4444
}
4545
}
4646

47+
func setupData(recentFile: Recent){
48+
nameLabel.text = recentFile.fileName
49+
showFile()
50+
51+
sizeModifiedLabel.text = "\(recentFile.fileDisplayText), \(recentFile.filesSize)"
52+
53+
setupArtWork(recentFile: recentFile, iconImageView: iconImageView)
54+
}
55+
4756
func showDirectory(){
4857
sizeModifiedLabel.isHidden = true
4958
moreButton.isHidden = true

0 commit comments

Comments
 (0)