mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-24 04:03:03 -04:00
Today widget refactor and NSDic representation of article
This commit is contained in:
parent
460f77791c
commit
31ff34b57f
@ -22,6 +22,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, OperationQueueDelegate {
|
||||
func recordActiveSession() {
|
||||
Preference.activeUseHistory.append(NSDate())
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
|
||||
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
|
||||
NSURLProtocol.registerClass(KiwixURLProtocol)
|
||||
@ -67,6 +69,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, OperationQueueDelegate {
|
||||
self.saveContext()
|
||||
}
|
||||
|
||||
func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
|
||||
guard url.scheme.caseInsensitiveCompare("kiwix") == .OrderedSame else {return false}
|
||||
mainController?.load(url)
|
||||
return true
|
||||
}
|
||||
|
||||
// MARK: - Active
|
||||
|
||||
func applicationDidBecomeActive(application: UIApplication) {
|
||||
|
@ -35,8 +35,21 @@
|
||||
<string>1.7</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>org.kiwix</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>kiwix</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.7.471</string>
|
||||
<string>1.7.485</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="M4Y-Lb-cyx">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
|
||||
</dependencies>
|
||||
@ -37,7 +36,7 @@
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="oCt-Oa-l7V">
|
||||
<rect key="frame" x="0.0" y="0.0" width="64" height="64"/>
|
||||
<color key="backgroundColor" cocoaTouchSystemColor="tableCellGroupedBackgroundColor"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="oCt-Oa-l7V" secondAttribute="height" multiplier="1:1" id="mTX-gY-AnP"/>
|
||||
</constraints>
|
||||
@ -49,7 +48,7 @@
|
||||
<constraint firstAttribute="width" secondItem="5ff-qy-Hgj" secondAttribute="height" multiplier="1:1" id="xey-BP-NuA"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cpM-fR-Nl4">
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="clip" numberOfLines="2" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cpM-fR-Nl4">
|
||||
<rect key="frame" x="0.0" y="66" width="64" height="12"/>
|
||||
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="10"/>
|
||||
<color key="textColor" red="1" green="1" blue="1" alpha="0.80000000000000004" colorSpace="calibratedRGB"/>
|
@ -17,7 +17,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.7</string>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
@ -19,8 +19,7 @@ class TodayViewController: UIViewController, NCWidgetProviding, UICollectionView
|
||||
private var itemHeight: CGFloat = 0.0
|
||||
private var itemWidth: CGFloat = 0.0
|
||||
|
||||
private var titles = [String]()
|
||||
private var thumbDatas = [NSData]()
|
||||
private var bookmarks = [NSDictionary]()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
@ -57,16 +56,14 @@ class TodayViewController: UIViewController, NCWidgetProviding, UICollectionView
|
||||
|
||||
func updateData() {
|
||||
let defaults = NSUserDefaults(suiteName: "group.kiwix")
|
||||
guard let bookmarks = defaults?.objectForKey("bookmarks") as? [String: NSArray],
|
||||
let titles = bookmarks["titles"] as? [String],
|
||||
let thumbDatas = bookmarks["thumbDatas"] as? [NSData] else {return}
|
||||
self.titles = titles
|
||||
self.thumbDatas = thumbDatas
|
||||
guard let bookmarks = defaults?.objectForKey("bookmarks") as? [NSDictionary] else {return}
|
||||
self.bookmarks = bookmarks
|
||||
}
|
||||
|
||||
func updateUI() {
|
||||
itemWidth = (collectionView.frame.width - 6 * hInset) / 5
|
||||
|
||||
let titles = bookmarks.flatMap({$0.objectForKey("title") as? String})
|
||||
let labelHeights = titles.map({$0.heightWithConstrainedWidth(itemWidth, font: UIFont.systemFontOfSize(10.0, weight: UIFontWeightMedium))})
|
||||
let labelMaxHeight = max(12.0, min((labelHeights.maxElement() ?? 12.0), 24.0))
|
||||
itemHeight = itemWidth + 2.0 + labelMaxHeight // itemHeight (1:1 ration) + label top spacing + label height
|
||||
@ -75,14 +72,14 @@ class TodayViewController: UIViewController, NCWidgetProviding, UICollectionView
|
||||
collectionView.reloadData()
|
||||
}
|
||||
|
||||
// MARK: - UICollectionView
|
||||
// MARK: - UICollectionViewDataSource
|
||||
|
||||
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||
return titles.count
|
||||
return bookmarks.count
|
||||
}
|
||||
|
||||
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
|
||||
@ -93,8 +90,25 @@ class TodayViewController: UIViewController, NCWidgetProviding, UICollectionView
|
||||
|
||||
func configureCell(cell: UICollectionViewCell, atIndexPath indexPath: NSIndexPath) {
|
||||
guard let cell = cell as? BookmarkWidgetCell else {return}
|
||||
cell.label.text = titles[indexPath.item]
|
||||
cell.imageView.image = UIImage(data: thumbDatas[indexPath.item])
|
||||
let bookmark = bookmarks[indexPath.item]
|
||||
guard let title = bookmark["title"] as? String,
|
||||
let thumbImageData = bookmark["thumbImageData"] as? NSData else {return}
|
||||
|
||||
cell.label.text = title
|
||||
cell.imageView.image = UIImage(data: thumbImageData)
|
||||
|
||||
}
|
||||
|
||||
// MARK: - UICollectionViewDelegate
|
||||
|
||||
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
|
||||
let bookmark = bookmarks[indexPath.item]
|
||||
guard let urlString = bookmark["url"] as? String,
|
||||
let url = NSURL(string: urlString) else {return}
|
||||
extensionContext?.openURL(url, completionHandler: { (completed) in
|
||||
collectionView.deselectItemAtIndexPath(indexPath, animated: true)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// MARK: - UICollectionViewDelegateFlowLayout
|
104
Kiwix-iOSWidgets/Bookmarks/Base.lproj/MainInterface.storyboard
Normal file
104
Kiwix-iOSWidgets/Bookmarks/Base.lproj/MainInterface.storyboard
Normal file
@ -0,0 +1,104 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="M4Y-Lb-cyx">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Today View Controller-->
|
||||
<scene sceneID="cwh-vc-ff4">
|
||||
<objects>
|
||||
<viewController id="M4Y-Lb-cyx" customClass="TodayViewController" customModule="Bookmarks" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="Ft6-oW-KC0"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="FKl-LY-JtV"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" simulatedAppContext="notificationCenter" id="S3S-Oj-5AN">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="100"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="rGU-qY-GzL">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="100"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="elH-Eg-whL">
|
||||
<size key="itemSize" width="64" height="92"/>
|
||||
<size key="headerReferenceSize" width="0.0" height="0.0"/>
|
||||
<size key="footerReferenceSize" width="0.0" height="0.0"/>
|
||||
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
|
||||
</collectionViewFlowLayout>
|
||||
<cells>
|
||||
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="BookmarkWidgetCell" id="shV-TG-J6y" customClass="BookmarkWidgetCell" customModule="Bookmarks" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="64" height="92"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="64" height="92"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="oCt-Oa-l7V">
|
||||
<rect key="frame" x="0.0" y="0.0" width="64" height="64"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="oCt-Oa-l7V" secondAttribute="height" multiplier="1:1" id="mTX-gY-AnP"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="5ff-qy-Hgj">
|
||||
<rect key="frame" x="2" y="2" width="60" height="60"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="5ff-qy-Hgj" secondAttribute="height" multiplier="1:1" id="xey-BP-NuA"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="clip" numberOfLines="2" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cpM-fR-Nl4">
|
||||
<rect key="frame" x="0.0" y="66" width="64" height="12"/>
|
||||
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="10"/>
|
||||
<color key="textColor" red="1" green="1" blue="1" alpha="0.80000000000000004" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
<constraints>
|
||||
<constraint firstItem="oCt-Oa-l7V" firstAttribute="leading" secondItem="shV-TG-J6y" secondAttribute="leading" id="3Iz-Ch-1ub"/>
|
||||
<constraint firstAttribute="trailing" secondItem="oCt-Oa-l7V" secondAttribute="trailing" id="4th-dr-nsA"/>
|
||||
<constraint firstItem="cpM-fR-Nl4" firstAttribute="leading" secondItem="shV-TG-J6y" secondAttribute="leading" id="R3a-Ik-dTO"/>
|
||||
<constraint firstItem="oCt-Oa-l7V" firstAttribute="top" secondItem="shV-TG-J6y" secondAttribute="top" id="fJC-Sd-n9A"/>
|
||||
<constraint firstItem="5ff-qy-Hgj" firstAttribute="top" secondItem="shV-TG-J6y" secondAttribute="top" constant="2" id="gyY-t5-3oU"/>
|
||||
<constraint firstAttribute="trailing" secondItem="5ff-qy-Hgj" secondAttribute="trailing" constant="2" id="n7k-4X-SYx"/>
|
||||
<constraint firstItem="cpM-fR-Nl4" firstAttribute="top" secondItem="oCt-Oa-l7V" secondAttribute="bottom" constant="2" id="pYC-H9-NbT"/>
|
||||
<constraint firstAttribute="trailing" secondItem="cpM-fR-Nl4" secondAttribute="trailing" id="rRQ-AL-9dU"/>
|
||||
<constraint firstItem="5ff-qy-Hgj" firstAttribute="leading" secondItem="shV-TG-J6y" secondAttribute="leading" constant="2" id="spE-wK-Obf"/>
|
||||
</constraints>
|
||||
<size key="customSize" width="64" height="92"/>
|
||||
<connections>
|
||||
<outlet property="imageBackgroundView" destination="oCt-Oa-l7V" id="0EK-gh-2yQ"/>
|
||||
<outlet property="imageView" destination="5ff-qy-Hgj" id="P92-ze-loY"/>
|
||||
<outlet property="label" destination="cpM-fR-Nl4" id="jQp-Vs-HaK"/>
|
||||
</connections>
|
||||
</collectionViewCell>
|
||||
</cells>
|
||||
</collectionView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="FKl-LY-JtV" firstAttribute="top" secondItem="rGU-qY-GzL" secondAttribute="bottom" id="0DU-Xd-zt9"/>
|
||||
<constraint firstItem="rGU-qY-GzL" firstAttribute="leading" secondItem="S3S-Oj-5AN" secondAttribute="leading" id="76F-49-Fzg"/>
|
||||
<constraint firstAttribute="trailing" secondItem="rGU-qY-GzL" secondAttribute="trailing" id="CEt-21-7VZ"/>
|
||||
<constraint firstItem="rGU-qY-GzL" firstAttribute="top" secondItem="Ft6-oW-KC0" secondAttribute="bottom" id="TFg-Zd-dq7"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<extendedEdge key="edgesForExtendedLayout"/>
|
||||
<nil key="simulatedStatusBarMetrics"/>
|
||||
<nil key="simulatedTopBarMetrics"/>
|
||||
<nil key="simulatedBottomBarMetrics"/>
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
|
||||
<size key="freeformSize" width="320" height="100"/>
|
||||
<connections>
|
||||
<outlet property="collectionView" destination="rGU-qY-GzL" id="lfU-S6-XrK"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="vXp-U4-Rya" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="516" y="285"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
22
Kiwix-iOSWidgets/Bookmarks/BookmarkWidgetCell.swift
Normal file
22
Kiwix-iOSWidgets/Bookmarks/BookmarkWidgetCell.swift
Normal file
@ -0,0 +1,22 @@
|
||||
//
|
||||
// BookmarkWidgetCell.swift
|
||||
// Kiwix
|
||||
//
|
||||
// Created by Chris Li on 7/20/16.
|
||||
// Copyright © 2016 Chris. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class BookmarkWidgetCell: UICollectionViewCell {
|
||||
override func awakeFromNib() {
|
||||
imageView.layer.masksToBounds = true
|
||||
imageView.layer.cornerRadius = 4.0
|
||||
imageBackgroundView.layer.masksToBounds = true
|
||||
imageBackgroundView.layer.cornerRadius = 6.0
|
||||
}
|
||||
|
||||
@IBOutlet weak var imageView: UIImageView!
|
||||
@IBOutlet weak var imageBackgroundView: UIView!
|
||||
@IBOutlet weak var label: UILabel!
|
||||
}
|
10
Kiwix-iOSWidgets/Bookmarks/Bookmarks.entitlements
Normal file
10
Kiwix-iOSWidgets/Bookmarks/Bookmarks.entitlements
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.kiwix</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
33
Kiwix-iOSWidgets/Bookmarks/Info.plist
Normal file
33
Kiwix-iOSWidgets/Bookmarks/Info.plist
Normal file
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Bookmarks</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionMainStoryboard</key>
|
||||
<string>MainInterface</string>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.widget-extension</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
135
Kiwix-iOSWidgets/Bookmarks/TodayViewController.swift
Normal file
135
Kiwix-iOSWidgets/Bookmarks/TodayViewController.swift
Normal file
@ -0,0 +1,135 @@
|
||||
//
|
||||
// TodayViewController.swift
|
||||
// Article
|
||||
//
|
||||
// Created by Chris Li on 7/19/16.
|
||||
// Copyright © 2016 Chris. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import NotificationCenter
|
||||
|
||||
class TodayViewController: UIViewController, NCWidgetProviding, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
|
||||
|
||||
@IBOutlet weak var collectionView: UICollectionView!
|
||||
|
||||
private var rowHeight: CGFloat = 110.0
|
||||
private let hInset: CGFloat = 15.0
|
||||
private let vInset: CGFloat = 10.0
|
||||
private var itemHeight: CGFloat = 0.0
|
||||
private var itemWidth: CGFloat = 0.0
|
||||
|
||||
private var bookmarks = [NSDictionary]()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
collectionView.dataSource = self
|
||||
collectionView.delegate = self
|
||||
|
||||
updateData()
|
||||
updateUI()
|
||||
}
|
||||
|
||||
override func viewWillAppear(animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
updateData()
|
||||
updateUI()
|
||||
}
|
||||
|
||||
// MARK: - NCWidgetProviding
|
||||
|
||||
func widgetMarginInsetsForProposedMarginInsets(defaultMarginInsets: UIEdgeInsets) -> UIEdgeInsets {
|
||||
return UIEdgeInsetsZero
|
||||
}
|
||||
|
||||
func widgetPerformUpdateWithCompletionHandler(completionHandler: ((NCUpdateResult) -> Void)) {
|
||||
// Perform any setup necessary in order to update the view.
|
||||
|
||||
// If an error is encountered, use NCUpdateResult.Failed
|
||||
// If there's no update required, use NCUpdateResult.NoData
|
||||
// If there's an update, use NCUpdateResult.NewData
|
||||
|
||||
updateData()
|
||||
updateUI()
|
||||
completionHandler(NCUpdateResult.NewData)
|
||||
}
|
||||
|
||||
func updateData() {
|
||||
let defaults = NSUserDefaults(suiteName: "group.kiwix")
|
||||
guard let bookmarks = defaults?.objectForKey("bookmarks") as? [NSDictionary] else {return}
|
||||
self.bookmarks = bookmarks
|
||||
}
|
||||
|
||||
func updateUI() {
|
||||
itemWidth = (collectionView.frame.width - 6 * hInset) / 5
|
||||
|
||||
let titles = bookmarks.flatMap({$0.objectForKey("title") as? String})
|
||||
let labelHeights = titles.map({$0.heightWithConstrainedWidth(itemWidth, font: UIFont.systemFontOfSize(10.0, weight: UIFontWeightMedium))})
|
||||
let labelMaxHeight = max(12.0, min((labelHeights.maxElement() ?? 12.0), 24.0))
|
||||
itemHeight = itemWidth + 2.0 + labelMaxHeight // itemHeight (1:1 ration) + label top spacing + label height
|
||||
|
||||
preferredContentSize = CGSizeMake(collectionView.frame.width, itemHeight + 2 * vInset)
|
||||
collectionView.reloadData()
|
||||
}
|
||||
|
||||
// MARK: - UICollectionViewDataSource
|
||||
|
||||
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||
return bookmarks.count
|
||||
}
|
||||
|
||||
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
|
||||
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("BookmarkWidgetCell", forIndexPath: indexPath)
|
||||
configureCell(cell, atIndexPath: indexPath)
|
||||
return cell
|
||||
}
|
||||
|
||||
func configureCell(cell: UICollectionViewCell, atIndexPath indexPath: NSIndexPath) {
|
||||
guard let cell = cell as? BookmarkWidgetCell else {return}
|
||||
let bookmark = bookmarks[indexPath.item]
|
||||
guard let title = bookmark["title"] as? String,
|
||||
let thumbImageData = bookmark["thumbImageData"] as? NSData else {return}
|
||||
|
||||
cell.label.text = title
|
||||
cell.imageView.image = UIImage(data: thumbImageData)
|
||||
|
||||
}
|
||||
|
||||
// MARK: - UICollectionViewDelegate
|
||||
|
||||
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
|
||||
let bookmark = bookmarks[indexPath.item]
|
||||
guard let urlString = bookmark["url"] as? String,
|
||||
let url = NSURL(string: urlString) else {return}
|
||||
extensionContext?.openURL(url, completionHandler: { (completed) in
|
||||
collectionView.deselectItemAtIndexPath(indexPath, animated: true)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// MARK: - UICollectionViewDelegateFlowLayout
|
||||
|
||||
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
|
||||
return CGSizeMake(itemWidth, itemHeight)
|
||||
}
|
||||
|
||||
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAtIndex section: Int) -> CGFloat {
|
||||
return 0.0
|
||||
}
|
||||
|
||||
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets {
|
||||
return UIEdgeInsetsMake(vInset, hInset, vInset, hInset)
|
||||
}
|
||||
}
|
||||
|
||||
private extension String {
|
||||
func heightWithConstrainedWidth(width: CGFloat, font: UIFont) -> CGFloat {
|
||||
let constraintRect = CGSize(width: width, height: CGFloat.max)
|
||||
let boundingBox = self.boundingRectWithSize(constraintRect, options: NSStringDrawingOptions.UsesLineFragmentOrigin, attributes: [NSFontAttributeName: font], context: nil)
|
||||
return boundingBox.height
|
||||
}
|
||||
}
|
@ -94,14 +94,7 @@
|
||||
971A10801D022F74007FC62C /* Pic_I.png in Resources */ = {isa = PBXBuildFile; fileRef = 971A107C1D022F74007FC62C /* Pic_I.png */; };
|
||||
971A10811D022F74007FC62C /* Pic_P.png in Resources */ = {isa = PBXBuildFile; fileRef = 971A107D1D022F74007FC62C /* Pic_P.png */; };
|
||||
971C4F0E1D400F010027B7D2 /* UpdateWidgetDataSourceOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 971C4F0D1D400F010027B7D2 /* UpdateWidgetDataSourceOperation.swift */; };
|
||||
971C4F121D4020E90027B7D2 /* BookmarkWidgetCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 971C4F111D4020E90027B7D2 /* BookmarkWidgetCell.swift */; };
|
||||
971C4F141D411DC00027B7D2 /* ArticleDataContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 971C4F131D411DC00027B7D2 /* ArticleDataContainer.swift */; };
|
||||
971C4F151D411DC00027B7D2 /* ArticleDataContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 971C4F131D411DC00027B7D2 /* ArticleDataContainer.swift */; };
|
||||
97219DBD1D383A00009FDFF1 /* BookmarkController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97219DBC1D383A00009FDFF1 /* BookmarkController.swift */; };
|
||||
9722121C1D3ECCFE00C0DCF2 /* NotificationCenter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 97E609F01D103DED00EBCB9D /* NotificationCenter.framework */; };
|
||||
9722121F1D3ECCFE00C0DCF2 /* TodayViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9722121E1D3ECCFE00C0DCF2 /* TodayViewController.swift */; };
|
||||
972212221D3ECCFE00C0DCF2 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 972212201D3ECCFE00C0DCF2 /* MainInterface.storyboard */; };
|
||||
972212261D3ECCFE00C0DCF2 /* Articles.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 9722121B1D3ECCFE00C0DCF2 /* Articles.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
9722122B1D3FCCE200C0DCF2 /* MainControllerShowHide.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9722122A1D3FCCE200C0DCF2 /* MainControllerShowHide.swift */; };
|
||||
9734E54E1D289D060061C39B /* Welcome.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9734E54D1D289D060061C39B /* Welcome.storyboard */; };
|
||||
973BCCEC1CEB3FA400F10B44 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 973BCCEB1CEB3FA400F10B44 /* AppDelegate.swift */; };
|
||||
@ -172,6 +165,10 @@
|
||||
9779A1CB1D34225E0071EFAB /* RefreshLibraryOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9779A1C51D34225E0071EFAB /* RefreshLibraryOperation.swift */; };
|
||||
9779A1CC1D34225E0071EFAB /* SearchOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9779A1C61D34225E0071EFAB /* SearchOperation.swift */; };
|
||||
9779A1CD1D34225E0071EFAB /* UIOperations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9779A1C71D34225E0071EFAB /* UIOperations.swift */; };
|
||||
9779C3141D4575AD0064CC8E /* NotificationCenter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 97E609F01D103DED00EBCB9D /* NotificationCenter.framework */; };
|
||||
9779C3171D4575AE0064CC8E /* TodayViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9779C3161D4575AE0064CC8E /* TodayViewController.swift */; };
|
||||
9779C31A1D4575AE0064CC8E /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9779C3181D4575AE0064CC8E /* MainInterface.storyboard */; };
|
||||
9779C31E1D4575AE0064CC8E /* Bookmarks.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 9779C3131D4575AD0064CC8E /* Bookmarks.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
978C58961C1CD86E0077AE47 /* Language.swift in Sources */ = {isa = PBXBuildFile; fileRef = 978C588E1C1CD86E0077AE47 /* Language.swift */; };
|
||||
978C58981C1CD86E0077AE47 /* Book.swift in Sources */ = {isa = PBXBuildFile; fileRef = 978C58901C1CD86E0077AE47 /* Book.swift */; };
|
||||
978C589C1C1CD86E0077AE47 /* Article.swift in Sources */ = {isa = PBXBuildFile; fileRef = 978C58941C1CD86E0077AE47 /* Article.swift */; };
|
||||
@ -188,6 +185,7 @@
|
||||
97D452BC1D16FF010033666F /* RecentSearchCVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D452BB1D16FF010033666F /* RecentSearchCVC.swift */; };
|
||||
97D452BE1D1723FF0033666F /* CollectionViewCells.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D452BD1D1723FF0033666F /* CollectionViewCells.swift */; };
|
||||
97D55EF61D2075180081B523 /* TableOfContentsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D55EF51D2075180081B523 /* TableOfContentsController.swift */; };
|
||||
97DB65DA1D4576B600A2CC42 /* BookmarkWidgetCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97DB65D91D4576B600A2CC42 /* BookmarkWidgetCell.swift */; };
|
||||
97E60A021D10423A00EBCB9D /* ShadowViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97E60A011D10423A00EBCB9D /* ShadowViews.swift */; };
|
||||
97E60A061D10504000EBCB9D /* LibraryBackupTBVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97E60A051D10504000EBCB9D /* LibraryBackupTBVC.swift */; };
|
||||
97E850CB1D2DA5B300A9F688 /* About.html in Resources */ = {isa = PBXBuildFile; fileRef = 97E850CA1D2DA5B300A9F688 /* About.html */; };
|
||||
@ -198,13 +196,6 @@
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
972212241D3ECCFE00C0DCF2 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 97A2AB801C1B80FF00052E74 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 9722121A1D3ECCFE00C0DCF2;
|
||||
remoteInfo = Article;
|
||||
};
|
||||
973BCCFD1CEB3FA500F10B44 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 97A2AB801C1B80FF00052E74 /* Project object */;
|
||||
@ -219,6 +210,13 @@
|
||||
remoteGlobalIDString = 973BCCE81CEB3FA400F10B44;
|
||||
remoteInfo = "Kiwix-OSX";
|
||||
};
|
||||
9779C31C1D4575AE0064CC8E /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 97A2AB801C1B80FF00052E74 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 9779C3121D4575AD0064CC8E;
|
||||
remoteInfo = Bookmarks;
|
||||
};
|
||||
97A2ABA01C1B80FF00052E74 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 97A2AB801C1B80FF00052E74 /* Project object */;
|
||||
@ -262,7 +260,7 @@
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 13;
|
||||
files = (
|
||||
972212261D3ECCFE00C0DCF2 /* Articles.appex in Embed App Extensions */,
|
||||
9779C31E1D4575AE0064CC8E /* Bookmarks.appex in Embed App Extensions */,
|
||||
);
|
||||
name = "Embed App Extensions";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@ -340,15 +338,8 @@
|
||||
971A107C1D022F74007FC62C /* Pic_I.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Pic_I.png; path = Kiwix/HelpDocuments/Pic_I.png; sourceTree = SOURCE_ROOT; };
|
||||
971A107D1D022F74007FC62C /* Pic_P.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Pic_P.png; path = Kiwix/HelpDocuments/Pic_P.png; sourceTree = SOURCE_ROOT; };
|
||||
971C4F0B1D3FFFA60027B7D2 /* Kiwix.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = Kiwix.entitlements; path = "Kiwix-iOS/Kiwix.entitlements"; sourceTree = SOURCE_ROOT; };
|
||||
971C4F0C1D3FFFFF0027B7D2 /* Articles.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = Articles.entitlements; path = ../../Articles.entitlements; sourceTree = "<group>"; };
|
||||
971C4F0D1D400F010027B7D2 /* UpdateWidgetDataSourceOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UpdateWidgetDataSourceOperation.swift; path = Operations/UpdateWidgetDataSourceOperation.swift; sourceTree = "<group>"; };
|
||||
971C4F111D4020E90027B7D2 /* BookmarkWidgetCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookmarkWidgetCell.swift; sourceTree = "<group>"; };
|
||||
971C4F131D411DC00027B7D2 /* ArticleDataContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ArticleDataContainer.swift; path = Kiwix/Tools/ArticleDataContainer.swift; sourceTree = "<group>"; };
|
||||
97219DBC1D383A00009FDFF1 /* BookmarkController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BookmarkController.swift; path = "Kiwix-iOS/Controller/Bookmark/BookmarkController.swift"; sourceTree = SOURCE_ROOT; };
|
||||
9722121B1D3ECCFE00C0DCF2 /* Articles.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = Articles.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
9722121E1D3ECCFE00C0DCF2 /* TodayViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayViewController.swift; sourceTree = "<group>"; };
|
||||
972212211D3ECCFE00C0DCF2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
|
||||
972212231D3ECCFE00C0DCF2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
9722122A1D3FCCE200C0DCF2 /* MainControllerShowHide.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MainControllerShowHide.swift; path = "Kiwix-iOS/Controller/Main/MainControllerShowHide.swift"; sourceTree = SOURCE_ROOT; };
|
||||
9734E54D1D289D060061C39B /* Welcome.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Welcome.storyboard; path = "Kiwix-iOS/Storyboard/Welcome.storyboard"; sourceTree = SOURCE_ROOT; };
|
||||
973BCCE91CEB3FA400F10B44 /* Kiwix.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Kiwix.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@ -427,6 +418,10 @@
|
||||
9779A1C51D34225E0071EFAB /* RefreshLibraryOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RefreshLibraryOperation.swift; path = Operations/RefreshLibraryOperation.swift; sourceTree = "<group>"; };
|
||||
9779A1C61D34225E0071EFAB /* SearchOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SearchOperation.swift; path = Operations/SearchOperation.swift; sourceTree = "<group>"; };
|
||||
9779A1C71D34225E0071EFAB /* UIOperations.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UIOperations.swift; path = Operations/UIOperations.swift; sourceTree = "<group>"; };
|
||||
9779C3131D4575AD0064CC8E /* Bookmarks.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = Bookmarks.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
9779C3161D4575AE0064CC8E /* TodayViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayViewController.swift; sourceTree = "<group>"; };
|
||||
9779C3191D4575AE0064CC8E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
|
||||
9779C31B1D4575AE0064CC8E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
978C588E1C1CD86E0077AE47 /* Language.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Language.swift; path = Kiwix/CoreData/Language.swift; sourceTree = "<group>"; };
|
||||
978C58901C1CD86E0077AE47 /* Book.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; name = Book.swift; path = Kiwix/CoreData/Book.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
|
||||
978C58941C1CD86E0077AE47 /* Article.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Article.swift; path = Kiwix/CoreData/Article.swift; sourceTree = "<group>"; };
|
||||
@ -448,6 +443,7 @@
|
||||
97D452C01D1871E70033666F /* SearchLocalBooksCVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SearchLocalBooksCVC.swift; path = "Kiwix-iOS/Controller/Search/SearchLocalBooksCVC.swift"; sourceTree = SOURCE_ROOT; };
|
||||
97D452C11D1871E70033666F /* SearchTabController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SearchTabController.swift; path = "Kiwix-iOS/Controller/Search/SearchTabController.swift"; sourceTree = SOURCE_ROOT; };
|
||||
97D55EF51D2075180081B523 /* TableOfContentsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TableOfContentsController.swift; path = "Kiwix-iOS/Controller/TableOfContentsController.swift"; sourceTree = SOURCE_ROOT; };
|
||||
97DB65D91D4576B600A2CC42 /* BookmarkWidgetCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookmarkWidgetCell.swift; sourceTree = "<group>"; };
|
||||
97E609F01D103DED00EBCB9D /* NotificationCenter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NotificationCenter.framework; path = System/Library/Frameworks/NotificationCenter.framework; sourceTree = SDKROOT; };
|
||||
97E60A011D10423A00EBCB9D /* ShadowViews.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShadowViews.swift; sourceTree = "<group>"; };
|
||||
97E60A051D10504000EBCB9D /* LibraryBackupTBVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LibraryBackupTBVC.swift; path = "Kiwix-iOS/Controller/LibraryBackupTBVC.swift"; sourceTree = SOURCE_ROOT; };
|
||||
@ -460,14 +456,6 @@
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
972212181D3ECCFE00C0DCF2 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
9722121C1D3ECCFE00C0DCF2 /* NotificationCenter.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
973BCCE61CEB3FA400F10B44 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@ -503,6 +491,14 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
9779C3101D4575AD0064CC8E /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
9779C3141D4575AD0064CC8E /* NotificationCenter.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
97A2AB851C1B80FF00052E74 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@ -726,18 +722,6 @@
|
||||
path = View;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9722121D1D3ECCFE00C0DCF2 /* Articles */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
971C4F0C1D3FFFFF0027B7D2 /* Articles.entitlements */,
|
||||
972212201D3ECCFE00C0DCF2 /* MainInterface.storyboard */,
|
||||
9722121E1D3ECCFE00C0DCF2 /* TodayViewController.swift */,
|
||||
971C4F111D4020E90027B7D2 /* BookmarkWidgetCell.swift */,
|
||||
972212231D3ECCFE00C0DCF2 /* Info.plist */,
|
||||
);
|
||||
path = Articles;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
97254FDD1C26442F0056950B /* ZimMultiReader */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -826,7 +810,6 @@
|
||||
97E891681CA976E90001CA32 /* FileManager.swift */,
|
||||
973C8D5B1C25F945007272F9 /* Preference.swift */,
|
||||
979C51511CECA9AF001707F2 /* StringTools.swift */,
|
||||
971C4F131D411DC00027B7D2 /* ArticleDataContainer.swift */,
|
||||
);
|
||||
name = Tools;
|
||||
sourceTree = "<group>";
|
||||
@ -923,6 +906,17 @@
|
||||
name = Setting;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9779C3151D4575AD0064CC8E /* Bookmarks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9779C3161D4575AE0064CC8E /* TodayViewController.swift */,
|
||||
97DB65D91D4576B600A2CC42 /* BookmarkWidgetCell.swift */,
|
||||
9779C3181D4575AE0064CC8E /* MainInterface.storyboard */,
|
||||
9779C31B1D4575AE0064CC8E /* Info.plist */,
|
||||
);
|
||||
path = Bookmarks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
978C58791C1CCC920077AE47 /* Supporting */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -1021,7 +1015,7 @@
|
||||
973BCCE91CEB3FA400F10B44 /* Kiwix.app */,
|
||||
973BCCFC1CEB3FA400F10B44 /* Kiwix-OSXTests.xctest */,
|
||||
973BCD071CEB3FA500F10B44 /* Kiwix-OSXUITests.xctest */,
|
||||
9722121B1D3ECCFE00C0DCF2 /* Articles.appex */,
|
||||
9779C3131D4575AD0064CC8E /* Bookmarks.appex */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@ -1118,7 +1112,7 @@
|
||||
97E609F21D103DED00EBCB9D /* iOSWidgets */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9722121D1D3ECCFE00C0DCF2 /* Articles */,
|
||||
9779C3151D4575AD0064CC8E /* Bookmarks */,
|
||||
);
|
||||
name = iOSWidgets;
|
||||
path = "Kiwix-iOSWidgets";
|
||||
@ -1148,23 +1142,6 @@
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
9722121A1D3ECCFE00C0DCF2 /* Articles */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 972212271D3ECCFE00C0DCF2 /* Build configuration list for PBXNativeTarget "Articles" */;
|
||||
buildPhases = (
|
||||
972212171D3ECCFE00C0DCF2 /* Sources */,
|
||||
972212181D3ECCFE00C0DCF2 /* Frameworks */,
|
||||
972212191D3ECCFE00C0DCF2 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = Articles;
|
||||
productName = Article;
|
||||
productReference = 9722121B1D3ECCFE00C0DCF2 /* Articles.appex */;
|
||||
productType = "com.apple.product-type.app-extension";
|
||||
};
|
||||
973BCCE81CEB3FA400F10B44 /* Kiwix-OSX */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 973BCD0E1CEB3FA500F10B44 /* Build configuration list for PBXNativeTarget "Kiwix-OSX" */;
|
||||
@ -1223,6 +1200,23 @@
|
||||
productReference = 973BCD071CEB3FA500F10B44 /* Kiwix-OSXUITests.xctest */;
|
||||
productType = "com.apple.product-type.bundle.ui-testing";
|
||||
};
|
||||
9779C3121D4575AD0064CC8E /* Bookmarks */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 9779C31F1D4575AE0064CC8E /* Build configuration list for PBXNativeTarget "Bookmarks" */;
|
||||
buildPhases = (
|
||||
9779C30F1D4575AD0064CC8E /* Sources */,
|
||||
9779C3101D4575AD0064CC8E /* Frameworks */,
|
||||
9779C3111D4575AD0064CC8E /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = Bookmarks;
|
||||
productName = Bookmarks;
|
||||
productReference = 9779C3131D4575AD0064CC8E /* Bookmarks.appex */;
|
||||
productType = "com.apple.product-type.app-extension";
|
||||
};
|
||||
97A2AB871C1B80FF00052E74 /* Kiwix-iOS */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 97A2ABB31C1B810000052E74 /* Build configuration list for PBXNativeTarget "Kiwix-iOS" */;
|
||||
@ -1239,7 +1233,7 @@
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
972212251D3ECCFE00C0DCF2 /* PBXTargetDependency */,
|
||||
9779C31D1D4575AE0064CC8E /* PBXTargetDependency */,
|
||||
);
|
||||
name = "Kiwix-iOS";
|
||||
productName = Kiwix;
|
||||
@ -1292,15 +1286,6 @@
|
||||
LastUpgradeCheck = 0730;
|
||||
ORGANIZATIONNAME = Chris;
|
||||
TargetAttributes = {
|
||||
9722121A1D3ECCFE00C0DCF2 = {
|
||||
CreatedOnToolsVersion = 7.3.1;
|
||||
DevelopmentTeam = L7HWM3SP3L;
|
||||
SystemCapabilities = {
|
||||
com.apple.ApplicationGroups.iOS = {
|
||||
enabled = 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
973BCCE81CEB3FA400F10B44 = {
|
||||
CreatedOnToolsVersion = 7.3.1;
|
||||
};
|
||||
@ -1312,6 +1297,15 @@
|
||||
CreatedOnToolsVersion = 7.3.1;
|
||||
TestTargetID = 973BCCE81CEB3FA400F10B44;
|
||||
};
|
||||
9779C3121D4575AD0064CC8E = {
|
||||
CreatedOnToolsVersion = 7.3.1;
|
||||
DevelopmentTeam = L7HWM3SP3L;
|
||||
SystemCapabilities = {
|
||||
com.apple.ApplicationGroups.iOS = {
|
||||
enabled = 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
97A2AB871C1B80FF00052E74 = {
|
||||
CreatedOnToolsVersion = 7.2;
|
||||
DevelopmentTeam = L7HWM3SP3L;
|
||||
@ -1356,20 +1350,12 @@
|
||||
973BCCE81CEB3FA400F10B44 /* Kiwix-OSX */,
|
||||
973BCCFB1CEB3FA400F10B44 /* Kiwix-OSXTests */,
|
||||
973BCD061CEB3FA500F10B44 /* Kiwix-OSXUITests */,
|
||||
9722121A1D3ECCFE00C0DCF2 /* Articles */,
|
||||
9779C3121D4575AD0064CC8E /* Bookmarks */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
972212191D3ECCFE00C0DCF2 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
972212221D3ECCFE00C0DCF2 /* MainInterface.storyboard in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
973BCCE71CEB3FA400F10B44 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@ -1395,6 +1381,14 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
9779C3111D4575AD0064CC8E /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
9779C31A1D4575AE0064CC8E /* MainInterface.storyboard in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
97A2AB861C1B80FF00052E74 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@ -1555,16 +1549,6 @@
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
972212171D3ECCFE00C0DCF2 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
971C4F121D4020E90027B7D2 /* BookmarkWidgetCell.swift in Sources */,
|
||||
9722121F1D3ECCFE00C0DCF2 /* TodayViewController.swift in Sources */,
|
||||
971C4F151D411DC00027B7D2 /* ArticleDataContainer.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
973BCCE51CEB3FA400F10B44 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@ -1626,6 +1610,15 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
9779C30F1D4575AD0064CC8E /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
9779C3171D4575AE0064CC8E /* TodayViewController.swift in Sources */,
|
||||
97DB65DA1D4576B600A2CC42 /* BookmarkWidgetCell.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
97A2AB841C1B80FF00052E74 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@ -1652,7 +1645,6 @@
|
||||
9779A1CC1D34225E0071EFAB /* SearchOperation.swift in Sources */,
|
||||
97BAA8EC1D3D2D7B0038F57F /* PacketAnalyzer.swift in Sources */,
|
||||
970E68BA1D3809A3001E8514 /* MainController.swift in Sources */,
|
||||
971C4F141D411DC00027B7D2 /* ArticleDataContainer.swift in Sources */,
|
||||
970C65501D398D5A007032F8 /* BookmarkControllerAnimator.swift in Sources */,
|
||||
978C58981C1CD86E0077AE47 /* Book.swift in Sources */,
|
||||
978C58961C1CD86E0077AE47 /* Language.swift in Sources */,
|
||||
@ -1733,11 +1725,6 @@
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
972212251D3ECCFE00C0DCF2 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 9722121A1D3ECCFE00C0DCF2 /* Articles */;
|
||||
targetProxy = 972212241D3ECCFE00C0DCF2 /* PBXContainerItemProxy */;
|
||||
};
|
||||
973BCCFE1CEB3FA500F10B44 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 973BCCE81CEB3FA400F10B44 /* Kiwix-OSX */;
|
||||
@ -1748,6 +1735,11 @@
|
||||
target = 973BCCE81CEB3FA400F10B44 /* Kiwix-OSX */;
|
||||
targetProxy = 973BCD081CEB3FA500F10B44 /* PBXContainerItemProxy */;
|
||||
};
|
||||
9779C31D1D4575AE0064CC8E /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 9779C3121D4575AD0064CC8E /* Bookmarks */;
|
||||
targetProxy = 9779C31C1D4575AE0064CC8E /* PBXContainerItemProxy */;
|
||||
};
|
||||
97A2ABA11C1B80FF00052E74 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 97A2AB871C1B80FF00052E74 /* Kiwix-iOS */;
|
||||
@ -1770,10 +1762,10 @@
|
||||
path = "Kiwix-iOS";
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
972212201D3ECCFE00C0DCF2 /* MainInterface.storyboard */ = {
|
||||
9779C3181D4575AE0064CC8E /* MainInterface.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
972212211D3ECCFE00C0DCF2 /* Base */,
|
||||
9779C3191D4575AE0064CC8E /* Base */,
|
||||
);
|
||||
name = MainInterface.storyboard;
|
||||
sourceTree = "<group>";
|
||||
@ -1781,38 +1773,6 @@
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
972212281D3ECCFE00C0DCF2 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Articles.entitlements;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
INFOPLIST_FILE = "Kiwix-iOSWidgets/Articles/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = self.Kiwix.Articles;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
972212291D3ECCFE00C0DCF2 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Articles.entitlements;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
INFOPLIST_FILE = "Kiwix-iOSWidgets/Articles/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = self.Kiwix.Articles;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
973BCD0F1CEB3FA500F10B44 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 6DCB0E958A1083CA248C5A12 /* Pods-Kiwix-OSX.debug.xcconfig */;
|
||||
@ -1940,6 +1900,38 @@
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
9779C3201D4575AE0064CC8E /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = "Kiwix-iOSWidgets/Bookmarks/Bookmarks.entitlements";
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
INFOPLIST_FILE = "Kiwix-iOSWidgets/Bookmarks/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = self.Kiwix.Bookmarks;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
9779C3211D4575AE0064CC8E /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = "Kiwix-iOSWidgets/Bookmarks/Bookmarks.entitlements";
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
INFOPLIST_FILE = "Kiwix-iOSWidgets/Bookmarks/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = self.Kiwix.Bookmarks;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
97A2ABB11C1B810000052E74 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
@ -2152,15 +2144,6 @@
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
972212271D3ECCFE00C0DCF2 /* Build configuration list for PBXNativeTarget "Articles" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
972212281D3ECCFE00C0DCF2 /* Debug */,
|
||||
972212291D3ECCFE00C0DCF2 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
973BCD0E1CEB3FA500F10B44 /* Build configuration list for PBXNativeTarget "Kiwix-OSX" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
@ -2188,6 +2171,15 @@
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
9779C31F1D4575AE0064CC8E /* Build configuration list for PBXNativeTarget "Bookmarks" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
9779C3201D4575AE0064CC8E /* Debug */,
|
||||
9779C3211D4575AE0064CC8E /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
97A2AB831C1B80FF00052E74 /* Build configuration list for PBXProject "Kiwix" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
|
@ -15,9 +15,9 @@
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9722121A1D3ECCFE00C0DCF2"
|
||||
BuildableName = "Articles.appex"
|
||||
BlueprintName = "Articles"
|
||||
BlueprintIdentifier = "97CF3EEA1D428F9600AE82FE"
|
||||
BuildableName = "Bookmarks.appex"
|
||||
BlueprintName = "Bookmarks"
|
||||
ReferencedContainer = "container:Kiwix.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
@ -47,9 +47,9 @@
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9722121A1D3ECCFE00C0DCF2"
|
||||
BuildableName = "Articles.appex"
|
||||
BlueprintName = "Articles"
|
||||
BlueprintIdentifier = "97CF3EEA1D428F9600AE82FE"
|
||||
BuildableName = "Bookmarks.appex"
|
||||
BlueprintName = "Bookmarks"
|
||||
ReferencedContainer = "container:Kiwix.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
@ -4,10 +4,10 @@
|
||||
<dict>
|
||||
<key>SchemeUserState</key>
|
||||
<dict>
|
||||
<key>Article.xcscheme</key>
|
||||
<key>Bookmarks.xcscheme</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>11</integer>
|
||||
<integer>2</integer>
|
||||
</dict>
|
||||
<key>Kiwix-OSX.xcscheme</key>
|
||||
<dict>
|
||||
@ -42,6 +42,16 @@
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>9779C2FD1D4574280064CC8E</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>9779C3121D4575AD0064CC8E</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>97A2AB871C1B80FF00052E74</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
@ -57,6 +67,11 @@
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>97CF3EEA1D428F9600AE82FE</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>97E609EE1D103DED00EBCB9D</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
|
@ -50,5 +50,17 @@ class Article: NSManagedObject {
|
||||
return book?.favIcon
|
||||
}
|
||||
}
|
||||
|
||||
func dictionarySerilization() -> NSDictionary? {
|
||||
guard let title = title,
|
||||
let data = thumbImageData,
|
||||
let url = url else {return nil}
|
||||
return [
|
||||
"title": title,
|
||||
"thumbImageData": data,
|
||||
"url": url.absoluteString,
|
||||
"isMainPage": NSNumber(bool: isMainPage)
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,15 +28,11 @@ class UpdateWidgetDataSourceOperation: Operation {
|
||||
articles = Article.fetchRecentFiveBookmarks(self.context)
|
||||
}
|
||||
|
||||
var titles = [String]()
|
||||
var thumbDatas = [NSData]()
|
||||
var bookmarks = [NSDictionary]()
|
||||
for article in articles {
|
||||
guard let title = article.title,
|
||||
let data = article.thumbImageData else {continue}
|
||||
titles.append(title)
|
||||
thumbDatas.append(data)
|
||||
guard let articleData = article.dictionarySerilization() else {continue}
|
||||
bookmarks.append(articleData)
|
||||
}
|
||||
let bookmarks = ["titles": titles, "thumbDatas": thumbDatas]
|
||||
defaults?.setObject(bookmarks, forKey: "bookmarks")
|
||||
|
||||
finish()
|
||||
|
@ -1,31 +0,0 @@
|
||||
//
|
||||
// ArticleDataContainer.swift
|
||||
// Kiwix
|
||||
//
|
||||
// Created by Chris Li on 7/21/16.
|
||||
// Copyright © 2016 Chris. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class ArticleDataContainer: NSObject, NSCoding {
|
||||
let title: String
|
||||
let thumbImageData: NSData
|
||||
|
||||
init(title: String, thumbImageData: NSData) {
|
||||
self.title = title
|
||||
self.thumbImageData = thumbImageData
|
||||
}
|
||||
|
||||
required convenience init?(coder aDecoder: NSCoder) {
|
||||
guard let title = aDecoder.decodeObjectForKey("title") as? String,
|
||||
let thumbImageData = aDecoder.decodeObjectForKey("thumbImageData") as? NSData else {return nil}
|
||||
self.init(title: title, thumbImageData: thumbImageData)
|
||||
}
|
||||
|
||||
func encodeWithCoder(aCoder: NSCoder) {
|
||||
aCoder.encodeObject(title, forKey: "title")
|
||||
aCoder.encodeObject(thumbImageData, forKey: "thumbImageData")
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user