diff options
author | Marino Faggiana <ios@nextcloud.com> | 2017-04-23 13:31:39 +0300 |
---|---|---|
committer | Marino Faggiana <ios@nextcloud.com> | 2017-04-23 13:31:39 +0300 |
commit | c75f778ac1356736c3fd6004ebdca215faaf5507 (patch) | |
tree | 0560529aae05d5309436b1f22a551f580259384a /Libraries external | |
parent | 0e66636483f2f41a8bc569cc9309588233a14b6f (diff) |
move library
Diffstat (limited to 'Libraries external')
125 files changed, 0 insertions, 11755 deletions
diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/fullscreen.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/fullscreen.png Binary files differdeleted file mode 100644 index 1876e8a3c..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/fullscreen.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/fullscreen@2x.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/fullscreen@2x.png Binary files differdeleted file mode 100644 index 8a93e578e..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/fullscreen@2x.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/pause.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/pause.png Binary files differdeleted file mode 100755 index fab3cab65..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/pause.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/pause@2x.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/pause@2x.png Binary files differdeleted file mode 100755 index b5b168cf0..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/pause@2x.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/play.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/play.png Binary files differdeleted file mode 100644 index cd24657d9..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/play.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/play@2x.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/play@2x.png Binary files differdeleted file mode 100644 index d266fd056..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/play@2x.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/repeat_all.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/repeat_all.png Binary files differdeleted file mode 100644 index c293a82ed..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/repeat_all.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/repeat_all@2x.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/repeat_all@2x.png Binary files differdeleted file mode 100644 index e82b6290e..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/repeat_all@2x.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/repeat_none.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/repeat_none.png Binary files differdeleted file mode 100644 index a2f73d020..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/repeat_none.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/repeat_none@2x.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/repeat_none@2x.png Binary files differdeleted file mode 100644 index 48bb7cd28..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/repeat_none@2x.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/repeat_one.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/repeat_one.png Binary files differdeleted file mode 100644 index eb28c76b8..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/repeat_one.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/repeat_one@2x.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/repeat_one@2x.png Binary files differdeleted file mode 100644 index 6902438a6..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/repeat_one@2x.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/shuffle.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/shuffle.png Binary files differdeleted file mode 100644 index 3d2025184..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/shuffle.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/shuffle@2x.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/shuffle@2x.png Binary files differdeleted file mode 100644 index cc3eb27f8..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/shuffle@2x.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/unfullscreen.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/unfullscreen.png Binary files differdeleted file mode 100644 index 0fcd6bafe..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/unfullscreen.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/unfullscreen@2x.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/unfullscreen@2x.png Binary files differdeleted file mode 100644 index 0419a0ae0..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/unfullscreen@2x.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/unshuffle.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/unshuffle.png Binary files differdeleted file mode 100644 index f875a4845..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/unshuffle.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/unshuffle@2x.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/unshuffle@2x.png Binary files differdeleted file mode 100644 index d4abd97d8..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/6/unshuffle@2x.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/fullscreen.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/fullscreen.png Binary files differdeleted file mode 100644 index 77a3f3695..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/fullscreen.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/fullscreen@2x.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/fullscreen@2x.png Binary files differdeleted file mode 100644 index 7af4de161..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/fullscreen@2x.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/pause.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/pause.png Binary files differdeleted file mode 100644 index e9cf7e415..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/pause.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/pause@2x.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/pause@2x.png Binary files differdeleted file mode 100644 index 541bef8a1..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/pause@2x.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/play.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/play.png Binary files differdeleted file mode 100644 index 13b4c8fcf..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/play.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/play@2x.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/play@2x.png Binary files differdeleted file mode 100644 index d266fd056..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/play@2x.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/repeat_all.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/repeat_all.png Binary files differdeleted file mode 100644 index 9a6b8a05c..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/repeat_all.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/repeat_all@2x.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/repeat_all@2x.png Binary files differdeleted file mode 100644 index 754333249..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/repeat_all@2x.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/repeat_none.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/repeat_none.png Binary files differdeleted file mode 100644 index 44de0c5b0..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/repeat_none.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/repeat_none@2x.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/repeat_none@2x.png Binary files differdeleted file mode 100644 index b01077b98..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/repeat_none@2x.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/repeat_one.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/repeat_one.png Binary files differdeleted file mode 100644 index c3acdc521..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/repeat_one.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/repeat_one@2x.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/repeat_one@2x.png Binary files differdeleted file mode 100644 index 732be27e6..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/repeat_one@2x.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/shuffle.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/shuffle.png Binary files differdeleted file mode 100755 index 954662b33..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/shuffle.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/shuffle@2x.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/shuffle@2x.png Binary files differdeleted file mode 100755 index 0611c301a..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/shuffle@2x.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/unfullscreen.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/unfullscreen.png Binary files differdeleted file mode 100644 index 485fb718a..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/unfullscreen.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/unfullscreen@2x.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/unfullscreen@2x.png Binary files differdeleted file mode 100644 index 5223c567d..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/unfullscreen@2x.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/unshuffle.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/unshuffle.png Binary files differdeleted file mode 100644 index c7ca2a68d..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/unshuffle.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/unshuffle@2x.png b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/unshuffle@2x.png Binary files differdeleted file mode 100644 index 45e32ab03..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.bundle/7/unshuffle@2x.png +++ /dev/null diff --git a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.xib b/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.xib deleted file mode 100644 index e0139b39c..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Assets/LMMediaPlayerView.xib +++ /dev/null @@ -1,250 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="8191" systemVersion="15A284" targetRuntime="iOS.CocoaTouch" variant="6xAndEarlier" propertyAccessControl="none" useAutolayout="YES"> - <dependencies> - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/> - </dependencies> - <objects> - <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> - <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> - <view contentMode="scaleToFill" id="1hC-He-NDs" customClass="LMMediaPlayerView"> - <rect key="frame" x="0.0" y="0.0" width="320" height="180"/> - <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> - <subviews> - <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="077-OQ-G8z"> - <rect key="frame" x="0.0" y="0.0" width="320" height="180"/> - <animations/> - </imageView> - <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="oc7-kf-peg"> - <rect key="frame" x="0.0" y="136" width="320" height="44"/> - <subviews> - <slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" minValue="0.0" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="tJg-rp-csT"> - <rect key="frame" x="73" y="10" width="169" height="25"/> - <animations/> - <constraints> - <constraint firstAttribute="height" constant="24" id="kJJ-cQ-bc6"/> - </constraints> - </slider> - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="lWT-Df-Byc"> - <rect key="frame" x="5" y="7" width="30" height="30"/> - <animations/> - <constraints> - <constraint firstAttribute="height" constant="30" id="BUb-5g-dxA"/> - <constraint firstAttribute="width" constant="30" id="bIg-SV-wIA"/> - </constraints> - <fontDescription key="fontDescription" type="system" pointSize="15"/> - <state key="normal"> - <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> - </state> - </button> - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="MJc-Lj-1A5"> - <rect key="frame" x="285" y="7" width="30" height="30"/> - <animations/> - <constraints> - <constraint firstAttribute="height" constant="30" id="PML-ws-xeY"/> - <constraint firstAttribute="width" constant="30" id="qv2-fR-aQZ"/> - </constraints> - <fontDescription key="fontDescription" type="system" pointSize="15"/> - <state key="normal"> - <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> - </state> - <connections> - <action selector="fullscreenButtonPressed:" destination="1hC-He-NDs" eventType="touchUpInside" id="11b-9P-ayj"/> - </connections> - </button> - <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="00:00" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7Vp-13-PyP"> - <rect key="frame" x="40" y="16" width="28" height="11"/> - <animations/> - <constraints> - <constraint firstAttribute="width" constant="28" id="BCY-AQ-tvj"/> - <constraint firstAttribute="height" constant="11" id="nTK-cl-WCl"/> - </constraints> - <fontDescription key="fontDescription" type="system" pointSize="9"/> - <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/> - <nil key="highlightedColor"/> - </label> - <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="-00:00" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dCu-1Y-f4h"> - <rect key="frame" x="248" y="16" width="32" height="11"/> - <animations/> - <constraints> - <constraint firstAttribute="height" constant="11" id="Owh-L6-e4H"/> - <constraint firstAttribute="width" constant="32" id="n6y-4F-K9E"/> - </constraints> - <fontDescription key="fontDescription" type="system" pointSize="9"/> - <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/> - <nil key="highlightedColor"/> - </label> - </subviews> - <animations/> - <color key="backgroundColor" cocoaTouchSystemColor="darkTextColor"/> - <constraints> - <constraint firstItem="MJc-Lj-1A5" firstAttribute="leading" secondItem="dCu-1Y-f4h" secondAttribute="trailing" constant="5" id="1Qe-bg-QJ0"/> - <constraint firstItem="tJg-rp-csT" firstAttribute="leading" secondItem="7Vp-13-PyP" secondAttribute="trailing" priority="750" constant="7" id="4m9-ZO-wuT"/> - <constraint firstAttribute="centerY" secondItem="MJc-Lj-1A5" secondAttribute="centerY" id="Aa6-9f-96F"/> - <constraint firstItem="lWT-Df-Byc" firstAttribute="leading" secondItem="oc7-kf-peg" secondAttribute="leading" constant="5" id="GyP-3u-tsG"/> - <constraint firstAttribute="centerY" secondItem="lWT-Df-Byc" secondAttribute="centerY" id="Z6T-ou-Pvm"/> - <constraint firstItem="dCu-1Y-f4h" firstAttribute="leading" secondItem="tJg-rp-csT" secondAttribute="trailing" priority="750" constant="8" id="e91-ZX-bNq"/> - <constraint firstAttribute="centerY" secondItem="tJg-rp-csT" secondAttribute="centerY" id="hqn-V1-zkD"/> - <constraint firstAttribute="trailing" secondItem="MJc-Lj-1A5" secondAttribute="trailing" constant="5" id="kVg-n9-9Kf"/> - <constraint firstAttribute="height" constant="44" id="mLK-Km-n5G"/> - <constraint firstAttribute="centerY" secondItem="dCu-1Y-f4h" secondAttribute="centerY" id="o4Y-ym-9zZ"/> - <constraint firstItem="7Vp-13-PyP" firstAttribute="leading" secondItem="lWT-Df-Byc" secondAttribute="trailing" constant="5" id="xKW-vM-AH5"/> - <constraint firstAttribute="centerY" secondItem="7Vp-13-PyP" secondAttribute="centerY" id="xkk-d8-cg2"/> - </constraints> - </view> - <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="GIL-kJ-GRw"> - <rect key="frame" x="0.0" y="0.0" width="320" height="44"/> - <subviews> - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gwr-a1-XwM"> - <rect key="frame" x="240" y="4" width="35" height="35"/> - <animations/> - <constraints> - <constraint firstAttribute="height" constant="35" id="DdA-mY-0fd"/> - <constraint firstAttribute="width" constant="35" id="Gi1-uZ-3x5"/> - </constraints> - <fontDescription key="fontDescription" type="system" pointSize="15"/> - <state key="normal"> - <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> - </state> - <connections> - <action selector="repeatButtonPressed:" destination="1hC-He-NDs" eventType="touchUpInside" id="PR5-Cb-hj1"/> - </connections> - </button> - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gdm-wB-X2t"> - <rect key="frame" x="273" y="4" width="35" height="35"/> - <animations/> - <constraints> - <constraint firstAttribute="width" constant="35" id="4cF-3j-vMh"/> - <constraint firstAttribute="height" constant="35" id="kS2-Ah-NpT"/> - </constraints> - <fontDescription key="fontDescription" type="system" pointSize="15"/> - <state key="normal"> - <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> - </state> - <connections> - <action selector="shuffleButtonPressed:" destination="1hC-He-NDs" eventType="touchUpInside" id="WQD-hl-85t"/> - </connections> - </button> - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9Qi-Gq-8h6"> - <rect key="frame" x="51" y="11" width="181" height="21"/> - <animations/> - <fontDescription key="fontDescription" type="system" pointSize="17"/> - <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/> - <nil key="highlightedColor"/> - </label> - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Xbe-CP-Is5"> - <rect key="frame" x="8" y="4" width="35" height="35"/> - <animations/> - <constraints> - <constraint firstAttribute="height" constant="35" id="AuO-11-G8A"/> - <constraint firstAttribute="width" constant="35" id="TF0-cD-vsO"/> - </constraints> - <state key="normal"> - <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> - </state> - </button> - </subviews> - <animations/> - <color key="backgroundColor" cocoaTouchSystemColor="darkTextColor"/> - <constraints> - <constraint firstItem="9Qi-Gq-8h6" firstAttribute="top" secondItem="GIL-kJ-GRw" secondAttribute="top" constant="11" id="5EV-RQ-nTc"/> - <constraint firstAttribute="centerY" secondItem="gwr-a1-XwM" secondAttribute="centerY" id="8U3-RP-BCS"/> - <constraint firstItem="Xbe-CP-Is5" firstAttribute="leading" secondItem="GIL-kJ-GRw" secondAttribute="leading" constant="8" id="BJa-Pf-HsP"/> - <constraint firstAttribute="trailing" secondItem="gdm-wB-X2t" secondAttribute="trailing" constant="12" id="D6O-mp-kdP"/> - <constraint firstAttribute="centerY" secondItem="Xbe-CP-Is5" secondAttribute="centerY" id="Gen-x5-5si"/> - <constraint firstItem="gdm-wB-X2t" firstAttribute="leading" secondItem="gwr-a1-XwM" secondAttribute="trailing" constant="-2" id="LKy-CR-E7x"/> - <constraint firstItem="gwr-a1-XwM" firstAttribute="leading" secondItem="9Qi-Gq-8h6" secondAttribute="trailing" constant="8" id="NMf-rN-2LZ"/> - <constraint firstAttribute="bottom" secondItem="9Qi-Gq-8h6" secondAttribute="bottom" constant="12" id="aus-9L-lpw"/> - <constraint firstItem="9Qi-Gq-8h6" firstAttribute="leading" secondItem="Xbe-CP-Is5" secondAttribute="trailing" constant="8" id="dPd-Vu-4Ul"/> - <constraint firstAttribute="height" constant="44" id="lSK-HM-Lxp"/> - <constraint firstAttribute="centerY" secondItem="gdm-wB-X2t" secondAttribute="centerY" id="rep-eI-5fV"/> - </constraints> - </view> - <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="KVB-cs-JcH"> - <rect key="frame" x="0.0" y="60" width="40" height="60"/> - <subviews> - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qWF-ZD-TKU"> - <rect key="frame" x="0.0" y="0.0" width="40" height="60"/> - <animations/> - <fontDescription key="fontDescription" type="system" pointSize="15"/> - <color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/> - <state key="normal" title="<"/> - </button> - </subviews> - <animations/> - <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> - <constraints> - <constraint firstAttribute="trailing" secondItem="qWF-ZD-TKU" secondAttribute="trailing" id="9sB-5g-AGt"/> - <constraint firstItem="qWF-ZD-TKU" firstAttribute="leading" secondItem="KVB-cs-JcH" secondAttribute="leading" id="G3s-5e-tXM"/> - <constraint firstAttribute="height" constant="60" id="KFU-0f-sbL"/> - <constraint firstAttribute="width" constant="40" id="aLT-vd-fDt"/> - <constraint firstAttribute="bottom" secondItem="qWF-ZD-TKU" secondAttribute="bottom" id="ars-b6-UsB"/> - <constraint firstItem="qWF-ZD-TKU" firstAttribute="top" secondItem="KVB-cs-JcH" secondAttribute="top" id="fdN-IR-owH"/> - </constraints> - </view> - <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="EsM-nS-vku"> - <rect key="frame" x="280" y="60" width="40" height="60"/> - <subviews> - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zy1-iS-KVp"> - <rect key="frame" x="0.0" y="0.0" width="40" height="60"/> - <animations/> - <fontDescription key="fontDescription" type="system" pointSize="17"/> - <color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/> - <state key="normal" title=">"/> - </button> - </subviews> - <animations/> - <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> - <constraints> - <constraint firstAttribute="bottom" secondItem="zy1-iS-KVp" secondAttribute="bottom" id="5P2-aL-2Mg"/> - <constraint firstAttribute="height" constant="60" id="Aka-6b-nJP"/> - <constraint firstAttribute="width" constant="40" id="DPD-LK-uqe"/> - <constraint firstAttribute="trailing" secondItem="zy1-iS-KVp" secondAttribute="trailing" id="Gfm-sb-b3O"/> - <constraint firstItem="zy1-iS-KVp" firstAttribute="leading" secondItem="EsM-nS-vku" secondAttribute="leading" id="HN0-cl-Pjp"/> - <constraint firstItem="zy1-iS-KVp" firstAttribute="top" secondItem="EsM-nS-vku" secondAttribute="top" id="YL4-tY-JVG"/> - </constraints> - </view> - </subviews> - <animations/> - <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/> - <constraints> - <constraint firstItem="077-OQ-G8z" firstAttribute="leading" secondItem="1hC-He-NDs" secondAttribute="leading" id="3CQ-UC-HQH"/> - <constraint firstAttribute="trailing" secondItem="EsM-nS-vku" secondAttribute="trailing" id="5UB-O3-88A"/> - <constraint firstItem="077-OQ-G8z" firstAttribute="top" secondItem="GIL-kJ-GRw" secondAttribute="top" id="Eua-v5-Vjh"/> - <constraint firstAttribute="trailing" secondItem="oc7-kf-peg" secondAttribute="trailing" id="Mbo-TJ-bhY"/> - <constraint firstAttribute="trailing" secondItem="077-OQ-G8z" secondAttribute="trailing" id="P81-MF-TC8"/> - <constraint firstItem="KVB-cs-JcH" firstAttribute="leading" secondItem="1hC-He-NDs" secondAttribute="leading" id="RSk-dt-5tT"/> - <constraint firstAttribute="trailing" secondItem="GIL-kJ-GRw" secondAttribute="trailing" id="V5n-Y2-znX"/> - <constraint firstItem="oc7-kf-peg" firstAttribute="leading" secondItem="1hC-He-NDs" secondAttribute="leading" id="Vzb-MO-TOX"/> - <constraint firstItem="077-OQ-G8z" firstAttribute="top" secondItem="1hC-He-NDs" secondAttribute="top" id="hKq-gd-WE6"/> - <constraint firstAttribute="centerY" secondItem="EsM-nS-vku" secondAttribute="centerY" id="lSO-qw-6Pr"/> - <constraint firstItem="GIL-kJ-GRw" firstAttribute="top" secondItem="1hC-He-NDs" secondAttribute="top" id="pYr-FF-FBu"/> - <constraint firstAttribute="bottom" secondItem="077-OQ-G8z" secondAttribute="bottom" id="q7c-z1-0ry"/> - <constraint firstAttribute="centerX" secondItem="077-OQ-G8z" secondAttribute="centerX" id="qXo-wX-bQC"/> - <constraint firstAttribute="centerY" secondItem="KVB-cs-JcH" secondAttribute="centerY" id="tfo-Z7-HDJ"/> - <constraint firstItem="GIL-kJ-GRw" firstAttribute="leading" secondItem="1hC-He-NDs" secondAttribute="leading" id="wKB-kG-MDX"/> - <constraint firstAttribute="bottom" secondItem="oc7-kf-peg" secondAttribute="bottom" id="wMT-nA-3u7"/> - </constraints> - <nil key="simulatedStatusBarMetrics"/> - <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/> - <connections> - <outlet property="actionButtonRightMergin" destination="dPd-Vu-4Ul" id="tl6-wA-ktN"/> - <outlet property="actionButtonWidth_" destination="TF0-cD-vsO" id="MZB-yc-oWV"/> - <outlet property="actionButton_" destination="Xbe-CP-Is5" id="1vZ-tI-63l"/> - <outlet property="artworkImageView_" destination="077-OQ-G8z" id="GvA-H8-HRb"/> - <outlet property="currentTimeSlider" destination="tJg-rp-csT" id="Ycb-MT-Xux"/> - <outlet property="footerView_" destination="oc7-kf-peg" id="lHD-pN-eyY"/> - <outlet property="fullscreenButton_" destination="MJc-Lj-1A5" id="eXw-RI-z30"/> - <outlet property="headerView_" destination="GIL-kJ-GRw" id="rId-yg-Edo"/> - <outlet property="nextButton" destination="zy1-iS-KVp" id="sBg-DL-vum"/> - <outlet property="playButton_" destination="lWT-Df-Byc" id="IxQ-r6-Rbc"/> - <outlet property="playbackTimeLabel_" destination="7Vp-13-PyP" id="IMr-Y3-nNp"/> - <outlet property="previousButton" destination="qWF-ZD-TKU" id="rsY-Eh-HzY"/> - <outlet property="remainingTimeLabel_" destination="dCu-1Y-f4h" id="rmY-Cx-VRN"/> - <outlet property="repeatButton_" destination="gwr-a1-XwM" id="60j-ab-ggg"/> - <outlet property="shuffleButton_" destination="gdm-wB-X2t" id="hap-jQ-Sd4"/> - <outlet property="titleLabel" destination="9Qi-Gq-8h6" id="LcN-IL-tU1"/> - </connections> - <point key="canvasLocation" x="301" y="749"/> - </view> - </objects> -</document> diff --git a/Libraries external/LMMediaPlayer/Pod/Classes/Category/NSArray+LMMediaPlayerShuffle/NSArray+LMMediaPlayerShuffle.h b/Libraries external/LMMediaPlayer/Pod/Classes/Category/NSArray+LMMediaPlayerShuffle/NSArray+LMMediaPlayerShuffle.h deleted file mode 100644 index 785108ad7..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Classes/Category/NSArray+LMMediaPlayerShuffle/NSArray+LMMediaPlayerShuffle.h +++ /dev/null @@ -1,21 +0,0 @@ -// -// NSArray+Shuffle.h -// iPodMusicSample -// -// Created by Akira Matsuda on 2014/01/22. -// Copyright (c) 2014年 Akira Matsuda. All rights reserved. -// - -#import <Foundation/Foundation.h> - -@interface NSArray (LMMediaPlayerShuffle) - -- (NSArray *)lm_shuffledArray; - -@end - -@interface NSMutableArray (LMMediaPlayerShuffle) - -- (void)lm_shuffle; - -@end
\ No newline at end of file diff --git a/Libraries external/LMMediaPlayer/Pod/Classes/Category/NSArray+LMMediaPlayerShuffle/NSArray+LMMediaPlayerShuffle.m b/Libraries external/LMMediaPlayer/Pod/Classes/Category/NSArray+LMMediaPlayerShuffle/NSArray+LMMediaPlayerShuffle.m deleted file mode 100644 index 7d361fd88..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Classes/Category/NSArray+LMMediaPlayerShuffle/NSArray+LMMediaPlayerShuffle.m +++ /dev/null @@ -1,37 +0,0 @@ -// -// NSArray+Shuffle.m -// iPodMusicSample -// -// Created by Akira Matsuda on 2014/01/22. -// Copyright (c) 2014年 Akira Matsuda. All rights reserved. -// - -#import "NSArray+LMMediaPlayerShuffle.h" - -@implementation NSArray (LMMediaPlayerShuffle) - -- (NSArray *)lm_shuffledArray -{ - NSMutableArray *results = [NSMutableArray arrayWithArray:self]; - NSUInteger i = [results count]; - - while (--i) { - [results exchangeObjectAtIndex:i withObjectAtIndex:(NSUInteger)arc4random_uniform(i + 1.0)]; - } - - return [NSArray arrayWithArray:results]; -} - -@end - -@implementation NSMutableArray (LMMediaPlayerShuffle) - -- (void)lm_shuffle -{ - NSUInteger i = [self count]; - while (--i) { - [self exchangeObjectAtIndex:i withObjectAtIndex:(NSUInteger)arc4random_uniform(i + 1.0)]; - } -} - -@end
\ No newline at end of file diff --git a/Libraries external/LMMediaPlayer/Pod/Classes/Hepler/LMMediaPlayerHelper.h b/Libraries external/LMMediaPlayer/Pod/Classes/Hepler/LMMediaPlayerHelper.h deleted file mode 100644 index 0ff5a73f6..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Classes/Hepler/LMMediaPlayerHelper.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// LMMediaPlayerHelper.h -// LMMediaPlayer -// -// Created by Akira Matsuda on 8/31/14. -// Copyright (c) 2014 Akira Matsuda. All rights reserved. -// - -#import <Foundation/Foundation.h> - -#if !__has_feature(objc_arc) -#define LM_AUTORELEASE(v) [v autorelease] -#define LM_RETAIN(v) [v retain] -#define LM_DEALLOC(v) [v dealloc] -#define LM_RELEASE(v) [v release] -#define LM_RELEASE_NIL(v) \ - [v release]; \ - v = nil; -#else -#define LM_AUTORELEASE(v) -#define LM_RETAIN(v) -#define LM_DEALLOC(v) -#define LM_RELEASE(v) -#define LM_RELEASE_NIL(v) -#endif - -@interface LMMediaPlayerHelper : NSObject - -@end diff --git a/Libraries external/LMMediaPlayer/Pod/Classes/Hepler/LMMediaPlayerHelper.m b/Libraries external/LMMediaPlayer/Pod/Classes/Hepler/LMMediaPlayerHelper.m deleted file mode 100644 index fbb2c73f5..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Classes/Hepler/LMMediaPlayerHelper.m +++ /dev/null @@ -1,13 +0,0 @@ -// -// LMMediaPlayerHelper.m -// LMMediaPlayer -// -// Created by Akira Matsuda on 8/31/14. -// Copyright (c) 2014 Akira Matsuda. All rights reserved. -// - -#import "LMMediaPlayerHelper.h" - -@implementation LMMediaPlayerHelper - -@end diff --git a/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaItem/LMMediaItem.h b/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaItem/LMMediaItem.h deleted file mode 100644 index 4b005deaa..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaItem/LMMediaItem.h +++ /dev/null @@ -1,40 +0,0 @@ -// -// LMMediaItem.h -// iPodMusicSample -// -// Created by Akira Matsuda on 2014/01/27. -// Copyright (c) 2014年 Akira Matsuda. All rights reserved. -// - -#import <Foundation/Foundation.h> -#import <UIKit/UIKit.h> - -extern NSString *LMMediaItemInfoTitleKey; -extern NSString *LMMediaItemInfoAlubumTitleKey; -extern NSString *LMMediaItemInfoArtistKey; -extern NSString *LMMediaItemInfoArtworkKey; -extern NSString *LMMediaItemInfoURLKey; -extern NSString *LMMediaItemInfoContentTypeKey; - -typedef NS_ENUM(NSUInteger, LMMediaItemContentType) { - LMMediaItemContentTypeUnknown = -1, - LMMediaItemContentTypeAudio = 0, - LMMediaItemContentTypeVideo = 1 -}; - -@interface LMMediaItem : NSObject <NSCoding, NSCopying> - -- (instancetype)initWithMetaMedia:(id)media contentType:(LMMediaItemContentType)type; -- (instancetype)initWithInfo:(NSDictionary *)info; -- (UIImage *)artworkImageWithSize:(CGSize)size; -- (void)setArtworkImage:(UIImage *)image; -- (BOOL)isVideo; - -@property (nonatomic, copy) NSString *title; -@property (nonatomic, copy) NSString *albumTitle; -@property (nonatomic, copy) NSString *artist; -@property (nonatomic, copy) id metaMedia; -@property (nonatomic, copy) NSURL *assetURL; -@property (nonatomic, readonly) LMMediaItemContentType contentType; - -@end diff --git a/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaItem/LMMediaItem.m b/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaItem/LMMediaItem.m deleted file mode 100644 index 949103d06..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaItem/LMMediaItem.m +++ /dev/null @@ -1,207 +0,0 @@ -// -// LMMediaItem.m -// iPodMusicSample -// -// Created by Akira Matsuda on 2014/01/27. -// Copyright (c) 2014年 Akira Matsuda. All rights reserved. -// - -#import "LMMediaItem.h" -#import <MediaPlayer/MediaPlayer.h> -#import <AVFoundation/AVFoundation.h> -#import "LMMediaPlayerHelper.h" - -@interface LMMediaItem () { - id metaMedia_; - NSString *title_; - NSString *albumTitle_; - NSString *artist_; - UIImage *artworkImage_; - NSURL *url_; -} - -@end - -@implementation LMMediaItem - -NSString *LMMediaItemInfoTitleKey = @"LMMediaItemInfoTitleKey"; -NSString *LMMediaItemInfoAlubumTitleKey = @"LMMediaItemInfoAlubumTitleKey"; -NSString *LMMediaItemInfoArtistKey = @"LMMediaItemInfoArtistKey"; -NSString *LMMediaItemInfoArtworkKey = @"LMMediaItemInfoArtworkKey"; -NSString *LMMediaItemInfoURLKey = @"LMMediaItemInfoURLKey"; -NSString *LMMediaItemInfoContentTypeKey = @"LMMediaItemInfoContentTypeKey"; - -@synthesize title = title_; -@synthesize albumTitle = albumTitle_; -@synthesize artist = artist_; -@synthesize assetURL = url_; - -- (void)dealloc -{ - LM_RELEASE(title_); - LM_RELEASE(albumTitle_); - LM_RELEASE(artist_); - LM_RELEASE(artworkImage_); - LM_RELEASE(url_); - LM_DEALLOC(super); -} - -- (instancetype)initWithMetaMedia:(id)media contentType:(LMMediaItemContentType)type -{ - self = [super init]; - if (self) { - metaMedia_ = media; - _contentType = type; - } - - return self; -} - -- (instancetype)initWithInfo:(NSDictionary *)info -{ - self = [super init]; - if (self) { - title_ = ([info[LMMediaItemInfoTitleKey] isKindOfClass:[NSString class]] ? [info[LMMediaItemInfoTitleKey] copy] : nil); - albumTitle_ = ([info[LMMediaItemInfoAlubumTitleKey] isKindOfClass:[NSString class]] ? [info[LMMediaItemInfoAlubumTitleKey] copy] : nil); - artist_ = ([info[LMMediaItemInfoArtistKey] isKindOfClass:[NSString class]] ? [info[LMMediaItemInfoArtistKey] copy] : nil); - artworkImage_ = ([info[LMMediaItemInfoArtworkKey] isKindOfClass:[UIImage class]] ? [info[LMMediaItemInfoArtworkKey] copy] : nil); - url_ = ([info[LMMediaItemInfoURLKey] isKindOfClass:[NSURL class]] ? [info[LMMediaItemInfoURLKey] copy] : nil); - _contentType = (LMMediaItemContentType)([info[LMMediaItemInfoContentTypeKey] isKindOfClass:[NSNumber class]] ? [info[LMMediaItemInfoContentTypeKey] integerValue] : -1); - } - - return self; -} - -- (instancetype)initWithCoder:(NSCoder *)coder -{ - self = [super init]; - if (self) { - title_ = [coder decodeObjectForKey:LMMediaItemInfoTitleKey]; - albumTitle_ = [coder decodeObjectForKey:LMMediaItemInfoAlubumTitleKey]; - artist_ = [coder decodeObjectForKey:LMMediaItemInfoArtistKey]; - artworkImage_ = [coder decodeObjectForKey:LMMediaItemInfoArtworkKey]; - url_ = [coder decodeObjectForKey:LMMediaItemInfoURLKey]; - _contentType = (LMMediaItemContentType)[[coder decodeObjectForKey:LMMediaItemInfoContentTypeKey] integerValue]; - } - - return self; -} - -- (void)encodeWithCoder:(NSCoder *)coder -{ - [coder encodeObject:title_ forKey:LMMediaItemInfoTitleKey]; - [coder encodeObject:albumTitle_ forKey:LMMediaItemInfoAlubumTitleKey]; - [coder encodeObject:artist_ forKey:LMMediaItemInfoArtistKey]; - [coder encodeObject:artworkImage_ forKey:LMMediaItemInfoArtworkKey]; - [coder encodeObject:url_ forKey:LMMediaItemInfoURLKey]; - [coder encodeObject:[NSNumber numberWithInteger:_contentType] forKey:LMMediaItemInfoContentTypeKey]; -} - -- (id)copyWithZone:(NSZone *)zone -{ - NSMutableDictionary *newInfo = [NSMutableDictionary new]; - if (self.title) { - NSString *newString = [self.title copy]; - LM_AUTORELEASE(newString); - newInfo[LMMediaItemInfoTitleKey] = newString ?: [NSNull null]; - } - if (self.albumTitle) { - NSString *newString = [self.albumTitle copy]; - LM_AUTORELEASE(newString); - newInfo[LMMediaItemInfoAlubumTitleKey] = newString ?: [NSNull null]; - } - if (self.artist) { - NSString *newString = [self.artist copy]; - LM_AUTORELEASE(newString); - newInfo[LMMediaItemInfoArtistKey] = newString ?: [NSNull null]; - } - if (artworkImage_) { - UIImage *newImage = [artworkImage_ copy]; - LM_AUTORELEASE(newImage); - newInfo[LMMediaItemInfoArtworkKey] = newImage ?: [NSNull null]; - } - if (self.assetURL) { - NSURL *newURL = [self.assetURL copy]; - LM_AUTORELEASE(newURL); - newInfo[LMMediaItemInfoURLKey] = newURL ?: [NSNull null]; - } - newInfo[LMMediaItemInfoContentTypeKey] = [NSNumber numberWithInteger:_contentType]; - - LMMediaItem *newObject = [[[self class] allocWithZone:zone] initWithInfo:newInfo]; - LM_RELEASE(newInfo); - - return newObject; -} - -- (id)valueWithProperty:(NSString *)property cache:(id)cache -{ - id returnValue = nil; - if ([metaMedia_ isKindOfClass:[MPMediaItem class]]) { - returnValue = cache = [metaMedia_ valueForProperty:property]; - } - - return returnValue; -} - -- (NSString *)title -{ - return title_ ?: [self valueWithProperty:MPMediaItemPropertyTitle cache:title_]; -} - -- (NSString *)albumTitle -{ - return albumTitle_ ?: [self valueWithProperty:MPMediaItemPropertyAlbumTitle cache:albumTitle_]; -} - -- (NSString *)artist -{ - return artist_ ?: [self valueWithProperty:MPMediaItemPropertyArtist cache:artist_]; -} - -- (UIImage *)artworkImageWithSize:(CGSize)size -{ - UIImage * (^f)(id) = ^UIImage *(id metaMedia) - { - UIImage *image = nil; - if ([metaMedia isKindOfClass:[MPMediaItem class]]) { - artworkImage_ = image = [[metaMedia_ valueForProperty:MPMediaItemPropertyArtwork] imageWithSize:size]; - } - - return image; - }; - - return artworkImage_ ?: f(metaMedia_); -} - -- (void)setArtworkImage:(UIImage *)image -{ - artworkImage_ = [image copy]; -} - -- (NSURL *)assetURL -{ - return url_ ?: [self valueWithProperty:MPMediaItemPropertyAssetURL cache:url_]; -} - -- (id)metaMedia -{ - return metaMedia_; -} - -- (BOOL)isVideo -{ - return _contentType == LMMediaItemContentTypeVideo; -} - -- (NSString *)description -{ - return [@{ @"title" : title_ ?: @"nil", - @"album" : albumTitle_ ?: @"nil", - @"artist" : artist_ ?: @"nil", - @"url" : url_ ?: @"nil", - @"artwork" : artworkImage_ ?: @"nil", - @"content type" : _contentType == LMMediaItemContentTypeAudio ? @"LMMediaItemContentTypeAudio" : @"LMMediaItemContentTypeVideo", - @"meta media" : metaMedia_ ?: @"nil" } description]; -} - -@end diff --git a/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaItemQueueManager/LMMediaItemQueueManager.h b/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaItemQueueManager/LMMediaItemQueueManager.h deleted file mode 100644 index 0c84e13aa..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaItemQueueManager/LMMediaItemQueueManager.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// LMMediaItemArchiver.h -// iPodMusicSample -// -// Created by Akira Matsuda on 2014/01/31. -// Copyright (c) 2014年 Akira Matsuda. All rights reserved. -// - -#import <Foundation/Foundation.h> -#import "LMMediaItem.h" - -@interface LMMediaItemQueueManager : NSObject - -+ (NSArray *)queueList; -+ (void)removeQueueWithKey:(NSString *)key; -+ (void)saveQueueWithKey:(NSString *)key queue:(NSArray *)queue; -+ (NSArray *)loadQueueWithKey:(NSString *)key; - -@end diff --git a/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaItemQueueManager/LMMediaItemQueueManager.m b/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaItemQueueManager/LMMediaItemQueueManager.m deleted file mode 100644 index f7b8f2e3a..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaItemQueueManager/LMMediaItemQueueManager.m +++ /dev/null @@ -1,65 +0,0 @@ -// -// LMMediaItemArchiver.m -// iPodMusicSample -// -// Created by Akira Matsuda on 2014/01/31. -// Copyright (c) 2014年 Akira Matsuda. All rights reserved. -// - -#import "LMMediaItemQueueManager.h" -#import "LMMediaPlayerHelper.h" - -static NSString *const kLMMediaItemQueueManagerQueueList = @"kLMMediaItemQueueManagerQueueList"; - -@implementation LMMediaItemQueueManager - -+ (NSArray *)queueList -{ - return [[NSUserDefaults standardUserDefaults] arrayForKey:kLMMediaItemQueueManagerQueueList]; -} - -+ (void)removeQueueWithKey:(NSString *)key -{ - [[NSUserDefaults standardUserDefaults] removeObjectForKey:key]; - NSMutableArray *keys = [NSMutableArray arrayWithArray:[LMMediaItemQueueManager queueList]]; - for (NSString *k in keys) { - if ([k isEqualToString:key]) { - [keys removeObject:k]; - break; - } - } - - [[NSUserDefaults standardUserDefaults] setObject:keys forKey:kLMMediaItemQueueManagerQueueList]; -} - -+ (void)saveQueueWithKey:(NSString *)key queue:(NSArray *)queue -{ - NSMutableArray *saveArray = [NSMutableArray new]; - LM_AUTORELEASE(saveArray); - for (LMMediaItem *item in queue) { - NSData *data = [NSKeyedArchiver archivedDataWithRootObject:item]; - [saveArray addObject:data]; - } - [[NSUserDefaults standardUserDefaults] setObject:saveArray forKey:key]; - - NSMutableArray *keys = [NSMutableArray arrayWithArray:[LMMediaItemQueueManager queueList]]; - [keys addObject:key]; - [[NSUserDefaults standardUserDefaults] setObject:keys forKey:kLMMediaItemQueueManagerQueueList]; -} - -+ (NSArray *)loadQueueWithKey:(NSString *)key -{ - NSMutableArray *result = [NSMutableArray new]; - LM_AUTORELEASE(result); - NSArray *array = [[NSUserDefaults standardUserDefaults] arrayForKey:key]; - for (id d in array) { - LMMediaItem *item = [NSKeyedUnarchiver unarchiveObjectWithData:d]; - [result addObject:item]; - } - - NSArray *newArray = [result copy]; - LM_AUTORELEASE(newArray); - return newArray; -} - -@end diff --git a/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaItemStreamingCache/LMMediaItemStreamingCache.h b/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaItemStreamingCache/LMMediaItemStreamingCache.h deleted file mode 100644 index 920550d28..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaItemStreamingCache/LMMediaItemStreamingCache.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// LMMediaItemCache.h -// LMMediaPlayer -// -// Created by Akira Matsuda on 10/13/14. -// Copyright (c) 2014 Akira Matsuda. All rights reserved. -// - -#import <Foundation/Foundation.h> -#import <AVFoundation/AVFoundation.h> - -@interface LMMediaItemStreamingCache : NSObject <AVAssetResourceLoaderDelegate> - -+ (instancetype)sharedCache; - -@end diff --git a/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaItemStreamingCache/LMMediaItemStreamingCache.m b/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaItemStreamingCache/LMMediaItemStreamingCache.m deleted file mode 100644 index c13503e23..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaItemStreamingCache/LMMediaItemStreamingCache.m +++ /dev/null @@ -1,45 +0,0 @@ -// -// LMMediaItemCache.m -// LMMediaPlayer -// -// Created by Akira Matsuda on 10/13/14. -// Copyright (c) 2014 Akira Matsuda. All rights reserved. -// - -#import "LMMediaItemStreamingCache.h" -#import <AVFoundation/AVFoundation.h> - -@interface LMMediaItemStreamingCache () - -@end - -@implementation LMMediaItemStreamingCache - -+ (instancetype)sharedCache -{ - static id sharedInstance; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - sharedInstance = [[[self class] alloc] init]; - }); - - return sharedInstance; -} - -- (BOOL)isCacheAvailable:(NSString *)key -{ - return NO; -} - -#pragma mark - AVAssetResourceLoaderDelegate - -- (BOOL)resourceLoader:(AVAssetResourceLoader *)resourceLoader shouldWaitForLoadingOfRequestedResource:(AVAssetResourceLoadingRequest *)loadingRequest -{ - return YES; -} - -- (void)resourceLoader:(AVAssetResourceLoader *)resourceLoader didCancelLoadingRequest:(AVAssetResourceLoadingRequest *)loadingRequest -{ -} - -@end diff --git a/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaPlayer/LMMediaPlayer.h b/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaPlayer/LMMediaPlayer.h deleted file mode 100644 index 119a9c0d2..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaPlayer/LMMediaPlayer.h +++ /dev/null @@ -1,84 +0,0 @@ -// -// LMMediaPlayer.h -// iPodMusicSample -// -// Created by Akira Matsuda on 2014/01/10. -// Copyright (c) 2014年 Akira Matsuda. All rights reserved. -// - -#import <Foundation/Foundation.h> -#import <UIKit/UIKit.h> -#import <MediaPlayer/MediaPlayer.h> -#import <AVFoundation/AVFoundation.h> -#import "LMMediaItem.h" - -@class LMMediaPlayer; - -typedef NS_ENUM(NSUInteger, LMMediaPlaybackState) { - LMMediaPlaybackStateStopped, - LMMediaPlaybackStatePlaying, - LMMediaPlaybackStatePaused -}; - -typedef NS_ENUM(NSUInteger, LMMediaRepeatMode) { - LMMediaRepeatModeDefault, - LMMediaRepeatModeOne, - LMMediaRepeatModeAll, - LMMediaRepeatModeNone = LMMediaRepeatModeDefault -}; - -extern NSString *const LMMediaPlayerPauseNotification; -extern NSString *const LMMediaPlayerStopNotification; - -@protocol LMMediaPlayerDelegate <NSObject> - -@required -- (BOOL)mediaPlayerWillStartPlaying:(LMMediaPlayer *)player media:(LMMediaItem *)media; - -@optional -- (void)mediaPlayerWillChangeState:(LMMediaPlaybackState)state; -- (void)mediaPlayerDidStartPlaying:(LMMediaPlayer *)player media:(LMMediaItem *)media; -- (void)mediaPlayerDidFinishPlaying:(LMMediaPlayer *)player media:(LMMediaItem *)media; -- (void)mediaPlayerDidStop:(LMMediaPlayer *)player media:(LMMediaItem *)media; -- (void)mediaPlayerDidChangeCurrentTime:(LMMediaPlayer *)player; -- (void)mediaPlayerDidChangeRepeatMode:(LMMediaRepeatMode)mode player:(LMMediaPlayer *)player; -- (void)mediaPlayerDidChangeShuffleMode:(BOOL)enabled player:(LMMediaPlayer *)player; - -@end - -@interface LMMediaPlayer : NSObject - -@property (nonatomic, assign) id<LMMediaPlayerDelegate> delegate; -@property (nonatomic, readonly) LMMediaItem *nowPlayingItem; -@property (nonatomic, readonly) LMMediaPlaybackState playbackState; -@property (nonatomic, assign) LMMediaRepeatMode repeatMode; -@property (nonatomic, readonly) BOOL shuffleMode; -@property (nonatomic, readonly) NSInteger index; - -+ (instancetype)sharedPlayer; -- (AVPlayer *)corePlayer; -- (void)pauseOtherPlayer; -- (void)stopOtherPlayer; -- (void)addMedia:(LMMediaItem *)media; -- (void)removeMediaAtIndex:(NSUInteger)index; -- (void)replaceMediaAtIndex:(LMMediaItem *)media index:(NSInteger)index; -- (void)removeAllMediaInQueue; -- (void)setQueue:(NSArray *)queue; -- (void)playMedia:(LMMediaItem *)media; -- (void)play; -- (void)playAtIndex:(NSInteger)index; -- (void)stop; -- (void)pause; -- (void)playNextMedia; -- (void)playPreviousMedia; -- (NSArray *)queue; -- (NSUInteger)numberOfQueue; -- (NSTimeInterval)currentPlaybackTime; -- (NSTimeInterval)currentPlaybackDuration; -- (void)seekTo:(NSTimeInterval)time; -- (void)setShuffleEnabled:(BOOL)enabled; -- (UIImage *)thumbnailAtTime:(CGFloat)time; -- (UIImage *)representativeThumbnail; -- (NSError *)setAudioSessionCategory:(NSString *)category; - -@end diff --git a/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaPlayer/LMMediaPlayer.m b/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaPlayer/LMMediaPlayer.m deleted file mode 100644 index ad21bc286..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayer/LMMediaPlayer/LMMediaPlayer.m +++ /dev/null @@ -1,399 +0,0 @@ -// -// LMMediaPlayer.m -// iPodMusicSample -// -// Created by Akira Matsuda on 2014/01/10. -// Copyright (c) 2014年 Akira Matsuda. All rights reserved. -// - -#import "LMMediaPlayer.h" -#import "NSArray+LMMediaPlayerShuffle.h" -#import <AudioToolbox/AudioToolbox.h> -#import "LMMediaPlayerHelper.h" - -NSString *const LMMediaPlayerPauseNotification = @"LMMediaPlayerPauseNotification"; -NSString *const LMMediaPlayerStopNotification = @"LMMediaPlayerStopNotification"; - -@interface LMMediaPlayer () { - NSMutableArray *queue_; - - LMMediaPlaybackState playbackState_; - AVPlayer *player_; - id playerObserver_; -} - -@property (nonatomic, strong) NSMutableArray *currentQueue; - -@end - -@implementation LMMediaPlayer - -@synthesize playbackState = playbackState_; - -static LMMediaPlayer *sharedPlayer; - -+ (instancetype)sharedPlayer -{ - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - sharedPlayer = [[self class] new]; - }); - - return sharedPlayer; -} - -- (instancetype)init -{ - self = [super init]; - if (self) { - player_ = [AVPlayer new]; - queue_ = [NSMutableArray new]; - self.currentQueue = queue_; - _repeatMode = LMMediaRepeatModeDefault; - _shuffleMode = YES; - - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; - [notificationCenter addObserver:self selector:@selector(pause) name:LMMediaPlayerPauseNotification object:nil]; - [notificationCenter addObserver:self selector:@selector(stop) name:LMMediaPlayerStopNotification object:nil]; - } - - return self; -} - -- (void)dealloc -{ - self.delegate = nil; - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; - [notificationCenter removeObserver:self name:LMMediaPlayerPauseNotification object:nil]; - [notificationCenter removeObserver:self name:LMMediaPlayerStopNotification object:nil]; - [notificationCenter removeObserver:self name:AVPlayerItemDidPlayToEndTimeNotification object:nil]; - LM_RELEASE(player_); - LM_RELEASE(queue_); - LM_RELEASE(_currentQueue); - LM_DEALLOC(super); -} - -#pragma mark - - -- (AVPlayer *)corePlayer -{ - return player_; -} - -- (void)pauseOtherPlayer -{ - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; - [notificationCenter removeObserver:self name:LMMediaPlayerPauseNotification object:nil]; - [notificationCenter postNotificationName:LMMediaPlayerPauseNotification object:nil]; - [notificationCenter addObserver:self selector:@selector(pause) name:LMMediaPlayerPauseNotification object:nil]; -} - -- (void)stopOtherPlayer -{ - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; - [notificationCenter removeObserver:self name:LMMediaPlayerStopNotification object:nil]; - [notificationCenter postNotificationName:LMMediaPlayerStopNotification object:nil]; - [notificationCenter addObserver:self selector:@selector(stop) name:LMMediaPlayerStopNotification object:nil]; -} - -- (void)playerItemDidReachEnd:(NSNotification *)notification -{ - AVPlayerItem *item = notification.object; - if (player_.currentItem == item) { - [self playNextMedia]; - } -} - -- (void)addMedia:(LMMediaItem *)media -{ - [self.currentQueue addObject:media]; -} - -- (void)removeMediaAtIndex:(NSUInteger)index -{ - LMMediaItem *item = _currentQueue[index]; - if (item == _nowPlayingItem) { - _nowPlayingItem = nil; - [self playNextMedia]; - } - [self.currentQueue removeObjectAtIndex:index]; -} - -- (void)replaceMediaAtIndex:(LMMediaItem *)media index:(NSInteger)index -{ - LMMediaItem *item = _currentQueue[index]; - if (item == _nowPlayingItem) { - _nowPlayingItem = nil; - } - [self.currentQueue replaceObjectAtIndex:index withObject:media]; -} - -- (void)removeAllMediaInQueue -{ - _nowPlayingItem = nil; - [self stop]; - [self.currentQueue removeAllObjects]; -} - -- (void)setQueue:(NSArray *)queue -{ - for (LMMediaItem *item in queue) { - [queue_ addObject:item]; - } - self.currentQueue = queue_; -} - -- (void)updateLockScreenInfo -{ - NSMutableDictionary *songInfo = [[NSMutableDictionary alloc] init]; - [songInfo setObject:[_nowPlayingItem title] ?: @"" forKey:MPMediaItemPropertyTitle]; - [songInfo setObject:[_nowPlayingItem albumTitle] ?: @"" forKey:MPMediaItemPropertyAlbumTitle]; - [songInfo setObject:[_nowPlayingItem artist] ?: @"" forKey:MPMediaItemPropertyArtist]; - [songInfo setObject:@([self currentPlaybackTime]) forKey:MPNowPlayingInfoPropertyElapsedPlaybackTime]; - [songInfo setObject:@([self currentPlaybackDuration]) forKey:MPMediaItemPropertyPlaybackDuration]; - UIImage *artworkImage = [_nowPlayingItem artworkImageWithSize:CGSizeMake(320, 320)]; - if (artworkImage) { - MPMediaItemArtwork *artwork = [[MPMediaItemArtwork alloc] initWithImage:artworkImage]; - [songInfo setObject:artwork forKey:MPMediaItemPropertyArtwork]; - LM_AUTORELEASE(artwork); - } - [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo]; - LM_AUTORELEASE(songInfo); -} - -- (void)playMedia:(LMMediaItem *)media -{ - [self stop]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:nil]; - if ([self.delegate respondsToSelector:@selector(mediaPlayerWillStartPlaying:media:)] == NO || [self.delegate mediaPlayerWillStartPlaying:self media:media] == YES) { - if (media != nil) { - NSURL *url = [media assetURL]; - _nowPlayingItem = media; - [player_ removeTimeObserver:playerObserver_]; - [player_ replaceCurrentItemWithPlayerItem:[AVPlayerItem playerItemWithURL:url]]; - [self play]; - if ([self.delegate respondsToSelector:@selector(mediaPlayerDidStartPlaying:media:)]) { - [self.delegate mediaPlayerDidStartPlaying:self media:media]; - } - player_.usesExternalPlaybackWhileExternalScreenIsActive = YES; - __block LMMediaPlayer *bself = self; - playerObserver_ = [player_ addPeriodicTimeObserverForInterval:CMTimeMake(1, 1) queue:dispatch_get_main_queue() usingBlock:^(CMTime time) { - if ([bself.delegate respondsToSelector:@selector(mediaPlayerDidChangeCurrentTime:)]) { - [bself.delegate mediaPlayerDidChangeCurrentTime:bself]; - } - }]; - } - } -} - -- (void)play -{ - if (playbackState_ == LMMediaPlaybackStateStopped) { - [player_ seekToTime:CMTimeMake(0, 1)]; - } - if (_nowPlayingItem == nil) { - [self playMedia:self.currentQueue.firstObject]; - } - else { - [player_ play]; - } - - [self setCurrentState:LMMediaPlaybackStatePlaying]; -} - -- (void)playAtIndex:(NSInteger)index -{ - _index = MAX(0, MIN(index, self.currentQueue.count - 1)); - [self playMedia:self.currentQueue[_index]]; -} - -- (void)stop -{ - [player_ pause]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:AVPlayerItemDidPlayToEndTimeNotification object:nil]; - [self setCurrentState:LMMediaPlaybackStateStopped]; - if ([self.delegate respondsToSelector:@selector(mediaPlayerDidStop:media:)]) { - [self.delegate mediaPlayerDidStop:self media:_nowPlayingItem]; - } - _nowPlayingItem = nil; -} - -- (void)pause -{ - [player_ pause]; - [self setCurrentState:LMMediaPlaybackStatePaused]; -} - -- (void)playNextMedia -{ - if ([self.delegate respondsToSelector:@selector(mediaPlayerDidFinishPlaying:media:)]) { - [self.delegate mediaPlayerDidFinishPlaying:self media:_nowPlayingItem]; - } - if (self.currentQueue.count) { - if (_repeatMode == LMMediaRepeatModeDefault) { - if (_index >= self.currentQueue.count - 1) { - _index = 0; - [self stop]; - } - else { - _index++; - [self playMedia:self.currentQueue[_index]]; - } - } - else if (_repeatMode == LMMediaRepeatModeAll) { - if (_index >= self.currentQueue.count - 1) { - _index = 0; - } - else { - _index++; - } - [self playMedia:self.currentQueue[_index]]; - } - else { - [self playMedia:self.nowPlayingItem]; - } - } - else if (_repeatMode == LMMediaRepeatModeOne || _repeatMode == LMMediaRepeatModeAll) { - [self playMedia:self.nowPlayingItem]; - } -} - -- (void)playPreviousMedia -{ - if ([self.delegate respondsToSelector:@selector(mediaPlayerDidFinishPlaying:media:)]) { - [self.delegate mediaPlayerDidFinishPlaying:self media:_nowPlayingItem]; - } - if (self.currentQueue.count) { - if (_repeatMode == LMMediaRepeatModeDefault) { - if (_index - 1 < 0) { - _index = 0; - [self stop]; - } - else { - _index--; - [self playMedia:self.currentQueue[_index]]; - } - } - else if (_repeatMode == LMMediaRepeatModeAll) { - if (_index - 1 < 0) { - _index = self.currentQueue.count - 1; - } - else { - _index--; - } - [self playMedia:self.currentQueue[_index]]; - } - else { - [self playMedia:self.currentQueue[_index]]; - } - } - else if (_repeatMode == LMMediaRepeatModeOne || _repeatMode == LMMediaRepeatModeAll) { - [self playMedia:self.nowPlayingItem]; - } -} - -- (NSArray *)queue -{ - NSArray *newArray = [self.currentQueue copy]; - LM_AUTORELEASE(newArray); - return newArray; -} - -- (NSUInteger)numberOfQueue -{ - return self.currentQueue.count; -} - -- (NSTimeInterval)currentPlaybackTime -{ - return player_.currentTime.value == 0 ? 0 : player_.currentTime.value / player_.currentTime.timescale; -} - -- (NSTimeInterval)currentPlaybackDuration -{ - return CMTimeGetSeconds([[player_.currentItem asset] duration]); -} - -- (void)seekTo:(NSTimeInterval)time -{ - [player_ seekToTime:CMTimeMake(time, 1)]; -} - -- (void)setShuffleEnabled:(BOOL)enabled -{ - _shuffleMode = enabled; - if ([self numberOfQueue] > 0 && _shuffleMode) { - NSMutableArray *newArray = [[self.currentQueue lm_shuffledArray] mutableCopy]; - self.currentQueue = newArray; - LM_RELEASE(newArray); - } - else { - self.currentQueue = queue_; - } - - if ([self.delegate respondsToSelector:@selector(mediaPlayerDidChangeShuffleMode:player:)]) { - [self.delegate mediaPlayerDidChangeShuffleMode:enabled player:self]; - } -} - -- (void)setRepeatMode:(LMMediaRepeatMode)repeatMode -{ - _repeatMode = repeatMode; - if ([self.delegate respondsToSelector:@selector(mediaPlayerDidChangeRepeatMode:player:)]) { - [self.delegate mediaPlayerDidChangeRepeatMode:repeatMode player:self]; - } -} - -#pragma mark - private - -- (void)setCurrentState:(LMMediaPlaybackState)state -{ - if (state == playbackState_) { - return; - } - - if ([self.delegate respondsToSelector:@selector(mediaPlayerWillChangeState:)]) { - [self.delegate mediaPlayerWillChangeState:state]; - } - - if (state == LMMediaPlaybackStatePlaying) { - [self updateLockScreenInfo]; - NSError *e = nil; - AVAudioSession *audioSession = [AVAudioSession sharedInstance]; - [audioSession setCategory:AVAudioSessionCategoryPlayback error:&e]; - [audioSession setActive:YES error:NULL]; - } - - playbackState_ = state; -} - -- (UIImage *)thumbnailAtTime:(CGFloat)time -{ - AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc] initWithAsset:[[player_ currentItem] asset]]; - imageGenerator.appliesPreferredTrackTransform = YES; - NSError *error = NULL; - CMTime ctime = CMTimeMake(time, 1); - CGImageRef imageRef = [imageGenerator copyCGImageAtTime:ctime actualTime:NULL error:&error]; - LM_RELEASE(imageGenerator); - UIImage *resultImage = [[UIImage alloc] initWithCGImage:imageRef]; - LM_AUTORELEASE(resultImage); - CGImageRelease(imageRef); - - return resultImage; -} - -- (UIImage *)representativeThumbnail -{ - return [self thumbnailAtTime:self.currentPlaybackDuration / 2]; -} - -- (NSError *)setAudioSessionCategory:(NSString *)category -{ - NSError *e = nil; - AVAudioSession *audioSession = [AVAudioSession sharedInstance]; - [audioSession setCategory:category error:&e]; - - return e; -} - -@end diff --git a/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayerView/LMMediaPlayerView.h b/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayerView/LMMediaPlayerView.h deleted file mode 100644 index 87d8a0ce4..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayerView/LMMediaPlayerView.h +++ /dev/null @@ -1,74 +0,0 @@ -// -// iPodMusicSample -// -// Created by Akira Matsuda on 2014/01/10. -// Copyright (c) 2014年 Akira Matsuda. All rights reserved. -// - -#import <Foundation/Foundation.h> -#import <UIKit/UIKit.h> -#import "LMMediaPlayer.h" - -extern NSString *const LMMediaPlayerViewPlayButtonImageKey; -extern NSString *const LMMediaPlayerViewPlayButtonSelectedImageKey; -extern NSString *const LMMediaPlayerViewStopButtonImageKey; -extern NSString *const LMMediaPlayerViewStopButtonSelectedImageKey; -extern NSString *const LMMediaPlayerViewFullscreenButtonImageKey; -extern NSString *const LMMediaPlayerViewFullscreenButtonSelectedImageKey; -extern NSString *const LMMediaPlayerViewUnfullscreenButtonImageKey; -extern NSString *const LMMediaPlayerViewUnfullscreenButtonSelectedImageKey; -extern NSString *const LMMediaPlayerViewShuffleButtonShuffledImageKey; -extern NSString *const LMMediaPlayerViewShuffleButtonShuffledSelectedImageKey; -extern NSString *const LMMediaPlayerViewShuffleButtonUnshuffledImageKey; -extern NSString *const LMMediaPlayerViewShuffleButtonUnshuffledSelectedImageKey; -extern NSString *const LMMediaPlayerViewRepeatButtonRepeatOneImageKey; -extern NSString *const LMMediaPlayerViewRepeatButtonRepeatOneSelectedImageKey; -extern NSString *const LMMediaPlayerViewRepeatButtonRepeatAllImageKey; -extern NSString *const LMMediaPlayerViewRepeatButtonRepeatAllSelectedImageKey; -extern NSString *const LMMediaPlayerViewRepeatButtonRepeatNoneImageKey; -extern NSString *const LMMediaPlayerViewRepeatButtonRepeatNoneSelectedImageKey; -extern NSString *const LMMediaPlayerViewActionButtonImageKey; - -@class LMMediaPlayerView; - -@protocol LMMediaPlayerViewDelegate <NSObject> - -@required -- (BOOL)mediaPlayerViewWillStartPlaying:(LMMediaPlayerView *)playerView media:(LMMediaItem *)media; - -@optional -- (void)mediaPlayerViewWillChangeState:(LMMediaPlayerView *)playerView state:(LMMediaPlaybackState)state; -- (void)mediaPlayerViewDidStartPlaying:(LMMediaPlayerView *)playerView media:(LMMediaItem *)media; -- (void)mediaPlayerViewDidFinishPlaying:(LMMediaPlayerView *)playerView media:(LMMediaItem *)media; -- (void)mediaPlayerViewDidChangeCurrentTime:(LMMediaPlayerView *)playerView; -- (void)mediaPlayerViewDidChangeRepeatMode:(LMMediaRepeatMode)mode playerView:(LMMediaPlayerView *)playerView; -- (void)mediaPlayerViewDidChangeShuffleMode:(BOOL)enabled playerView:(LMMediaPlayerView *)playerView; -- (void)mediaPlayerViewWillChangeFullscreenMode:(BOOL)fullscreen; -- (void)mediaPlayerViewDidChangeFullscreenMode:(BOOL)fullscreen; - -@end - -@interface LMMediaPlayerView : UIView <LMMediaPlayerDelegate> - -@property (nonatomic, assign) id<LMMediaPlayerViewDelegate> delegate; -@property (nonatomic, readonly) LMMediaPlayer *mediaPlayer; -@property (nonatomic, unsafe_unretained) IBOutlet UISlider *currentTimeSlider; -@property (nonatomic, unsafe_unretained) IBOutlet UILabel *titleLabel; -@property (nonatomic, readonly) BOOL isFullscreen; -@property (nonatomic, unsafe_unretained) IBOutlet UIButton *nextButton; -@property (nonatomic, unsafe_unretained) IBOutlet UIButton *fullscreenButton_; -@property (nonatomic, unsafe_unretained) IBOutlet UIButton *previousButton; -@property (nonatomic, readonly) UIButton *actionButton; -@property (nonatomic, assign) BOOL userInterfaceHidden; -@property (nonatomic, readonly) BOOL bluredUserInterface; - -+ (instancetype)sharedPlayerView; -+ (instancetype)create; -- (void)setHeaderViewHidden:(BOOL)hidden; -- (void)setFooterViewHidden:(BOOL)hidden; -- (void)setFullscreen:(BOOL)fullscreen animated:(BOOL)animated; -- (void)setFullscreen:(BOOL)fullscreen; -- (void)setButtonImages:(NSDictionary *)info; -- (void)setBluredUserInterface:(BOOL)bluredUserInterface visualEffect:(UIVisualEffect *)effect; - -@end diff --git a/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayerView/LMMediaPlayerView.m b/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayerView/LMMediaPlayerView.m deleted file mode 100644 index 0d1a301db..000000000 --- a/Libraries external/LMMediaPlayer/Pod/Classes/MediaPlayerView/LMMediaPlayerView.m +++ /dev/null @@ -1,761 +0,0 @@ -// -// LMMediaPlayerView.m -// iPodMusicSample -// -// Created by Akira Matsuda on 2014/01/10. -// Copyright (c) 2014年 Akira Matsuda. All rights reserved. -// - -#import "LMMediaPlayerView.h" -#import <MediaPlayer/MediaPlayer.h> -#import <objc/runtime.h> -#import "LMMediaPlayerHelper.h" - -static CGFloat const kFullscreenTransitionDuration = 0.2; -static CGFloat const kActionButtonDefaultEdgeLength = 35; -static CGFloat const kActionButtonDefaultRightMergin = 8; - -NSString *const LMMediaPlayerViewPlayButtonImageKey = @"playButtonImageKey"; -NSString *const LMMediaPlayerViewPlayButtonSelectedImageKey = @"playButtonSelectedImageKey"; -NSString *const LMMediaPlayerViewStopButtonImageKey = @"stopButtonImageKey"; -NSString *const LMMediaPlayerViewStopButtonSelectedImageKey = @"stopButtonSelectedImageKey"; -NSString *const LMMediaPlayerViewFullscreenButtonImageKey = @"fullscreenButtonImageKey"; -NSString *const LMMediaPlayerViewFullscreenButtonSelectedImageKey = @"fullscreenButtonSelectedImageKey"; -NSString *const LMMediaPlayerViewUnfullscreenButtonImageKey = @"unfullscreenButtonImageKey"; -NSString *const LMMediaPlayerViewUnfullscreenButtonSelectedImageKey = @"unfullscreenButtonSelectedImageKey"; -NSString *const LMMediaPlayerViewShuffleButtonShuffledImageKey = @"shuffleButtonShuffledImageKey"; -NSString *const LMMediaPlayerViewShuffleButtonShuffledSelectedImageKey = @"shuffleButtonShuffledSelectedImageKey"; -NSString *const LMMediaPlayerViewShuffleButtonUnshuffledImageKey = @"shuffleButtonUnshuffledImageKey"; -NSString *const LMMediaPlayerViewShuffleButtonUnshuffledSelectedImageKey = @"shuffleButtonUnshuffledSelectedImageKey"; -NSString *const LMMediaPlayerViewRepeatButtonRepeatOneImageKey = @"repeatButtonRepeatOneImageKey"; -NSString *const LMMediaPlayerViewRepeatButtonRepeatOneSelectedImageKey = @"repeatButtonRepeatOneSelectedImageKey"; -NSString *const LMMediaPlayerViewRepeatButtonRepeatAllImageKey = @"repeatButtonRepeatAllImageKey"; -NSString *const LMMediaPlayerViewRepeatButtonRepeatAllSelectedImageKey = @"repeatButtonRepeatAllSelectedImageKey"; -NSString *const LMMediaPlayerViewRepeatButtonRepeatNoneImageKey = @"repeatButtonRepeatNoneImageKey"; -NSString *const LMMediaPlayerViewRepeatButtonRepeatNoneSelectedImageKey = @"repeatButtonRepeatNoneSelectedImageKey"; -NSString *const LMMediaPlayerViewActionButtonImageKey = @"LMMediaPlayerViewActionButtonImageKey"; - -@interface UIViewController (LMMediaPlayerPrefersStatusBarHidden) - -- (void)mediaPlayerPrefersStatusBarHidden:(BOOL)hidden; - -@end - -@interface LMMediaPlayerFullscreenViewController : UIViewController - -@end - -@implementation LMMediaPlayerFullscreenViewController - -- (BOOL)shouldAutorotate -{ - return YES; -} - -- (UIInterfaceOrientationMask)supportedInterfaceOrientations -{ - return UIInterfaceOrientationMaskAllButUpsideDown; -} - -- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation -{ - return UIInterfaceOrientationPortrait; -} - -@end - -@interface LMMediaPlayerView () { - __unsafe_unretained IBOutlet UILabel *playbackTimeLabel_; - __unsafe_unretained IBOutlet UILabel *remainingTimeLabel_; - __unsafe_unretained IBOutlet UIView *headerView_; - __unsafe_unretained IBOutlet UIView *footerView_; - __unsafe_unretained IBOutlet UIImageView *artworkImageView_; - __unsafe_unretained IBOutlet UIButton *playButton_; - __unsafe_unretained IBOutlet UIButton *shuffleButton_; - __unsafe_unretained IBOutlet UIButton *repeatButton_; - //__unsafe_unretained IBOutlet UIButton *fullscreenButton_; - __unsafe_unretained IBOutlet UIButton *actionButton_; - __unsafe_unretained IBOutlet NSLayoutConstraint *actionButtonWidth_; - __unsafe_unretained IBOutlet NSLayoutConstraint *actionButtonRightMergin; - BOOL fullscreen_; - BOOL seeking_; - BOOL needToSetPlayer_; - UIView *superView_; - NSMutableDictionary *buttonImages_; - AVPlayerLayer *playerLayer_; - -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0 - UIVisualEffectView *headerBlurView_; - UIVisualEffectView *footerBlurView_; -#endif - - UIWindow *mainWindow_; -} - -@end - -@implementation LMMediaPlayerView - -@synthesize isFullscreen = fullscreen_; - -static LMMediaPlayerView *sharedPlayerView; - -+ (instancetype)sharedPlayerView -{ - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - sharedPlayerView = [[self class] create]; - }); - return sharedPlayerView; -} - -+ (instancetype)create -{ - return [[UINib nibWithNibName:NSStringFromClass([self class]) bundle:[NSBundle mainBundle]] instantiateWithOwner:nil options:nil][0]; -} - -- (instancetype)initWithFrame:(CGRect)frame -{ - self = [super initWithFrame:frame]; - if (self) { - [self setup]; - } - - return self; -} - -- (void)drawRect:(CGRect)rect -{ - [super drawRect:rect]; - - if (needToSetPlayer_) { - [playerLayer_ setPlayer:self.mediaPlayer.corePlayer]; - needToSetPlayer_ = NO; - } -} - -- (void)dealloc -{ - _mediaPlayer.delegate = nil; - [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil]; - - LM_RELEASE(playbackTimeLabel_); - LM_RELEASE(remainingTimeLabel_); - LM_RELEASE(headerView_); - LM_RELEASE(footerView_); - LM_RELEASE(artworkImageView_); - LM_RELEASE(playButton_); - LM_RELEASE(_nextButton); - LM_RELEASE(_previousButton); - LM_RELEASE(shuffleButton_); - LM_RELEASE(repeatButton_); - LM_RELEASE(fullscreenButton_); - LM_RELEASE(_mediaPlayer); - LM_RELEASE(buttonImages_); - LM_DEALLOC(super); -} - -- (void)awakeFromNib -{ - [super awakeFromNib]; - [self setup]; - [self setupUserInterface]; -} - -- (void)layoutSubviews -{ - // resize your layers based on the view's new bounds - [super layoutSubviews]; - playerLayer_.frame = self.bounds; -} - -- (UIButton *)actionButton -{ - return actionButton_; -} - -- (void)setBluredUserInterface:(BOOL)bluredUserInterface visualEffect:(UIVisualEffect *)effect -{ -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0 - if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1) { - _bluredUserInterface = bluredUserInterface; - if (_bluredUserInterface == YES) { - if (headerBlurView_ == nil) { - headerBlurView_ = [[UIVisualEffectView alloc] initWithEffect:effect]; - footerBlurView_ = [[UIVisualEffectView alloc] initWithEffect:effect]; - - headerBlurView_.frame = headerView_.bounds; - headerBlurView_.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - - footerBlurView_.frame = footerView_.bounds; - footerBlurView_.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - - [headerView_ insertSubview:headerBlurView_ atIndex:0]; - [footerView_ insertSubview:footerBlurView_ atIndex:0]; - } - - headerView_.backgroundColor = [UIColor clearColor]; - footerView_.backgroundColor = [UIColor clearColor]; - } - else { - UIColor *backgroundColor = [UIColor colorWithWhite:0.000 alpha:0.400]; - headerView_.backgroundColor = backgroundColor; - footerView_.backgroundColor = backgroundColor; - } - - headerBlurView_.hidden = footerBlurView_.hidden = !_bluredUserInterface; - } -#endif -} - -#pragma mark - - -- (void)setup -{ - [self setTranslatesAutoresizingMaskIntoConstraints:YES]; - self.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; - - mainWindow_ = [[UIApplication sharedApplication] keyWindow]; - if (mainWindow_ == nil) { - mainWindow_ = [[UIApplication sharedApplication] windows][0]; - } - LM_RETAIN(mainWindow_); - - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mediaPlayerBecomeForgroundMode:) name:UIApplicationWillEnterForegroundNotification object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mediaPlayerBecomeBackgroundMode:) name:UIApplicationDidEnterBackgroundNotification object:nil]; - - needToSetPlayer_ = NO; - _userInterfaceHidden = NO; - - _mediaPlayer = [[LMMediaPlayer alloc] init]; - _mediaPlayer.delegate = self; -} - -- (void)setupUserInterface -{ - UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(reverseUserInterfaceHidden)]; - [self addGestureRecognizer:gesture]; - LM_RELEASE(gesture); - - artworkImageView_.contentMode = UIViewContentModeScaleAspectFit; - - [_currentTimeSlider addTarget:self action:@selector(beginSeek:) forControlEvents:UIControlEventTouchDown]; - [_currentTimeSlider addTarget:self action:@selector(seekPositionChanged:) forControlEvents:UIControlEventValueChanged]; - [_currentTimeSlider addTarget:self action:@selector(endSeek:) forControlEvents:(UIControlEventTouchUpInside | UIControlEventTouchUpOutside | UIControlEventTouchCancel)]; - - [playButton_ addTarget:self action:@selector(changePlaybackState:) forControlEvents:UIControlEventTouchUpInside]; - [_nextButton addTarget:self action:@selector(fourcePlayNextMedia) forControlEvents:UIControlEventTouchUpInside]; - [_previousButton addTarget:self action:@selector(fourcePlayPreviousMedia) forControlEvents:UIControlEventTouchUpInside]; - - UIColor *backgroundColor = [UIColor colorWithWhite:0.000 alpha:0.400]; - footerView_.backgroundColor = headerView_.backgroundColor = backgroundColor; - [_mediaPlayer setShuffleEnabled:NO]; - [_mediaPlayer setRepeatMode:LMMediaRepeatModeDefault]; - - buttonImages_ = [@{ LMMediaPlayerViewPlayButtonImageKey : [[self class] imageForFilename:@"play"], - LMMediaPlayerViewPlayButtonSelectedImageKey : [[self class] imageForFilename:@"play"], - LMMediaPlayerViewStopButtonImageKey : [[self class] imageForFilename:@"pause"], - LMMediaPlayerViewStopButtonSelectedImageKey : [[self class] imageForFilename:@"pause"], - LMMediaPlayerViewShuffleButtonShuffledImageKey : [[self class] imageForFilename:@"shuffle"], - LMMediaPlayerViewShuffleButtonShuffledSelectedImageKey : [[self class] imageForFilename:@"shuffle"], - LMMediaPlayerViewShuffleButtonUnshuffledImageKey : [[self class] imageForFilename:@"unshuffle"], - LMMediaPlayerViewShuffleButtonUnshuffledSelectedImageKey : [[self class] imageForFilename:@"unshuffle"], - LMMediaPlayerViewRepeatButtonRepeatNoneImageKey : [[self class] imageForFilename:@"repeat_none"], - LMMediaPlayerViewRepeatButtonRepeatNoneSelectedImageKey : [[self class] imageForFilename:@"repeat_none"], - LMMediaPlayerViewRepeatButtonRepeatOneImageKey : [[self class] imageForFilename:@"repeat_one"], - LMMediaPlayerViewRepeatButtonRepeatOneSelectedImageKey : [[self class] imageForFilename:@"repeat_one"], - LMMediaPlayerViewRepeatButtonRepeatAllImageKey : [[self class] imageForFilename:@"repeat_all"], - LMMediaPlayerViewRepeatButtonRepeatAllSelectedImageKey : [[self class] imageForFilename:@"repeat_all"], - LMMediaPlayerViewFullscreenButtonImageKey : [[self class] imageForFilename:@"fullscreen"], - LMMediaPlayerViewFullscreenButtonSelectedImageKey : [[self class] imageForFilename:@"fullscreen"], - LMMediaPlayerViewUnfullscreenButtonImageKey : [[self class] imageForFilename:@"unfullscreen"], - LMMediaPlayerViewUnfullscreenButtonSelectedImageKey : [[self class] imageForFilename:@"unfullscreen"] - } mutableCopy]; - - [playButton_.imageView setContentMode:UIViewContentModeScaleAspectFit]; - [playButton_ setImage:buttonImages_[LMMediaPlayerViewPlayButtonImageKey] forState:UIControlStateNormal]; - [playButton_ setImage:buttonImages_[LMMediaPlayerViewPlayButtonSelectedImageKey] forState:UIControlStateSelected]; - - [_fullscreenButton_.imageView setContentMode:UIViewContentModeScaleAspectFit]; - [_fullscreenButton_ setImage:buttonImages_[LMMediaPlayerViewFullscreenButtonImageKey] forState:UIControlStateNormal]; - [_fullscreenButton_ setImage:buttonImages_[LMMediaPlayerViewFullscreenButtonSelectedImageKey] forState:UIControlStateSelected]; - - [repeatButton_.imageView setContentMode:UIViewContentModeScaleAspectFit]; - [repeatButton_ setImage:buttonImages_[LMMediaPlayerViewRepeatButtonRepeatNoneImageKey] forState:UIControlStateNormal]; - [repeatButton_ setImage:buttonImages_[LMMediaPlayerViewRepeatButtonRepeatNoneSelectedImageKey] forState:UIControlStateSelected]; - - [shuffleButton_.imageView setContentMode:UIViewContentModeScaleAspectFit]; - [shuffleButton_ setImage:buttonImages_[LMMediaPlayerViewShuffleButtonUnshuffledImageKey] forState:UIControlStateNormal]; - [shuffleButton_ setImage:buttonImages_[LMMediaPlayerViewShuffleButtonUnshuffledSelectedImageKey] forState:UIControlStateSelected]; - - [actionButton_.imageView setContentMode:UIViewContentModeScaleAspectFit]; - actionButtonWidth_.constant = 0; - actionButtonRightMergin.constant = 0; -} - -- (void)mediaPlayerBecomeForgroundMode:(NSNotification *)notification -{ - needToSetPlayer_ = YES; - [self setNeedsDisplay]; -} - -- (void)mediaPlayerBecomeBackgroundMode:(NSNotification *)notification -{ - double delayInSeconds = 0.01; - dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); - dispatch_after(popTime, dispatch_get_main_queue(), ^(void) { - [playerLayer_ setPlayer:nil]; - if (self.mediaPlayer.playbackState == LMMediaPlaybackStatePlaying) { - [self.mediaPlayer play]; - } - }); -} - -#pragma mark LMMediaPlayerDelegate - -- (void)mediaPlayerWillChangeState:(LMMediaPlaybackState)state -{ - if ([self.delegate respondsToSelector:@selector(mediaPlayerViewWillChangeState:state:)]) { - [self.delegate mediaPlayerViewWillChangeState:self state:state]; - } - - if (state == LMMediaPlaybackStateStopped || state == LMMediaPlaybackStatePaused) { - [playButton_ setImage:buttonImages_[LMMediaPlayerViewPlayButtonImageKey] ?: nil forState:UIControlStateNormal]; - [playButton_ setImage:buttonImages_[LMMediaPlayerViewPlayButtonSelectedImageKey] ?: nil forState:UIControlStateSelected]; - } - else { - [playButton_ setImage:buttonImages_[LMMediaPlayerViewStopButtonImageKey] ?: nil forState:UIControlStateNormal]; - [playButton_ setImage:buttonImages_[LMMediaPlayerViewStopButtonSelectedImageKey] ?: nil forState:UIControlStateSelected]; - } -} - -- (BOOL)mediaPlayerWillStartPlaying:(LMMediaPlayer *)player media:(LMMediaItem *)media -{ - BOOL result = NO; - if ([self.delegate respondsToSelector:@selector(mediaPlayerViewWillStartPlaying:media:)] == YES) { - result = [self.delegate mediaPlayerViewWillStartPlaying:self media:media]; - } - else { - result = YES; - } - self.titleLabel.text = media.title; - - return result; -} - -- (void)mediaPlayerDidStartPlaying:(LMMediaPlayer *)player media:(LMMediaItem *)media -{ - if (media.isVideo) { - artworkImageView_.hidden = YES; - self.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; - if (playerLayer_ == nil) { - playerLayer_ = [AVPlayerLayer playerLayerWithPlayer:player.corePlayer]; - playerLayer_.frame = self.frame; - [self.layer insertSublayer:playerLayer_ atIndex:0]; - } - needToSetPlayer_ = YES; - - playerLayer_.hidden = NO; - } - else { - playerLayer_.hidden = YES; - artworkImageView_.hidden = NO; - artworkImageView_.image = [media artworkImageWithSize:self.frame.size]; - } - if ([self.delegate respondsToSelector:@selector(mediaPlayerViewDidStartPlaying:media:)]) { - [self.delegate mediaPlayerViewDidStartPlaying:self media:media]; - } -} - -- (void)mediaPlayerDidFinishPlaying:(LMMediaPlayer *)player media:(LMMediaItem *)media -{ - _currentTimeSlider.value = 1.0; - if ([self.delegate respondsToSelector:@selector(mediaPlayerViewDidFinishPlaying:media:)]) { - [self.delegate mediaPlayerViewDidFinishPlaying:self media:media]; - } -} - -- (void)mediaPlayerDidChangeCurrentTime:(LMMediaPlayer *)player -{ - if (seeking_ == NO) { - _currentTimeSlider.value = player.currentPlaybackTime / player.currentPlaybackDuration; - - NSMutableString *durationString = [NSMutableString new]; - NSInteger duration = (NSInteger)player.currentPlaybackTime; - if (duration / (60 * 60) > 0) { - [durationString appendFormat:@"%02ld:", - (long int)duration / (60 * 60)]; - duration /= 60 * 60; - } - [durationString appendFormat:@"%02ld:", (long int)duration / 60]; - duration %= 60; - [durationString appendFormat:@"%02ld", (long int)duration]; - playbackTimeLabel_.text = durationString; - LM_RELEASE(durationString); - - durationString = [[NSMutableString alloc] initWithString:@"-"]; - duration = (NSInteger)fabs(player.currentPlaybackTime - player.currentPlaybackDuration); - if (duration / (60 * 60) > 0) { - [durationString appendFormat:@"%02ld:", - (long int)duration / (60 * 60)]; - duration /= 60 * 60; - } - [durationString appendFormat:@"%02ld:", (long int)duration / 60]; - duration %= 60; - [durationString appendFormat:@"%02ld", (long int)duration]; - remainingTimeLabel_.text = durationString; - LM_RELEASE(durationString); - } - if ([self.delegate respondsToSelector:@selector(mediaPlayerViewDidChangeCurrentTime:)]) { - [self.delegate mediaPlayerViewDidChangeCurrentTime:self]; - } -} - -- (void)mediaPlayerDidChangeRepeatMode:(LMMediaRepeatMode)mode player:(LMMediaPlayer *)player -{ - [self setRepeatButtonImageWithRepeatMode:mode]; - if ([self.delegate respondsToSelector:@selector(mediaPlayerViewDidChangeRepeatMode:playerView:)]) { - [self.delegate mediaPlayerViewDidChangeRepeatMode:mode playerView:self]; - } -} - -- (void)mediaPlayerDidChangeShuffleMode:(BOOL)enabled player:(LMMediaPlayer *)player -{ - [self setShuffleButtonImageWithShuffleMode:enabled]; - if ([self.delegate respondsToSelector:@selector(mediaPlayerViewDidChangeShuffleMode:playerView:)]) { - [self.delegate mediaPlayerViewDidChangeShuffleMode:enabled playerView:self]; - } -} - -#pragma mark - - -- (void)beginSeek:(id)sender -{ - seeking_ = YES; -} - -- (void)seekPositionChanged:(id)sender -{ - NSMutableString *durationString = [NSMutableString new]; - NSInteger currentTime = (NSInteger)_mediaPlayer.currentPlaybackDuration * _currentTimeSlider.value; - NSInteger duration = currentTime; - if (duration / (60 * 60) > 0) { - [durationString appendFormat:@"%02ld:", - (long int)duration / (60 * 60)]; - duration /= 60 * 60; - } - [durationString appendFormat:@"%02ld:", (long int)duration / 60]; - duration %= 60; - [durationString appendFormat:@"%02ld", (long int)duration]; - playbackTimeLabel_.text = durationString; - LM_RELEASE(durationString); - - durationString = [[NSMutableString alloc] initWithString:@"-"]; - duration = (NSInteger)_mediaPlayer.currentPlaybackDuration - currentTime; - if (duration / (60 * 60) > 0) { - [durationString appendFormat:@"%02ld:", - (long int)duration / (60 * 60)]; - duration /= 60 * 60; - } - [durationString appendFormat:@"%02ld:", (long int)duration / 60]; - duration %= 60; - [durationString appendFormat:@"%02ld", (long int)duration]; - remainingTimeLabel_.text = durationString; - LM_RELEASE(durationString); -} - -- (void)endSeek:(id)sender -{ - UISlider *slider = (UISlider *)sender; - [_mediaPlayer seekTo:_mediaPlayer.currentPlaybackDuration * slider.value]; - seeking_ = NO; -} - -- (void)changePlaybackState:(id)sender -{ - if ([_mediaPlayer playbackState] == LMMediaPlaybackStatePlaying) { - [_mediaPlayer pause]; - } - else if ([_mediaPlayer playbackState] == LMMediaPlaybackStatePaused || [_mediaPlayer playbackState] == LMMediaPlaybackStateStopped) { - [_mediaPlayer play]; - } -} - -- (void)reverseUserInterfaceHidden -{ - if (seeking_ == NO) { - [self setUserInterfaceHidden:!_userInterfaceHidden]; - } -} - -- (void)fourcePlayNextMedia -{ - LMMediaRepeatMode repeatMode = _mediaPlayer.repeatMode; - if (repeatMode == LMMediaRepeatModeOne) { - _mediaPlayer.repeatMode = LMMediaRepeatModeDefault; - } - [_mediaPlayer playNextMedia]; - _mediaPlayer.repeatMode = repeatMode; -} - -- (void)fourcePlayPreviousMedia -{ - LMMediaRepeatMode repeatMode = _mediaPlayer.repeatMode; - if (repeatMode == LMMediaRepeatModeOne) { - _mediaPlayer.repeatMode = LMMediaRepeatModeDefault; - } - [_mediaPlayer playPreviousMedia]; - _mediaPlayer.repeatMode = repeatMode; -} - -- (IBAction)shuffleButtonPressed:(id)sender -{ - [_mediaPlayer setShuffleEnabled:!_mediaPlayer.shuffleMode]; - - if (_mediaPlayer.shuffleMode) { - [shuffleButton_ setImage:buttonImages_[LMMediaPlayerViewShuffleButtonShuffledImageKey] forState:UIControlStateNormal]; - [shuffleButton_ setImage:buttonImages_[LMMediaPlayerViewShuffleButtonShuffledSelectedImageKey] forState:UIControlStateSelected]; - } - else { - [shuffleButton_ setImage:buttonImages_[LMMediaPlayerViewShuffleButtonUnshuffledImageKey] forState:UIControlStateNormal]; - [shuffleButton_ setImage:buttonImages_[LMMediaPlayerViewShuffleButtonUnshuffledSelectedImageKey] forState:UIControlStateSelected]; - } - [self setRepeatButtonImageWithRepeatMode:_mediaPlayer.repeatMode]; -} - -- (IBAction)repeatButtonPressed:(id)sender -{ - switch (_mediaPlayer.repeatMode) { - case LMMediaRepeatModeAll: { - _mediaPlayer.repeatMode = LMMediaRepeatModeOne; - } break; - case LMMediaRepeatModeOne: { - _mediaPlayer.repeatMode = LMMediaRepeatModeDefault; - } break; - case LMMediaRepeatModeDefault: { - _mediaPlayer.repeatMode = LMMediaRepeatModeAll; - } break; - default: - break; - } - [self setRepeatButtonImageWithRepeatMode:_mediaPlayer.repeatMode]; -} - -- (void)setShuffleButtonImageWithShuffleMode:(BOOL)mode -{ - if (mode) { - [shuffleButton_ setImage:buttonImages_[LMMediaPlayerViewShuffleButtonShuffledImageKey] forState:UIControlStateNormal]; - [shuffleButton_ setImage:buttonImages_[LMMediaPlayerViewShuffleButtonShuffledSelectedImageKey] forState:UIControlStateSelected]; - } - else { - [shuffleButton_ setImage:buttonImages_[LMMediaPlayerViewShuffleButtonUnshuffledImageKey] forState:UIControlStateNormal]; - [shuffleButton_ setImage:buttonImages_[LMMediaPlayerViewShuffleButtonUnshuffledSelectedImageKey] forState:UIControlStateSelected]; - } -} - -- (void)setRepeatButtonImageWithRepeatMode:(LMMediaRepeatMode)mode -{ - switch (_mediaPlayer.repeatMode) { - case LMMediaRepeatModeAll: { - [repeatButton_ setImage:buttonImages_[LMMediaPlayerViewRepeatButtonRepeatAllImageKey] forState:UIControlStateNormal]; - [repeatButton_ setImage:buttonImages_[LMMediaPlayerViewRepeatButtonRepeatAllSelectedImageKey] forState:UIControlStateSelected]; - } break; - case LMMediaRepeatModeOne: { - [repeatButton_ setImage:buttonImages_[LMMediaPlayerViewRepeatButtonRepeatOneImageKey] forState:UIControlStateNormal]; - [repeatButton_ setImage:buttonImages_[LMMediaPlayerViewRepeatButtonRepeatOneSelectedImageKey] forState:UIControlStateSelected]; - } break; - case LMMediaRepeatModeDefault: { - [repeatButton_ setImage:buttonImages_[LMMediaPlayerViewRepeatButtonRepeatNoneImageKey] forState:UIControlStateNormal]; - [repeatButton_ setImage:buttonImages_[LMMediaPlayerViewRepeatButtonRepeatNoneSelectedImageKey] forState:UIControlStateSelected]; - } break; - default: { - [repeatButton_ setImage:buttonImages_[LMMediaPlayerViewRepeatButtonRepeatNoneImageKey] forState:UIControlStateNormal]; - [repeatButton_ setImage:buttonImages_[LMMediaPlayerViewRepeatButtonRepeatNoneSelectedImageKey] forState:UIControlStateSelected]; - } break; - } -} - -- (IBAction)fullscreenButtonPressed:(id)sender -{ - [self setFullscreen:!fullscreen_]; -} - -#pragma mark - - -- (void)setHeaderViewHidden:(BOOL)hidden -{ - headerView_.hidden = hidden; -} - -- (void)setFooterViewHidden:(BOOL)hidden -{ - footerView_.hidden = hidden; -} - -- (void)setUserInterfaceHidden:(BOOL)hidden -{ - _userInterfaceHidden = hidden; - if (hidden) { - [UIView animateWithDuration:0.3 animations:^{ - headerView_.alpha = 0; - footerView_.alpha = 0; - _currentTimeSlider.alpha = 0; - _nextButton.superview.alpha = 0; - _previousButton.superview.alpha = 0; - } completion:^(BOOL finished){ - }]; - } - else { - [UIView animateWithDuration:0.3 animations:^{ - headerView_.alpha = 1; - footerView_.alpha = 1; - _currentTimeSlider.alpha = 1; - _nextButton.superview.alpha = 1; - _previousButton.superview.alpha = 1; - } completion:^(BOOL finished){ - }]; - } -} - -- (void)setFullscreen:(BOOL)fullscreen animated:(BOOL)animated -{ - if (fullscreen_ == fullscreen) { - return; - } - - if ([self.delegate respondsToSelector:@selector(mediaPlayerViewWillChangeFullscreenMode:)]) { - [self.delegate mediaPlayerViewWillChangeFullscreenMode:fullscreen]; - } - - LMMediaPlayerFullscreenViewController *viewController = [[LMMediaPlayerFullscreenViewController alloc] init]; - LM_AUTORELEASE(viewController); - viewController.view.frame = [UIScreen mainScreen].bounds; - - if (floor(NSFoundationVersionNumber) >= NSFoundationVersionNumber_iOS_7_0) { - viewController.extendedLayoutIncludesOpaqueBars = YES; - } - else { - //viewController.wantsFullScreenLayout = YES; - } - - CGRect newRect; - if (fullscreen == NO) { - [_fullscreenButton_ setImage:buttonImages_[LMMediaPlayerViewFullscreenButtonImageKey] forState:UIControlStateNormal]; - [_fullscreenButton_ setImage:buttonImages_[LMMediaPlayerViewFullscreenButtonSelectedImageKey] forState:UIControlStateSelected]; - - newRect = superView_.bounds; - newRect.size.height = newRect.size.height - 20; // TWS - - self.frame = newRect; - [superView_ addSubview:self]; - LM_RELEASE(superView_); - [mainWindow_ makeKeyAndVisible]; - [[[UIApplication sharedApplication] delegate] setWindow:mainWindow_]; - [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone]; - [[UIApplication sharedApplication] setStatusBarOrientation:[[UIApplication sharedApplication] statusBarOrientation]]; - [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade]; - } - else { - [_fullscreenButton_ setImage:buttonImages_[LMMediaPlayerViewUnfullscreenButtonImageKey] forState:UIControlStateNormal]; - [_fullscreenButton_ setImage:buttonImages_[LMMediaPlayerViewUnfullscreenButtonSelectedImageKey] forState:UIControlStateSelected]; - superView_ = self.superview; - LM_RETAIN(superView_); - newRect = mainWindow_.frame; - - //UIViewController *rootViewController = [mainWindow_ rootViewController]; - UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; //rootViewController.interfaceOrientation; - - if (orientation == UIInterfaceOrientationLandscapeRight || orientation == UIInterfaceOrientationLandscapeLeft) { - if (floor(NSFoundationVersionNumber) >= NSFoundationVersionNumber_iOS_7_0) { - newRect = CGRectMake(0, 0, CGRectGetWidth(mainWindow_.frame), CGRectGetHeight(mainWindow_.frame)); - } - else { - newRect = CGRectMake(0, 0, CGRectGetHeight(mainWindow_.frame), CGRectGetWidth(mainWindow_.frame)); - } - } - - [self removeFromSuperview]; - [viewController.view addSubview:self]; - UIWindow *newWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - newWindow.windowLevel = UIWindowLevelAlert; - newWindow.rootViewController = viewController; - [newWindow addSubview:viewController.view]; - [newWindow makeKeyAndVisible]; - [[[UIApplication sharedApplication] delegate] setWindow:newWindow]; - LM_RELEASE(newWindow); - } - - self.frame = newRect; - if (animated) { - self.alpha = 0; - [UIView animateWithDuration:kFullscreenTransitionDuration animations:^{ - self.alpha = 1; - }]; - } - fullscreen_ = fullscreen; - if ([self.delegate respondsToSelector:@selector(mediaPlayerViewDidChangeFullscreenMode:)]) { - [self.delegate mediaPlayerViewDidChangeFullscreenMode:fullscreen]; - } - [[UIApplication sharedApplication] setStatusBarHidden:fullscreen]; - [[NSNotificationCenter defaultCenter] postNotificationName:UIDeviceOrientationDidChangeNotification object:[UIDevice currentDevice]]; -} - -- (void)setFullscreen:(BOOL)fullscreen -{ - [self setFullscreen:fullscreen animated:YES]; -} - -- (void)setButtonImages:(NSDictionary *)info -{ - for (NSString *key in info) { - buttonImages_[key] = info[key]; - } - if ([buttonImages_[LMMediaPlayerViewActionButtonImageKey] isKindOfClass:[UIImage class]]) { - actionButtonWidth_.constant = kActionButtonDefaultEdgeLength; - actionButtonRightMergin.constant = kActionButtonDefaultRightMergin; - [actionButton_ setImage:info[LMMediaPlayerViewActionButtonImageKey] forState:UIControlStateNormal]; - } - else { - actionButtonWidth_.constant = 0; - actionButtonRightMergin.constant = 0; - } - [self updateButtonImages]; -} - -- (void)updateButtonImages -{ - if (self.mediaPlayer.playbackState == LMMediaPlaybackStatePlaying) { - [playButton_ setImage:buttonImages_[LMMediaPlayerViewStopButtonImageKey] forState:UIControlStateNormal]; - [playButton_ setImage:buttonImages_[LMMediaPlayerViewStopButtonSelectedImageKey] forState:UIControlStateSelected]; - } - else { - [playButton_ setImage:buttonImages_[LMMediaPlayerViewPlayButtonImageKey] forState:UIControlStateNormal]; - [playButton_ setImage:buttonImages_[LMMediaPlayerViewPlayButtonSelectedImageKey] forState:UIControlStateSelected]; - } - - if (self.isFullscreen) { - [_fullscreenButton_ setImage:buttonImages_[LMMediaPlayerViewUnfullscreenButtonImageKey] forState:UIControlStateNormal]; - [_fullscreenButton_ setImage:buttonImages_[LMMediaPlayerViewUnfullscreenButtonSelectedImageKey] forState:UIControlStateSelected]; - } - else { - [_fullscreenButton_ setImage:buttonImages_[LMMediaPlayerViewFullscreenButtonImageKey] forState:UIControlStateNormal]; - [_fullscreenButton_ setImage:buttonImages_[LMMediaPlayerViewFullscreenButtonSelectedImageKey] forState:UIControlStateSelected]; - } - - [self setRepeatButtonImageWithRepeatMode:self.mediaPlayer.repeatMode]; - [self setShuffleButtonImageWithShuffleMode:self.mediaPlayer.shuffleMode]; -} - -+ (UIImage *)imageForFilename:(NSString *)filename -{ - NSString *version = @"7"; - if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) { - version = @"6"; - } - UIImage *image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@/%@.png", [[NSBundle mainBundle] pathForResource:@"LMMediaPlayerView" ofType:@"bundle"], version, filename]]; - - return image; -} - -@end diff --git a/Libraries external/REMenu/RECommonFunctions.h b/Libraries external/REMenu/RECommonFunctions.h deleted file mode 100644 index ff5564d65..000000000 --- a/Libraries external/REMenu/RECommonFunctions.h +++ /dev/null @@ -1,32 +0,0 @@ -// -// RECommonFunctions.h -// REMenu -// -// Copyright (c) 2013 Roman Efimov (https://github.com/romaonthego) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#import <Foundation/Foundation.h> -#import <UIKit/UIKit.h> - -#ifndef REUIKitIsFlatModeFunction -#define REUIKitIsFlatModeFunction -BOOL REUIKitIsFlatMode(); -#endif
\ No newline at end of file diff --git a/Libraries external/REMenu/RECommonFunctions.m b/Libraries external/REMenu/RECommonFunctions.m deleted file mode 100755 index 6197253b1..000000000 --- a/Libraries external/REMenu/RECommonFunctions.m +++ /dev/null @@ -1,44 +0,0 @@ -// -// RECommonFunctions.m -// REMenu -// -// Copyright (c) 2013 Roman Efimov (https://github.com/romaonthego) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#import "RECommonFunctions.h" - -BOOL REUIKitIsFlatMode() -{ - static BOOL isUIKitFlatMode = NO; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - if (floor(NSFoundationVersionNumber) > 993.0) { - // If your app is running in legacy mode, tintColor will be nil - else it must be set to some color. - if (UIApplication.sharedApplication.keyWindow) { - isUIKitFlatMode = [UIApplication.sharedApplication.delegate.window respondsToSelector:@selector(tintColor)]; - } else { - // Possible that we're called early on (e.g. when used in a Storyboard). Adapt and use a temporary window. - isUIKitFlatMode = [[UIWindow new] respondsToSelector:@selector(tintColor)]; - } - } - }); - return isUIKitFlatMode; -} diff --git a/Libraries external/REMenu/REMenu.h b/Libraries external/REMenu/REMenu.h deleted file mode 100644 index 816c656b4..000000000 --- a/Libraries external/REMenu/REMenu.h +++ /dev/null @@ -1,119 +0,0 @@ -// -// REMenu.h -// REMenu -// -// Copyright (c) 2013 Roman Efimov (https://github.com/romaonthego) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#import <UIKit/UIKit.h> -#import <QuartzCore/QuartzCore.h> -#import "RECommonFunctions.h" -#import "REMenuItem.h" -#import "REMenuContainerView.h" - -@class REMenuItem; - -typedef NS_ENUM(NSInteger, REMenuImageAlignment) { - REMenuImageAlignmentLeft, - REMenuImageAlignmentRight -}; - -typedef NS_ENUM(NSInteger, REMenuLiveBackgroundStyle) { - REMenuLiveBackgroundStyleLight, - REMenuLiveBackgroundStyleDark -}; - -@interface REMenu : NSObject - -// Menu View -// -@property (strong, readwrite, nonatomic) UIView *menuView; - -// Data -// -@property (strong, readwrite, nonatomic) NSArray *items; -@property (strong, readwrite, nonatomic) UIView *backgroundView; -@property (assign, readonly, nonatomic) BOOL isOpen; -@property (assign, readonly, nonatomic) BOOL isAnimating; -@property (assign, readwrite, nonatomic) BOOL waitUntilAnimationIsComplete; -@property (copy, readwrite, nonatomic) void (^closeCompletionHandler)(void); -@property (copy, readwrite, nonatomic) void (^closePreparationBlock)(void); -@property (assign, readwrite, nonatomic) BOOL closeOnSelection; - -// Style -// -@property (assign, readwrite, nonatomic) CGFloat cornerRadius; -@property (strong, readwrite, nonatomic) UIColor *shadowColor; -@property (assign, readwrite, nonatomic) CGSize shadowOffset; -@property (assign, readwrite, nonatomic) CGFloat shadowOpacity; -@property (assign, readwrite, nonatomic) CGFloat shadowRadius; -@property (assign, readwrite, nonatomic) CGFloat itemHeight; -@property (assign, readwrite, nonatomic) CGFloat backgroundAlpha; -@property (strong, readwrite, nonatomic) UIColor *backgroundColor; -@property (strong, readwrite, nonatomic) UIColor *separatorColor; -@property (assign, readwrite, nonatomic) CGFloat separatorHeight; -@property (assign, readwrite, nonatomic) CGSize separatorOffset; -@property (strong, readwrite, nonatomic) UIFont *font; -@property (strong, readwrite, nonatomic) UIColor *textColor; -@property (strong, readwrite, nonatomic) UIColor *textShadowColor; -@property (assign, readwrite, nonatomic) CGSize textOffset; -@property (assign, readwrite, nonatomic) CGSize textShadowOffset; -@property (assign, readwrite, nonatomic) REMenuImageAlignment imageAlignment; -@property (strong, readwrite, nonatomic) UIColor *imageTintColor; -@property (assign, readwrite, nonatomic) CGSize imageOffset; -@property (strong, readwrite, nonatomic) UIColor *highlightedBackgroundColor; -@property (strong, readwrite, nonatomic) UIColor *highlightedSeparatorColor; -@property (strong, readwrite, nonatomic) UIColor *highlightedTextColor; -@property (strong, readwrite, nonatomic) UIColor *highlightedTextShadowColor; -@property (strong, readwrite, nonatomic) UIColor *highlightedImageTintColor; -@property (assign, readwrite, nonatomic) CGSize highlightedTextShadowOffset; -@property (assign, readwrite, nonatomic) CGFloat borderWidth; -@property (strong, readwrite, nonatomic) UIColor *borderColor; -@property (assign, readwrite, nonatomic) NSTextAlignment textAlignment; -@property (strong, readwrite, nonatomic) UIFont *subtitleFont; -@property (strong, readwrite, nonatomic) UIColor *subtitleTextColor; -@property (strong, readwrite, nonatomic) UIColor *subtitleTextShadowColor; -@property (assign, readwrite, nonatomic) CGSize subtitleTextOffset; -@property (assign, readwrite, nonatomic) CGSize subtitleTextShadowOffset; -@property (strong, readwrite, nonatomic) UIColor *subtitleHighlightedTextColor; -@property (strong, readwrite, nonatomic) UIColor *subtitleHighlightedTextShadowColor; -@property (assign, readwrite, nonatomic) CGSize subtitleHighlightedTextShadowOffset; -@property (assign, readwrite, nonatomic) NSTextAlignment subtitleTextAlignment; -@property (assign, readwrite, nonatomic) NSTimeInterval animationDuration; -@property (assign, readwrite, nonatomic) NSTimeInterval closeAnimationDuration; -@property (assign, readwrite, nonatomic) NSTimeInterval bounceAnimationDuration; -@property (assign, readwrite, nonatomic) BOOL appearsBehindNavigationBar; -@property (assign, readwrite, nonatomic) BOOL bounce; -@property (assign, readwrite, nonatomic) BOOL liveBlur; // Available only in iOS 7 -@property (strong, readwrite, nonatomic) UIColor *liveBlurTintColor; // Available only in iOS 7 -@property (assign, readwrite, nonatomic) REMenuLiveBackgroundStyle liveBlurBackgroundStyle; // Available only in iOS 7 -@property (copy, readwrite, nonatomic) void (^badgeLabelConfigurationBlock)(UILabel *badgeLabel, REMenuItem *item); - -- (id)initWithItems:(NSArray *)items; -- (void)showFromRect:(CGRect)rect inView:(UIView *)view; -- (void)showInView:(UIView *)view; -- (void)showFromNavigationController:(UINavigationController *)navigationController; -- (void)showFromNavigationController:(UINavigationController *)navigationController offsetX:(CGFloat)offsetX width:(CGFloat)width; -- (void)setNeedsLayout; -- (void)closeWithCompletion:(void (^)(void))completion; -- (void)close; - -@end diff --git a/Libraries external/REMenu/REMenu.m b/Libraries external/REMenu/REMenu.m deleted file mode 100644 index 12108bce5..000000000 --- a/Libraries external/REMenu/REMenu.m +++ /dev/null @@ -1,421 +0,0 @@ -// -// REMenu.m -// REMenu -// -// Copyright (c) 2013 Roman Efimov (https://github.com/romaonthego) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#import "REMenu.h" -#import "REMenuItem.h" -#import "REMenuItemView.h" - -@interface REMenuItem () - -@property (assign, readwrite, nonatomic) REMenuItemView *itemView; - -@end - -@interface REMenu () - -@property (strong, readwrite, nonatomic) UIView *menuWrapperView; -@property (strong, readwrite, nonatomic) REMenuContainerView *containerView; -@property (strong, readwrite, nonatomic) UIButton *backgroundButton; -@property (assign, readwrite, nonatomic) BOOL isOpen; -@property (assign, readwrite, nonatomic) BOOL isAnimating; -@property (strong, readwrite, nonatomic) NSMutableArray *itemViews; -@property (weak, readwrite, nonatomic) UINavigationBar *navigationBar; -@property (strong, readwrite, nonatomic) UIToolbar *toolbar; - -@end - -@implementation REMenu - -- (id)init -{ - self = [super init]; - if (self) { - _imageAlignment = REMenuImageAlignmentLeft; - _closeOnSelection = YES; - _itemHeight = 48.0; - _separatorHeight = 2.0; - _separatorOffset = CGSizeMake(0.0, 0.0); - _waitUntilAnimationIsComplete = YES; - - _textOffset = CGSizeMake(0, 0); - _subtitleTextOffset = CGSizeMake(0, 0); - _font = [UIFont boldSystemFontOfSize:21.0]; - _subtitleFont = [UIFont systemFontOfSize:14.0]; - - _backgroundAlpha = 1.0; - _backgroundColor = [UIColor colorWithRed:53/255.0 green:53/255.0 blue:52/255.0 alpha:1.0]; - _separatorColor = [UIColor colorWithPatternImage:self.separatorImage]; - _textColor = [UIColor colorWithRed:128/255.0 green:126/255.0 blue:124/255.0 alpha:1.0]; - _textShadowColor = [UIColor blackColor]; - _textShadowOffset = CGSizeMake(0, -1.0); - _textAlignment = NSTextAlignmentCenter; - - _highlightedBackgroundColor = [UIColor colorWithRed:28/255.0 green:28/255.0 blue:27/255.0 alpha:1.0]; - _highlightedSeparatorColor = [UIColor colorWithRed:28/255.0 green:28/255.0 blue:27/255.0 alpha:1.0]; - _highlightedTextColor = [UIColor colorWithRed:128/255.0 green:126/255.0 blue:124/255.0 alpha:1.0]; - _highlightedTextShadowColor = [UIColor blackColor]; - _highlightedTextShadowOffset = CGSizeMake(0, -1.0); - - _subtitleTextColor = [UIColor colorWithWhite:0.425 alpha:1.000]; - _subtitleTextShadowColor = [UIColor blackColor]; - _subtitleTextShadowOffset = CGSizeMake(0, -1.0); - _subtitleHighlightedTextColor = [UIColor colorWithRed:0.389 green:0.384 blue:0.379 alpha:1.000]; - _subtitleHighlightedTextShadowColor = [UIColor blackColor]; - _subtitleHighlightedTextShadowOffset = CGSizeMake(0, -1.0); - _subtitleTextAlignment = NSTextAlignmentCenter; - - _borderWidth = 1.0; - _borderColor = [UIColor colorWithRed:28/255.0 green:28/255.0 blue:27/255.0 alpha:1.0]; - _animationDuration = 0.3; - _closeAnimationDuration = 0.2; - _bounce = YES; - _bounceAnimationDuration = 0.2; - - _appearsBehindNavigationBar = REUIKitIsFlatMode() ? YES : NO; - } - return self; -} - -- (id)initWithItems:(NSArray *)items -{ - self = [self init]; - if (self) { - _items = items; - } - return self; -} - -- (void)showFromRect:(CGRect)rect inView:(UIView *)view -{ - if (self.isAnimating) { - return; - } - - self.isOpen = YES; - self.isAnimating = YES; - - // Create views - // - self.containerView = ({ - REMenuContainerView *view = [[REMenuContainerView alloc] init]; - view.clipsToBounds = YES; - view.autoresizingMask = UIViewAutoresizingFlexibleWidth; - - if (self.backgroundView) { - self.backgroundView.alpha = 0; - [view addSubview:self.backgroundView]; - } - view; - }); - - self.menuView = ({ - UIView *view = [[UIView alloc] init]; - if (!self.liveBlur || !REUIKitIsFlatMode()) { - view.backgroundColor = self.backgroundColor; - } - view.layer.cornerRadius = self.cornerRadius; - view.layer.borderColor = self.borderColor.CGColor; - view.layer.borderWidth = self.borderWidth; - view.layer.masksToBounds = YES; - view.layer.shouldRasterize = YES; - view.layer.rasterizationScale = [UIScreen mainScreen].scale; - view.autoresizingMask = UIViewAutoresizingFlexibleWidth; - view; - }); - - if (REUIKitIsFlatMode()) { - self.toolbar = ({ - UIToolbar *toolbar = [[UIToolbar alloc] init]; - toolbar.barStyle = (UIBarStyle)self.liveBlurBackgroundStyle; - if ([toolbar respondsToSelector:@selector(setBarTintColor:)]) - [toolbar performSelector:@selector(setBarTintColor:) withObject:self.liveBlurTintColor]; - toolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth; - toolbar.layer.cornerRadius = self.cornerRadius; - toolbar.layer.borderColor = self.borderColor.CGColor; - toolbar.layer.borderWidth = self.borderWidth; - toolbar.layer.masksToBounds = YES; - toolbar; - }); - } - - self.menuWrapperView = ({ - UIView *view = [[UIView alloc] init]; - view.autoresizingMask = UIViewAutoresizingFlexibleWidth; - if (!self.liveBlur || !REUIKitIsFlatMode()) { - view.layer.shadowColor = self.shadowColor.CGColor; - view.layer.shadowOffset = self.shadowOffset; - view.layer.shadowOpacity = self.shadowOpacity; - view.layer.shadowRadius = self.shadowRadius; - view.layer.shouldRasterize = YES; - view.layer.rasterizationScale = [UIScreen mainScreen].scale; - } - view; - }); - - self.backgroundButton = ({ - UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; - button.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - button.accessibilityLabel = NSLocalizedString(@"Menu background", @"Menu background"); - button.accessibilityHint = NSLocalizedString(@"Double tap to close", @"Double tap to close"); - [button addTarget:self action:@selector(close) forControlEvents:UIControlEventTouchUpInside]; - button; - }); - - CGFloat navigationBarOffset = [self computeNavigationBarOffset]; - - // Append new item views to REMenuView - // - for (REMenuItem *item in self.items) { - NSInteger index = [self.items indexOfObject:item]; - - CGFloat itemHeight = self.itemHeight; - if (index == self.items.count - 1) - itemHeight += self.cornerRadius; - - UIView *separatorView = [[UIView alloc] initWithFrame:CGRectMake(self.separatorOffset.width, - index * self.itemHeight + index * self.separatorHeight + 40.0 + navigationBarOffset + self.separatorOffset.height, - rect.size.width - self.separatorOffset.width, - self.separatorHeight)]; - separatorView.backgroundColor = self.separatorColor; - separatorView.autoresizingMask = UIViewAutoresizingFlexibleWidth; - [self.menuView addSubview:separatorView]; - - REMenuItemView *itemView = [[REMenuItemView alloc] initWithFrame:CGRectMake(0, - index * self.itemHeight + (index + 1.0) * self.separatorHeight + 40.0 + navigationBarOffset, - rect.size.width, - itemHeight) - menu:self item:item - hasSubtitle:item.subtitle.length > 0]; - itemView.autoresizingMask = UIViewAutoresizingFlexibleWidth; - item.itemView = itemView; - itemView.separatorView = separatorView; - itemView.autoresizesSubviews = YES; - if (item.customView) { - item.customView.frame = itemView.bounds; - [itemView addSubview:item.customView]; - } - [self.menuView addSubview:itemView]; - } - - // Set up frames - // - self.menuWrapperView.frame = CGRectMake(0, -self.combinedHeight - navigationBarOffset, rect.size.width, self.combinedHeight + navigationBarOffset); - self.menuView.frame = self.menuWrapperView.bounds; - if (REUIKitIsFlatMode() && self.liveBlur) { - self.toolbar.frame = self.menuWrapperView.bounds; - } - self.containerView.frame = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); - self.backgroundButton.frame = self.containerView.bounds; - - // Add subviews - // - if (REUIKitIsFlatMode() && self.liveBlur) { - [self.menuWrapperView addSubview:self.toolbar]; - } - [self.menuWrapperView addSubview:self.menuView]; - [self.containerView addSubview:self.backgroundButton]; - [self.containerView addSubview:self.menuWrapperView]; - [view addSubview:self.containerView]; - - // Animate appearance - // - if (self.bounce) { - self.isAnimating = YES; - if ([UIView respondsToSelector:@selector(animateWithDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion:)]) { - [UIView animateWithDuration:self.animationDuration+self.bounceAnimationDuration - delay:0.0 - usingSpringWithDamping:0.6 - initialSpringVelocity:4.0 - options:UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionCurveEaseInOut - animations:^{ - self.backgroundView.alpha = self.backgroundAlpha; - CGRect frame = self.menuView.frame; - frame.origin.y = -40.0 - self.separatorHeight; - self.menuWrapperView.frame = frame; - } completion:^(BOOL finished) { - self.isAnimating = NO; - }]; - } else { - [UIView animateWithDuration:self.animationDuration - delay:0.0 - options:UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionCurveEaseInOut - animations:^{ - self.backgroundView.alpha = self.backgroundAlpha; - CGRect frame = self.menuView.frame; - frame.origin.y = -40.0 - self.separatorHeight; - self.menuWrapperView.frame = frame; - } completion:^(BOOL finished) { - self.isAnimating = NO; - }]; - - } - } else { - [UIView animateWithDuration:self.animationDuration - delay:0.0 - options:UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionCurveEaseInOut - animations:^{ - self.backgroundView.alpha = self.backgroundAlpha; - CGRect frame = self.menuView.frame; - frame.origin.y = -40.0 - self.separatorHeight; - self.menuWrapperView.frame = frame; - } completion:^(BOOL finished) { - self.isAnimating = NO; - }]; - } -} - -- (void)showInView:(UIView *)view -{ - [self showFromRect:view.bounds inView:view]; -} - --(void)showFromNavigationController:(UINavigationController *)navigationController -{ - [self showFromNavigationController:navigationController offsetX:0 width:navigationController.navigationBar.frame.size.width]; -} - -- (void)showFromNavigationController:(UINavigationController *)navigationController offsetX:(CGFloat)offsetX width:(CGFloat)width -{ - if (self.isAnimating) { - return; - } - - self.navigationBar = navigationController.navigationBar; - - [self showFromRect:CGRectMake(offsetX, 0, width, navigationController.view.frame.size.height) inView:navigationController.view]; - self.containerView.appearsBehindNavigationBar = self.appearsBehindNavigationBar; - self.containerView.navigationBar = navigationController.navigationBar; - if (self.appearsBehindNavigationBar) { - [navigationController.view bringSubviewToFront:navigationController.navigationBar]; - } - - if(width != navigationController.navigationBar.frame.size.width) - { - self.containerView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin; - } -} - -- (void)closeWithCompletion:(void (^)(void))completion -{ - if (self.isAnimating) return; - - self.isAnimating = YES; - - CGFloat navigationBarOffset = [self computeNavigationBarOffset]; - - void (^closeMenu)(void) = ^{ - [UIView animateWithDuration:self.closeAnimationDuration - delay:0.0 - options:UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionCurveEaseInOut - animations:^ { - CGRect frame = self.menuView.frame; - frame.origin.y = - self.combinedHeight - navigationBarOffset; - self.menuWrapperView.frame = frame; - self.backgroundView.alpha = 0; - } completion:^(BOOL finished) { - self.isOpen = NO; - self.isAnimating = NO; - - [self.menuView removeFromSuperview]; - [self.menuWrapperView removeFromSuperview]; - [self.backgroundButton removeFromSuperview]; - [self.backgroundView removeFromSuperview]; - [self.containerView removeFromSuperview]; - - if (completion) { - completion(); - } - - if (self.closeCompletionHandler) { - self.closeCompletionHandler(); - } - }]; - - }; - - if (self.closePreparationBlock) { - self.closePreparationBlock(); - } - - if (self.bounce) { - [UIView animateWithDuration:self.bounceAnimationDuration animations:^{ - CGRect frame = self.menuView.frame; - frame.origin.y = -20.0; - self.menuWrapperView.frame = frame; - } completion:^(BOOL finished) { - closeMenu(); - }]; - } else { - closeMenu(); - } -} - -- (void)close -{ - [self closeWithCompletion:nil]; -} - -- (CGFloat)combinedHeight -{ - return self.items.count * self.itemHeight + self.items.count * self.separatorHeight + 40.0 + self.cornerRadius; -} - -- (void)setNeedsLayout -{ - [UIView animateWithDuration:0.35 animations:^{ - [self.containerView layoutSubviews]; - }]; -} - -#pragma mark - -#pragma mark Setting style - -- (UIImage *)separatorImage -{ - UIGraphicsBeginImageContext(CGSizeMake(1, 4.0)); - CGContextRef context = UIGraphicsGetCurrentContext(); - UIGraphicsPushContext(context); - CGContextSetFillColorWithColor(context, [UIColor colorWithRed:28/255.0 green:28/255.0 blue:27/255.0 alpha:1.0].CGColor); - CGContextFillRect(context, CGRectMake(0, 0, 1.0, 2.0)); - CGContextSetFillColorWithColor(context, [UIColor colorWithRed:79/255.0 green:79/255.0 blue:77/255.0 alpha:1.0].CGColor); - CGContextFillRect(context, CGRectMake(0, 3.0, 1.0, 2.0)); - UIGraphicsPopContext(); - UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - - return [UIImage imageWithCGImage:outputImage.CGImage scale:2.0 orientation:UIImageOrientationUp]; -} - -- (CGFloat)computeNavigationBarOffset -{ - //TWS - //CGFloat navigationBarOffset = self.appearsBehindNavigationBar && self.navigationBar ? ([UIApplication sharedApplication].statusBarHidden ? 44 : 64) : 0; - CGFloat navigationBarOffset = self.appearsBehindNavigationBar && self.navigationBar ? ([UIApplication sharedApplication].statusBarHidden ? 64 : 64) : 0; - - return navigationBarOffset; -} - - -@end diff --git a/Libraries external/REMenu/REMenuContainerView.h b/Libraries external/REMenu/REMenuContainerView.h deleted file mode 100644 index 47f3492bd..000000000 --- a/Libraries external/REMenu/REMenuContainerView.h +++ /dev/null @@ -1,33 +0,0 @@ -// -// REMenuContainerView.h -// REMenu -// -// Copyright (c) 2013 Roman Efimov (https://github.com/romaonthego) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -@interface REMenuContainerView : UIView - -@property (strong, readwrite, nonatomic) UINavigationBar *navigationBar; -@property (assign, readwrite, nonatomic) BOOL appearsBehindNavigationBar; - -@end diff --git a/Libraries external/REMenu/REMenuContainerView.m b/Libraries external/REMenu/REMenuContainerView.m deleted file mode 100644 index e01b31c18..000000000 --- a/Libraries external/REMenu/REMenuContainerView.m +++ /dev/null @@ -1,66 +0,0 @@ -// -// REMenuContainerView.m -// REMenu -// -// Copyright (c) 2013 Roman Efimov (https://github.com/romaonthego) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#import "REMenuContainerView.h" -#import <QuartzCore/QuartzCore.h> - -@implementation REMenuContainerView - -- (void)layoutSubviews -{ - [super layoutSubviews]; - UIDeviceOrientation orientation = [UIDevice currentDevice].orientation; - - CGFloat landscapeOffset = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ? 32.0 : 44.0; - - if (self.navigationBar && !self.appearsBehindNavigationBar) { - CGRect frame = self.frame; - frame.origin.y = self.navigationBar.frame.origin.y + (UIDeviceOrientationIsPortrait(orientation) ? 44.0 : landscapeOffset); - self.frame = frame; - } - - if (self.appearsBehindNavigationBar) { - CGRect frame = self.frame; - long height = [[UIScreen mainScreen] bounds].size.height; - - if (([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait) || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown) { - frame.origin.y = 0; - frame.size.height = height; - } else { - // landscape - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { - frame.origin.y = -12; - frame.size.height = height + 12; - } else { - frame.origin.y = 0; - frame.size.height = height; - } - } - - self.frame = frame; - } -} - -@end diff --git a/Libraries external/REMenu/REMenuItem.h b/Libraries external/REMenu/REMenuItem.h deleted file mode 100644 index 9fc5d8f5f..000000000 --- a/Libraries external/REMenu/REMenuItem.h +++ /dev/null @@ -1,69 +0,0 @@ -// -// REMenuItem.h -// REMenu -// -// Copyright (c) 2013 Roman Efimov (https://github.com/romaonthego) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#import <Foundation/Foundation.h> -#import <UIKit/UIKit.h> - -@interface REMenuItem : NSObject - -@property (strong, readwrite, nonatomic) UIColor *backgroundColor; -@property (strong, readwrite, nonatomic) UIColor *separatorColor; -@property (strong, readwrite, nonatomic) UIFont *font; -@property (strong, readwrite, nonatomic) UIColor *textColor; -@property (strong, readwrite, nonatomic) UIColor *textShadowColor; -@property (assign, readwrite, nonatomic) CGSize textOffset; -@property (assign, readwrite, nonatomic) CGSize textShadowOffset; -@property (strong, readwrite, nonatomic) UIColor *highlightedBackgroundColor; -@property (strong, readwrite, nonatomic) UIColor *highlightedSeparatorColor; -@property (strong, readwrite, nonatomic) UIColor *highlightedTextColor; -@property (strong, readwrite, nonatomic) UIColor *highlightedTextShadowColor; -@property (assign, readwrite, nonatomic) CGSize highlightedTextShadowOffset; -@property (assign, readwrite, nonatomic) NSTextAlignment textAlignment; -@property (strong, readwrite, nonatomic) UIFont *subtitleFont; -@property (strong, readwrite, nonatomic) UIColor *subtitleTextColor; -@property (strong, readwrite, nonatomic) UIColor *subtitleTextShadowColor; -@property (assign, readwrite, nonatomic) CGSize subtitleTextOffset; -@property (assign, readwrite, nonatomic) CGSize subtitleTextShadowOffset; -@property (strong, readwrite, nonatomic) UIColor *subtitleHighlightedTextColor; -@property (strong, readwrite, nonatomic) UIColor *subtitleHighlightedTextShadowColor; -@property (assign, readwrite, nonatomic) CGSize subtitleHighlightedTextShadowOffset; -@property (assign, readwrite, nonatomic) NSTextAlignment subtitleTextAlignment; - -@property (copy, readwrite, nonatomic) NSString *title; -@property (copy, readwrite, nonatomic) NSString *subtitle; -@property (copy, readwrite, nonatomic) NSString *badge; -@property (strong, readwrite, nonatomic) UIImage *image; -@property (strong, readwrite, nonatomic) UIImage *highlightedImage; -@property (copy, readwrite, nonatomic) void (^action)(REMenuItem *item); -@property (assign, readwrite, nonatomic) NSInteger tag; -@property (strong, readwrite, nonatomic) UIView *customView; - -- (id)initWithTitle:(NSString *)title image:(UIImage *)image highlightedImage:(UIImage *)highlightedImage action:(void (^)(REMenuItem *item))action; -- (id)initWithTitle:(NSString *)title subtitle:(NSString *)subtitle image:(UIImage *)image highlightedImage:(UIImage *)highlightedImage action:(void (^)(REMenuItem *item))action; -- (id)initWithCustomView:(UIView *)customView action:(void (^)(REMenuItem *item))action; -- (id)initWithCustomView:(UIView *)customView; -- (void)setNeedsLayout; - -@end diff --git a/Libraries external/REMenu/REMenuItem.m b/Libraries external/REMenu/REMenuItem.m deleted file mode 100644 index 3aaafe503..000000000 --- a/Libraries external/REMenu/REMenuItem.m +++ /dev/null @@ -1,120 +0,0 @@ -// -// REMenuItem.m -// REMenu -// -// Copyright (c) 2013 Roman Efimov (https://github.com/romaonthego) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#import "REMenuItem.h" -#import "REMenuItemView.h" - -@interface REMenuItem () -@property (assign, nonatomic) REMenuItemView *itemView; -@end - - -@implementation REMenuItem - -- (id)initWithTitle:(NSString *)title image:(UIImage *)image highlightedImage:(UIImage *)highlightedImage action:(void (^)(REMenuItem *item))action -{ - self = [super init]; - if (self) { - _title = title; - _image = image; - _highlightedImage = highlightedImage; - _action = action; - _textAlignment = -1; - _subtitleTextAlignment = -1; - } - return self; -} - -- (id)initWithTitle:(NSString *)title subtitle:(NSString *)subtitle image:(UIImage *)image highlightedImage:(UIImage *)highlightedImage action:(void (^)(REMenuItem *item))action -{ - self = [super init]; - if (self) { - _title = title; - _subtitle = subtitle; - _image = image; - _highlightedImage = highlightedImage; - _action = action; - _textAlignment = -1; - _subtitleTextAlignment = -1; - } - return self; -} - -- (id)initWithCustomView:(UIView *)customView action:(void (^)(REMenuItem *item))action -{ - self = [super init]; - if (self) { - _customView = customView; - _action = action; - } - return self; -} - -- (id)initWithCustomView:(UIView *)customView -{ - self = [super init]; - if (self) { - _customView = customView; - } - return self; -} - -- (NSString *)description -{ - return [NSString stringWithFormat:@"<title: %@; subtitle: %@; tag: %li>", self.title, self.subtitle, (long)self.tag]; -} - -- (void)setTitle:(NSString *)title -{ - _title = title; - self.itemView.titleLabel.text = title; - self.itemView.accessibilityLabel = title; -} - -- (void)setSubtitle:(NSString *)subtitle -{ - _subtitle = subtitle; - self.itemView.subtitleLabel.text = subtitle; - self.itemView.accessibilityLabel = [NSString stringWithFormat:@"%@, %@", self.itemView.titleLabel.text, subtitle]; -} - -- (void)setImage:(UIImage *)image -{ - _image = image; - self.itemView.imageView.image = image; -} - -- (void)setHighlightedImage:(UIImage *)highlightedImage -{ - _highlightedImage = highlightedImage; - self.itemView.imageView.highlightedImage = highlightedImage; -} - -- (void)setNeedsLayout -{ - [self.itemView layoutSubviews]; -} - -@end diff --git a/Libraries external/REMenu/REMenuItemView.h b/Libraries external/REMenu/REMenuItemView.h deleted file mode 100644 index 87900523d..000000000 --- a/Libraries external/REMenu/REMenuItemView.h +++ /dev/null @@ -1,42 +0,0 @@ -// -// REMenuItemView.h -// REMenu -// -// Copyright (c) 2013 Roman Efimov (https://github.com/romaonthego) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#import <UIKit/UIKit.h> -#import "REMenuItem.h" -#import "REMenu.h" - -@interface REMenuItemView : UIView - -@property (weak, readwrite, nonatomic) REMenu *menu; -@property (weak, readwrite, nonatomic) UIView *separatorView; -@property (strong, readwrite, nonatomic) UILabel *titleLabel; -@property (strong, readwrite, nonatomic) UILabel *subtitleLabel; -@property (strong, readwrite, nonatomic) UIImageView *imageView; -@property (strong, readwrite, nonatomic) UILabel *badgeLabel; -@property (strong, readwrite, nonatomic) REMenuItem *item; - -- (id)initWithFrame:(CGRect)frame menu:(REMenu *)menu item:(REMenuItem*) item hasSubtitle:(BOOL)hasSubtitle; - -@end diff --git a/Libraries external/REMenu/REMenuItemView.m b/Libraries external/REMenu/REMenuItemView.m deleted file mode 100644 index 499a89199..000000000 --- a/Libraries external/REMenu/REMenuItemView.m +++ /dev/null @@ -1,241 +0,0 @@ -// -// REMenuItemView.m -// REMenu -// -// Copyright (c) 2013 Roman Efimov (https://github.com/romaonthego) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#import "REMenuItemView.h" -#import "REMenuItem.h" - -@interface REMenuItemView () - -@property (strong, readwrite, nonatomic) UIView *backgroundView; - -@end - -@implementation REMenuItemView - -- (id)initWithFrame:(CGRect)frame menu:(REMenu *)menu item:(REMenuItem*) item hasSubtitle:(BOOL)hasSubtitle -{ - self = [super initWithFrame:frame]; - if (self) { - self.menu = menu; - self.item = item; - self.isAccessibilityElement = YES; - self.accessibilityTraits = UIAccessibilityTraitButton; - self.accessibilityHint = NSLocalizedString(@"Double tap to choose", @"Double tap to choose"); - - _backgroundView = ({ - UIView *view = [[UIView alloc] initWithFrame:self.bounds]; - view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - if (menu.liveBlur && REUIKitIsFlatMode()) - view.alpha = 0.5f; - view; - }); - [self addSubview:_backgroundView]; - - - CGRect titleFrame; - if (hasSubtitle) { - // Dividing lines at 1/1.725 (vs 1/2.000) results in labels about 28-top 20-bottom or 60/40 title/subtitle (for a 48 frame height) - // - titleFrame = CGRectMake(self.item.textOffset.width == 0.0 && self.item.textOffset.height == 0.0 ? self.menu.textOffset.width : self.item.textOffset.width, self.item.textOffset.width == 0.0 && self.item.textOffset.height == 0.0 ? self.menu.textOffset.height : self.item.textOffset.height, 0, floorf(frame.size.height / 1.725)); - - CGRect subtitleFrame = CGRectMake(self.item.subtitleTextOffset.width == 0.0 && self.item.subtitleTextOffset.height == 0.0 ? self.menu.subtitleTextOffset.width : self.item.subtitleTextOffset.width, (self.item.subtitleTextOffset.width == 0.0 && self.item.subtitleTextOffset.height == 0.0 ? self.menu.subtitleTextOffset.height : self.item.subtitleTextOffset.height) + titleFrame.size.height, 0, floorf(frame.size.height * (1.0 - 1.0 / 1.725))); - self.subtitleLabel = ({ - UILabel *label =[[UILabel alloc] initWithFrame:subtitleFrame]; - label.contentMode = UIViewContentModeCenter; - label.textAlignment = (NSInteger)self.item.subtitleTextAlignment == -1 ? self.menu.subtitleTextAlignment : self.item.subtitleTextAlignment; - label.backgroundColor = [UIColor clearColor]; - label.autoresizingMask = UIViewAutoresizingFlexibleWidth; - label.isAccessibilityElement = NO; - label; - }); - [self addSubview:_subtitleLabel]; - } else { - titleFrame = CGRectMake(self.item.textOffset.width == 0.0 && self.item.textOffset.height == 0.0 ? self.menu.textOffset.width : self.item.textOffset.width, self.item.textOffset.width == 0.0 && self.item.textOffset.height == 0.0 ? self.menu.textOffset.height : self.item.textOffset.height, 0, frame.size.height); - } - - _titleLabel = ({ - UILabel *label = [[UILabel alloc] initWithFrame:titleFrame]; - label.isAccessibilityElement = NO; - label.contentMode = UIViewContentModeCenter; - label.textAlignment = (NSInteger)self.item.textAlignment == -1 ? self.menu.textAlignment : self.item.subtitleTextAlignment; - label.backgroundColor = [UIColor clearColor]; - label.autoresizingMask = UIViewAutoresizingFlexibleWidth; - label; - }); - - _imageView = [[UIImageView alloc] initWithFrame:CGRectNull]; - - _badgeLabel = ({ - UILabel *label = [[UILabel alloc] init]; - label.backgroundColor = [UIColor colorWithWhite:0.559 alpha:1.000]; - label.font = [UIFont systemFontOfSize:11]; - label.textAlignment = NSTextAlignmentCenter; - label.textColor = [UIColor whiteColor]; - label.hidden = YES; - label.layer.cornerRadius = 4.0; - label.layer.borderColor = [UIColor colorWithWhite:0.630 alpha:1.000].CGColor; - label.layer.borderWidth = 1.0; - label.layer.masksToBounds = YES; - label; - }); - - [self addSubview:_titleLabel]; - [self addSubview:_imageView]; - [self addSubview:_badgeLabel]; - } - return self; -} - -- (void)layoutSubviews -{ - [super layoutSubviews]; - - self.imageView.image = self.item.image; - - // Adjust frames - // - CGFloat verticalOffset = floor((self.frame.size.height - self.item.image.size.height) / 2.0); - CGFloat horizontalOffset = floor((self.menu.itemHeight - self.item.image.size.height) / 2.0); - CGFloat x = (self.menu.imageAlignment == REMenuImageAlignmentLeft) ? horizontalOffset + self.menu.imageOffset.width : - self.titleLabel.frame.size.width - (horizontalOffset + self.menu.imageOffset.width + self.item.image.size.width); - self.imageView.frame = CGRectMake(x, verticalOffset + self.menu.imageOffset.height, self.item.image.size.width, self.item.image.size.height); - if ([self.imageView respondsToSelector:@selector(setTintColor:)]) { - self.imageView.tintColor = self.menu.imageTintColor; - } - - // Set up badge - // - self.badgeLabel.hidden = !self.item.badge; - if (self.item.badge) { - self.badgeLabel.text = self.item.badge; - NSAttributedString *badgeAttributedString = [[NSAttributedString alloc] initWithString:self.item.badge - attributes:@{NSFontAttributeName:self.badgeLabel.font}]; - CGRect rect = [badgeAttributedString boundingRectWithSize:CGSizeMake(CGRectGetMaxX(self.frame), CGRectGetMaxY(self.frame)) - options:NSStringDrawingUsesLineFragmentOrigin - context:nil]; - CGFloat x = self.menu.imageAlignment == REMenuImageAlignmentLeft ? CGRectGetMaxX(self.imageView.frame) - 2.0 : - CGRectGetMinX(self.imageView.frame) - rect.size.height - 4.0; - self.badgeLabel.frame = CGRectMake(x, self.imageView.frame.origin.y - 2.0, rect.size.width + 6.0, rect.size.height + 2.0); - - if (self.menu.badgeLabelConfigurationBlock) - self.menu.badgeLabelConfigurationBlock(self.badgeLabel, self.item); - } - - // Accessibility - // - self.accessibilityLabel = self.item.title; - if (self.subtitleLabel.text) - self.accessibilityLabel = [NSString stringWithFormat:@"%@, %@", self.item.title, self.item.subtitle]; - - // Adjust styles - // - self.backgroundView.backgroundColor = self.item.backgroundColor == nil ? [UIColor clearColor] : self.item.backgroundColor; - self.titleLabel.font = self.item.font == nil ? self.menu.font : self.item.font; - self.titleLabel.text = self.item.title; - self.titleLabel.textColor = self.item.textColor == nil ? self.menu.textColor : self.item.textColor; - self.titleLabel.shadowColor = self.item.textShadowColor ? self.menu.textShadowColor : self.item.textShadowColor; - self.titleLabel.shadowOffset = self.item.textShadowOffset.width == 0 && self.item.textShadowOffset.height == 0 ? self.menu.textShadowOffset : self.item.textShadowOffset; - self.titleLabel.textAlignment = (NSInteger)self.item.textAlignment == -1 ? self.menu.textAlignment : self.item.textAlignment; - self.subtitleLabel.font = self.item.subtitleFont == nil ? self.menu.subtitleFont : self.item.subtitleFont -; - self.subtitleLabel.text = self.item.subtitle; - self.subtitleLabel.textColor = self.item.subtitleTextColor == nil ? self.menu.subtitleTextColor : self.item.subtitleTextColor; - self.subtitleLabel.shadowColor = self.item.subtitleTextShadowColor == nil ? self.menu.subtitleTextShadowColor : self.item.subtitleTextShadowColor; - self.subtitleLabel.shadowOffset = self.item.subtitleTextShadowOffset.width == 0 && self.item.subtitleTextShadowOffset.height == 0 ? self.menu.subtitleTextShadowOffset : self.item.subtitleTextShadowOffset; - self.subtitleLabel.textAlignment = (NSInteger)self.item.subtitleTextAlignment == -1 ? self.menu.subtitleTextAlignment : self.item.subtitleTextAlignment; - - self.item.customView.frame = CGRectMake(0, 0, self.titleLabel.frame.size.width, self.frame.size.height); -} - -- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event -{ - self.backgroundView.backgroundColor = self.item.highlightedBackgroundColor == nil ? self.menu.highlightedBackgroundColor : self.item.highlightedBackgroundColor; - self.separatorView.backgroundColor = self.item.highlightedSeparatorColor == nil ? self.menu.highlightedSeparatorColor : self.item.highlightedSeparatorColor; - self.imageView.image = self.item.highlightedImage ? self.item.highlightedImage : self.item.image; - if ([self.imageView respondsToSelector:@selector(setTintColor:)]) { - self.imageView.tintColor = self.menu.highlightedImageTintColor; - } - self.titleLabel.textColor = self.item.highlightedTextColor == nil ? self.menu.highlightedTextColor : self.item.highlightedTextColor; - self.titleLabel.shadowColor = self.item.highlightedTextShadowColor == nil ? self.menu.highlightedTextShadowColor : self.item.highlightedTextShadowColor; - self.titleLabel.shadowOffset = self.item.highlightedTextShadowOffset.width == 0 && self.item.highlightedTextShadowOffset.height == 0 ? self.menu.highlightedTextShadowOffset : self.item.highlightedTextShadowOffset; - self.subtitleLabel.textColor = self.item.subtitleHighlightedTextColor == nil ? self.menu.subtitleHighlightedTextColor : self.item.subtitleHighlightedTextColor; - self.subtitleLabel.shadowColor = self.item.subtitleHighlightedTextShadowColor == nil ? self.menu.subtitleHighlightedTextShadowColor : self.item.subtitleHighlightedTextShadowColor; - self.subtitleLabel.shadowOffset = self.item.subtitleHighlightedTextShadowOffset.width == 0 && self.item.subtitleHighlightedTextShadowOffset.height == 0 ? self.menu.subtitleHighlightedTextShadowOffset : self.item.subtitleHighlightedTextShadowOffset; -} - -- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event -{ - self.backgroundView.backgroundColor = self.item.backgroundColor == nil ? [UIColor clearColor] : self.item.backgroundColor; - self.separatorView.backgroundColor = self.menu.separatorColor; - self.imageView.image = self.item.image; - if ([self.imageView respondsToSelector:@selector(setTintColor:)]) { - self.imageView.tintColor = self.menu.imageTintColor; - } - self.titleLabel.textColor = self.item.textColor == nil ? self.menu.textColor : self.item.textColor; - self.titleLabel.shadowColor = self.item.textShadowColor == nil ?self.menu.textShadowColor : self.item.textShadowColor; - self.titleLabel.shadowOffset = self.item.textShadowOffset.width == 0 && self.item.textShadowOffset.height == 0 ? self.menu.textShadowOffset : self.item.textShadowOffset; - self.subtitleLabel.textColor = self.item.subtitleTextColor == nil ? self.menu.subtitleTextColor : self.item.subtitleTextColor; - self.subtitleLabel.shadowColor = self.item.subtitleTextShadowColor == nil ? self.menu.subtitleTextShadowColor : self.item.subtitleTextShadowColor; - self.subtitleLabel.shadowOffset = self.item.subtitleTextShadowOffset.width == 0 && self.item.subtitleTextShadowOffset.height == 0 ? self.menu.subtitleTextShadowOffset : self.item.subtitleTextShadowOffset; -} - -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event -{ - self.backgroundView.backgroundColor = self.item.backgroundColor == nil ? [UIColor clearColor] : self.item.backgroundColor; - self.separatorView.backgroundColor = self.item.separatorColor == nil ? self.menu.separatorColor : self.item.separatorColor; - self.imageView.image = self.item.image; - if ([self.imageView respondsToSelector:@selector(setTintColor:)]) { - self.imageView.tintColor = self.menu.imageTintColor; - } - self.titleLabel.textColor = self.item.textColor == nil ? self.menu.textColor : self.item.textColor; - self.titleLabel.shadowColor = self.item.textShadowColor == nil ? self.menu.textShadowColor : self.item.textShadowColor; - self.titleLabel.shadowOffset = self.item.textShadowOffset.width == 0 && self.item.textShadowOffset.height ? self.menu.textShadowOffset : self.item.textShadowOffset; - self.subtitleLabel.textColor = self.item.subtitleTextColor == nil ? self.menu.subtitleTextColor : self.item.subtitleTextColor; - self.subtitleLabel.shadowColor = self.menu.subtitleTextShadowColor == nil ? self.menu.subtitleTextShadowColor : self.item.subtitleTextShadowColor; - self.subtitleLabel.shadowOffset = self.item.subtitleTextShadowOffset.width == 0 && self.item.subtitleTextShadowOffset.height == 0 ? self.menu.subtitleTextShadowOffset : self.item.subtitleTextShadowOffset; - - CGPoint endedPoint = [touches.anyObject locationInView:self]; - if (endedPoint.y < 0 || endedPoint.y > CGRectGetHeight(self.bounds)) - return; - - if (!self.menu.closeOnSelection) { - if (self.item.action) - self.item.action(self.item); - } else { - if (self.item.action) { - if (self.menu.waitUntilAnimationIsComplete) { - __typeof (&*self) __weak weakSelf = self; - [self.menu closeWithCompletion:^{ - weakSelf.item.action(weakSelf.item); - }]; - } else { - [self.menu close]; - self.item.action(self.item); - } - } - } -} - -@end diff --git a/Libraries external/TWMessageBarManager/Icons/icon-error.png b/Libraries external/TWMessageBarManager/Icons/icon-error.png Binary files differdeleted file mode 100755 index abe0e7faa..000000000 --- a/Libraries external/TWMessageBarManager/Icons/icon-error.png +++ /dev/null diff --git a/Libraries external/TWMessageBarManager/Icons/icon-error@2x.png b/Libraries external/TWMessageBarManager/Icons/icon-error@2x.png Binary files differdeleted file mode 100755 index 2c11135b4..000000000 --- a/Libraries external/TWMessageBarManager/Icons/icon-error@2x.png +++ /dev/null diff --git a/Libraries external/TWMessageBarManager/Icons/icon-info.png b/Libraries external/TWMessageBarManager/Icons/icon-info.png Binary files differdeleted file mode 100755 index 0a04165ce..000000000 --- a/Libraries external/TWMessageBarManager/Icons/icon-info.png +++ /dev/null diff --git a/Libraries external/TWMessageBarManager/Icons/icon-info@2x.png b/Libraries external/TWMessageBarManager/Icons/icon-info@2x.png Binary files differdeleted file mode 100755 index d11784c48..000000000 --- a/Libraries external/TWMessageBarManager/Icons/icon-info@2x.png +++ /dev/null diff --git a/Libraries external/TWMessageBarManager/Icons/icon-success.png b/Libraries external/TWMessageBarManager/Icons/icon-success.png Binary files differdeleted file mode 100755 index d77a870fc..000000000 --- a/Libraries external/TWMessageBarManager/Icons/icon-success.png +++ /dev/null diff --git a/Libraries external/TWMessageBarManager/Icons/icon-success@2x.png b/Libraries external/TWMessageBarManager/Icons/icon-success@2x.png Binary files differdeleted file mode 100755 index 911ae2106..000000000 --- a/Libraries external/TWMessageBarManager/Icons/icon-success@2x.png +++ /dev/null diff --git a/Libraries external/TWMessageBarManager/TWMessageBarManager.h b/Libraries external/TWMessageBarManager/TWMessageBarManager.h deleted file mode 100755 index 613e5d9dc..000000000 --- a/Libraries external/TWMessageBarManager/TWMessageBarManager.h +++ /dev/null @@ -1,239 +0,0 @@ -// -// TWMessageBarManager.h -// -// Created by Terry Worona on 5/13/13. -// Copyright (c) 2013 Terry Worona. All rights reserved. -// - -#import <Foundation/Foundation.h> -#import <UIKit/UIKit.h> - -/** - * Three base message bar types. Their look & feel is defined within the MessageBarStyleSheet. - */ -typedef NS_ENUM(NSInteger, TWMessageBarMessageType) { - TWMessageBarMessageTypeError, - TWMessageBarMessageTypeSuccess, - TWMessageBarMessageTypeInfo -}; - -@protocol TWMessageBarStyleSheet <NSObject> - -/** - * Background color of message view. - * - * @param type A MessageBarMessageType (error, information, success, etc). - * - * @return UIColor istance representing the message view's background color. - */ -- (nonnull UIColor *)backgroundColorForMessageType:(TWMessageBarMessageType)type; - -/** - * Bottom stroke color of message view. - * - * @param type A MessageBarMessageType (error, information, success, etc). - * - * @return UIColor istance representing the message view's bottom stroke color. - */ -- (nonnull UIColor *)strokeColorForMessageType:(TWMessageBarMessageType)type; - -/** - * Icon image of the message view. - * - * @param type A MessageBarMessageType (error, information, success, etc). - * - * @return UIImage istance representing the message view's icon. - */ -- (nonnull UIImage *)iconImageForMessageType:(TWMessageBarMessageType)type; - -@optional - -/** - * The (optional) UIFont to be used for the message's title. - * - * Default: 16pt bold - * - * @param type A MessageBarMessageType (error, information, success, etc). - * - * @return UIFont instance representing the title font. - */ -- (nonnull UIFont *)titleFontForMessageType:(TWMessageBarMessageType)type; - -/** - * The (optional) UIFont to be used for the message's description. - * - * Default: 14pt regular - * - * @param type A MessageBarMessageType (error, information, success, etc). - * - * @return UIFont instance representing the description font. - */ -- (nonnull UIFont *)descriptionFontForMessageType:(TWMessageBarMessageType)type; - -/** - * The (optional) UIColor to be used for the message's title. - * - * Default: white - * - * @param type A MessageBarMessageType (error, information, success, etc). - * - * @return UIColor instance representing the title color. - */ -- (nonnull UIColor *)titleColorForMessageType:(TWMessageBarMessageType)type; - -/** - * The (optional) UIColor to be used for the message's description. - * - * Default: white - * - * @param type A MessageBarMessageType (error, information, success, etc). - * - * @return UIColor instance representing the description color. - */ -- (nonnull UIColor *)descriptionColorForMessageType:(TWMessageBarMessageType)type; - -@end - -@interface TWMessageBarManager : NSObject - -/** - * Singleton instance through which all presentation is managed. - * - * @return MessageBarManager instance (singleton). - */ -+ (nonnull TWMessageBarManager *)sharedInstance; - -/** - * Default display duration for each message. - * This can be customized on a per-message basis (see presentation functions below). - * - * @return Default display duration (3 seconds). - */ -+ (CGFloat)defaultDuration; - -/** - * Flag indicating if message is currently visible on screen. - */ -@property (nonatomic, readonly, getter = isMessageVisible) BOOL messageVisible; - -/** - * The orientations supported by the manager. - * In most cases, this value will match the caller's orientation mask. - * - * @return Default behaviour - all orientations. - */ -@property (nonatomic, assign) UIInterfaceOrientationMask managerSupportedOrientationsMask; - -/** - * An object conforming to the TWMessageBarStyleSheet protocol defines the message bar's look and feel. - * If no style sheet is supplied, a default class is provided on initialization (see implementation for details). - */ -@property (nonnull, nonatomic, strong) NSObject<TWMessageBarStyleSheet> *styleSheet; - -/** - * Shows a message with the supplied title, description and type. - * - * @param title Header text in the message view. - * @param description Description text in the message view. - * @param type Type dictates color, stroke and icon shown in the message view. - */ -- (void)showMessageWithTitle:(nullable NSString *)title description:(nullable NSString *)description type:(TWMessageBarMessageType)type; - -/** - * Shows a message with the supplied title, description, type & callback block. - * - * @param title Header text in the message view. - * @param description Description text in the message view. - * @param type Type dictates color, stroke and icon shown in the message view. - * @param callback Callback block to be executed if a message is tapped. - */ -- (void)showMessageWithTitle:(nullable NSString *)title description:(nullable NSString *)description type:(TWMessageBarMessageType)type callback:(nullable void (^)())callback; - -/** - * Shows a message with the supplied title, description, type & duration. - * - * @param title Header text in the message view. - * @param description Description text in the message view. - * @param type Type dictates color, stroke and icon shown in the message view. - * @param duration Default duration is 3 seconds, this can be overridden by supplying an optional duration parameter. - */ -- (void)showMessageWithTitle:(nullable NSString *)title description:(nullable NSString *)description type:(TWMessageBarMessageType)type duration:(CGFloat)duration; - -/** - * Shows a message with the supplied title, description, type, duration and callback block. - * - * @param title Header text in the message view. - * @param description Description text in the message view. - * @param type Type dictates color, stroke and icon shown in the message view. - * @param duration Default duration is 3 seconds, this can be overridden by supplying an optional duration parameter. - * @param callback Callback block to be executed if a message is tapped. - */ -- (void)showMessageWithTitle:(nullable NSString *)title description:(nullable NSString *)description type:(TWMessageBarMessageType)type duration:(CGFloat)duration callback:(nullable void (^)())callback; - -/** - * Shows a message with the supplied title, description, type, status bar style and callback block. - * - * @param title Header text in the message view. - * @param description Description text in the message view. - * @param type Type dictates color, stroke and icon shown in the message view. - * @param statusBarStyle Applied during the presentation of the message. If not supplied, style will default to UIStatusBarStyleDefault. - * @param callback Callback block to be executed if a message is tapped. - */ -- (void)showMessageWithTitle:(nullable NSString *)title description:(nullable NSString *)description type:(TWMessageBarMessageType)type statusBarStyle:(UIStatusBarStyle)statusBarStyle callback:(nullable void (^)())callback; - -/** - * Shows a message with the supplied title, description, type, duration, status bar style and callback block. - * - * @param title Header text in the message view. - * @param description Description text in the message view. - * @param type Type dictates color, stroke and icon shown in the message view. - * @param duration Default duration is 3 seconds, this can be overridden by supplying an optional duration parameter. - * @param statusBarStyle Applied during the presentation of the message. If not supplied, style will default to UIStatusBarStyleDefault. - * @param callback Callback block to be executed if a message is tapped. - */ -- (void)showMessageWithTitle:(nullable NSString *)title description:(nullable NSString *)description type:(TWMessageBarMessageType)type duration:(CGFloat)duration statusBarStyle:(UIStatusBarStyle)statusBarStyle callback:(nullable void (^)())callback; - -/** - * Shows a message with the supplied title, description, type, status bar hidden toggle and callback block. - * - * @param title Header text in the message view. - * @param description Description text in the message view. - * @param type Type dictates color, stroke and icon shown in the message view. - * @param statusBarHidden Status bars are shown by default. To hide it during the presentation of a message, set to NO. - * @param callback Callback block to be executed if a message is tapped. - */ -- (void)showMessageWithTitle:(nullable NSString *)title description:(nullable NSString *)description type:(TWMessageBarMessageType)type statusBarHidden:(BOOL)statusBarHidden callback:(nullable void (^)())callback; - -/** - * Shows a message with the supplied title, description, type, duration, status bar hidden toggle and callback block. - * - * @param title Header text in the message view. - * @param description Description text in the message view. - * @param type Type dictates color, stroke and icon shown in the message view. - * @param duration Default duration is 3 seconds, this can be overridden by supplying an optional duration parameter. - * @param statusBarHidden Status bars are shown by default. To hide it during the presentation of a message, set to NO. - * @param callback Callback block to be executed if a message is tapped. - */ -- (void)showMessageWithTitle:(nullable NSString *)title description:(nullable NSString *)description type:(TWMessageBarMessageType)type duration:(CGFloat)duration statusBarHidden:(BOOL)statusBarHidden callback:(nullable void (^)())callback; - -/** - * Hides the topmost message and removes all remaining messages in the queue. - * - * @param animated Animates the current message view off the screen. - */ -- (void)hideAllAnimated:(BOOL)animated; -- (void)hideAll; // non-animated - - -@end - -@interface UIDevice (Additions) - -/** - * Determines if the device instance is running iOS 7 or later. - * - * @return YES if the device instance is running an OS >= 7, otherwise NO. - */ -- (BOOL)tw_isRunningiOS7OrLater; - -@end diff --git a/Libraries external/TWMessageBarManager/TWMessageBarManager.m b/Libraries external/TWMessageBarManager/TWMessageBarManager.m deleted file mode 100755 index 90ec26e95..000000000 --- a/Libraries external/TWMessageBarManager/TWMessageBarManager.m +++ /dev/null @@ -1,927 +0,0 @@ -// -// TWMessageBarManager.m -// -// Created by Terry Worona on 5/13/13. -// Copyright (c) 2013 Terry Worona. All rights reserved. -// - -#import "TWMessageBarManager.h" - -// Quartz -#import <QuartzCore/QuartzCore.h> - -// Numerics (TWMessageBarStyleSheet) -CGFloat const kTWMessageBarStyleSheetMessageBarAlpha = 0.96f; - -// Numerics (TWMessageView) -CGFloat const kTWMessageViewBarPadding = 10.0f; -CGFloat const kTWMessageViewIconSize = 36.0f; -CGFloat const kTWMessageViewTextOffset = 2.0f; -NSUInteger const kTWMessageViewiOS7Identifier = 7; - -// Numerics (TWMessageBarManager) -CGFloat const kTWMessageBarManagerDisplayDelay = 3.0f; -CGFloat const kTWMessageBarManagerDismissAnimationDuration = 0.25f; -CGFloat const kTWMessageBarManagerPanVelocity = 0.2f; -CGFloat const kTWMessageBarManagerPanAnimationDuration = 0.0002f; - -// Strings (TWMessageBarStyleSheet) -NSString * const kTWMessageBarStyleSheetImageIconError = @"icon-error.png"; -NSString * const kTWMessageBarStyleSheetImageIconSuccess = @"icon-success.png"; -NSString * const kTWMessageBarStyleSheetImageIconInfo = @"icon-info.png"; - -// Fonts (TWMessageView) -static UIFont *kTWMessageViewTitleFont = nil; -static UIFont *kTWMessageViewDescriptionFont = nil; - -// Colors (TWMessageView) -static UIColor *kTWMessageViewTitleColor = nil; -static UIColor *kTWMessageViewDescriptionColor = nil; - -// Colors (TWDefaultMessageBarStyleSheet) -static UIColor *kTWDefaultMessageBarStyleSheetErrorBackgroundColor = nil; -static UIColor *kTWDefaultMessageBarStyleSheetSuccessBackgroundColor = nil; -static UIColor *kTWDefaultMessageBarStyleSheetInfoBackgroundColor = nil; -static UIColor *kTWDefaultMessageBarStyleSheetErrorStrokeColor = nil; -static UIColor *kTWDefaultMessageBarStyleSheetSuccessStrokeColor = nil; -static UIColor *kTWDefaultMessageBarStyleSheetInfoStrokeColor = nil; - -static NSString *prevMessage; - -@protocol TWMessageViewDelegate; - -@interface TWMessageView : UIView - -@property (nonatomic, copy) NSString *titleString; -@property (nonatomic, copy) NSString *descriptionString; - -@property (nonatomic, assign) TWMessageBarMessageType messageType; - -@property (nonatomic, assign) BOOL hasCallback; -@property (nonatomic, strong) NSArray *callbacks; - -@property (nonatomic, assign, getter = isHit) BOOL hit; - -@property (nonatomic, assign) CGFloat duration; - -@property (nonatomic, assign) UIStatusBarStyle statusBarStyle; -@property (nonatomic, assign) BOOL statusBarHidden; - -@property (nonatomic, weak) id <TWMessageViewDelegate> delegate; - -// Initializers -- (id)initWithTitle:(NSString *)title description:(NSString *)description type:(TWMessageBarMessageType)type; - -// Getters -- (CGFloat)height; -- (CGFloat)width; -- (CGFloat)statusBarOffset; -- (CGFloat)availableWidth; -- (CGSize)titleSize; -- (CGSize)descriptionSize; -- (CGRect)statusBarFrame; -- (UIFont *)titleFont; -- (UIFont *)descriptionFont; -- (UIColor *)titleColor; -- (UIColor *)descriptionColor; - -// Helpers -- (CGRect)orientFrame:(CGRect)frame; - -// Notifications -- (void)didChangeDeviceOrientation:(NSNotification *)notification; - -@end - -@protocol TWMessageViewDelegate <NSObject> - -- (NSObject<TWMessageBarStyleSheet> *)styleSheetForMessageView:(TWMessageView *)messageView; - -@end - -@interface TWDefaultMessageBarStyleSheet : NSObject <TWMessageBarStyleSheet> - -+ (TWDefaultMessageBarStyleSheet *)styleSheet; - -@end - -@interface TWMessageWindow : UIWindow - -@end - -@interface TWMessageBarViewController : UIViewController - -@property (nonatomic, assign) UIStatusBarStyle statusBarStyle; -@property (nonatomic, assign) BOOL statusBarHidden; - -@end - -@interface TWMessageBarManager () <TWMessageViewDelegate> - -@property (nonatomic, strong) NSMutableArray *messageBarQueue; -@property (nonatomic, assign, getter = isMessageVisible) BOOL messageVisible; -@property (nonatomic, strong) TWMessageWindow *messageWindow; -@property (nonatomic, readwrite) NSArray *accessibleElements; // accessibility - -// Static -+ (CGFloat)durationForMessageType:(TWMessageBarMessageType)messageType; - -// Helpers -- (void)showNextMessage; -- (void)generateAccessibleElementWithTitle:(NSString *)title description:(NSString *)description; - -// Gestures -- (void)itemSelected:(UITapGestureRecognizer *)recognizer; - -// Getters -- (UIView *)messageWindowView; -- (TWMessageBarViewController *)messageBarViewController; - -// Master presetation -- (void)showMessageWithTitle:(NSString *)title description:(NSString *)description type:(TWMessageBarMessageType)type duration:(CGFloat)duration statusBarHidden:(BOOL)statusBarHidden statusBarStyle:(UIStatusBarStyle)statusBarStyle callback:(void (^)())callback; - -@end - -@implementation TWMessageBarManager - -#pragma mark - Singleton - -+ (nonnull TWMessageBarManager *)sharedInstance -{ - static dispatch_once_t pred; - static TWMessageBarManager *instance = nil; - dispatch_once(&pred, ^{ - instance = [[self alloc] init]; - }); - return instance; -} - -#pragma mark - Static - -+ (CGFloat)defaultDuration -{ - return kTWMessageBarManagerDisplayDelay; -} - -+ (CGFloat)durationForMessageType:(TWMessageBarMessageType)messageType -{ - return kTWMessageBarManagerDisplayDelay; -} - -#pragma mark - Alloc/Init - -- (id)init -{ - self = [super init]; - if (self) - { - _messageBarQueue = [[NSMutableArray alloc] init]; - _messageVisible = NO; - _styleSheet = [TWDefaultMessageBarStyleSheet styleSheet]; - _managerSupportedOrientationsMask = UIInterfaceOrientationMaskAll; - } - return self; -} - -#pragma mark - Public - -- (void)showMessageWithTitle:(nullable NSString *)title description:(nullable NSString *)description type:(TWMessageBarMessageType)type -{ - [self showMessageWithTitle:title description:description type:type duration:[TWMessageBarManager durationForMessageType:type] callback:nil]; -} - -- (void)showMessageWithTitle:(nullable NSString *)title description:(nullable NSString *)description type:(TWMessageBarMessageType)type callback:(nullable void (^)())callback -{ - [self showMessageWithTitle:title description:description type:type duration:[TWMessageBarManager durationForMessageType:type] callback:callback]; -} - -- (void)showMessageWithTitle:(nullable NSString *)title description:(nullable NSString *)description type:(TWMessageBarMessageType)type duration:(CGFloat)duration -{ - [self showMessageWithTitle:title description:description type:type duration:duration callback:nil]; -} - -- (void)showMessageWithTitle:(nullable NSString *)title description:(nullable NSString *)description type:(TWMessageBarMessageType)type duration:(CGFloat)duration callback:(nullable void (^)())callback -{ - [self showMessageWithTitle:title description:description type:type duration:duration statusBarStyle:UIStatusBarStyleDefault callback:callback]; -} - -- (void)showMessageWithTitle:(nullable NSString *)title description:(nullable NSString *)description type:(TWMessageBarMessageType)type statusBarStyle:(UIStatusBarStyle)statusBarStyle callback:(nullable void (^)())callback -{ - [self showMessageWithTitle:title description:description type:type duration:kTWMessageBarManagerDisplayDelay statusBarStyle:statusBarStyle callback:callback]; -} - -- (void)showMessageWithTitle:(nullable NSString *)title description:(nullable NSString *)description type:(TWMessageBarMessageType)type duration:(CGFloat)duration statusBarStyle:(UIStatusBarStyle)statusBarStyle callback:(nullable void (^)())callback -{ - [self showMessageWithTitle:title description:description type:type duration:duration statusBarHidden:NO statusBarStyle:statusBarStyle callback:callback]; -} - -- (void)showMessageWithTitle:(nullable NSString *)title description:(nullable NSString *)description type:(TWMessageBarMessageType)type statusBarHidden:(BOOL)statusBarHidden callback:(nullable void (^)())callback -{ - [self showMessageWithTitle:title description:description type:type duration:[TWMessageBarManager durationForMessageType:type] statusBarHidden:statusBarHidden statusBarStyle:UIStatusBarStyleDefault callback:callback]; -} - -- (void)showMessageWithTitle:(nullable NSString *)title description:(nullable NSString *)description type:(TWMessageBarMessageType)type duration:(CGFloat)duration statusBarHidden:(BOOL)statusBarHidden callback:(nullable void (^)())callback -{ - [self showMessageWithTitle:title description:description type:type duration:duration statusBarHidden:statusBarHidden statusBarStyle:UIStatusBarStyleDefault callback:callback]; -} - -#pragma mark - Master Presentation - -- (void)showMessageWithTitle:(NSString *)title description:(NSString *)description type:(TWMessageBarMessageType)type duration:(CGFloat)duration statusBarHidden:(BOOL)statusBarHidden statusBarStyle:(UIStatusBarStyle)statusBarStyle callback:(void (^)())callback -{ - //TWS - if ([prevMessage isEqualToString:[title stringByAppendingString:description]]) { - - return; - - } else { - - prevMessage = [title stringByAppendingString:description]; - } - - - for (TWMessageView *messageView in self.messageBarQueue) { - if ([messageView.titleString isEqualToString:title] && [messageView.descriptionString isEqualToString:description]) - return; - } - - TWMessageView *messageView = [[TWMessageView alloc] initWithTitle:title description:description type:type]; - messageView.delegate = self; - - messageView.callbacks = callback ? [NSArray arrayWithObject:callback] : [NSArray array]; - messageView.hasCallback = callback ? YES : NO; - - messageView.duration = duration; - messageView.hidden = YES; - - messageView.statusBarStyle = statusBarStyle; - messageView.statusBarHidden = statusBarHidden; - - [[self messageWindowView] addSubview:messageView]; - [[self messageWindowView] bringSubviewToFront:messageView]; - - [self.messageBarQueue addObject:messageView]; - - if (!self.messageVisible) - { - [self showNextMessage]; - } -} - -- (void)hideAllAnimated:(BOOL)animated -{ - for (UIView *subview in [[self messageWindowView] subviews]) - { - if ([subview isKindOfClass:[TWMessageView class]]) - { - TWMessageView *currentMessageView = (TWMessageView *)subview; - if (animated) - { - [UIView animateWithDuration:kTWMessageBarManagerDismissAnimationDuration animations:^{ - currentMessageView.frame = CGRectMake(currentMessageView.frame.origin.x, -currentMessageView.frame.size.height, currentMessageView.frame.size.width, currentMessageView.frame.size.height); - } completion:^(BOOL finished) { - [currentMessageView removeFromSuperview]; - }]; - } - else - { - [currentMessageView removeFromSuperview]; - } - } - } - - self.messageVisible = NO; - [self.messageBarQueue removeAllObjects]; - [NSObject cancelPreviousPerformRequestsWithTarget:self]; - self.messageWindow.hidden = YES; - self.messageWindow = nil; - - //TWS - prevMessage = nil; -} - -- (void)hideAll -{ - [self hideAllAnimated:NO]; -} - -#pragma mark - Helpers - -- (void)showNextMessage -{ - if ([self.messageBarQueue count] > 0) - { - self.messageVisible = YES; - - TWMessageView *messageView = [self.messageBarQueue objectAtIndex:0]; - [self messageBarViewController].statusBarHidden = messageView.statusBarHidden; // important to do this prior to hiding - messageView.frame = CGRectMake(0, -[messageView height], [messageView width], [messageView height]); - messageView.hidden = NO; - [messageView setNeedsDisplay]; - - UITapGestureRecognizer *gest = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(itemSelected:)]; - [messageView addGestureRecognizer:gest]; - - if (messageView) - { - [self.messageBarQueue removeObject:messageView]; - - [self messageBarViewController].statusBarStyle = messageView.statusBarStyle; - - [UIView animateWithDuration:kTWMessageBarManagerDismissAnimationDuration animations:^{ - [messageView setFrame:CGRectMake(messageView.frame.origin.x, messageView.frame.origin.y + [messageView height], [messageView width], [messageView height])]; // slide down - }]; - [self performSelector:@selector(itemSelected:) withObject:messageView afterDelay:messageView.duration]; - - [self generateAccessibleElementWithTitle:messageView.titleString description:messageView.descriptionString]; - } - } -} - -- (void)generateAccessibleElementWithTitle:(NSString *)title description:(NSString *)description -{ - UIAccessibilityElement *textElement = [[UIAccessibilityElement alloc] initWithAccessibilityContainer:self]; - textElement.accessibilityLabel = [NSString stringWithFormat:@"%@\n%@", title, description]; - textElement.accessibilityTraits = UIAccessibilityTraitStaticText; - self.accessibleElements = @[textElement]; - UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, self); // notify the accessibility framework to read the message -} - -#pragma mark - Gestures - -- (void)itemSelected:(id)sender -{ - TWMessageView *messageView = nil; - BOOL itemHit = NO; - if ([sender isKindOfClass:[UIGestureRecognizer class]]) - { - messageView = (TWMessageView *)((UIGestureRecognizer *)sender).view; - itemHit = YES; - } - else if ([sender isKindOfClass:[TWMessageView class]]) - { - messageView = (TWMessageView *)sender; - } - - if (messageView && ![messageView isHit]) - { - messageView.hit = YES; - - [UIView animateWithDuration:kTWMessageBarManagerDismissAnimationDuration animations:^{ - [messageView setFrame:CGRectMake(messageView.frame.origin.x, messageView.frame.origin.y - [messageView height], [messageView width], [messageView height])]; // slide back up - } completion:^(BOOL finished) { - if (itemHit) - { - if ([messageView.callbacks count] > 0) - { - id obj = [messageView.callbacks objectAtIndex:0]; - if (![obj isEqual:[NSNull null]]) - { - ((void (^)())obj)(); - } - } - } - - self.messageVisible = NO; - [messageView removeFromSuperview]; - - //TWS - prevMessage = nil; - - if([self.messageBarQueue count] > 0) - { - [self showNextMessage]; - } - else - { - self.messageWindow.hidden = YES; - self.messageWindow = nil; - } - }]; - } -} - -#pragma mark - Getters - -- (UIView *)messageWindowView -{ - return [self messageBarViewController].view; -} - -- (TWMessageBarViewController *)messageBarViewController -{ - if (!self.messageWindow) - { - self.messageWindow = [[TWMessageWindow alloc] init]; - self.messageWindow.frame = [UIApplication sharedApplication].keyWindow.frame; - self.messageWindow.hidden = NO; - self.messageWindow.windowLevel = UIWindowLevelNormal; - self.messageWindow.backgroundColor = [UIColor clearColor]; - self.messageWindow.rootViewController = [[TWMessageBarViewController alloc] init]; - } - return (TWMessageBarViewController *)self.messageWindow.rootViewController; -} - -- (NSArray *)accessibleElements -{ - if (_accessibleElements != nil) - { - return _accessibleElements; - } - _accessibleElements = [NSArray array]; - return _accessibleElements; -} - -#pragma mark - Setters - -- (void)setStyleSheet:(NSObject<TWMessageBarStyleSheet> *)styleSheet -{ - if (styleSheet != nil) - { - _styleSheet = styleSheet; - } -} - -#pragma mark - TWMessageViewDelegate - -- (NSObject<TWMessageBarStyleSheet> *)styleSheetForMessageView:(TWMessageView *)messageView -{ - return self.styleSheet; -} - -#pragma mark - UIAccessibilityContainer - -- (NSInteger)accessibilityElementCount -{ - return (NSInteger)[self.accessibleElements count]; -} - -- (id)accessibilityElementAtIndex:(NSInteger)index -{ - return [self.accessibleElements objectAtIndex:(NSUInteger)index]; -} - -- (NSInteger)indexOfAccessibilityElement:(id)element -{ - return (NSInteger)[self.accessibleElements indexOfObject:element]; -} - -- (BOOL)isAccessibilityElement -{ - return NO; -} - -@end - -@implementation TWMessageView - -#pragma mark - Alloc/Init - -+ (void)initialize -{ - if (self == [TWMessageView class]) - { - // Fonts - kTWMessageViewTitleFont = [UIFont boldSystemFontOfSize:16.0]; - kTWMessageViewDescriptionFont = [UIFont systemFontOfSize:14.0]; - - // Colors - kTWMessageViewTitleColor = [UIColor colorWithWhite:1.0 alpha:1.0]; - kTWMessageViewDescriptionColor = [UIColor colorWithWhite:1.0 alpha:1.0]; - } -} - -- (id)initWithTitle:(NSString *)title description:(NSString *)description type:(TWMessageBarMessageType)type -{ - self = [super initWithFrame:CGRectZero]; - if (self) - { - self.backgroundColor = [UIColor clearColor]; - self.clipsToBounds = NO; - self.userInteractionEnabled = YES; - - _titleString = title; - _descriptionString = description; - _messageType = type; - - _hasCallback = NO; - _hit = NO; - - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didChangeDeviceOrientation:) name:UIDeviceOrientationDidChangeNotification object:nil]; - } - return self; -} - -#pragma mark - Memory Management - -- (void)dealloc -{ - [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil]; -} - -#pragma mark - Drawing - -- (void)drawRect:(CGRect)rect -{ - CGContextRef context = UIGraphicsGetCurrentContext(); - - if ([self.delegate respondsToSelector:@selector(styleSheetForMessageView:)]) - { - id<TWMessageBarStyleSheet> styleSheet = [self.delegate styleSheetForMessageView:self]; - - // background fill - CGContextSaveGState(context); - { - if ([styleSheet respondsToSelector:@selector(backgroundColorForMessageType:)]) - { - [[styleSheet backgroundColorForMessageType:self.messageType] set]; - CGContextFillRect(context, rect); - } - } - CGContextRestoreGState(context); - - // bottom stroke - CGContextSaveGState(context); - { - if ([styleSheet respondsToSelector:@selector(strokeColorForMessageType:)]) - { - CGContextBeginPath(context); - CGContextMoveToPoint(context, 0, rect.size.height); - CGContextSetStrokeColorWithColor(context, [styleSheet strokeColorForMessageType:self.messageType].CGColor); - CGContextSetLineWidth(context, 1.0); - CGContextAddLineToPoint(context, rect.size.width, rect.size.height); - CGContextStrokePath(context); - } - } - CGContextRestoreGState(context); - - CGFloat xOffset = kTWMessageViewBarPadding; - CGFloat yOffset = kTWMessageViewBarPadding + [self statusBarOffset]; - - // icon - CGContextSaveGState(context); - { - if ([styleSheet respondsToSelector:@selector(iconImageForMessageType:)]) - { - [[styleSheet iconImageForMessageType:self.messageType] drawInRect:CGRectMake(xOffset, yOffset, kTWMessageViewIconSize, kTWMessageViewIconSize)]; - } - } - CGContextRestoreGState(context); - - yOffset -= kTWMessageViewTextOffset; - xOffset += kTWMessageViewIconSize + kTWMessageViewBarPadding; - - CGSize titleLabelSize = [self titleSize]; - CGSize descriptionLabelSize = [self descriptionSize]; - - if (self.titleString && !self.descriptionString) - { - yOffset = ceil(rect.size.height * 0.5) - ceil(titleLabelSize.height * 0.5) - kTWMessageViewTextOffset; - } - - if ([[UIDevice currentDevice] tw_isRunningiOS7OrLater]) - { - NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; - paragraphStyle.alignment = NSTextAlignmentLeft; - - [[self titleColor] set]; - [self.titleString drawWithRect:CGRectMake(xOffset, yOffset, titleLabelSize.width, titleLabelSize.height) - options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingTruncatesLastVisibleLine - attributes:@{NSFontAttributeName:[self titleFont], NSForegroundColorAttributeName:[self titleColor], NSParagraphStyleAttributeName:paragraphStyle} - context:nil]; - - yOffset += titleLabelSize.height; - - [[self descriptionColor] set]; - [self.descriptionString drawWithRect:CGRectMake(xOffset, yOffset, descriptionLabelSize.width, descriptionLabelSize.height) - options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingTruncatesLastVisibleLine - attributes:@{NSFontAttributeName:[self descriptionFont], NSForegroundColorAttributeName:[self descriptionColor], NSParagraphStyleAttributeName:paragraphStyle} - context:nil]; - } - else - { - [[self titleColor] set]; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - [self.titleString drawInRect:CGRectMake(xOffset, yOffset, titleLabelSize.width, titleLabelSize.height) withFont:[self titleFont] lineBreakMode:NSLineBreakByTruncatingTail alignment:NSTextAlignmentLeft]; -#pragma clang diagnostic pop - - yOffset += titleLabelSize.height; - - [[self descriptionColor] set]; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - [self.descriptionString drawInRect:CGRectMake(xOffset, yOffset, descriptionLabelSize.width, descriptionLabelSize.height) withFont:[self descriptionFont] lineBreakMode:NSLineBreakByTruncatingTail alignment:NSTextAlignmentLeft]; -#pragma clang diagnostic pop - } - } -} - -#pragma mark - Getters - -- (CGFloat)height -{ - CGSize titleLabelSize = [self titleSize]; - CGSize descriptionLabelSize = [self descriptionSize]; - return MAX((kTWMessageViewBarPadding * 2) + titleLabelSize.height + descriptionLabelSize.height + [self statusBarOffset], (kTWMessageViewBarPadding * 2) + kTWMessageViewIconSize + [self statusBarOffset]); -} - -- (CGFloat)width -{ - return [self statusBarFrame].size.width; -} - -- (CGFloat)statusBarOffset -{ - return [[UIDevice currentDevice] tw_isRunningiOS7OrLater] ? [self statusBarFrame].size.height : 0.0; -} - -- (CGFloat)availableWidth -{ - return ([self width] - (kTWMessageViewBarPadding * 3) - kTWMessageViewIconSize); -} - -- (CGSize)titleSize -{ - CGSize boundedSize = CGSizeMake([self availableWidth], CGFLOAT_MAX); - CGSize titleLabelSize; - - if ([[UIDevice currentDevice] tw_isRunningiOS7OrLater]) - { - NSDictionary *titleStringAttributes = [NSDictionary dictionaryWithObject:[self titleFont] forKey: NSFontAttributeName]; - titleLabelSize = [self.titleString boundingRectWithSize:boundedSize - options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin - attributes:titleStringAttributes - context:nil].size; - } - else - { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - titleLabelSize = [_titleString sizeWithFont:[self titleFont] constrainedToSize:boundedSize lineBreakMode:NSLineBreakByTruncatingTail]; -#pragma clang diagnostic pop - } - - return CGSizeMake(ceilf(titleLabelSize.width), ceilf(titleLabelSize.height)); -} - -- (CGSize)descriptionSize -{ - CGSize boundedSize = CGSizeMake([self availableWidth], CGFLOAT_MAX); - CGSize descriptionLabelSize; - - if ([[UIDevice currentDevice] tw_isRunningiOS7OrLater]) - { - NSDictionary *descriptionStringAttributes = [NSDictionary dictionaryWithObject:[self descriptionFont] forKey: NSFontAttributeName]; - descriptionLabelSize = [self.descriptionString boundingRectWithSize:boundedSize - options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin - attributes:descriptionStringAttributes - context:nil].size; - } - else - { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - descriptionLabelSize = [_descriptionString sizeWithFont:[self descriptionFont] constrainedToSize:boundedSize lineBreakMode:NSLineBreakByTruncatingTail]; -#pragma clang diagnostic pop - } - - return CGSizeMake(ceilf(descriptionLabelSize.width), ceilf(descriptionLabelSize.height)); -} - -- (CGRect)statusBarFrame -{ - CGRect windowFrame = NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_7_1 ? [self orientFrame:[UIApplication sharedApplication].keyWindow.frame] : [UIApplication sharedApplication].keyWindow.frame; - CGRect statusFrame = NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_7_1 ? [self orientFrame:[UIApplication sharedApplication].statusBarFrame] : [UIApplication sharedApplication].statusBarFrame; - return CGRectMake(windowFrame.origin.x, windowFrame.origin.y, windowFrame.size.width, statusFrame.size.height); -} - -- (UIFont *)titleFont -{ - if ([self.delegate respondsToSelector:@selector(styleSheetForMessageView:)]) - { - id<TWMessageBarStyleSheet> styleSheet = [self.delegate styleSheetForMessageView:self]; - if ([styleSheet respondsToSelector:@selector(titleFontForMessageType:)]) - { - return [styleSheet titleFontForMessageType:self.messageType]; - } - } - return kTWMessageViewTitleFont; -} - -- (UIFont *)descriptionFont -{ - if ([self.delegate respondsToSelector:@selector(styleSheetForMessageView:)]) - { - id<TWMessageBarStyleSheet> styleSheet = [self.delegate styleSheetForMessageView:self]; - if ([styleSheet respondsToSelector:@selector(descriptionFontForMessageType:)]) - { - return [styleSheet descriptionFontForMessageType:self.messageType]; - } - } - return kTWMessageViewDescriptionFont; -} - -- (UIColor *)titleColor -{ - if ([self.delegate respondsToSelector:@selector(styleSheetForMessageView:)]) - { - id<TWMessageBarStyleSheet> styleSheet = [self.delegate styleSheetForMessageView:self]; - if ([styleSheet respondsToSelector:@selector(titleColorForMessageType:)]) - { - return [styleSheet titleColorForMessageType:self.messageType]; - } - } - return kTWMessageViewTitleColor; -} - -- (UIColor *)descriptionColor -{ - if ([self.delegate respondsToSelector:@selector(styleSheetForMessageView:)]) - { - id<TWMessageBarStyleSheet> styleSheet = [self.delegate styleSheetForMessageView:self]; - if ([styleSheet respondsToSelector:@selector(descriptionColorForMessageType:)]) - { - return [styleSheet descriptionColorForMessageType:self.messageType]; - } - } - return kTWMessageViewDescriptionColor; -} - -#pragma mark - Helpers - -- (CGRect)orientFrame:(CGRect)frame -{ - return frame; -} - -#pragma mark - Notifications - -- (void)didChangeDeviceOrientation:(NSNotification *)notification -{ - self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, [self statusBarFrame].size.width, self.frame.size.height); - [self setNeedsDisplay]; -} - -@end - -@implementation TWDefaultMessageBarStyleSheet - -#pragma mark - Alloc/Init - -+ (void)initialize -{ - if (self == [TWDefaultMessageBarStyleSheet class]) - { - // Colors (background) - kTWDefaultMessageBarStyleSheetErrorBackgroundColor = [UIColor colorWithRed:1.0 green:0.611 blue:0.0 alpha:kTWMessageBarStyleSheetMessageBarAlpha]; // orange - kTWDefaultMessageBarStyleSheetSuccessBackgroundColor = [UIColor colorWithRed:0.0f green:0.831f blue:0.176f alpha:kTWMessageBarStyleSheetMessageBarAlpha]; // green - kTWDefaultMessageBarStyleSheetInfoBackgroundColor = [UIColor colorWithRed:0.0 green:0.482 blue:1.0 alpha:kTWMessageBarStyleSheetMessageBarAlpha]; // blue - - // Colors (stroke) - kTWDefaultMessageBarStyleSheetErrorStrokeColor = [UIColor colorWithRed:0.949f green:0.580f blue:0.0f alpha:1.0f]; // orange - kTWDefaultMessageBarStyleSheetSuccessStrokeColor = [UIColor colorWithRed:0.0f green:0.772f blue:0.164f alpha:1.0f]; // green - kTWDefaultMessageBarStyleSheetInfoStrokeColor = [UIColor colorWithRed:0.0f green:0.415f blue:0.803f alpha:1.0f]; // blue - } -} - -+ (TWDefaultMessageBarStyleSheet *)styleSheet -{ - return [[TWDefaultMessageBarStyleSheet alloc] init]; -} - -#pragma mark - TWMessageBarStyleSheet - -- (nonnull UIColor *)backgroundColorForMessageType:(TWMessageBarMessageType)type -{ - UIColor *backgroundColor = nil; - switch (type) - { - case TWMessageBarMessageTypeError: - backgroundColor = kTWDefaultMessageBarStyleSheetErrorBackgroundColor; - break; - case TWMessageBarMessageTypeSuccess: - backgroundColor = kTWDefaultMessageBarStyleSheetSuccessBackgroundColor; - break; - case TWMessageBarMessageTypeInfo: - backgroundColor = kTWDefaultMessageBarStyleSheetInfoBackgroundColor; - break; - } - return backgroundColor; -} - -- (nonnull UIColor *)strokeColorForMessageType:(TWMessageBarMessageType)type -{ - UIColor *strokeColor = nil; - switch (type) - { - case TWMessageBarMessageTypeError: - strokeColor = kTWDefaultMessageBarStyleSheetErrorStrokeColor; - break; - case TWMessageBarMessageTypeSuccess: - strokeColor = kTWDefaultMessageBarStyleSheetSuccessStrokeColor; - break; - case TWMessageBarMessageTypeInfo: - strokeColor = kTWDefaultMessageBarStyleSheetInfoStrokeColor; - break; - } - return strokeColor; -} - -- (nonnull UIImage *)iconImageForMessageType:(TWMessageBarMessageType)type -{ - UIImage *iconImage = nil; - switch (type) - { - case TWMessageBarMessageTypeError: - iconImage = [UIImage imageNamed:kTWMessageBarStyleSheetImageIconError]; - break; - case TWMessageBarMessageTypeSuccess: - iconImage = [UIImage imageNamed:kTWMessageBarStyleSheetImageIconSuccess]; - break; - case TWMessageBarMessageTypeInfo: - iconImage = [UIImage imageNamed:kTWMessageBarStyleSheetImageIconInfo]; - break; - } - return iconImage; -} - -@end - -@implementation TWMessageWindow - -#pragma mark - Touches - -- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event -{ - UIView *hitView = [super hitTest:point withEvent:event]; - - /* - * Pass touches through if they land on the rootViewController's view. - * Allows notification interaction without blocking the window below. - */ - if ([hitView isEqual: self.rootViewController.view]) - { - hitView = nil; - } - - return hitView; -} - -@end - -@implementation UIDevice (Additions) - -#pragma mark - OS Helpers - -- (BOOL)tw_isRunningiOS7OrLater -{ - NSString *systemVersion = self.systemVersion; - NSUInteger systemInt = [systemVersion intValue]; - return systemInt >= kTWMessageViewiOS7Identifier; -} - -@end - -@implementation TWMessageBarViewController - -- (UIInterfaceOrientationMask)supportedInterfaceOrientations -{ - return [TWMessageBarManager sharedInstance].managerSupportedOrientationsMask; -} - -#pragma mark - Setters - -- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle -{ - _statusBarStyle = statusBarStyle; - - if ([[UIDevice currentDevice] tw_isRunningiOS7OrLater]) - { - [self setNeedsStatusBarAppearanceUpdate]; - } -} - -- (void)setStatusBarHidden:(BOOL)statusBarHidden -{ - _statusBarHidden = statusBarHidden; - - if ([[UIDevice currentDevice] tw_isRunningiOS7OrLater]) - { - [self setNeedsStatusBarAppearanceUpdate]; - } -} - -#pragma mark - Status Bar - -- (UIStatusBarStyle)preferredStatusBarStyle -{ - return self.statusBarStyle; -} - -- (BOOL)prefersStatusBarHidden -{ - return self.statusBarHidden; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Graphics/Reader-Button-H.png b/Libraries external/VFR Pdf Reader/Graphics/Reader-Button-H.png Binary files differdeleted file mode 100755 index 855fe7c05..000000000 --- a/Libraries external/VFR Pdf Reader/Graphics/Reader-Button-H.png +++ /dev/null diff --git a/Libraries external/VFR Pdf Reader/Graphics/Reader-Button-H@2x.png b/Libraries external/VFR Pdf Reader/Graphics/Reader-Button-H@2x.png Binary files differdeleted file mode 100755 index 0d212b639..000000000 --- a/Libraries external/VFR Pdf Reader/Graphics/Reader-Button-H@2x.png +++ /dev/null diff --git a/Libraries external/VFR Pdf Reader/Graphics/Reader-Button-N.png b/Libraries external/VFR Pdf Reader/Graphics/Reader-Button-N.png Binary files differdeleted file mode 100755 index cc85f4db9..000000000 --- a/Libraries external/VFR Pdf Reader/Graphics/Reader-Button-N.png +++ /dev/null diff --git a/Libraries external/VFR Pdf Reader/Graphics/Reader-Button-N@2x.png b/Libraries external/VFR Pdf Reader/Graphics/Reader-Button-N@2x.png Binary files differdeleted file mode 100755 index 915771c3c..000000000 --- a/Libraries external/VFR Pdf Reader/Graphics/Reader-Button-N@2x.png +++ /dev/null diff --git a/Libraries external/VFR Pdf Reader/Graphics/Reader-Email.png b/Libraries external/VFR Pdf Reader/Graphics/Reader-Email.png Binary files differdeleted file mode 100755 index 967a9eae8..000000000 --- a/Libraries external/VFR Pdf Reader/Graphics/Reader-Email.png +++ /dev/null diff --git a/Libraries external/VFR Pdf Reader/Graphics/Reader-Email@2x.png b/Libraries external/VFR Pdf Reader/Graphics/Reader-Email@2x.png Binary files differdeleted file mode 100755 index 15c35cd6b..000000000 --- a/Libraries external/VFR Pdf Reader/Graphics/Reader-Email@2x.png +++ /dev/null diff --git a/Libraries external/VFR Pdf Reader/Graphics/Reader-Export.png b/Libraries external/VFR Pdf Reader/Graphics/Reader-Export.png Binary files differdeleted file mode 100755 index 830a3ad7f..000000000 --- a/Libraries external/VFR Pdf Reader/Graphics/Reader-Export.png +++ /dev/null diff --git a/Libraries external/VFR Pdf Reader/Graphics/Reader-Export@2x.png b/Libraries external/VFR Pdf Reader/Graphics/Reader-Export@2x.png Binary files differdeleted file mode 100755 index 32a54b1d4..000000000 --- a/Libraries external/VFR Pdf Reader/Graphics/Reader-Export@2x.png +++ /dev/null diff --git a/Libraries external/VFR Pdf Reader/Graphics/Reader-Mark-N.png b/Libraries external/VFR Pdf Reader/Graphics/Reader-Mark-N.png Binary files differdeleted file mode 100755 index 6482a772d..000000000 --- a/Libraries external/VFR Pdf Reader/Graphics/Reader-Mark-N.png +++ /dev/null diff --git a/Libraries external/VFR Pdf Reader/Graphics/Reader-Mark-N@2x.png b/Libraries external/VFR Pdf Reader/Graphics/Reader-Mark-N@2x.png Binary files differdeleted file mode 100755 index cdc247094..000000000 --- a/Libraries external/VFR Pdf Reader/Graphics/Reader-Mark-N@2x.png +++ /dev/null diff --git a/Libraries external/VFR Pdf Reader/Graphics/Reader-Mark-Y.png b/Libraries external/VFR Pdf Reader/Graphics/Reader-Mark-Y.png Binary files differdeleted file mode 100755 index fbdc11a5e..000000000 --- a/Libraries external/VFR Pdf Reader/Graphics/Reader-Mark-Y.png +++ /dev/null diff --git a/Libraries external/VFR Pdf Reader/Graphics/Reader-Mark-Y@2x.png b/Libraries external/VFR Pdf Reader/Graphics/Reader-Mark-Y@2x.png Binary files differdeleted file mode 100755 index 413e0f42c..000000000 --- a/Libraries external/VFR Pdf Reader/Graphics/Reader-Mark-Y@2x.png +++ /dev/null diff --git a/Libraries external/VFR Pdf Reader/Graphics/Reader-Print.png b/Libraries external/VFR Pdf Reader/Graphics/Reader-Print.png Binary files differdeleted file mode 100755 index 2fab6cb87..000000000 --- a/Libraries external/VFR Pdf Reader/Graphics/Reader-Print.png +++ /dev/null diff --git a/Libraries external/VFR Pdf Reader/Graphics/Reader-Print@2x.png b/Libraries external/VFR Pdf Reader/Graphics/Reader-Print@2x.png Binary files differdeleted file mode 100755 index 72790a8da..000000000 --- a/Libraries external/VFR Pdf Reader/Graphics/Reader-Print@2x.png +++ /dev/null diff --git a/Libraries external/VFR Pdf Reader/Graphics/Reader-Thumbs.png b/Libraries external/VFR Pdf Reader/Graphics/Reader-Thumbs.png Binary files differdeleted file mode 100755 index 7144d3233..000000000 --- a/Libraries external/VFR Pdf Reader/Graphics/Reader-Thumbs.png +++ /dev/null diff --git a/Libraries external/VFR Pdf Reader/Graphics/Reader-Thumbs@2x.png b/Libraries external/VFR Pdf Reader/Graphics/Reader-Thumbs@2x.png Binary files differdeleted file mode 100755 index 8d659b677..000000000 --- a/Libraries external/VFR Pdf Reader/Graphics/Reader-Thumbs@2x.png +++ /dev/null diff --git a/Libraries external/VFR Pdf Reader/Sources/CGPDFDocument.h b/Libraries external/VFR Pdf Reader/Sources/CGPDFDocument.h deleted file mode 100755 index 8c6ad80cb..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/CGPDFDocument.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// CGPDFDocument.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <Foundation/Foundation.h> -#import <QuartzCore/QuartzCore.h> - -// -// Custom CGPDFDocument[...] functions -// - -CGPDFDocumentRef CGPDFDocumentCreateUsingUrl(CFURLRef theURL, NSString *password); - -CGPDFDocumentRef CGPDFDocumentCreateUsingData(CGDataProviderRef dataProvider, NSString *password); - -BOOL CGPDFDocumentUrlNeedsPassword(CFURLRef theURL, NSString *password); - -BOOL CGPDFDocumentDataNeedsPassword(CGDataProviderRef dataProvider, NSString *password); diff --git a/Libraries external/VFR Pdf Reader/Sources/CGPDFDocument.m b/Libraries external/VFR Pdf Reader/Sources/CGPDFDocument.m deleted file mode 100755 index 20c6b63fa..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/CGPDFDocument.m +++ /dev/null @@ -1,242 +0,0 @@ -// -// CGPDFDocument.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "CGPDFDocument.h" - -// -// CGPDFDocumentRef CGPDFDocumentCreateUsingUrl(CFURLRef, NSString *) function -// - -CGPDFDocumentRef CGPDFDocumentCreateUsingUrl(CFURLRef theURL, NSString *password) -{ - CGPDFDocumentRef thePDFDocRef = NULL; // CGPDFDocument - - if (theURL != NULL) // Check for non-NULL CFURLRef - { - thePDFDocRef = CGPDFDocumentCreateWithURL(theURL); - - if (thePDFDocRef != NULL) // Check for non-NULL CGPDFDocumentRef - { - if (CGPDFDocumentIsEncrypted(thePDFDocRef) == TRUE) // Encrypted - { - // Try a blank password first, per Apple's Quartz PDF example - - if (CGPDFDocumentUnlockWithPassword(thePDFDocRef, "") == FALSE) - { - // Nope, now let's try the provided password to unlock the PDF - - if ((password != nil) && (password.length > 0)) // Not blank? - { - char text[128]; // char array buffer for the string conversion - - [password getCString:text maxLength:126 encoding:NSUTF8StringEncoding]; - - if (CGPDFDocumentUnlockWithPassword(thePDFDocRef, text) == FALSE) // Log failure - { - #ifdef DEBUG - NSLog(@"CGPDFDocumentCreateUsingUrl: Unable to unlock [%@] with [%@]", theURL, password); - #endif - } - } - } - - if (CGPDFDocumentIsUnlocked(thePDFDocRef) == FALSE) // Cleanup unlock failure - { - CGPDFDocumentRelease(thePDFDocRef), thePDFDocRef = NULL; - } - } - } - } - else // Log an error diagnostic - { - #ifdef DEBUG - NSLog(@"CGPDFDocumentCreateUsingUrl: theURL == NULL"); - #endif - } - - return thePDFDocRef; -} - -// -// CGPDFDocumentRef CGPDFDocumentCreateUsingData(CGDataProviderRef, NSString *) function -// - -CGPDFDocumentRef CGPDFDocumentCreateUsingData(CGDataProviderRef dataProvider, NSString *password) -{ - CGPDFDocumentRef thePDFDocRef = NULL; // CGPDFDocument - - if (dataProvider != NULL) // Check for non-NULL CGDataProviderRef - { - thePDFDocRef = CGPDFDocumentCreateWithProvider(dataProvider); - - if (thePDFDocRef != NULL) // Check for non-NULL CGPDFDocumentRef - { - if (CGPDFDocumentIsEncrypted(thePDFDocRef) == TRUE) // Encrypted - { - // Try a blank password first, per Apple's Quartz PDF example - - if (CGPDFDocumentUnlockWithPassword(thePDFDocRef, "") == FALSE) - { - // Nope, now let's try the provided password to unlock the PDF - - if ((password != nil) && (password.length > 0)) // Not blank? - { - char text[128]; // char array buffer for the string conversion - - [password getCString:text maxLength:126 encoding:NSUTF8StringEncoding]; - - if (CGPDFDocumentUnlockWithPassword(thePDFDocRef, text) == FALSE) // Log failure - { - #ifdef DEBUG - NSLog(@"CGPDFDocumentCreateUsingData: Unable to unlock data with '%@'", password); - #endif - } - } - } - - if (CGPDFDocumentIsUnlocked(thePDFDocRef) == FALSE) // Cleanup unlock failure - { - CGPDFDocumentRelease(thePDFDocRef), thePDFDocRef = NULL; - } - } - } - } - else // Log an error diagnostic - { - #ifdef DEBUG - NSLog(@"CGPDFDocumentCreateUsingData: theURL == NULL"); - #endif - } - - return thePDFDocRef; -} - -// -// BOOL CGPDFDocumentUrlNeedsPassword(CFURLRef, NSString *) function -// - -BOOL CGPDFDocumentUrlNeedsPassword(CFURLRef theURL, NSString *password) -{ - BOOL needPassword = NO; // Default flag - - if (theURL != NULL) // Check for non-NULL CFURLRef - { - CGPDFDocumentRef thePDFDocRef = CGPDFDocumentCreateWithURL(theURL); - - if (thePDFDocRef != NULL) // Check for non-NULL CGPDFDocumentRef - { - if (CGPDFDocumentIsEncrypted(thePDFDocRef) == TRUE) // Encrypted - { - // Try a blank password first, per Apple's Quartz PDF example - - if (CGPDFDocumentUnlockWithPassword(thePDFDocRef, "") == FALSE) - { - // Nope, now let's try the provided password to unlock the PDF - - if ((password != nil) && (password.length > 0)) // Not blank? - { - char text[128]; // char array buffer for the string conversion - - [password getCString:text maxLength:126 encoding:NSUTF8StringEncoding]; - - if (CGPDFDocumentUnlockWithPassword(thePDFDocRef, text) == FALSE) - { - needPassword = YES; - } - } - else - { - needPassword = YES; - } - } - } - - CGPDFDocumentRelease(thePDFDocRef); // Cleanup CGPDFDocumentRef - } - } - else // Log an error diagnostic - { - #ifdef DEBUG - NSLog(@"CGPDFDocumentUrlNeedsPassword: theURL == NULL"); - #endif - } - - return needPassword; -} - -// -// BOOL CGPDFDocumentUrlNeedsPassword(CGDataProviderRef, NSString *) function -// - -BOOL CGPDFDocumentDataNeedsPassword(CGDataProviderRef dataProvider, NSString *password) -{ - BOOL needPassword = NO; // Default flag - - if (dataProvider != NULL) // Check for non-NULL CGDataProviderRef - { - CGPDFDocumentRef thePDFDocRef = CGPDFDocumentCreateWithProvider(dataProvider); - - if (thePDFDocRef != NULL) // Check for non-NULL CGPDFDocumentRef - { - if (CGPDFDocumentIsEncrypted(thePDFDocRef) == TRUE) // Encrypted - { - // Try a blank password first, per Apple's Quartz PDF example - - if (CGPDFDocumentUnlockWithPassword(thePDFDocRef, "") == FALSE) - { - // Nope, now let's try the provided password to unlock the PDF - - if ((password != nil) && (password.length > 0)) // Not blank? - { - char text[128]; // char array buffer for the string conversion - - [password getCString:text maxLength:126 encoding:NSUTF8StringEncoding]; - - if (CGPDFDocumentUnlockWithPassword(thePDFDocRef, text) == FALSE) - { - needPassword = YES; - } - } - else - { - needPassword = YES; - } - } - } - - CGPDFDocumentRelease(thePDFDocRef); // Cleanup CGPDFDocumentRef - } - } - else // Log an error diagnostic - { - #ifdef DEBUG - NSLog(@"CGPDFDocumentUrlNeedsPassword: theURL == NULL"); - #endif - } - - return needPassword; -} - -// EOF diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderConstants.h b/Libraries external/VFR Pdf Reader/Sources/ReaderConstants.h deleted file mode 100755 index 3d1b06da0..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderConstants.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// ReaderConstants.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#if !__has_feature(objc_arc) - #error ARC (-fobjc-arc) is required to build this code. -#endif - -#import <Foundation/Foundation.h> - -#define READER_FLAT_UI TRUE -#define READER_SHOW_SHADOWS TRUE -#define READER_ENABLE_THUMBS TRUE -#define READER_DISABLE_RETINA FALSE -#define READER_ENABLE_PREVIEW TRUE -#define READER_DISABLE_IDLE FALSE -#define READER_STANDALONE TRUE -#define READER_BOOKMARKS TRUE diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderConstants.m b/Libraries external/VFR Pdf Reader/Sources/ReaderConstants.m deleted file mode 100755 index cb11f9886..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderConstants.m +++ /dev/null @@ -1,28 +0,0 @@ -// -// ReaderConstants.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderConstants.h" - -static NSString *const kReaderCopyrightNotice = @"Reader v2.x.y • Copyright © 2011-2015 Julius Oklamcak. All rights reserved."; diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderContentPage.h b/Libraries external/VFR Pdf Reader/Sources/ReaderContentPage.h deleted file mode 100755 index 92f540801..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderContentPage.h +++ /dev/null @@ -1,50 +0,0 @@ -// -// ReaderContentPage.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -@interface ReaderContentPage : UIView - -- (instancetype)initWithURL:(NSURL *)fileURL page:(NSInteger)page password:(NSString *)phrase; - -- (id)processSingleTap:(UITapGestureRecognizer *)recognizer; - -@end - -#pragma mark - - -// -// ReaderDocumentLink class interface -// - -@interface ReaderDocumentLink : NSObject <NSObject> - -@property (nonatomic, assign, readonly) CGRect rect; - -@property (nonatomic, assign, readonly) CGPDFDictionaryRef dictionary; - -+ (instancetype)newWithRect:(CGRect)linkRect dictionary:(CGPDFDictionaryRef)linkDictionary; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderContentPage.m b/Libraries external/VFR Pdf Reader/Sources/ReaderContentPage.m deleted file mode 100755 index e6902c191..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderContentPage.m +++ /dev/null @@ -1,593 +0,0 @@ -// -// ReaderContentPage.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderConstants.h" -#import "ReaderContentPage.h" -#import "ReaderContentTile.h" -#import "CGPDFDocument.h" - -@implementation ReaderContentPage -{ - NSMutableArray *_links; - - CGPDFDocumentRef _PDFDocRef; - - CGPDFPageRef _PDFPageRef; - - NSInteger _pageAngle; - - CGFloat _pageWidth; - CGFloat _pageHeight; - - CGFloat _pageOffsetX; - CGFloat _pageOffsetY; -} - -#pragma mark - ReaderContentPage class methods - -+ (Class)layerClass -{ - return [ReaderContentTile class]; -} - -#pragma mark - ReaderContentPage PDF link methods - -- (void)highlightPageLinks -{ - if (_links.count > 0) // Add highlight views over all links - { - UIColor *hilite = [UIColor colorWithRed:0.0f green:0.0f blue:1.0f alpha:0.15f]; - - for (ReaderDocumentLink *link in _links) // Enumerate the links array - { - UIView *highlight = [[UIView alloc] initWithFrame:link.rect]; - - highlight.autoresizesSubviews = NO; - highlight.userInteractionEnabled = NO; - highlight.contentMode = UIViewContentModeRedraw; - highlight.autoresizingMask = UIViewAutoresizingNone; - highlight.backgroundColor = hilite; // Color - - [self addSubview:highlight]; - } - } -} - -- (ReaderDocumentLink *)linkFromAnnotation:(CGPDFDictionaryRef)annotationDictionary -{ - ReaderDocumentLink *documentLink = nil; // Document link object - - CGPDFArrayRef annotationRectArray = NULL; // Annotation co-ordinates array - - if (CGPDFDictionaryGetArray(annotationDictionary, "Rect", &annotationRectArray)) - { - CGPDFReal ll_x = 0.0f; CGPDFReal ll_y = 0.0f; // PDFRect lower-left X and Y - CGPDFReal ur_x = 0.0f; CGPDFReal ur_y = 0.0f; // PDFRect upper-right X and Y - - CGPDFArrayGetNumber(annotationRectArray, 0, &ll_x); // Lower-left X co-ordinate - CGPDFArrayGetNumber(annotationRectArray, 1, &ll_y); // Lower-left Y co-ordinate - - CGPDFArrayGetNumber(annotationRectArray, 2, &ur_x); // Upper-right X co-ordinate - CGPDFArrayGetNumber(annotationRectArray, 3, &ur_y); // Upper-right Y co-ordinate - - if (ll_x > ur_x) { CGPDFReal t = ll_x; ll_x = ur_x; ur_x = t; } // Normalize Xs - if (ll_y > ur_y) { CGPDFReal t = ll_y; ll_y = ur_y; ur_y = t; } // Normalize Ys - - ll_x -= _pageOffsetX; ll_y -= _pageOffsetY; // Offset lower-left co-ordinate - ur_x -= _pageOffsetX; ur_y -= _pageOffsetY; // Offset upper-right co-ordinate - - switch (_pageAngle) // Page rotation angle (in degrees) - { - case 90: // 90 degree page rotation - { - CGPDFReal swap; - swap = ll_y; ll_y = ll_x; ll_x = swap; - swap = ur_y; ur_y = ur_x; ur_x = swap; - break; - } - - case 270: // 270 degree page rotation - { - CGPDFReal swap; - swap = ll_y; ll_y = ll_x; ll_x = swap; - swap = ur_y; ur_y = ur_x; ur_x = swap; - ll_x = ((0.0f - ll_x) + _pageWidth); - ur_x = ((0.0f - ur_x) + _pageWidth); - break; - } - - case 0: // 0 degree page rotation - { - ll_y = ((0.0f - ll_y) + _pageHeight); - ur_y = ((0.0f - ur_y) + _pageHeight); - break; - } - } - - NSInteger vr_x = ll_x; NSInteger vr_w = (ur_x - ll_x); // Integer X and width - NSInteger vr_y = ll_y; NSInteger vr_h = (ur_y - ll_y); // Integer Y and height - - CGRect viewRect = CGRectMake(vr_x, vr_y, vr_w, vr_h); // View CGRect from PDFRect - - documentLink = [ReaderDocumentLink newWithRect:viewRect dictionary:annotationDictionary]; - } - - return documentLink; -} - -- (void)buildAnnotationLinksList -{ - _links = [NSMutableArray new]; // Links list array - - CGPDFArrayRef pageAnnotations = NULL; // Page annotations array - - CGPDFDictionaryRef pageDictionary = CGPDFPageGetDictionary(_PDFPageRef); - - if (CGPDFDictionaryGetArray(pageDictionary, "Annots", &pageAnnotations) == true) - { - NSInteger count = CGPDFArrayGetCount(pageAnnotations); // Number of annotations - - for (NSInteger index = 0; index < count; index++) // Iterate through all annotations - { - CGPDFDictionaryRef annotationDictionary = NULL; // PDF annotation dictionary - - if (CGPDFArrayGetDictionary(pageAnnotations, index, &annotationDictionary) == true) - { - const char *annotationSubtype = NULL; // PDF annotation subtype string - - if (CGPDFDictionaryGetName(annotationDictionary, "Subtype", &annotationSubtype) == true) - { - if (strcmp(annotationSubtype, "Link") == 0) // Found annotation subtype of 'Link' - { - ReaderDocumentLink *documentLink = [self linkFromAnnotation:annotationDictionary]; - - if (documentLink != nil) [_links insertObject:documentLink atIndex:0]; // Add link - } - } - } - } - - //[self highlightPageLinks]; // Link support debugging - } -} - -- (CGPDFArrayRef)destinationWithName:(const char *)destinationName inDestsTree:(CGPDFDictionaryRef)node -{ - CGPDFArrayRef destinationArray = NULL; - - CGPDFArrayRef limitsArray = NULL; // Limits array - - if (CGPDFDictionaryGetArray(node, "Limits", &limitsArray) == true) - { - CGPDFStringRef lowerLimit = NULL; CGPDFStringRef upperLimit = NULL; - - if (CGPDFArrayGetString(limitsArray, 0, &lowerLimit) == true) // Lower limit - { - if (CGPDFArrayGetString(limitsArray, 1, &upperLimit) == true) // Upper limit - { - const char *ll = (const char *)CGPDFStringGetBytePtr(lowerLimit); // Lower string - const char *ul = (const char *)CGPDFStringGetBytePtr(upperLimit); // Upper string - - if ((strcmp(destinationName, ll) < 0) || (strcmp(destinationName, ul) > 0)) - { - return NULL; // Destination name is outside this node's limits - } - } - } - } - - CGPDFArrayRef namesArray = NULL; // Names array - - if (CGPDFDictionaryGetArray(node, "Names", &namesArray) == true) - { - NSInteger namesCount = CGPDFArrayGetCount(namesArray); - - for (NSInteger index = 0; index < namesCount; index += 2) - { - CGPDFStringRef destName; // Destination name string - - if (CGPDFArrayGetString(namesArray, index, &destName) == true) - { - const char *dn = (const char *)CGPDFStringGetBytePtr(destName); - - if (strcmp(dn, destinationName) == 0) // Found the destination name - { - if (CGPDFArrayGetArray(namesArray, (index + 1), &destinationArray) == false) - { - CGPDFDictionaryRef destinationDictionary = NULL; // Destination dictionary - - if (CGPDFArrayGetDictionary(namesArray, (index + 1), &destinationDictionary) == true) - { - CGPDFDictionaryGetArray(destinationDictionary, "D", &destinationArray); - } - } - - return destinationArray; // Return the destination array - } - } - } - } - - CGPDFArrayRef kidsArray = NULL; // Kids array - - if (CGPDFDictionaryGetArray(node, "Kids", &kidsArray) == true) - { - NSInteger kidsCount = CGPDFArrayGetCount(kidsArray); - - for (NSInteger index = 0; index < kidsCount; index++) - { - CGPDFDictionaryRef kidNode = NULL; // Kid node dictionary - - if (CGPDFArrayGetDictionary(kidsArray, index, &kidNode) == true) // Recurse into node - { - destinationArray = [self destinationWithName:destinationName inDestsTree:kidNode]; - - if (destinationArray != NULL) return destinationArray; // Return destination array - } - } - } - - return NULL; -} - -- (id)annotationLinkTarget:(CGPDFDictionaryRef)annotationDictionary -{ - id linkTarget = nil; // Link target object - - CGPDFStringRef destName = NULL; const char *destString = NULL; - - CGPDFDictionaryRef actionDictionary = NULL; CGPDFArrayRef destArray = NULL; - - if (CGPDFDictionaryGetDictionary(annotationDictionary, "A", &actionDictionary) == true) - { - const char *actionType = NULL; // Annotation action type string - - if (CGPDFDictionaryGetName(actionDictionary, "S", &actionType) == true) - { - if (strcmp(actionType, "GoTo") == 0) // GoTo action type - { - if (CGPDFDictionaryGetArray(actionDictionary, "D", &destArray) == false) - { - CGPDFDictionaryGetString(actionDictionary, "D", &destName); - } - } - else // Handle other link action type possibility - { - if (strcmp(actionType, "URI") == 0) // URI action type - { - CGPDFStringRef uriString = NULL; // Action's URI string - - if (CGPDFDictionaryGetString(actionDictionary, "URI", &uriString) == true) - { - const char *uri = (const char *)CGPDFStringGetBytePtr(uriString); // Destination URI string - - NSString *target = [NSString stringWithCString:uri encoding:NSUTF8StringEncoding]; // NSString - UTF8 - - linkTarget = [NSURL URLWithString:[target stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; - - if (linkTarget == nil) NSLog(@"%s Bad URI '%@'", __FUNCTION__, target); - } - } - } - } - } - else // Handle other link target possibilities - { - if (CGPDFDictionaryGetArray(annotationDictionary, "Dest", &destArray) == false) - { - if (CGPDFDictionaryGetString(annotationDictionary, "Dest", &destName) == false) - { - CGPDFDictionaryGetName(annotationDictionary, "Dest", &destString); - } - } - } - - if (destName != NULL) // Handle a destination name - { - CGPDFDictionaryRef catalogDictionary = CGPDFDocumentGetCatalog(_PDFDocRef); - - CGPDFDictionaryRef namesDictionary = NULL; // Destination names in the document - - if (CGPDFDictionaryGetDictionary(catalogDictionary, "Names", &namesDictionary) == true) - { - CGPDFDictionaryRef destsDictionary = NULL; // Document destinations dictionary - - if (CGPDFDictionaryGetDictionary(namesDictionary, "Dests", &destsDictionary) == true) - { - const char *destinationName = (const char *)CGPDFStringGetBytePtr(destName); // Name - - destArray = [self destinationWithName:destinationName inDestsTree:destsDictionary]; - } - } - } - - if (destString != NULL) // Handle a destination string - { - CGPDFDictionaryRef catalogDictionary = CGPDFDocumentGetCatalog(_PDFDocRef); - - CGPDFDictionaryRef destsDictionary = NULL; // Document destinations dictionary - - if (CGPDFDictionaryGetDictionary(catalogDictionary, "Dests", &destsDictionary) == true) - { - CGPDFDictionaryRef targetDictionary = NULL; // Destination target dictionary - - if (CGPDFDictionaryGetDictionary(destsDictionary, destString, &targetDictionary) == true) - { - CGPDFDictionaryGetArray(targetDictionary, "D", &destArray); - } - } - } - - if (destArray != NULL) // Handle a destination array - { - NSInteger targetPageNumber = 0; // The target page number - - CGPDFDictionaryRef pageDictionaryFromDestArray = NULL; // Target reference - - if (CGPDFArrayGetDictionary(destArray, 0, &pageDictionaryFromDestArray) == true) - { - NSInteger pageCount = CGPDFDocumentGetNumberOfPages(_PDFDocRef); // Pages - - for (NSInteger pageNumber = 1; pageNumber <= pageCount; pageNumber++) - { - CGPDFPageRef pageRef = CGPDFDocumentGetPage(_PDFDocRef, pageNumber); - - CGPDFDictionaryRef pageDictionaryFromPage = CGPDFPageGetDictionary(pageRef); - - if (pageDictionaryFromPage == pageDictionaryFromDestArray) // Found it - { - targetPageNumber = pageNumber; break; - } - } - } - else // Try page number from array possibility - { - CGPDFInteger pageNumber = 0; // Page number in array - - if (CGPDFArrayGetInteger(destArray, 0, &pageNumber) == true) - { - targetPageNumber = (pageNumber + 1); // 1-based - } - } - - if (targetPageNumber > 0) // We have a target page number - { - linkTarget = [NSNumber numberWithInteger:targetPageNumber]; - } - } - - return linkTarget; -} - -- (id)processSingleTap:(UITapGestureRecognizer *)recognizer -{ - id result = nil; // Tap result object - - if (recognizer.state == UIGestureRecognizerStateRecognized) - { - if (_links.count > 0) // Process the single tap - { - CGPoint point = [recognizer locationInView:self]; - - for (ReaderDocumentLink *link in _links) // Enumerate links - { - if (CGRectContainsPoint(link.rect, point) == true) // Found it - { - result = [self annotationLinkTarget:link.dictionary]; break; - } - } - } - } - - return result; -} - -#pragma mark - ReaderContentPage instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) - { - self.autoresizesSubviews = NO; - self.userInteractionEnabled = NO; - self.contentMode = UIViewContentModeRedraw; - self.autoresizingMask = UIViewAutoresizingNone; - self.backgroundColor = [UIColor clearColor]; - } - - return self; -} - -- (instancetype)initWithURL:(NSURL *)fileURL page:(NSInteger)page password:(NSString *)phrase -{ - CGRect viewRect = CGRectZero; // View rect - - if (fileURL != nil) // Check for non-nil file URL - { - _PDFDocRef = CGPDFDocumentCreateUsingUrl((__bridge CFURLRef)fileURL, phrase); - - if (_PDFDocRef != NULL) // Check for non-NULL CGPDFDocumentRef - { - if (page < 1) page = 1; // Check the lower page bounds - - NSInteger pages = CGPDFDocumentGetNumberOfPages(_PDFDocRef); - - if (page > pages) page = pages; // Check the upper page bounds - - _PDFPageRef = CGPDFDocumentGetPage(_PDFDocRef, page); // Get page - - if (_PDFPageRef != NULL) // Check for non-NULL CGPDFPageRef - { - CGPDFPageRetain(_PDFPageRef); // Retain the PDF page - - CGRect cropBoxRect = CGPDFPageGetBoxRect(_PDFPageRef, kCGPDFCropBox); - CGRect mediaBoxRect = CGPDFPageGetBoxRect(_PDFPageRef, kCGPDFMediaBox); - CGRect effectiveRect = CGRectIntersection(cropBoxRect, mediaBoxRect); - - _pageAngle = CGPDFPageGetRotationAngle(_PDFPageRef); // Angle - - switch (_pageAngle) // Page rotation angle (in degrees) - { - default: // Default case - case 0: case 180: // 0 and 180 degrees - { - _pageWidth = effectiveRect.size.width; - _pageHeight = effectiveRect.size.height; - _pageOffsetX = effectiveRect.origin.x; - _pageOffsetY = effectiveRect.origin.y; - break; - } - - case 90: case 270: // 90 and 270 degrees - { - _pageWidth = effectiveRect.size.height; - _pageHeight = effectiveRect.size.width; - _pageOffsetX = effectiveRect.origin.y; - _pageOffsetY = effectiveRect.origin.x; - break; - } - } - - NSInteger page_w = _pageWidth; // Integer width - NSInteger page_h = _pageHeight; // Integer height - - if (page_w % 2) page_w--; if (page_h % 2) page_h--; // Even - - viewRect.size = CGSizeMake(page_w, page_h); // View size - } - else // Error out with a diagnostic - { - CGPDFDocumentRelease(_PDFDocRef), _PDFDocRef = NULL; - - NSAssert(NO, @"CGPDFPageRef == NULL"); - } - } - else // Error out with a diagnostic - { - NSAssert(NO, @"CGPDFDocumentRef == NULL"); - } - } - else // Error out with a diagnostic - { - NSAssert(NO, @"fileURL == nil"); - } - - ReaderContentPage *view = [self initWithFrame:viewRect]; - - if (view != nil) [self buildAnnotationLinksList]; - - return view; -} - -- (void)removeFromSuperview -{ - self.layer.delegate = nil; - - //self.layer.contents = nil; - - [super removeFromSuperview]; -} - -- (void)dealloc -{ - CGPDFPageRelease(_PDFPageRef), _PDFPageRef = NULL; - - CGPDFDocumentRelease(_PDFDocRef), _PDFDocRef = NULL; -} - -#if (READER_DISABLE_RETINA == TRUE) // Option - -- (void)didMoveToWindow -{ - self.contentScaleFactor = 1.0f; // Override scale factor -} - -#endif // end of READER_DISABLE_RETINA Option - -#pragma mark - CATiledLayer delegate methods - -- (void)drawLayer:(CATiledLayer *)layer inContext:(CGContextRef)context -{ - ReaderContentPage *readerContentPage = self; // Retain self - - CGContextSetRGBFillColor(context, 1.0f, 1.0f, 1.0f, 1.0f); // White - - CGContextFillRect(context, CGContextGetClipBoundingBox(context)); // Fill - - //NSLog(@"%s %@", __FUNCTION__, NSStringFromCGRect(CGContextGetClipBoundingBox(context))); - - CGContextTranslateCTM(context, 0.0f, self.bounds.size.height); CGContextScaleCTM(context, 1.0f, -1.0f); - - CGContextConcatCTM(context, CGPDFPageGetDrawingTransform(_PDFPageRef, kCGPDFCropBox, self.bounds, 0, true)); - - //CGContextSetRenderingIntent(context, kCGRenderingIntentDefault); CGContextSetInterpolationQuality(context, kCGInterpolationDefault); - - CGContextDrawPDFPage(context, _PDFPageRef); // Render the PDF page into the context - - if (readerContentPage != nil) readerContentPage = nil; // Release self -} - -@end - -#pragma mark - - -// -// ReaderDocumentLink class implementation -// - -@implementation ReaderDocumentLink -{ - CGPDFDictionaryRef _dictionary; - - CGRect _rect; -} - -#pragma mark - Properties - -@synthesize rect = _rect; -@synthesize dictionary = _dictionary; - -#pragma mark - ReaderDocumentLink class methods - -+ (instancetype)newWithRect:(CGRect)linkRect dictionary:(CGPDFDictionaryRef)linkDictionary -{ - return [[ReaderDocumentLink alloc] initWithRect:linkRect dictionary:linkDictionary]; -} - -#pragma mark - ReaderDocumentLink instance methods - -- (instancetype)initWithRect:(CGRect)linkRect dictionary:(CGPDFDictionaryRef)linkDictionary -{ - if ((self = [super init])) - { - _dictionary = linkDictionary; - - _rect = linkRect; - } - - return self; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderContentTile.h b/Libraries external/VFR Pdf Reader/Sources/ReaderContentTile.h deleted file mode 100755 index 6c8ba808d..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderContentTile.h +++ /dev/null @@ -1,31 +0,0 @@ -// -// ReaderContentTile.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> -#import <QuartzCore/QuartzCore.h> - -@interface ReaderContentTile : CATiledLayer - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderContentTile.m b/Libraries external/VFR Pdf Reader/Sources/ReaderContentTile.m deleted file mode 100755 index b80132357..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderContentTile.m +++ /dev/null @@ -1,71 +0,0 @@ -// -// ReaderContentTile.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderContentTile.h" - -@implementation ReaderContentTile - -#pragma mark - Constants - -#define LEVELS_OF_DETAIL 16 - -#pragma mark - ReaderContentTile class methods - -+ (CFTimeInterval)fadeDuration -{ - return 0.001; // iOS bug (flickering tiles) workaround -} - -#pragma mark - ReaderContentTile instance methods - -- (instancetype)init -{ - if ((self = [super init])) // Initialize superclass - { - self.levelsOfDetail = LEVELS_OF_DETAIL; // Zoom levels - - self.levelsOfDetailBias = (LEVELS_OF_DETAIL - 1); // Bias - - UIScreen *mainScreen = [UIScreen mainScreen]; // Main screen - - CGFloat screenScale = [mainScreen scale]; // Main screen scale - - CGRect screenBounds = [mainScreen bounds]; // Main screen bounds - - CGFloat w_pixels = (screenBounds.size.width * screenScale); - - CGFloat h_pixels = (screenBounds.size.height * screenScale); - - CGFloat max = ((w_pixels < h_pixels) ? h_pixels : w_pixels); - - CGFloat sizeOfTiles = ((max < 512.0f) ? 512.0f : 1024.0f); - - self.tileSize = CGSizeMake(sizeOfTiles, sizeOfTiles); - } - - return self; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderContentView.h b/Libraries external/VFR Pdf Reader/Sources/ReaderContentView.h deleted file mode 100755 index 1738309c4..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderContentView.h +++ /dev/null @@ -1,66 +0,0 @@ -// -// ReaderContentView.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -#import "ReaderThumbView.h" - -@class ReaderContentView; -@class ReaderContentPage; -@class ReaderContentThumb; - -@protocol ReaderContentViewDelegate <NSObject> - -@required // Delegate protocols - -- (void)contentView:(ReaderContentView *)contentView touchesBegan:(NSSet *)touches; - -@end - -@interface ReaderContentView : UIScrollView - -@property (nonatomic, weak, readwrite) id <ReaderContentViewDelegate> message; - -- (instancetype)initWithFrame:(CGRect)frame fileURL:(NSURL *)fileURL page:(NSUInteger)page password:(NSString *)phrase; - -- (void)showPageThumb:(NSURL *)fileURL page:(NSInteger)page password:(NSString *)phrase guid:(NSString *)guid; - -- (id)processSingleTap:(UITapGestureRecognizer *)recognizer; - -- (void)zoomIncrement:(UITapGestureRecognizer *)recognizer; -- (void)zoomDecrement:(UITapGestureRecognizer *)recognizer; -- (void)zoomResetAnimated:(BOOL)animated; - -@end - -#pragma mark - - -// -// ReaderContentThumb class interface -// - -@interface ReaderContentThumb : ReaderThumbView - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderContentView.m b/Libraries external/VFR Pdf Reader/Sources/ReaderContentView.m deleted file mode 100755 index f6ab8421d..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderContentView.m +++ /dev/null @@ -1,402 +0,0 @@ -// -// ReaderContentView.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderConstants.h" -#import "ReaderContentView.h" -#import "ReaderContentPage.h" -#import "ReaderThumbCache.h" - -#import <QuartzCore/QuartzCore.h> - -@interface ReaderContentView () <UIScrollViewDelegate> - -@end - -@implementation ReaderContentView -{ - UIView *theContainerView; - - UIUserInterfaceIdiom userInterfaceIdiom; - - ReaderContentPage *theContentPage; - - ReaderContentThumb *theThumbView; - - CGFloat realMaximumZoom; - CGFloat tempMaximumZoom; - - BOOL zoomBounced; -} - -#pragma mark - Constants - -#define ZOOM_FACTOR 2.0f -#define ZOOM_MAXIMUM 16.0f - -#define PAGE_THUMB_LARGE 240 -#define PAGE_THUMB_SMALL 144 - -static void *ReaderContentViewContext = &ReaderContentViewContext; - -static CGFloat g_BugFixWidthInset = 0.0f; - -#pragma mark - Properties - -@synthesize message; - -#pragma mark - ReaderContentView functions - -static inline CGFloat zoomScaleThatFits(CGSize target, CGSize source) -{ - CGFloat w_scale = (target.width / (source.width + g_BugFixWidthInset)); - - CGFloat h_scale = (target.height / source.height); - - return ((w_scale < h_scale) ? w_scale : h_scale); -} - -#pragma mark - ReaderContentView class methods - -+ (void)initialize -{ - if (self == [ReaderContentView self]) // Do once - iOS 8.0 UIScrollView bug workaround - { - if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) // Not iPads - { - NSString *iosVersion = [UIDevice currentDevice].systemVersion; // iOS version as a string - - if ([@"8.0" compare:iosVersion options:NSNumericSearch] != NSOrderedDescending) // 8.0 and up - { - if ([@"8.2" compare:iosVersion options:NSNumericSearch] == NSOrderedDescending) // Below 8.2 - { - g_BugFixWidthInset = 2.0f * [[UIScreen mainScreen] scale]; // Reduce width of content view - } - } - } - } -} - -#pragma mark - ReaderContentView instance methods - -- (void)updateMinimumMaximumZoom -{ - CGFloat zoomScale = zoomScaleThatFits(self.bounds.size, theContentPage.bounds.size); - - self.minimumZoomScale = zoomScale; self.maximumZoomScale = (zoomScale * ZOOM_MAXIMUM); - - realMaximumZoom = self.maximumZoomScale; tempMaximumZoom = (realMaximumZoom * ZOOM_FACTOR); -} - -- (void)centerScrollViewContent -{ - CGFloat iw = 0.0f; CGFloat ih = 0.0f; // Content width and height insets - - CGSize boundsSize = self.bounds.size; CGSize contentSize = self.contentSize; // Sizes - - if (contentSize.width < boundsSize.width) iw = ((boundsSize.width - contentSize.width) * 0.5f); - - if (contentSize.height < boundsSize.height) ih = ((boundsSize.height - contentSize.height) * 0.5f); - - UIEdgeInsets insets = UIEdgeInsetsMake(ih, iw, ih, iw); // Create (possibly updated) content insets - - if (UIEdgeInsetsEqualToEdgeInsets(self.contentInset, insets) == false) self.contentInset = insets; -} - -- (instancetype)initWithFrame:(CGRect)frame fileURL:(NSURL *)fileURL page:(NSUInteger)page password:(NSString *)phrase -{ - if ((self = [super initWithFrame:frame])) - { - self.scrollsToTop = NO; - self.delaysContentTouches = NO; - self.showsVerticalScrollIndicator = NO; - self.showsHorizontalScrollIndicator = NO; - self.contentMode = UIViewContentModeRedraw; - self.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); - self.backgroundColor = [UIColor clearColor]; - self.autoresizesSubviews = NO; - self.clipsToBounds = NO; - self.delegate = self; - - userInterfaceIdiom = [UIDevice currentDevice].userInterfaceIdiom; // User interface idiom - - theContentPage = [[ReaderContentPage alloc] initWithURL:fileURL page:page password:phrase]; - - if (theContentPage != nil) // Must have a valid and initialized content page - { - theContainerView = [[UIView alloc] initWithFrame:theContentPage.bounds]; - - theContainerView.autoresizesSubviews = NO; - theContainerView.userInteractionEnabled = NO; - theContainerView.contentMode = UIViewContentModeRedraw; - theContainerView.autoresizingMask = UIViewAutoresizingNone; - theContainerView.backgroundColor = [UIColor whiteColor]; - -#if (READER_SHOW_SHADOWS == TRUE) // Option - - theContainerView.layer.shadowOffset = CGSizeMake(0.0f, 0.0f); - theContainerView.layer.shadowRadius = 4.0f; theContainerView.layer.shadowOpacity = 1.0f; - theContainerView.layer.shadowPath = [UIBezierPath bezierPathWithRect:theContainerView.bounds].CGPath; - -#endif // end of READER_SHOW_SHADOWS Option - - self.contentSize = theContentPage.bounds.size; [self centerScrollViewContent]; - -#if (READER_ENABLE_PREVIEW == TRUE) // Option - - theThumbView = [[ReaderContentThumb alloc] initWithFrame:theContentPage.bounds]; // Page thumb view - - [theContainerView addSubview:theThumbView]; // Add the page thumb view to the container view - -#endif // end of READER_ENABLE_PREVIEW Option - - [theContainerView addSubview:theContentPage]; // Add the content page to the container view - - [self addSubview:theContainerView]; // Add the container view to the scroll view - - [self updateMinimumMaximumZoom]; // Update the minimum and maximum zoom scales - - self.zoomScale = self.minimumZoomScale; // Set the zoom scale to fit page content - - [self addObserver:self forKeyPath:@"frame" options:0 context:ReaderContentViewContext]; - } - - self.tag = page; // Tag the view with the page number - } - - return self; -} - -- (void)dealloc -{ - [self removeObserver:self forKeyPath:@"frame" context:ReaderContentViewContext]; -} - -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context -{ - if (context == ReaderContentViewContext) // Our context - { - if ((object == self) && [keyPath isEqualToString:@"frame"]) - { - [self centerScrollViewContent]; // Center content - - CGFloat oldMinimumZoomScale = self.minimumZoomScale; - - [self updateMinimumMaximumZoom]; // Update zoom scale limits - - if (self.zoomScale == oldMinimumZoomScale) // Old minimum - { - self.zoomScale = self.minimumZoomScale; - } - else // Check against minimum zoom scale - { - if (self.zoomScale < self.minimumZoomScale) - { - self.zoomScale = self.minimumZoomScale; - } - else // Check against maximum zoom scale - { - if (self.zoomScale > self.maximumZoomScale) - { - self.zoomScale = self.maximumZoomScale; - } - } - } - } - } -} - -- (void)showPageThumb:(NSURL *)fileURL page:(NSInteger)page password:(NSString *)phrase guid:(NSString *)guid -{ -#if (READER_ENABLE_PREVIEW == TRUE) // Option - - CGSize size = ((userInterfaceIdiom == UIUserInterfaceIdiomPad) ? CGSizeMake(PAGE_THUMB_LARGE, PAGE_THUMB_LARGE) : CGSizeMake(PAGE_THUMB_SMALL, PAGE_THUMB_SMALL)); - - ReaderThumbRequest *request = [ReaderThumbRequest newForView:theThumbView fileURL:fileURL password:phrase guid:guid page:page size:size]; - - UIImage *image = [[ReaderThumbCache sharedInstance] thumbRequest:request priority:YES]; // Request the page thumb - - if ([image isKindOfClass:[UIImage class]]) [theThumbView showImage:image]; // Show image from cache - -#endif // end of READER_ENABLE_PREVIEW Option -} - -- (id)processSingleTap:(UITapGestureRecognizer *)recognizer -{ - return [theContentPage processSingleTap:recognizer]; -} - -- (CGRect)zoomRectForScale:(CGFloat)scale withCenter:(CGPoint)center -{ - CGRect zoomRect; // Centered zoom rect - - zoomRect.size.width = (self.bounds.size.width / scale); - zoomRect.size.height = (self.bounds.size.height / scale); - - zoomRect.origin.x = (center.x - (zoomRect.size.width * 0.5f)); - zoomRect.origin.y = (center.y - (zoomRect.size.height * 0.5f)); - - return zoomRect; -} - -- (void)zoomIncrement:(UITapGestureRecognizer *)recognizer -{ - CGFloat zoomScale = self.zoomScale; // Current zoom - - CGPoint point = [recognizer locationInView:theContentPage]; - - if (zoomScale < self.maximumZoomScale) // Zoom in - { - zoomScale *= ZOOM_FACTOR; // Zoom in by zoom factor amount - - if (zoomScale > self.maximumZoomScale) zoomScale = self.maximumZoomScale; - - CGRect zoomRect = [self zoomRectForScale:zoomScale withCenter:point]; - - [self zoomToRect:zoomRect animated:YES]; - } - else // Handle fully zoomed in - { - if (zoomBounced == NO) // Zoom bounce - { - self.maximumZoomScale = tempMaximumZoom; - - [self setZoomScale:tempMaximumZoom animated:YES]; - } - else // Zoom all the way out - { - zoomScale = self.minimumZoomScale; - - [self setZoomScale:zoomScale animated:YES]; - } - } -} - -- (void)zoomDecrement:(UITapGestureRecognizer *)recognizer -{ - CGFloat zoomScale = self.zoomScale; // Current zoom - - CGPoint point = [recognizer locationInView:theContentPage]; - - if (zoomScale > self.minimumZoomScale) // Zoom out - { - zoomScale /= ZOOM_FACTOR; // Zoom out by zoom factor amount - - if (zoomScale < self.minimumZoomScale) zoomScale = self.minimumZoomScale; - - CGRect zoomRect = [self zoomRectForScale:zoomScale withCenter:point]; - - [self zoomToRect:zoomRect animated:YES]; - } - else // Handle fully zoomed out - { - zoomScale = self.maximumZoomScale; // Full zoom in - - CGRect zoomRect = [self zoomRectForScale:zoomScale withCenter:point]; - - [self zoomToRect:zoomRect animated:YES]; - } -} - -- (void)zoomResetAnimated:(BOOL)animated -{ - if (self.zoomScale > self.minimumZoomScale) // Reset zoom - { - if (animated) [self setZoomScale:self.minimumZoomScale animated:YES]; else self.zoomScale = self.minimumZoomScale; zoomBounced = NO; - } -} - -#pragma mark - UIScrollViewDelegate methods - -- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView -{ - return theContainerView; -} - -- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale -{ - if (self.zoomScale > realMaximumZoom) // Bounce back to real maximum zoom scale - { - [self setZoomScale:realMaximumZoom animated:YES]; self.maximumZoomScale = realMaximumZoom; zoomBounced = YES; - } - else // Normal scroll view did end zooming - { - if (self.zoomScale < realMaximumZoom) zoomBounced = NO; - } -} - -- (void)scrollViewDidZoom:(UIScrollView *)scrollView -{ - [self centerScrollViewContent]; // Center content -} - -#pragma mark - UIResponder instance methods - -- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event -{ - [super touchesBegan:touches withEvent:event]; // Message superclass - - [message contentView:self touchesBegan:touches]; // Message delegate -} - -- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event -{ - [super touchesCancelled:touches withEvent:event]; // Message superclass -} - -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event -{ - [super touchesEnded:touches withEvent:event]; // Message superclass -} - -- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event -{ - [super touchesMoved:touches withEvent:event]; // Message superclass -} - -@end - -#pragma mark - - -// -// ReaderContentThumb class implementation -// - -@implementation ReaderContentThumb - -#pragma mark - ReaderContentThumb instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) // Superclass init - { - imageView.contentMode = UIViewContentModeScaleAspectFill; - - imageView.clipsToBounds = YES; // Needed for aspect fill - } - - return self; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderDocument.h b/Libraries external/VFR Pdf Reader/Sources/ReaderDocument.h deleted file mode 100755 index a144e745b..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderDocument.h +++ /dev/null @@ -1,55 +0,0 @@ -// -// ReaderDocument.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <Foundation/Foundation.h> - -@interface ReaderDocument : NSObject <NSObject, NSCoding> - -@property (nonatomic, strong, readonly) NSString *guid; -@property (nonatomic, strong, readonly) NSDate *fileDate; -@property (nonatomic, strong, readwrite) NSDate *lastOpen; -@property (nonatomic, strong, readonly) NSNumber *fileSize; -@property (nonatomic, strong, readonly) NSNumber *pageCount; -@property (nonatomic, strong, readwrite) NSNumber *pageNumber; -@property (nonatomic, strong, readonly) NSMutableIndexSet *bookmarks; -@property (nonatomic, strong, readonly) NSString *password; -@property (nonatomic, strong, readonly) NSString *fileName; -@property (nonatomic, strong, readonly) NSURL *fileURL; - -@property (nonatomic, readonly) BOOL canEmail; -@property (nonatomic, readonly) BOOL canExport; -@property (nonatomic, readonly) BOOL canPrint; - -+ (ReaderDocument *)withDocumentFilePath:(NSString *)filePath password:(NSString *)phrase; - -+ (ReaderDocument *)unarchiveFromFileName:(NSString *)filePath password:(NSString *)phrase; - -- (instancetype)initWithFilePath:(NSString *)filePath password:(NSString *)phrase; - -- (BOOL)archiveDocumentProperties; - -- (void)updateDocumentProperties; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderDocument.m b/Libraries external/VFR Pdf Reader/Sources/ReaderDocument.m deleted file mode 100755 index ea54b04d0..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderDocument.m +++ /dev/null @@ -1,354 +0,0 @@ -// -// ReaderDocument.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderDocument.h" -#import "CGPDFDocument.h" -#import <fcntl.h> - -@interface ReaderDocument () - -@property (nonatomic, strong, readwrite) NSString *password; -@property (nonatomic, strong, readwrite) NSString *filePath; - -@end - -@implementation ReaderDocument -{ - NSString *_guid; - - NSDate *_fileDate; - - NSDate *_lastOpen; - - NSNumber *_fileSize; - - NSNumber *_pageCount; - - NSNumber *_pageNumber; - - NSMutableIndexSet *_bookmarks; - - NSString *_password; - - NSString *_fileName; - - NSString *_filePath; - - NSURL *_fileURL; -} - -#pragma mark - Properties - -@synthesize guid = _guid; -@synthesize fileDate = _fileDate; -@synthesize lastOpen = _lastOpen; -@synthesize fileSize = _fileSize; -@synthesize pageCount = _pageCount; -@synthesize pageNumber = _pageNumber; -@synthesize bookmarks = _bookmarks; -@synthesize password = _password; -@synthesize filePath = _filePath; -@dynamic fileName, fileURL; -@dynamic canEmail, canExport, canPrint; - -#pragma mark - ReaderDocument class methods - -+ (NSString *)GUID -{ - CFUUIDRef theUUID = CFUUIDCreate(NULL); - - CFStringRef theString = CFUUIDCreateString(NULL, theUUID); - - NSString *unique = [NSString stringWithString:(__bridge id)theString]; - - CFRelease(theString); CFRelease(theUUID); // Cleanup CF objects - - return unique; -} - -+ (NSString *)documentsPath -{ - NSFileManager *fileManager = [NSFileManager defaultManager]; // Singleton - - NSURL *pathURL = [fileManager URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL]; - - return [pathURL path]; // Path to the application's "~/Documents" directory -} - -+ (NSString *)applicationSupportPath -{ - NSFileManager *fileManager = [NSFileManager defaultManager]; // Singleton - - NSURL *pathURL = [fileManager URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL]; - - return [pathURL path]; // Path to the application's "~/Library/Application Support" directory -} - -+ (NSString *)archiveFilePath:(NSString *)fileName -{ - NSFileManager *fileManager = [NSFileManager defaultManager]; // Singleton - - NSString *applicationSupportPath = [ReaderDocument applicationSupportPath]; // See above - - NSString *archivePath = [applicationSupportPath stringByAppendingPathComponent:@"Reader Metadata"]; - - [fileManager createDirectoryAtPath:archivePath withIntermediateDirectories:NO attributes:nil error:NULL]; - - NSString *archiveName = [[fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"plist"]; - - return [archivePath stringByAppendingPathComponent:archiveName]; // "{archivePath}/'fileName'.plist" -} - -+ (ReaderDocument *)unarchiveFromFileName:(NSString *)filePath password:(NSString *)phrase -{ - ReaderDocument *document = nil; // ReaderDocument object - - NSString *fileName = [filePath lastPathComponent]; // File name only - - NSString *archiveFilePath = [ReaderDocument archiveFilePath:fileName]; - - @try // Unarchive an archived ReaderDocument object from its property list - { - document = [NSKeyedUnarchiver unarchiveObjectWithFile:archiveFilePath]; - - if (document != nil) // Set the document's file path and password properties - { - document.filePath = [filePath copy]; document.password = [phrase copy]; - } - } - @catch (NSException *exception) // Exception handling (just in case O_o) - { - #ifdef DEBUG - NSLog(@"%s Caught %@: %@", __FUNCTION__, [exception name], [exception reason]); - #endif - } - - return document; -} - -+ (ReaderDocument *)withDocumentFilePath:(NSString *)filePath password:(NSString *)phrase -{ - ReaderDocument *document = nil; // ReaderDocument object - - document = [ReaderDocument unarchiveFromFileName:filePath password:phrase]; - - if (document == nil) // Unarchive failed so create a new ReaderDocument object - { - document = [[ReaderDocument alloc] initWithFilePath:filePath password:phrase]; - } - - return document; -} - -+ (BOOL)isPDF:(NSString *)filePath -{ - BOOL state = NO; - - if (filePath != nil) // Must have a file path - { - const char *path = [filePath fileSystemRepresentation]; - - int fd = open(path, O_RDONLY); // Open the file - - if (fd > 0) // We have a valid file descriptor - { - const char sig[1024]; // File signature buffer - - ssize_t len = read(fd, (void *)&sig, sizeof(sig)); - - state = (strnstr(sig, "%PDF", len) != NULL); - - close(fd); // Close the file - } - } - - return state; -} - -#pragma mark - ReaderDocument instance methods - -- (instancetype)initWithFilePath:(NSString *)filePath password:(NSString *)phrase -{ - if ((self = [super init])) // Initialize superclass first - { - if ([ReaderDocument isPDF:filePath] == YES) // Valid PDF - { - _guid = [ReaderDocument GUID]; // Create document's GUID - - _password = [phrase copy]; // Keep copy of document password - - _filePath = [filePath copy]; // Keep copy of document file path - - _pageNumber = [NSNumber numberWithInteger:1]; // Start on page one - - _bookmarks = [NSMutableIndexSet new]; // Bookmarked pages index set - - CFURLRef docURLRef = (__bridge CFURLRef)[self fileURL]; // CFURLRef from NSURL - - CGPDFDocumentRef thePDFDocRef = CGPDFDocumentCreateUsingUrl(docURLRef, _password); - - if (thePDFDocRef != NULL) // Get the total number of pages in the document - { - NSInteger pageCount = CGPDFDocumentGetNumberOfPages(thePDFDocRef); - - _pageCount = [NSNumber numberWithInteger:pageCount]; - - CGPDFDocumentRelease(thePDFDocRef); // Cleanup - } - else // Cupertino, we have a problem with the document - { - NSAssert(NO, @"CGPDFDocumentRef == NULL"); - } - - _lastOpen = [NSDate dateWithTimeIntervalSinceReferenceDate:0.0]; - - NSFileManager *fileManager = [NSFileManager defaultManager]; // Singleton - - NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath:_filePath error:NULL]; - - _fileDate = [fileAttributes objectForKey:NSFileModificationDate]; // File date - - _fileSize = [fileAttributes objectForKey:NSFileSize]; // File size (bytes) - - [self archiveDocumentProperties]; // Archive ReaderDocument object - } - else // Not a valid PDF file - { - self = nil; - } - } - - return self; -} - -- (NSString *)fileName -{ - if (_fileName == nil) _fileName = [_filePath lastPathComponent]; - - return _fileName; -} - -- (NSURL *)fileURL -{ - if (_fileURL == nil) _fileURL = [[NSURL alloc] initFileURLWithPath:_filePath isDirectory:NO]; - - return _fileURL; -} - -- (BOOL)canEmail -{ - return YES; -} - -- (BOOL)canExport -{ - return NO; -} - -- (BOOL)canPrint -{ - return YES; -} - -- (BOOL)archiveDocumentProperties -{ - NSString *archiveFilePath = [ReaderDocument archiveFilePath:[self fileName]]; - - return [NSKeyedArchiver archiveRootObject:self toFile:archiveFilePath]; -} - -- (void)updateDocumentProperties -{ - CFURLRef docURLRef = (__bridge CFURLRef)[self fileURL]; // CFURLRef from NSURL - - CGPDFDocumentRef thePDFDocRef = CGPDFDocumentCreateUsingUrl(docURLRef, _password); - - if (thePDFDocRef != NULL) // Get the total number of pages in the document - { - NSInteger pageCount = CGPDFDocumentGetNumberOfPages(thePDFDocRef); - - _pageCount = [NSNumber numberWithInteger:pageCount]; - - CGPDFDocumentRelease(thePDFDocRef); // Cleanup - } - - NSFileManager *fileManager = [NSFileManager defaultManager]; // Singleton - - NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath:_filePath error:NULL]; - - _fileDate = [fileAttributes objectForKey:NSFileModificationDate]; // File date - - _fileSize = [fileAttributes objectForKey:NSFileSize]; // File size (bytes) -} - -#pragma mark - NSCoding protocol methods - -- (void)encodeWithCoder:(NSCoder *)encoder -{ - [encoder encodeObject:_guid forKey:@"FileGUID"]; - - [encoder encodeObject:_fileDate forKey:@"FileDate"]; - - [encoder encodeObject:_pageCount forKey:@"PageCount"]; - - [encoder encodeObject:_pageNumber forKey:@"PageNumber"]; - - [encoder encodeObject:_bookmarks forKey:@"Bookmarks"]; - - [encoder encodeObject:_fileSize forKey:@"FileSize"]; - - [encoder encodeObject:_lastOpen forKey:@"LastOpen"]; -} - -- (instancetype)initWithCoder:(NSCoder *)decoder -{ - if ((self = [super init])) // Superclass init - { - _guid = [decoder decodeObjectForKey:@"FileGUID"]; - - _fileDate = [decoder decodeObjectForKey:@"FileDate"]; - - _pageCount = [decoder decodeObjectForKey:@"PageCount"]; - - _pageNumber = [decoder decodeObjectForKey:@"PageNumber"]; - - _bookmarks = [decoder decodeObjectForKey:@"Bookmarks"]; - - _fileSize = [decoder decodeObjectForKey:@"FileSize"]; - - _lastOpen = [decoder decodeObjectForKey:@"LastOpen"]; - - if (_guid == nil) _guid = [ReaderDocument GUID]; - - if (_bookmarks != nil) - _bookmarks = [_bookmarks mutableCopy]; - else - _bookmarks = [NSMutableIndexSet new]; - } - - return self; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderDocumentOutline.h b/Libraries external/VFR Pdf Reader/Sources/ReaderDocumentOutline.h deleted file mode 100755 index 7fecc3918..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderDocumentOutline.h +++ /dev/null @@ -1,45 +0,0 @@ -// -// ReaderDocumentOutline.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2012-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <Foundation/Foundation.h> - -@interface ReaderDocumentOutline : NSObject <NSObject> - -+ (NSArray *)outlineFromFileURL:(NSURL *)fileURL password:(NSString *)phrase; - -+ (void)logDocumentOutlineArray:(NSArray *)array; - -@end - -@interface DocumentOutlineEntry : NSObject <NSObject> - -+ (instancetype)newWithTitle:(NSString *)title target:(id)target level:(NSInteger)level; - -@property (nonatomic, assign, readonly) NSInteger level; -@property (nonatomic, strong, readwrite) NSMutableArray *children; -@property (nonatomic, strong, readonly) NSString *title; -@property (nonatomic, strong, readonly) id target; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderDocumentOutline.m b/Libraries external/VFR Pdf Reader/Sources/ReaderDocumentOutline.m deleted file mode 100755 index 2c94ff155..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderDocumentOutline.m +++ /dev/null @@ -1,467 +0,0 @@ -// -// ReaderDocumentOutline.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2012-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderDocumentOutline.h" -#import "CGPDFDocument.h" - -@implementation ReaderDocumentOutline - -#pragma mark - Build option flags - -#define HIERARCHICAL_OUTLINE TRUE - -#pragma mark - ReaderDocumentOutline functions - -void logDictionaryEntry(const char *key, CGPDFObjectRef object, void *info) -{ - //CGPDFDictionaryApplyFunction(dictionary, logDictionaryEntry, NULL); - - NSString *kind = nil; // CGPDFObject type - - CGPDFObjectType type = CGPDFObjectGetType(object); - - switch (type) // CGPDFObjectTypes - { - case kCGPDFObjectTypeNull: - kind = @"CGPDFObjectTypeNull"; - NSLog(@"%s %@", key, kind); - break; - - case kCGPDFObjectTypeBoolean: - kind = @"CGPDFObjectTypeBoolean"; - NSLog(@"%s %@", key, kind); - break; - - case kCGPDFObjectTypeInteger: - kind = @"CGPDFObjectTypeInteger"; - NSLog(@"%s %@", key, kind); - break; - - case kCGPDFObjectTypeReal: - kind = @"CGPDFObjectTypeReal"; - NSLog(@"%s %@", key, kind); - break; - - case kCGPDFObjectTypeName: - { - kind = @"CGPDFObjectTypeName"; const char *pdfName = NULL; - - if (CGPDFObjectGetValue(object, kCGPDFObjectTypeName, &pdfName)) - { - if (pdfName != NULL) NSLog(@"%s %@ %s", key, kind, pdfName); - } - break; - } - - case kCGPDFObjectTypeString: - { - kind = @"CGPDFObjectTypeString"; CGPDFStringRef pdfString = NULL; - - if (CGPDFObjectGetValue(object, kCGPDFObjectTypeString, &pdfString)) - { - const unsigned char *string = CGPDFStringGetBytePtr(pdfString); - - if (string != NULL) NSLog(@"%s %@ %s", key, kind, string); - } - break; - } - - case kCGPDFObjectTypeArray: - kind = @"CGPDFObjectTypeArray"; - NSLog(@"%s %@", key, kind); - break; - - case kCGPDFObjectTypeDictionary: - kind = @"CGPDFObjectTypeDictionary"; - NSLog(@"%s %@", key, kind); - break; - - case kCGPDFObjectTypeStream: - kind = @"CGPDFObjectTypeStream"; - NSLog(@"%s %@", key, kind); - break; - } -} - -#pragma mark - ReaderDocumentOutline class methods - -+ (void)logDocumentOutlineArray:(NSArray *)array -{ - for (DocumentOutlineEntry *item in array) // Enumerate array entries - { - NSInteger indent = (item.level * 2); // Indent amount for NSLog output - - NSLog(@"%@%@", [@"" stringByPaddingToLength:indent withString:@" " startingAtIndex:0], item); - - [self logDocumentOutlineArray:item.children]; // Log any child entries - } -} - -+ (CGPDFArrayRef)destinationWithName:(const char *)destinationName inDestsTree:(CGPDFDictionaryRef)node -{ - CGPDFArrayRef destinationArray = NULL; - - CGPDFArrayRef limitsArray = NULL; // Limits array - - if (CGPDFDictionaryGetArray(node, "Limits", &limitsArray) == true) - { - CGPDFStringRef lowerLimit = NULL; CGPDFStringRef upperLimit = NULL; - - if (CGPDFArrayGetString(limitsArray, 0, &lowerLimit) == true) // Lower limit - { - if (CGPDFArrayGetString(limitsArray, 1, &upperLimit) == true) // Upper limit - { - const char *ll = (const char *)CGPDFStringGetBytePtr(lowerLimit); // Lower string - const char *ul = (const char *)CGPDFStringGetBytePtr(upperLimit); // Upper string - - if ((strcmp(destinationName, ll) < 0) || (strcmp(destinationName, ul) > 0)) - { - return NULL; // Destination name is outside this node's limits - } - } - } - } - - CGPDFArrayRef namesArray = NULL; // Names array - - if (CGPDFDictionaryGetArray(node, "Names", &namesArray) == true) - { - NSInteger namesCount = CGPDFArrayGetCount(namesArray); - - for (NSInteger index = 0; index < namesCount; index += 2) - { - CGPDFStringRef destName; // Destination name string - - if (CGPDFArrayGetString(namesArray, index, &destName) == true) - { - const char *dn = (const char *)CGPDFStringGetBytePtr(destName); - - if (strcmp(dn, destinationName) == 0) // Found the destination name - { - if (CGPDFArrayGetArray(namesArray, (index + 1), &destinationArray) == false) - { - CGPDFDictionaryRef destinationDictionary = NULL; // Destination dictionary - - if (CGPDFArrayGetDictionary(namesArray, (index + 1), &destinationDictionary) == true) - { - CGPDFDictionaryGetArray(destinationDictionary, "D", &destinationArray); - } - } - - return destinationArray; // Return the destination array - } - } - } - } - - CGPDFArrayRef kidsArray = NULL; // Kids array - - if (CGPDFDictionaryGetArray(node, "Kids", &kidsArray) == true) - { - NSInteger kidsCount = CGPDFArrayGetCount(kidsArray); - - for (NSInteger index = 0; index < kidsCount; index++) - { - CGPDFDictionaryRef kidNode = NULL; // Kid node dictionary - - if (CGPDFArrayGetDictionary(kidsArray, index, &kidNode) == true) // Recurse into node - { - destinationArray = [self destinationWithName:destinationName inDestsTree:kidNode]; - - if (destinationArray != NULL) return destinationArray; // Return destination array - } - } - } - - return NULL; -} - -+ (id)outlineEntryTarget:(CGPDFDictionaryRef)outlineDictionary document:(CGPDFDocumentRef)document -{ - id entryTarget = nil; // Entry target object - - CGPDFStringRef destName = NULL; const char *destString = NULL; - - CGPDFDictionaryRef actionDictionary = NULL; CGPDFArrayRef destArray = NULL; - - if (CGPDFDictionaryGetDictionary(outlineDictionary, "A", &actionDictionary) == true) - { - const char *actionType = NULL; // Outline entry action type string - - if (CGPDFDictionaryGetName(actionDictionary, "S", &actionType) == true) - { - if (strcmp(actionType, "GoTo") == 0) // GoTo action type - { - if (CGPDFDictionaryGetArray(actionDictionary, "D", &destArray) == false) - { - CGPDFDictionaryGetString(actionDictionary, "D", &destName); - } - } - else // Handle other entry action type possibility - { - if (strcmp(actionType, "URI") == 0) // URI action type - { - CGPDFStringRef uriString = NULL; // Action's URI string - - if (CGPDFDictionaryGetString(actionDictionary, "URI", &uriString) == true) - { - const char *uri = (const char *)CGPDFStringGetBytePtr(uriString); // Destination URI string - - entryTarget = [NSURL URLWithString:[NSString stringWithCString:uri encoding:NSASCIIStringEncoding]]; - } - } - } - } - } - else // Handle other entry target possibilities - { - if (CGPDFDictionaryGetArray(outlineDictionary, "Dest", &destArray) == false) - { - if (CGPDFDictionaryGetString(outlineDictionary, "Dest", &destName) == false) - { - CGPDFDictionaryGetName(outlineDictionary, "Dest", &destString); - } - } - } - - if (destName != NULL) // Handle a destination name - { - CGPDFDictionaryRef catalogDictionary = CGPDFDocumentGetCatalog(document); - - CGPDFDictionaryRef namesDictionary = NULL; // Destination names in the document - - if (CGPDFDictionaryGetDictionary(catalogDictionary, "Names", &namesDictionary) == true) - { - CGPDFDictionaryRef destsDictionary = NULL; // Document destinations dictionary - - if (CGPDFDictionaryGetDictionary(namesDictionary, "Dests", &destsDictionary) == true) - { - const char *destinationName = (const char *)CGPDFStringGetBytePtr(destName); // Name - - destArray = [self destinationWithName:destinationName inDestsTree:destsDictionary]; - } - } - } - - if (destString != NULL) // Handle a destination string - { - CGPDFDictionaryRef catalogDictionary = CGPDFDocumentGetCatalog(document); - - CGPDFDictionaryRef destsDictionary = NULL; // Document destinations dictionary - - if (CGPDFDictionaryGetDictionary(catalogDictionary, "Dests", &destsDictionary) == true) - { - CGPDFDictionaryRef targetDictionary = NULL; // Destination target dictionary - - if (CGPDFDictionaryGetDictionary(destsDictionary, destString, &targetDictionary) == true) - { - CGPDFDictionaryGetArray(targetDictionary, "D", &destArray); - } - } - } - - if (destArray != NULL) // Handle a destination array - { - NSInteger targetPageNumber = 0; // The target page number - - CGPDFDictionaryRef pageDictionaryFromDestArray = NULL; // Target reference - - if (CGPDFArrayGetDictionary(destArray, 0, &pageDictionaryFromDestArray) == true) - { - NSInteger pageCount = CGPDFDocumentGetNumberOfPages(document); // Pages - - for (NSInteger pageNumber = 1; pageNumber <= pageCount; pageNumber++) - { - CGPDFPageRef pageRef = CGPDFDocumentGetPage(document, pageNumber); - - CGPDFDictionaryRef pageDictionaryFromPage = CGPDFPageGetDictionary(pageRef); - - if (pageDictionaryFromPage == pageDictionaryFromDestArray) // Found it - { - targetPageNumber = pageNumber; break; - } - } - } - else // Try page number from array possibility - { - CGPDFInteger pageNumber = 0; // Page number in array - - if (CGPDFArrayGetInteger(destArray, 0, &pageNumber) == true) - { - targetPageNumber = (pageNumber + 1); // 1-based - } - } - - if (targetPageNumber > 0) // We have a target page number - { - entryTarget = [NSNumber numberWithInteger:targetPageNumber]; - } - } - - return entryTarget; -} - -+ (void)outlineItems:(CGPDFDictionaryRef)outlineDictionary document:(CGPDFDocumentRef)document array:(NSMutableArray *)array level:(NSInteger)level -{ - do // Loop through current level outline entries - { - DocumentOutlineEntry *outlineEntry = nil; // An entry - - CGPDFStringRef string = NULL; // Outline entry title string - - if (CGPDFDictionaryGetString(outlineDictionary, "Title", &string) == true) - { - CFStringRef title = NULL; // Actual outline title (CFObject) string - - if ((title = CGPDFStringCopyTextString(string)) != NULL) // Copy of CFObject string - { - NSString *titleString = (__bridge NSString *)title; // CFString to NSString toll-free bridge cast - - id entryTarget = [self outlineEntryTarget:outlineDictionary document:document]; // Get target object - - NSString *trimmed = [titleString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; - - outlineEntry = [DocumentOutlineEntry newWithTitle:trimmed target:entryTarget level:level]; // New entry - - [array addObject:outlineEntry]; CFRelease(title); // Add new entry and cleanup - } - } - - if (outlineEntry != nil) // Must have a current outline entry - { - CGPDFDictionaryRef childItem = NULL; // First child outline item - - if (CGPDFDictionaryGetDictionary(outlineDictionary, "First", &childItem) == true) - { -#if (HIERARCHICAL_OUTLINE == TRUE) // Option - NSMutableArray *childArray = [NSMutableArray array]; outlineEntry.children = childArray; - - [self outlineItems:childItem document:document array:childArray level:(level + 1)]; -#else // Flat - [self outlineItems:childItem document:document array:array level:(level + 1)]; - -#endif // end of HIERARCHICAL_OUTLINE Option - } - } - - } while (CGPDFDictionaryGetDictionary(outlineDictionary, "Next", &outlineDictionary) == true); -} - -+ (NSArray *)outlineFromFileURL:(NSURL *)fileURL password:(NSString *)phrase -{ - NSMutableArray *outlineArray = nil; // Mutable outline array - - if ((fileURL != nil) && [fileURL isFileURL]) // Check for valid file URL - { - CGPDFDocumentRef document = CGPDFDocumentCreateUsingUrl((__bridge CFURLRef)fileURL, phrase); - - if (document != NULL) // Check for non-NULL CGPDFDocumentRef - { - CGPDFDictionaryRef outlines = NULL; // Document's outlines - - CGPDFDictionaryRef catalog = CGPDFDocumentGetCatalog(document); - - if (CGPDFDictionaryGetDictionary(catalog, "Outlines", &outlines) == true) - { - CGPDFDictionaryRef firstItem = NULL; // First outline item entry - - if (CGPDFDictionaryGetDictionary(outlines, "First", &firstItem) == true) - { - outlineArray = [NSMutableArray array]; // Top level outline entries array - - [self outlineItems:firstItem document:document array:outlineArray level:0]; - } - } - - CGPDFDocumentRelease(document); // Cleanup - } - } - - //[self logDocumentOutlineArray:outlineArray]; // Log it - - return [outlineArray copy]; // NSArray -} - -@end - -#pragma mark - - -// -// DocumentOutlineEntry class implementation -// - -@interface DocumentOutlineEntry () - -@property (nonatomic, assign, readwrite) NSInteger level; -@property (nonatomic, strong, readwrite) NSString *title; -@property (nonatomic, strong, readwrite) id target; - -@end - -@implementation DocumentOutlineEntry -{ - NSInteger _level; - - NSMutableArray *_children; - - NSString *_title; - - id _target; -} - -#pragma mark - Properties - -@synthesize level = _level; -@synthesize children = _children; -@synthesize target = _target; -@synthesize title = _title; - -#pragma mark - DocumentOutlineEntry class methods - -+ (instancetype)newWithTitle:(NSString *)title target:(id)target level:(NSInteger)level -{ - return [[DocumentOutlineEntry alloc] initWithTitle:title target:target level:level]; -} - -#pragma mark - DocumentOutlineEntry instance methods - -- (instancetype)initWithTitle:(NSString *)title target:(id)target level:(NSInteger)level -{ - if ((self = [super init])) - { - self.title = title; self.target = target; self.level = level; - } - - return self; -} - -- (NSString *)description -{ - NSString *format = @"%@ Title = '%@', Target = '%@', Level = (%i)"; - - return [[NSString alloc] initWithFormat:format, [super description], _title, _target, _level]; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderMainPagebar.h b/Libraries external/VFR Pdf Reader/Sources/ReaderMainPagebar.h deleted file mode 100755 index 0c8a1357a..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderMainPagebar.h +++ /dev/null @@ -1,88 +0,0 @@ -// -// ReaderMainPagebar.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -#import "ReaderThumbView.h" - -@class ReaderMainPagebar; -@class ReaderTrackControl; -@class ReaderPagebarThumb; -@class ReaderDocument; - -@protocol ReaderMainPagebarDelegate <NSObject> - -@required // Delegate protocols - -- (void)pagebar:(ReaderMainPagebar *)pagebar gotoPage:(NSInteger)page; - -@end - -@interface ReaderMainPagebar : UIView - -@property (nonatomic, weak, readwrite) id <ReaderMainPagebarDelegate> delegate; - -- (instancetype)initWithFrame:(CGRect)frame document:(ReaderDocument *)object; - -- (void)updatePagebar; - -- (void)hidePagebar; -- (void)showPagebar; - -@end - -#pragma mark - - -// -// ReaderTrackControl class interface -// - -@interface ReaderTrackControl : UIControl - -@property (nonatomic, assign, readonly) CGFloat value; - -@end - -#pragma mark - - -// -// ReaderPagebarThumb class interface -// - -@interface ReaderPagebarThumb : ReaderThumbView - -- (instancetype)initWithFrame:(CGRect)frame small:(BOOL)small; - -@end - -#pragma mark - - -// -// ReaderPagebarShadow class interface -// - -@interface ReaderPagebarShadow : UIView - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderMainPagebar.m b/Libraries external/VFR Pdf Reader/Sources/ReaderMainPagebar.m deleted file mode 100755 index 5a5934553..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderMainPagebar.m +++ /dev/null @@ -1,642 +0,0 @@ -// -// ReaderMainPagebar.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderConstants.h" -#import "ReaderMainPagebar.h" -#import "ReaderThumbCache.h" -#import "ReaderDocument.h" - -#import <QuartzCore/QuartzCore.h> - -@implementation ReaderMainPagebar -{ - ReaderDocument *document; - - ReaderTrackControl *trackControl; - - NSMutableDictionary *miniThumbViews; - - ReaderPagebarThumb *pageThumbView; - - UILabel *pageNumberLabel; - - UIView *pageNumberView; - - NSTimer *enableTimer; - NSTimer *trackTimer; -} - -#pragma mark - Constants - -#define THUMB_SMALL_GAP 2 -#define THUMB_SMALL_WIDTH 22 -#define THUMB_SMALL_HEIGHT 28 - -#define THUMB_LARGE_WIDTH 32 -#define THUMB_LARGE_HEIGHT 42 - -#define PAGE_NUMBER_WIDTH 96.0f -#define PAGE_NUMBER_HEIGHT 30.0f - -#define PAGE_NUMBER_SPACE_SMALL 16.0f -#define PAGE_NUMBER_SPACE_LARGE 32.0f - -#define SHADOW_HEIGHT 4.0f - -#pragma mark - Properties - -@synthesize delegate; - -#pragma mark - ReaderMainPagebar class methods - -+ (Class)layerClass -{ -#if (READER_FLAT_UI == FALSE) // Option - return [CAGradientLayer class]; -#else - return [CALayer class]; -#endif // end of READER_FLAT_UI Option -} - -#pragma mark - ReaderMainPagebar instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - return [self initWithFrame:frame document:nil]; -} - -- (void)updatePageThumbView:(NSInteger)page -{ - NSInteger pages = [document.pageCount integerValue]; - - if (pages > 1) // Only update frame if more than one page - { - CGFloat controlWidth = trackControl.bounds.size.width; - - CGFloat useableWidth = (controlWidth - THUMB_LARGE_WIDTH); - - CGFloat stride = (useableWidth / (pages - 1)); // Page stride - - NSInteger X = (stride * (page - 1)); CGFloat pageThumbX = X; - - CGRect pageThumbRect = pageThumbView.frame; // Current frame - - if (pageThumbX != pageThumbRect.origin.x) // Only if different - { - pageThumbRect.origin.x = pageThumbX; // The new X position - - pageThumbView.frame = pageThumbRect; // Update the frame - } - } - - if (page != pageThumbView.tag) // Only if page number changed - { - pageThumbView.tag = page; [pageThumbView reuse]; // Reuse the thumb view - - CGSize size = CGSizeMake(THUMB_LARGE_WIDTH, THUMB_LARGE_HEIGHT); // Maximum thumb size - - NSURL *fileURL = document.fileURL; NSString *guid = document.guid; NSString *phrase = document.password; - - ReaderThumbRequest *request = [ReaderThumbRequest newForView:pageThumbView fileURL:fileURL password:phrase guid:guid page:page size:size]; - - UIImage *image = [[ReaderThumbCache sharedInstance] thumbRequest:request priority:YES]; // Request the thumb - - UIImage *thumb = ([image isKindOfClass:[UIImage class]] ? image : nil); [pageThumbView showImage:thumb]; - } -} - -- (void)updatePageNumberText:(NSInteger)page -{ - if (page != pageNumberLabel.tag) // Only if page number changed - { - NSInteger pages = [document.pageCount integerValue]; // Total pages - - NSString *format = NSLocalizedString(@"%i of %i", @"format"); // Format - - NSString *number = [[NSString alloc] initWithFormat:format, (int)page, (int)pages]; - - pageNumberLabel.text = number; // Update the page number label text - - pageNumberLabel.tag = page; // Update the last page number tag - } -} - -- (instancetype)initWithFrame:(CGRect)frame document:(ReaderDocument *)object -{ - assert(object != nil); // Must have a valid ReaderDocument - - if ((self = [super initWithFrame:frame])) - { - self.autoresizesSubviews = YES; - self.userInteractionEnabled = YES; - self.contentMode = UIViewContentModeRedraw; - self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin; - - if ([self.layer isKindOfClass:[CAGradientLayer class]]) - { - self.backgroundColor = [UIColor clearColor]; - - CAGradientLayer *layer = (CAGradientLayer *)self.layer; - UIColor *liteColor = [UIColor colorWithWhite:0.82f alpha:0.8f]; - UIColor *darkColor = [UIColor colorWithWhite:0.32f alpha:0.8f]; - layer.colors = [NSArray arrayWithObjects:(id)liteColor.CGColor, (id)darkColor.CGColor, nil]; - - CGRect shadowRect = self.bounds; shadowRect.size.height = SHADOW_HEIGHT; shadowRect.origin.y -= shadowRect.size.height; - - ReaderPagebarShadow *shadowView = [[ReaderPagebarShadow alloc] initWithFrame:shadowRect]; - - [self addSubview:shadowView]; // Add shadow to toolbar - } - else // Follow The Fuglyosity of Flat Fad - { - self.backgroundColor = [UIColor colorWithWhite:0.94f alpha:0.94f]; - - CGRect lineRect = self.bounds; lineRect.size.height = 1.0f; lineRect.origin.y -= lineRect.size.height; - - UIView *lineView = [[UIView alloc] initWithFrame:lineRect]; - lineView.autoresizesSubviews = NO; - lineView.userInteractionEnabled = NO; - lineView.contentMode = UIViewContentModeRedraw; - lineView.autoresizingMask = UIViewAutoresizingFlexibleWidth; - lineView.backgroundColor = [UIColor colorWithWhite:0.64f alpha:0.94f]; - [self addSubview:lineView]; - } - - CGFloat space = (([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) ? PAGE_NUMBER_SPACE_LARGE : PAGE_NUMBER_SPACE_SMALL); - CGFloat numberY = (0.0f - (PAGE_NUMBER_HEIGHT + space)); CGFloat numberX = ((self.bounds.size.width - PAGE_NUMBER_WIDTH) * 0.5f); - CGRect numberRect = CGRectMake(numberX, numberY, PAGE_NUMBER_WIDTH, PAGE_NUMBER_HEIGHT); - - pageNumberView = [[UIView alloc] initWithFrame:numberRect]; // Page numbers view - - pageNumberView.autoresizesSubviews = NO; - pageNumberView.userInteractionEnabled = NO; - pageNumberView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; - pageNumberView.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.4f]; - - pageNumberView.layer.shadowOffset = CGSizeMake(0.0f, 0.0f); - pageNumberView.layer.shadowColor = [UIColor colorWithWhite:0.0f alpha:0.6f].CGColor; - pageNumberView.layer.shadowPath = [UIBezierPath bezierPathWithRect:pageNumberView.bounds].CGPath; - pageNumberView.layer.shadowRadius = 2.0f; pageNumberView.layer.shadowOpacity = 1.0f; - - CGRect textRect = CGRectInset(pageNumberView.bounds, 4.0f, 2.0f); // Inset the text a bit - - pageNumberLabel = [[UILabel alloc] initWithFrame:textRect]; // Page numbers label - - pageNumberLabel.autoresizesSubviews = NO; - pageNumberLabel.autoresizingMask = UIViewAutoresizingNone; - pageNumberLabel.textAlignment = NSTextAlignmentCenter; - pageNumberLabel.backgroundColor = [UIColor clearColor]; - pageNumberLabel.textColor = [UIColor whiteColor]; - pageNumberLabel.font = [UIFont systemFontOfSize:16.0f]; - pageNumberLabel.shadowOffset = CGSizeMake(0.0f, 1.0f); - pageNumberLabel.shadowColor = [UIColor blackColor]; - pageNumberLabel.adjustsFontSizeToFitWidth = YES; - pageNumberLabel.minimumScaleFactor = 0.75f; - - [pageNumberView addSubview:pageNumberLabel]; // Add label view - - [self addSubview:pageNumberView]; // Add page numbers display view - - trackControl = [[ReaderTrackControl alloc] initWithFrame:self.bounds]; // Track control view - - [trackControl addTarget:self action:@selector(trackViewTouchDown:) forControlEvents:UIControlEventTouchDown]; - [trackControl addTarget:self action:@selector(trackViewValueChanged:) forControlEvents:UIControlEventValueChanged]; - [trackControl addTarget:self action:@selector(trackViewTouchUp:) forControlEvents:UIControlEventTouchUpOutside]; - [trackControl addTarget:self action:@selector(trackViewTouchUp:) forControlEvents:UIControlEventTouchUpInside]; - - [self addSubview:trackControl]; // Add the track control and thumbs view - - document = object; // Retain the document object for our use - - [self updatePageNumberText:[document.pageNumber integerValue]]; - - miniThumbViews = [NSMutableDictionary new]; // Small thumbs - } - - return self; -} - -- (void)removeFromSuperview -{ - [trackTimer invalidate]; [enableTimer invalidate]; - - [super removeFromSuperview]; -} - -- (void)layoutSubviews -{ - CGRect controlRect = CGRectInset(self.bounds, 4.0f, 0.0f); - - CGFloat thumbWidth = (THUMB_SMALL_WIDTH + THUMB_SMALL_GAP); - - NSInteger thumbs = (controlRect.size.width / thumbWidth); - - NSInteger pages = [document.pageCount integerValue]; // Pages - - if (thumbs > pages) thumbs = pages; // No more than total pages - - CGFloat controlWidth = ((thumbs * thumbWidth) - THUMB_SMALL_GAP); - - controlRect.size.width = controlWidth; // Update control width - - CGFloat widthDelta = (self.bounds.size.width - controlWidth); - - NSInteger X = (widthDelta * 0.5f); controlRect.origin.x = X; - - trackControl.frame = controlRect; // Update track control frame - - if (pageThumbView == nil) // Create the page thumb view when needed - { - CGFloat heightDelta = (controlRect.size.height - THUMB_LARGE_HEIGHT); - - NSInteger thumbY = (heightDelta * 0.5f); NSInteger thumbX = 0; // Thumb X, Y - - CGRect thumbRect = CGRectMake(thumbX, thumbY, THUMB_LARGE_WIDTH, THUMB_LARGE_HEIGHT); - - pageThumbView = [[ReaderPagebarThumb alloc] initWithFrame:thumbRect]; // Create the thumb view - - pageThumbView.layer.zPosition = 1.0f; // Z position so that it sits on top of the small thumbs - - [trackControl addSubview:pageThumbView]; // Add as the first subview of the track control - } - - [self updatePageThumbView:[document.pageNumber integerValue]]; // Update page thumb view - - NSInteger strideThumbs = (thumbs - 1); if (strideThumbs < 1) strideThumbs = 1; - - CGFloat stride = ((CGFloat)pages / (CGFloat)strideThumbs); // Page stride - - CGFloat heightDelta = (controlRect.size.height - THUMB_SMALL_HEIGHT); - - NSInteger thumbY = (heightDelta * 0.5f); NSInteger thumbX = 0; // Initial X, Y - - CGRect thumbRect = CGRectMake(thumbX, thumbY, THUMB_SMALL_WIDTH, THUMB_SMALL_HEIGHT); - - NSMutableDictionary *thumbsToHide = [miniThumbViews mutableCopy]; - - for (NSInteger thumb = 0; thumb < thumbs; thumb++) // Iterate through needed thumbs - { - NSInteger page = ((stride * thumb) + 1); if (page > pages) page = pages; // Page - - NSNumber *key = [NSNumber numberWithInteger:page]; // Page number key for thumb view - - ReaderPagebarThumb *smallThumbView = [miniThumbViews objectForKey:key]; // Thumb view - - if (smallThumbView == nil) // We need to create a new small thumb view for the page number - { - CGSize size = CGSizeMake(THUMB_SMALL_WIDTH, THUMB_SMALL_HEIGHT); // Maximum thumb size - - NSURL *fileURL = document.fileURL; NSString *guid = document.guid; NSString *phrase = document.password; - - smallThumbView = [[ReaderPagebarThumb alloc] initWithFrame:thumbRect small:YES]; // Create a small thumb view - - ReaderThumbRequest *thumbRequest = [ReaderThumbRequest newForView:smallThumbView fileURL:fileURL password:phrase guid:guid page:page size:size]; - - UIImage *image = [[ReaderThumbCache sharedInstance] thumbRequest:thumbRequest priority:NO]; // Request the thumb - - if ([image isKindOfClass:[UIImage class]]) [smallThumbView showImage:image]; // Use thumb image from cache - - [trackControl addSubview:smallThumbView]; [miniThumbViews setObject:smallThumbView forKey:key]; - } - else // Resue existing small thumb view for the page number - { - smallThumbView.hidden = NO; [thumbsToHide removeObjectForKey:key]; - - if (CGRectEqualToRect(smallThumbView.frame, thumbRect) == false) - { - smallThumbView.frame = thumbRect; // Update thumb frame - } - } - - thumbRect.origin.x += thumbWidth; // Next thumb X position - } - - [thumbsToHide enumerateKeysAndObjectsUsingBlock: // Hide unused thumbs - ^(id key, id object, BOOL *stop) - { - ReaderPagebarThumb *thumb = object; thumb.hidden = YES; - } - ]; -} - -- (void)updatePagebarViews -{ - NSInteger page = [document.pageNumber integerValue]; // # - - [self updatePageNumberText:page]; // Update page number text - - [self updatePageThumbView:page]; // Update page thumb view -} - -- (void)updatePagebar -{ - if (self.hidden == NO) // Only if visible - { - [self updatePagebarViews]; // Update views - } -} - -- (void)hidePagebar -{ - if (self.hidden == NO) // Only if visible - { - [UIView animateWithDuration:0.25 delay:0.0 - options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction - animations:^(void) - { - self.alpha = 0.0f; - } - completion:^(BOOL finished) - { - self.hidden = YES; - } - ]; - } -} - -- (void)showPagebar -{ - if (self.hidden == YES) // Only if hidden - { - [self updatePagebarViews]; // Update views first - - [UIView animateWithDuration:0.25 delay:0.0 - options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction - animations:^(void) - { - self.hidden = NO; - self.alpha = 1.0f; - } - completion:NULL - ]; - } -} - -#pragma mark - ReaderTrackControl action methods - -- (void)trackTimerFired:(NSTimer *)timer -{ - [trackTimer invalidate]; trackTimer = nil; // Cleanup timer - - if (trackControl.tag != [document.pageNumber integerValue]) // Only if different - { - [delegate pagebar:self gotoPage:trackControl.tag]; // Go to document page - } -} - -- (void)enableTimerFired:(NSTimer *)timer -{ - [enableTimer invalidate]; enableTimer = nil; // Cleanup timer - - trackControl.userInteractionEnabled = YES; // Enable track control interaction -} - -- (void)restartTrackTimer -{ - if (trackTimer != nil) { [trackTimer invalidate]; trackTimer = nil; } // Invalidate and release previous timer - - trackTimer = [NSTimer scheduledTimerWithTimeInterval:0.25 target:self selector:@selector(trackTimerFired:) userInfo:nil repeats:NO]; -} - -- (void)startEnableTimer -{ - if (enableTimer != nil) { [enableTimer invalidate]; enableTimer = nil; } // Invalidate and release previous timer - - enableTimer = [NSTimer scheduledTimerWithTimeInterval:0.25 target:self selector:@selector(enableTimerFired:) userInfo:nil repeats:NO]; -} - -- (NSInteger)trackViewPageNumber:(ReaderTrackControl *)trackView -{ - CGFloat controlWidth = trackView.bounds.size.width; // View width - - CGFloat stride = (controlWidth / [document.pageCount integerValue]); - - NSInteger page = (trackView.value / stride); // Integer page number - - return (page + 1); // + 1 -} - -- (void)trackViewTouchDown:(ReaderTrackControl *)trackView -{ - NSInteger page = [self trackViewPageNumber:trackView]; // Page - - if (page != [document.pageNumber integerValue]) // Only if different - { - [self updatePageNumberText:page]; // Update page number text - - [self updatePageThumbView:page]; // Update page thumb view - - [self restartTrackTimer]; // Start the track timer - } - - trackView.tag = page; // Start page tracking -} - -- (void)trackViewValueChanged:(ReaderTrackControl *)trackView -{ - NSInteger page = [self trackViewPageNumber:trackView]; // Page - - if (page != trackView.tag) // Only if the page number has changed - { - [self updatePageNumberText:page]; // Update page number text - - [self updatePageThumbView:page]; // Update page thumb view - - trackView.tag = page; // Update the page tracking tag - - [self restartTrackTimer]; // Restart the track timer - } -} - -- (void)trackViewTouchUp:(ReaderTrackControl *)trackView -{ - [trackTimer invalidate]; trackTimer = nil; // Cleanup - - if (trackView.tag != [document.pageNumber integerValue]) // Only if different - { - trackView.userInteractionEnabled = NO; // Disable track control interaction - - [delegate pagebar:self gotoPage:trackView.tag]; // Go to document page - - [self startEnableTimer]; // Start track control enable timer - } - - trackView.tag = 0; // Reset page tracking -} - -@end - -#pragma mark - - -// -// ReaderTrackControl class implementation -// - -@implementation ReaderTrackControl -{ - CGFloat _value; -} - -#pragma mark - Properties - -@synthesize value = _value; - -#pragma mark - ReaderTrackControl instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) - { - self.autoresizesSubviews = NO; - self.userInteractionEnabled = YES; - self.contentMode = UIViewContentModeRedraw; - self.autoresizingMask = UIViewAutoresizingNone; - self.backgroundColor = [UIColor clearColor]; - self.exclusiveTouch = YES; - } - - return self; -} - -- (CGFloat)limitValue:(CGFloat)valueX -{ - CGFloat minX = self.bounds.origin.x; // 0.0f; - CGFloat maxX = (self.bounds.size.width - 1.0f); - - if (valueX < minX) valueX = minX; // Minimum X - if (valueX > maxX) valueX = maxX; // Maximum X - - return valueX; -} - -#pragma mark - UIControl subclass methods - -- (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event -{ - CGPoint point = [touch locationInView:self]; // Touch point - - _value = [self limitValue:point.x]; // Limit control value - - return YES; -} - -- (BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event -{ - if (self.touchInside == YES) // Only if inside the control - { - CGPoint point = [touch locationInView:touch.view]; // Touch point - - CGFloat x = [self limitValue:point.x]; // Potential new control value - - if (x != _value) // Only if the new value has changed since the last time - { - _value = x; [self sendActionsForControlEvents:UIControlEventValueChanged]; - } - } - - return YES; -} - -- (void)endTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event -{ - CGPoint point = [touch locationInView:self]; // Touch point - - _value = [self limitValue:point.x]; // Limit control value -} - -@end - -#pragma mark - - -// -// ReaderPagebarThumb class implementation -// - -@implementation ReaderPagebarThumb - -#pragma mark - ReaderPagebarThumb instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - return [self initWithFrame:frame small:NO]; -} - -- (instancetype)initWithFrame:(CGRect)frame small:(BOOL)small -{ - if ((self = [super initWithFrame:frame])) // Superclass init - { - CGFloat value = (small ? 0.6f : 0.7f); // Size based alpha value - - UIColor *background = [UIColor colorWithWhite:0.8f alpha:value]; - - self.backgroundColor = background; imageView.backgroundColor = background; - - imageView.layer.borderColor = [UIColor colorWithWhite:0.4f alpha:0.6f].CGColor; - - imageView.layer.borderWidth = 1.0f; // Give the thumb image view a border - } - - return self; -} - -@end - -#pragma mark - - -// -// ReaderPagebarShadow class implementation -// - -@implementation ReaderPagebarShadow - -#pragma mark - ReaderPagebarShadow class methods - -+ (Class)layerClass -{ - return [CAGradientLayer class]; -} - -#pragma mark - ReaderPagebarShadow instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) - { - self.autoresizesSubviews = NO; - self.userInteractionEnabled = NO; - self.contentMode = UIViewContentModeRedraw; - self.autoresizingMask = UIViewAutoresizingFlexibleWidth; - self.backgroundColor = [UIColor clearColor]; - - CAGradientLayer *layer = (CAGradientLayer *)self.layer; - UIColor *blackColor = [UIColor colorWithWhite:0.42f alpha:1.0f]; - UIColor *clearColor = [UIColor colorWithWhite:0.42f alpha:0.0f]; - layer.colors = [NSArray arrayWithObjects:(id)clearColor.CGColor, (id)blackColor.CGColor, nil]; - } - - return self; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderMainToolbar.h b/Libraries external/VFR Pdf Reader/Sources/ReaderMainToolbar.h deleted file mode 100755 index caf543877..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderMainToolbar.h +++ /dev/null @@ -1,57 +0,0 @@ -// -// ReaderMainToolbar.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -#import "UIXToolbarView.h" - -@class ReaderMainToolbar; -@class ReaderDocument; - -@protocol ReaderMainToolbarDelegate <NSObject> - -@required // Delegate protocols - -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar doneButton:(UIButton *)button; -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar thumbsButton:(UIButton *)button; -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar exportButton:(UIButton *)button; -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar printButton:(UIButton *)button; -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar emailButton:(UIButton *)button; -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar markButton:(UIButton *)button; - -@end - -@interface ReaderMainToolbar : UIXToolbarView - -@property (nonatomic, weak, readwrite) id <ReaderMainToolbarDelegate> delegate; - -- (instancetype)initWithFrame:(CGRect)frame document:(ReaderDocument *)document; - -- (void)setBookmarkState:(BOOL)state; - -- (void)hideToolbar; -- (void)showToolbar; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderMainToolbar.m b/Libraries external/VFR Pdf Reader/Sources/ReaderMainToolbar.m deleted file mode 100755 index d97c92eaa..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderMainToolbar.m +++ /dev/null @@ -1,360 +0,0 @@ -// -// ReaderMainToolbar.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderConstants.h" -#import "ReaderMainToolbar.h" -#import "ReaderDocument.h" - -#import <MessageUI/MessageUI.h> - -@implementation ReaderMainToolbar -{ - UIButton *markButton; - - UIImage *markImageN; - UIImage *markImageY; -} - -#pragma mark - Constants - -#define BUTTON_X 8.0f -#define BUTTON_Y 8.0f - -#define BUTTON_SPACE 8.0f -#define BUTTON_HEIGHT 30.0f - -#define BUTTON_FONT_SIZE 15.0f -#define TEXT_BUTTON_PADDING 24.0f - -#define ICON_BUTTON_WIDTH 40.0f - -#define TITLE_FONT_SIZE 19.0f -#define TITLE_HEIGHT 28.0f - -#define COLOR_BAR [UIColor colorWithRed:(248.0f/255.0f) green:(248.0f/255.0f) blue:(248.0f/255.0f) alpha:1.0] -#define COLOR_ARANCIO [UIColor colorWithRed:241.0/255.0 green:90.0/255.0 blue:34.0/255.0 alpha:1.0] - - -#pragma mark - Properties - -@synthesize delegate; - -#pragma mark - ReaderMainToolbar instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - return [self initWithFrame:frame document:nil]; -} - -- (instancetype)initWithFrame:(CGRect)frame document:(ReaderDocument *)document -{ - assert(document != nil); // Must have a valid ReaderDocument - - if ((self = [super initWithFrame:frame])) - { - CGFloat viewWidth = self.bounds.size.width; // Toolbar view width - -#if (READER_FLAT_UI == TRUE) // Option - UIImage *buttonH = nil; UIImage *buttonN = nil; -#else - UIImage *buttonH = [[UIImage imageNamed:@"Reader-Button-H"] stretchableImageWithLeftCapWidth:5 topCapHeight:0]; - UIImage *buttonN = [[UIImage imageNamed:@"Reader-Button-N"] stretchableImageWithLeftCapWidth:5 topCapHeight:0]; -#endif // end of READER_FLAT_UI Option - - BOOL largeDevice = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad); - - const CGFloat buttonSpacing = BUTTON_SPACE; const CGFloat iconButtonWidth = ICON_BUTTON_WIDTH; - - CGFloat titleX = BUTTON_X; CGFloat titleWidth = (viewWidth - (titleX + titleX)); - - CGFloat leftButtonX = BUTTON_X; // Left-side button start X position - -#if (READER_STANDALONE == FALSE) // Option - - UIFont *doneButtonFont = [UIFont systemFontOfSize:BUTTON_FONT_SIZE]; - NSString *doneButtonText = NSLocalizedString(@"Done", @"button"); - CGSize doneButtonSize = [doneButtonText sizeWithFont:doneButtonFont]; - CGFloat doneButtonWidth = (doneButtonSize.width + TEXT_BUTTON_PADDING); - - UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom]; - doneButton.frame = CGRectMake(leftButtonX, BUTTON_Y, doneButtonWidth, BUTTON_HEIGHT); - [doneButton setTitleColor:[UIColor colorWithWhite:0.0f alpha:1.0f] forState:UIControlStateNormal]; - [doneButton setTitleColor:[UIColor colorWithWhite:1.0f alpha:1.0f] forState:UIControlStateHighlighted]; - [doneButton setTitle:doneButtonText forState:UIControlStateNormal]; doneButton.titleLabel.font = doneButtonFont; - [doneButton addTarget:self action:@selector(doneButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; - [doneButton setBackgroundImage:buttonH forState:UIControlStateHighlighted]; - [doneButton setBackgroundImage:buttonN forState:UIControlStateNormal]; - doneButton.autoresizingMask = UIViewAutoresizingNone; - //doneButton.backgroundColor = [UIColor grayColor]; - doneButton.exclusiveTouch = YES; - - [self addSubview:doneButton]; leftButtonX += (doneButtonWidth + buttonSpacing); - - titleX += (doneButtonWidth + buttonSpacing); titleWidth -= (doneButtonWidth + buttonSpacing); - -#endif // end of READER_STANDALONE Option - -#if (READER_ENABLE_THUMBS == TRUE) // Option - - UIButton *thumbsButton = [UIButton buttonWithType:UIButtonTypeCustom]; - thumbsButton.frame = CGRectMake(leftButtonX, BUTTON_Y, iconButtonWidth, BUTTON_HEIGHT); - [thumbsButton setImage:[UIImage imageNamed:@"Reader-Thumbs"] forState:UIControlStateNormal]; - [thumbsButton addTarget:self action:@selector(thumbsButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; - [thumbsButton setBackgroundImage:buttonH forState:UIControlStateHighlighted]; - [thumbsButton setBackgroundImage:buttonN forState:UIControlStateNormal]; - thumbsButton.autoresizingMask = UIViewAutoresizingNone; - //thumbsButton.backgroundColor = [UIColor grayColor]; - thumbsButton.exclusiveTouch = YES; - - [self addSubview:thumbsButton]; //leftButtonX += (iconButtonWidth + buttonSpacing); - - titleX += (iconButtonWidth + buttonSpacing); titleWidth -= (iconButtonWidth + buttonSpacing); - -#endif // end of READER_ENABLE_THUMBS Option - - CGFloat rightButtonX = viewWidth; // Right-side buttons start X position - -#if (READER_BOOKMARKS == TRUE) // Option - - rightButtonX -= (iconButtonWidth + buttonSpacing); // Position - - UIButton *flagButton = [UIButton buttonWithType:UIButtonTypeCustom]; - flagButton.frame = CGRectMake(rightButtonX, BUTTON_Y, iconButtonWidth, BUTTON_HEIGHT); - //[flagButton setImage:[UIImage imageNamed:@"Reader-Mark-N"] forState:UIControlStateNormal]; - [flagButton addTarget:self action:@selector(markButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; - [flagButton setBackgroundImage:buttonH forState:UIControlStateHighlighted]; - [flagButton setBackgroundImage:buttonN forState:UIControlStateNormal]; - flagButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin; - //flagButton.backgroundColor = [UIColor grayColor]; - flagButton.exclusiveTouch = YES; - - [self addSubview:flagButton]; titleWidth -= (iconButtonWidth + buttonSpacing); - - markButton = flagButton; markButton.enabled = NO; markButton.tag = NSIntegerMin; - - markImageN = [UIImage imageNamed:@"Reader-Mark-N"]; // N image - markImageY = [UIImage imageNamed:@"Reader-Mark-Y"]; // Y image - -#endif // end of READER_BOOKMARKS Option - - if (document.canEmail == YES) // Document email enabled - { - if ([MFMailComposeViewController canSendMail] == YES) // Can email - { - unsigned long long fileSize = [document.fileSize unsignedLongLongValue]; - - if (fileSize < 15728640ull) // Check attachment size limit (15MB) - { - rightButtonX -= (iconButtonWidth + buttonSpacing); // Next position - - UIButton *emailButton = [UIButton buttonWithType:UIButtonTypeCustom]; - emailButton.frame = CGRectMake(rightButtonX, BUTTON_Y, iconButtonWidth, BUTTON_HEIGHT); - [emailButton setImage:[UIImage imageNamed:@"Reader-Email"] forState:UIControlStateNormal]; - [emailButton addTarget:self action:@selector(emailButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; - [emailButton setBackgroundImage:buttonH forState:UIControlStateHighlighted]; - [emailButton setBackgroundImage:buttonN forState:UIControlStateNormal]; - emailButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin; - //emailButton.backgroundColor = [UIColor grayColor]; - emailButton.exclusiveTouch = YES; - - [self addSubview:emailButton]; titleWidth -= (iconButtonWidth + buttonSpacing); - } - } - } - - if ((document.canPrint == YES) && (document.password == nil)) // Document print enabled - { - Class printInteractionController = NSClassFromString(@"UIPrintInteractionController"); - - if ((printInteractionController != nil) && [printInteractionController isPrintingAvailable]) - { - rightButtonX -= (iconButtonWidth + buttonSpacing); // Next position - - UIButton *printButton = [UIButton buttonWithType:UIButtonTypeCustom]; - printButton.frame = CGRectMake(rightButtonX, BUTTON_Y, iconButtonWidth, BUTTON_HEIGHT); - [printButton setImage:[UIImage imageNamed:@"Reader-Print"] forState:UIControlStateNormal]; - [printButton addTarget:self action:@selector(printButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; - [printButton setBackgroundImage:buttonH forState:UIControlStateHighlighted]; - [printButton setBackgroundImage:buttonN forState:UIControlStateNormal]; - printButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin; - //printButton.backgroundColor = [UIColor grayColor]; - printButton.exclusiveTouch = YES; - - [self addSubview:printButton]; titleWidth -= (iconButtonWidth + buttonSpacing); - } - } - - if (document.canExport == YES) // Document export enabled - { - rightButtonX -= (iconButtonWidth + buttonSpacing); // Next position - - UIButton *exportButton = [UIButton buttonWithType:UIButtonTypeCustom]; - exportButton.frame = CGRectMake(rightButtonX, BUTTON_Y, iconButtonWidth, BUTTON_HEIGHT); - [exportButton setImage:[UIImage imageNamed:@"Reader-Export"] forState:UIControlStateNormal]; - [exportButton addTarget:self action:@selector(exportButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; - [exportButton setBackgroundImage:buttonH forState:UIControlStateHighlighted]; - [exportButton setBackgroundImage:buttonN forState:UIControlStateNormal]; - exportButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin; - //exportButton.backgroundColor = [UIColor grayColor]; - exportButton.exclusiveTouch = YES; - - [self addSubview:exportButton]; titleWidth -= (iconButtonWidth + buttonSpacing); - } - - if (largeDevice == YES) // Show document filename in toolbar - { - CGRect titleRect = CGRectMake(titleX, BUTTON_Y, titleWidth, TITLE_HEIGHT); - - UILabel *titleLabel = [[UILabel alloc] initWithFrame:titleRect]; - - titleLabel.textAlignment = NSTextAlignmentCenter; - titleLabel.font = [UIFont systemFontOfSize:TITLE_FONT_SIZE]; - titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth; - titleLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters; - titleLabel.textColor = [UIColor colorWithWhite:0.0f alpha:1.0f]; - titleLabel.backgroundColor = [UIColor clearColor]; - titleLabel.adjustsFontSizeToFitWidth = YES; - titleLabel.minimumScaleFactor = 0.75f; - titleLabel.text = [document.fileName stringByDeletingPathExtension]; -#if (READER_FLAT_UI == FALSE) // Option - titleLabel.shadowColor = [UIColor colorWithWhite:0.75f alpha:1.0f]; - titleLabel.shadowOffset = CGSizeMake(0.0f, 1.0f); -#endif // end of READER_FLAT_UI Option - - [self addSubview:titleLabel]; - } - } - - return self; -} - -- (void)setBookmarkState:(BOOL)state -{ -#if (READER_BOOKMARKS == TRUE) // Option - - if (state != markButton.tag) // Only if different state - { - if (self.hidden == NO) // Only if toolbar is visible - { - UIImage *image = (state ? markImageY : markImageN); - - [markButton setImage:image forState:UIControlStateNormal]; - } - - markButton.tag = state; // Update bookmarked state tag - } - - if (markButton.enabled == NO) markButton.enabled = YES; - -#endif // end of READER_BOOKMARKS Option -} - -- (void)updateBookmarkImage -{ -#if (READER_BOOKMARKS == TRUE) // Option - - if (markButton.tag != NSIntegerMin) // Valid tag - { - BOOL state = markButton.tag; // Bookmarked state - - UIImage *image = (state ? markImageY : markImageN); - - [markButton setImage:image forState:UIControlStateNormal]; - } - - if (markButton.enabled == NO) markButton.enabled = YES; - -#endif // end of READER_BOOKMARKS Option -} - -- (void)hideToolbar -{ - if (self.hidden == NO) - { - [UIView animateWithDuration:0.25 delay:0.0 - options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction - animations:^(void) - { - self.alpha = 0.0f; - } - completion:^(BOOL finished) - { - self.hidden = YES; - } - ]; - } -} - -- (void)showToolbar -{ - if (self.hidden == YES) - { - [self updateBookmarkImage]; // First - - [UIView animateWithDuration:0.25 delay:0.0 - options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction - animations:^(void) - { - self.hidden = NO; - self.alpha = 1.0f; - } - completion:NULL - ]; - } -} - -#pragma mark - UIButton action methods - -- (void)doneButtonTapped:(UIButton *)button -{ - [delegate tappedInToolbar:self doneButton:button]; -} - -- (void)thumbsButtonTapped:(UIButton *)button -{ - [delegate tappedInToolbar:self thumbsButton:button]; -} - -- (void)exportButtonTapped:(UIButton *)button -{ - [delegate tappedInToolbar:self exportButton:button]; -} - -- (void)printButtonTapped:(UIButton *)button -{ - [delegate tappedInToolbar:self printButton:button]; -} - -- (void)emailButtonTapped:(UIButton *)button -{ - [delegate tappedInToolbar:self emailButton:button]; -} - -- (void)markButtonTapped:(UIButton *)button -{ - [delegate tappedInToolbar:self markButton:button]; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbCache.h b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbCache.h deleted file mode 100755 index 948022d66..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbCache.h +++ /dev/null @@ -1,54 +0,0 @@ -// -// ReaderThumbCache.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -#import "ReaderThumbRequest.h" - -@interface ReaderThumbCache : NSObject <NSObject> - -+ (ReaderThumbCache *)sharedInstance; - -+ (void)touchThumbCacheWithGUID:(NSString *)guid; - -+ (void)createThumbCacheWithGUID:(NSString *)guid; - -+ (void)removeThumbCacheWithGUID:(NSString *)guid; - -+ (void)purgeThumbCachesOlderThan:(NSTimeInterval)age; - -+ (NSString *)thumbCachePathForGUID:(NSString *)guid; - -- (id)thumbRequest:(ReaderThumbRequest *)request priority:(BOOL)priority; - -- (void)setObject:(UIImage *)image forKey:(NSString *)key; - -- (void)removeObjectForKey:(NSString *)key; - -- (void)removeNullForKey:(NSString *)key; - -- (void)removeAllObjects; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbCache.m b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbCache.m deleted file mode 100755 index 5f0220460..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbCache.m +++ /dev/null @@ -1,228 +0,0 @@ -// -// ReaderThumbCache.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderThumbCache.h" -#import "ReaderThumbQueue.h" -#import "ReaderThumbFetch.h" -#import "ReaderThumbView.h" - -@implementation ReaderThumbCache -{ - NSCache *thumbCache; -} - -#pragma mark - Constants - -#define CACHE_SIZE 2097152 - -#pragma mark - ReaderThumbCache class methods - -+ (ReaderThumbCache *)sharedInstance -{ - static dispatch_once_t predicate = 0; - - static ReaderThumbCache *object = nil; // Object - - dispatch_once(&predicate, ^{ object = [self new]; }); - - return object; // ReaderThumbCache singleton -} - -+ (NSString *)appCachesPath -{ - static dispatch_once_t predicate = 0; - - static NSString *theCachesPath = nil; // Application caches path string - - dispatch_once(&predicate, // Save a copy of the application caches path the first time it is needed - ^{ - NSArray *cachesPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); - - theCachesPath = [[cachesPaths objectAtIndex:0] copy]; // Keep a copy for later abusage - }); - - return theCachesPath; -} - -+ (NSString *)thumbCachePathForGUID:(NSString *)guid -{ - NSString *cachesPath = [ReaderThumbCache appCachesPath]; // Caches path - - return [cachesPath stringByAppendingPathComponent:guid]; // Append GUID -} - -+ (void)createThumbCacheWithGUID:(NSString *)guid -{ - NSFileManager *fileManager = [NSFileManager new]; // File manager instance - - NSString *cachePath = [ReaderThumbCache thumbCachePathForGUID:guid]; // Thumb cache path - - [fileManager createDirectoryAtPath:cachePath withIntermediateDirectories:NO attributes:nil error:NULL]; -} - -+ (void)removeThumbCacheWithGUID:(NSString *)guid -{ - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), - ^{ - NSFileManager *fileManager = [NSFileManager new]; // File manager instance - - NSString *cachePath = [ReaderThumbCache thumbCachePathForGUID:guid]; // Thumb cache path - - [fileManager removeItemAtPath:cachePath error:NULL]; // Remove thumb cache directory - }); -} - -+ (void)touchThumbCacheWithGUID:(NSString *)guid -{ - NSFileManager *fileManager = [NSFileManager new]; // File manager instance - - NSString *cachePath = [ReaderThumbCache thumbCachePathForGUID:guid]; // Thumb cache path - - NSDictionary *attributes = [NSDictionary dictionaryWithObject:[NSDate date] forKey:NSFileModificationDate]; - - [fileManager setAttributes:attributes ofItemAtPath:cachePath error:NULL]; // New modification date -} - -+ (void)purgeThumbCachesOlderThan:(NSTimeInterval)age -{ - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), - ^{ - NSDate *now = [NSDate date]; // Right about now time - - NSString *cachesPath = [ReaderThumbCache appCachesPath]; // Caches path - - NSFileManager *fileManager = [NSFileManager new]; // File manager instance - - NSArray *cachesList = [fileManager contentsOfDirectoryAtPath:cachesPath error:NULL]; - - if (cachesList != nil) // Process caches directory contents - { - for (NSString *cacheName in cachesList) // Enumerate directory contents - { - if (cacheName.length == 36) // This is a very hacky cache ident kludge - { - NSString *cachePath = [cachesPath stringByAppendingPathComponent:cacheName]; - - NSDictionary *attributes = [fileManager attributesOfItemAtPath:cachePath error:NULL]; - - NSDate *cacheDate = [attributes objectForKey:NSFileModificationDate]; // Cache date - - NSTimeInterval seconds = [now timeIntervalSinceDate:cacheDate]; // Cache age - - if (seconds > age) // Older than so remove the thumb cache - { - [fileManager removeItemAtPath:cachePath error:NULL]; - - #ifdef DEBUG - NSLog(@"%s purged %@", __FUNCTION__, cacheName); - #endif - } - } - } - } - }); -} - -#pragma mark - ReaderThumbCache instance methods - -- (instancetype)init -{ - if ((self = [super init])) // Initialize - { - thumbCache = [NSCache new]; // Cache - - [thumbCache setName:@"ReaderThumbCache"]; - - [thumbCache setTotalCostLimit:CACHE_SIZE]; - } - - return self; -} - -- (id)thumbRequest:(ReaderThumbRequest *)request priority:(BOOL)priority -{ - @synchronized(thumbCache) // Mutex lock - { - id object = [thumbCache objectForKey:request.cacheKey]; - - if (object == nil) // Thumb object does not yet exist in the cache - { - object = [NSNull null]; // Return an NSNull thumb placeholder object - - [thumbCache setObject:object forKey:request.cacheKey cost:2]; // Cache the placeholder object - - ReaderThumbFetch *thumbFetch = [[ReaderThumbFetch alloc] initWithRequest:request]; // Create a thumb fetch operation - - [thumbFetch setQueuePriority:(priority ? NSOperationQueuePriorityNormal : NSOperationQueuePriorityLow)]; // Queue priority - - request.thumbView.operation = thumbFetch; [thumbFetch setThreadPriority:(priority ? 0.55 : 0.35)]; // Thread priority - - [[ReaderThumbQueue sharedInstance] addLoadOperation:thumbFetch]; // Queue the operation - } - - return object; // NSNull or UIImage - } -} - -- (void)setObject:(UIImage *)image forKey:(NSString *)key -{ - @synchronized(thumbCache) // Mutex lock - { - NSUInteger bytes = (image.size.width * image.size.height * 4.0f); - - [thumbCache setObject:image forKey:key cost:bytes]; // Cache image - } -} - -- (void)removeObjectForKey:(NSString *)key -{ - @synchronized(thumbCache) // Mutex lock - { - [thumbCache removeObjectForKey:key]; - } -} - -- (void)removeNullForKey:(NSString *)key -{ - @synchronized(thumbCache) // Mutex lock - { - id object = [thumbCache objectForKey:key]; - - if ([object isMemberOfClass:[NSNull class]]) - { - [thumbCache removeObjectForKey:key]; - } - } -} - -- (void)removeAllObjects -{ - @synchronized(thumbCache) // Mutex lock - { - [thumbCache removeAllObjects]; - } -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbFetch.h b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbFetch.h deleted file mode 100755 index 39f077070..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbFetch.h +++ /dev/null @@ -1,36 +0,0 @@ -// -// ReaderThumbFetch.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <Foundation/Foundation.h> - -#import "ReaderThumbQueue.h" - -@class ReaderThumbRequest; - -@interface ReaderThumbFetch : ReaderThumbOperation - -- (instancetype)initWithRequest:(ReaderThumbRequest *)options; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbFetch.m b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbFetch.m deleted file mode 100755 index 83593aca6..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbFetch.m +++ /dev/null @@ -1,128 +0,0 @@ -// -// ReaderThumbFetch.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderThumbFetch.h" -#import "ReaderThumbRender.h" -#import "ReaderThumbCache.h" -#import "ReaderThumbView.h" - -#import <ImageIO/ImageIO.h> - -@implementation ReaderThumbFetch -{ - ReaderThumbRequest *request; -} - -#pragma mark - ReaderThumbFetch instance methods - -- (instancetype)initWithRequest:(ReaderThumbRequest *)options -{ - if ((self = [super initWithGUID:options.guid])) - { - request = options; - } - - return self; -} - -- (void)cancel -{ - [super cancel]; // Cancel the operation - - request.thumbView.operation = nil; // Break retain loop - - request.thumbView = nil; // Release target thumb view on cancel - - [[ReaderThumbCache sharedInstance] removeNullForKey:request.cacheKey]; -} - -- (NSURL *)thumbFileURL -{ - NSString *cachePath = [ReaderThumbCache thumbCachePathForGUID:request.guid]; // Thumb cache path - - NSString *fileName = [[NSString alloc] initWithFormat:@"%@.png", request.thumbName]; // Thumb file name - - return [NSURL fileURLWithPath:[cachePath stringByAppendingPathComponent:fileName]]; // File URL -} - -- (void)main -{ - CGImageRef imageRef = NULL; NSURL *thumbURL = [self thumbFileURL]; - - CGImageSourceRef loadRef = CGImageSourceCreateWithURL((__bridge CFURLRef)thumbURL, NULL); - - if (loadRef != NULL) // Load the existing thumb image - { - imageRef = CGImageSourceCreateImageAtIndex(loadRef, 0, NULL); // Load it - - CFRelease(loadRef); // Release CGImageSource reference - } - else // Existing thumb image not found - so create and queue up a thumb render operation on the work queue - { - ReaderThumbRender *thumbRender = [[ReaderThumbRender alloc] initWithRequest:request]; // Create a thumb render operation - - [thumbRender setQueuePriority:self.queuePriority]; [thumbRender setThreadPriority:(self.threadPriority - 0.1)]; // Priority - - if (self.isCancelled == NO) // We're not cancelled - so update things and add the render operation to the work queue - { - request.thumbView.operation = thumbRender; // Update the thumb view operation property to the new operation - - [[ReaderThumbQueue sharedInstance] addWorkOperation:thumbRender]; return; // Queue the operation - } - } - - if (imageRef != NULL) // Create a UIImage from a CGImage and show it - { - UIImage *image = [UIImage imageWithCGImage:imageRef scale:request.scale orientation:UIImageOrientationUp]; - - CGImageRelease(imageRef); // Release the CGImage reference from the above thumb load code - - UIGraphicsBeginImageContextWithOptions(image.size, YES, request.scale); // Graphics context - - [image drawAtPoint:CGPointZero]; // Decode and draw the image on this background thread - - UIImage *decoded = UIGraphicsGetImageFromCurrentImageContext(); // Newly decoded image - - UIGraphicsEndImageContext(); // Cleanup after the bitmap-based graphics drawing context - - [[ReaderThumbCache sharedInstance] setObject:decoded forKey:request.cacheKey]; // Cache it - - if (self.isCancelled == NO) // Show the image in the target thumb view on the main thread - { - ReaderThumbView *thumbView = request.thumbView; // Target thumb view for image show - - NSUInteger targetTag = request.targetTag; // Target reference tag for image show - - dispatch_async(dispatch_get_main_queue(), // Queue image show on main thread - ^{ - if (thumbView.targetTag == targetTag) [thumbView showImage:decoded]; - }); - } - } - - request.thumbView.operation = nil; // Break retain loop -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbQueue.h b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbQueue.h deleted file mode 100755 index 9532813b4..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbQueue.h +++ /dev/null @@ -1,54 +0,0 @@ -// -// ReaderThumbQueue.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <Foundation/Foundation.h> - -@interface ReaderThumbQueue : NSObject <NSObject> - -+ (ReaderThumbQueue *)sharedInstance; - -- (void)addLoadOperation:(NSOperation *)operation; - -- (void)addWorkOperation:(NSOperation *)operation; - -- (void)cancelOperationsWithGUID:(NSString *)guid; - -- (void)cancelAllOperations; - -@end - -#pragma mark - - -// -// ReaderThumbOperation class interface -// - -@interface ReaderThumbOperation : NSOperation - -@property (nonatomic, strong, readonly) NSString *guid; - -- (instancetype)initWithGUID:(NSString *)guid; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbQueue.m b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbQueue.m deleted file mode 100755 index dc256ab30..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbQueue.m +++ /dev/null @@ -1,141 +0,0 @@ -// -// ReaderThumbQueue.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderThumbQueue.h" - -@implementation ReaderThumbQueue -{ - NSOperationQueue *loadQueue; - - NSOperationQueue *workQueue; -} - -#pragma mark - ReaderThumbQueue class methods - -+ (ReaderThumbQueue *)sharedInstance -{ - static dispatch_once_t predicate = 0; - - static ReaderThumbQueue *object = nil; // Object - - dispatch_once(&predicate, ^{ object = [self new]; }); - - return object; // ReaderThumbQueue singleton -} - -#pragma mark - ReaderThumbQueue instance methods - -- (instancetype)init -{ - if ((self = [super init])) // Initialize - { - loadQueue = [NSOperationQueue new]; - - [loadQueue setName:@"ReaderThumbLoadQueue"]; - - [loadQueue setMaxConcurrentOperationCount:1]; - - workQueue = [NSOperationQueue new]; - - [workQueue setName:@"ReaderThumbWorkQueue"]; - - [workQueue setMaxConcurrentOperationCount:1]; - } - - return self; -} - -- (void)addLoadOperation:(NSOperation *)operation -{ - if ([operation isKindOfClass:[ReaderThumbOperation class]]) - { - [loadQueue addOperation:operation]; // Add to load queue - } -} - -- (void)addWorkOperation:(NSOperation *)operation -{ - if ([operation isKindOfClass:[ReaderThumbOperation class]]) - { - [workQueue addOperation:operation]; // Add to work queue - } -} - -- (void)cancelOperationsWithGUID:(NSString *)guid -{ - [loadQueue setSuspended:YES]; [workQueue setSuspended:YES]; - - for (ReaderThumbOperation *operation in loadQueue.operations) - { - if ([operation isKindOfClass:[ReaderThumbOperation class]]) - { - if ([operation.guid isEqualToString:guid]) [operation cancel]; - } - } - - for (ReaderThumbOperation *operation in workQueue.operations) - { - if ([operation isKindOfClass:[ReaderThumbOperation class]]) - { - if ([operation.guid isEqualToString:guid]) [operation cancel]; - } - } - - [workQueue setSuspended:NO]; [loadQueue setSuspended:NO]; -} - -- (void)cancelAllOperations -{ - [loadQueue cancelAllOperations]; [workQueue cancelAllOperations]; -} - -@end - -#pragma mark - - -// -// ReaderThumbOperation class implementation -// - -@implementation ReaderThumbOperation -{ - NSString *_guid; -} - -@synthesize guid = _guid; - -#pragma mark - ReaderThumbOperation instance methods - -- (instancetype)initWithGUID:(NSString *)guid -{ - if ((self = [super init])) - { - _guid = guid; - } - - return self; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRender.h b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRender.h deleted file mode 100755 index 953b93ce9..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRender.h +++ /dev/null @@ -1,36 +0,0 @@ -// -// ReaderThumbRender.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <Foundation/Foundation.h> - -#import "ReaderThumbQueue.h" - -@class ReaderThumbRequest; - -@interface ReaderThumbRender : ReaderThumbOperation - -- (instancetype)initWithRequest:(ReaderThumbRequest *)options; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRender.m b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRender.m deleted file mode 100755 index fa01461b5..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRender.m +++ /dev/null @@ -1,204 +0,0 @@ -// -// ReaderThumbRender.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderThumbRender.h" -#import "ReaderThumbCache.h" -#import "ReaderThumbView.h" -#import "CGPDFDocument.h" - -#import <ImageIO/ImageIO.h> - -@implementation ReaderThumbRender -{ - ReaderThumbRequest *request; -} - -#pragma mark - ReaderThumbRender instance methods - -- (instancetype)initWithRequest:(ReaderThumbRequest *)options -{ - if ((self = [super initWithGUID:options.guid])) - { - request = options; - } - - return self; -} - -- (void)cancel -{ - [super cancel]; // Cancel the operation - - request.thumbView.operation = nil; // Break retain loop - - request.thumbView = nil; // Release target thumb view on cancel - - [[ReaderThumbCache sharedInstance] removeNullForKey:request.cacheKey]; -} - -- (NSURL *)thumbFileURL -{ - NSFileManager *fileManager = [NSFileManager new]; // File manager instance - - NSString *cachePath = [ReaderThumbCache thumbCachePathForGUID:request.guid]; // Thumb cache path - - [fileManager createDirectoryAtPath:cachePath withIntermediateDirectories:NO attributes:nil error:NULL]; - - NSString *fileName = [[NSString alloc] initWithFormat:@"%@.png", request.thumbName]; // Thumb file name - - return [NSURL fileURLWithPath:[cachePath stringByAppendingPathComponent:fileName]]; // File URL -} - -- (void)main -{ - NSInteger page = request.thumbPage; NSString *password = request.password; - - CGImageRef imageRef = NULL; CFURLRef fileURL = (__bridge CFURLRef)request.fileURL; - - CGPDFDocumentRef thePDFDocRef = CGPDFDocumentCreateUsingUrl(fileURL, password); - - if (thePDFDocRef != NULL) // Check for non-NULL CGPDFDocumentRef - { - CGPDFPageRef thePDFPageRef = CGPDFDocumentGetPage(thePDFDocRef, page); - - if (thePDFPageRef != NULL) // Check for non-NULL CGPDFPageRef - { - CGFloat thumb_w = request.thumbSize.width; // Maximum thumb width - CGFloat thumb_h = request.thumbSize.height; // Maximum thumb height - - CGRect cropBoxRect = CGPDFPageGetBoxRect(thePDFPageRef, kCGPDFCropBox); - CGRect mediaBoxRect = CGPDFPageGetBoxRect(thePDFPageRef, kCGPDFMediaBox); - CGRect effectiveRect = CGRectIntersection(cropBoxRect, mediaBoxRect); - - NSInteger pageRotate = CGPDFPageGetRotationAngle(thePDFPageRef); // Angle - - CGFloat page_w = 0.0f; CGFloat page_h = 0.0f; // Rotated page size - - switch (pageRotate) // Page rotation (in degrees) - { - default: // Default case - case 0: case 180: // 0 and 180 degrees - { - page_w = effectiveRect.size.width; - page_h = effectiveRect.size.height; - break; - } - - case 90: case 270: // 90 and 270 degrees - { - page_h = effectiveRect.size.width; - page_w = effectiveRect.size.height; - break; - } - } - - CGFloat scale_w = (thumb_w / page_w); // Width scale - CGFloat scale_h = (thumb_h / page_h); // Height scale - - CGFloat scale = 0.0f; // Page to target thumb size scale - - if (page_h > page_w) - scale = ((thumb_h > thumb_w) ? scale_w : scale_h); // Portrait - else - scale = ((thumb_h < thumb_w) ? scale_h : scale_w); // Landscape - - NSInteger target_w = (page_w * scale); // Integer target thumb width - NSInteger target_h = (page_h * scale); // Integer target thumb height - - if (target_w % 2) target_w--; if (target_h % 2) target_h--; // Even - - target_w *= request.scale; target_h *= request.scale; // Screen scale - - CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB(); // RGB color space - - CGBitmapInfo bmi = (kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst); - - CGContextRef context = CGBitmapContextCreate(NULL, target_w, target_h, 8, 0, rgb, bmi); - - if (context != NULL) // Must have a valid custom CGBitmap context to draw into - { - CGRect thumbRect = CGRectMake(0.0f, 0.0f, target_w, target_h); // Target thumb rect - - CGContextSetRGBFillColor(context, 1.0f, 1.0f, 1.0f, 1.0f); CGContextFillRect(context, thumbRect); // White fill - - CGContextConcatCTM(context, CGPDFPageGetDrawingTransform(thePDFPageRef, kCGPDFCropBox, thumbRect, 0, true)); // Fit rect - - //CGContextSetRenderingIntent(context, kCGRenderingIntentDefault); CGContextSetInterpolationQuality(context, kCGInterpolationDefault); - - CGContextDrawPDFPage(context, thePDFPageRef); // Render the PDF page into the custom CGBitmap context - - imageRef = CGBitmapContextCreateImage(context); // Create CGImage from custom CGBitmap context - - CGContextRelease(context); // Release custom CGBitmap context reference - } - - CGColorSpaceRelease(rgb); // Release device RGB color space reference - } - - CGPDFDocumentRelease(thePDFDocRef); // Release CGPDFDocumentRef reference - } - - if (imageRef != NULL) // Create UIImage from CGImage and show it, then save thumb as PNG - { - UIImage *image = [UIImage imageWithCGImage:imageRef scale:request.scale orientation:UIImageOrientationUp]; - - [[ReaderThumbCache sharedInstance] setObject:image forKey:request.cacheKey]; // Update cache - - if (self.isCancelled == NO) // Show the image in the target thumb view on the main thread - { - ReaderThumbView *thumbView = request.thumbView; // Target thumb view for image show - - NSUInteger targetTag = request.targetTag; // Target reference tag for image show - - dispatch_async(dispatch_get_main_queue(), // Queue image show on main thread - ^{ - if (thumbView.targetTag == targetTag) [thumbView showImage:image]; - }); - } - - CFURLRef thumbURL = (__bridge CFURLRef)[self thumbFileURL]; // Thumb cache path with PNG file name URL - - CGImageDestinationRef thumbRef = CGImageDestinationCreateWithURL(thumbURL, (CFStringRef)@"public.png", 1, NULL); - - if (thumbRef != NULL) // Write the thumb image file out to the thumb cache directory - { - CGImageDestinationAddImage(thumbRef, imageRef, NULL); // Add the image - - CGImageDestinationFinalize(thumbRef); // Finalize the image file - - CFRelease(thumbRef); // Release CGImageDestination reference - } - - CGImageRelease(imageRef); // Release CGImage reference - } - else // No image - so remove the placeholder object from the cache - { - [[ReaderThumbCache sharedInstance] removeNullForKey:request.cacheKey]; - } - - request.thumbView.operation = nil; // Break retain loop -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRequest.h b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRequest.h deleted file mode 100755 index f4846d03f..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRequest.h +++ /dev/null @@ -1,45 +0,0 @@ -// -// ReaderThumbRequest.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -@class ReaderThumbView; - -@interface ReaderThumbRequest : NSObject <NSObject> - -@property (nonatomic, strong, readonly) NSURL *fileURL; -@property (nonatomic, strong, readonly) NSString *guid; -@property (nonatomic, strong, readonly) NSString *password; -@property (nonatomic, strong, readonly) NSString *cacheKey; -@property (nonatomic, strong, readonly) NSString *thumbName; -@property (nonatomic, strong, readwrite) ReaderThumbView *thumbView; -@property (nonatomic, assign, readonly) NSUInteger targetTag; -@property (nonatomic, assign, readonly) NSInteger thumbPage; -@property (nonatomic, assign, readonly) CGSize thumbSize; -@property (nonatomic, assign, readonly) CGFloat scale; - -+ (instancetype)newForView:(ReaderThumbView *)view fileURL:(NSURL *)url password:(NSString *)phrase guid:(NSString *)guid page:(NSInteger)page size:(CGSize)size; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRequest.m b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRequest.m deleted file mode 100755 index 93ed9ad2f..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRequest.m +++ /dev/null @@ -1,96 +0,0 @@ -// -// ReaderThumbRequest.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderThumbRequest.h" -#import "ReaderThumbView.h" - -@implementation ReaderThumbRequest -{ - NSURL *_fileURL; - - NSString *_guid; - - NSString *_password; - - NSString *_cacheKey; - - NSString *_thumbName; - - ReaderThumbView *_thumbView; - - NSUInteger _targetTag; - - NSInteger _thumbPage; - - CGSize _thumbSize; - - CGFloat _scale; -} - -#pragma mark - Properties - -@synthesize guid = _guid; -@synthesize fileURL = _fileURL; -@synthesize password = _password; -@synthesize thumbView = _thumbView; -@synthesize thumbPage = _thumbPage; -@synthesize thumbSize = _thumbSize; -@synthesize thumbName = _thumbName; -@synthesize targetTag = _targetTag; -@synthesize cacheKey = _cacheKey; -@synthesize scale = _scale; - -#pragma mark - ReaderThumbRequest class methods - -+ (instancetype)newForView:(ReaderThumbView *)view fileURL:(NSURL *)url password:(NSString *)phrase guid:(NSString *)guid page:(NSInteger)page size:(CGSize)size -{ - return [[ReaderThumbRequest alloc] initForView:view fileURL:url password:phrase guid:guid page:page size:size]; -} - -#pragma mark - ReaderThumbRequest instance methods - -- (instancetype)initForView:(ReaderThumbView *)view fileURL:(NSURL *)url password:(NSString *)phrase guid:(NSString *)guid page:(NSInteger)page size:(CGSize)size -{ - if ((self = [super init])) // Initialize object - { - NSInteger w = size.width; NSInteger h = size.height; - - _thumbView = view; _thumbPage = page; _thumbSize = size; - - _fileURL = [url copy]; _password = [phrase copy]; _guid = [guid copy]; - - _thumbName = [[NSString alloc] initWithFormat:@"%07i-%04ix%04i", (int)page, (int)w, (int)h]; - - _cacheKey = [[NSString alloc] initWithFormat:@"%@+%@", _thumbName, _guid]; - - _targetTag = [_cacheKey hash]; _thumbView.targetTag = _targetTag; - - _scale = [[UIScreen mainScreen] scale]; // Thumb screen scale - } - - return self; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbView.h b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbView.h deleted file mode 100755 index 42356819a..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbView.h +++ /dev/null @@ -1,45 +0,0 @@ -// -// ReaderThumbView.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -@interface ReaderThumbView : UIView -{ -@protected // Instance variables - - UIImageView *imageView; -} - -@property (atomic, strong, readwrite) NSOperation *operation; - -@property (nonatomic, assign, readwrite) NSUInteger targetTag; - -- (void)showImage:(UIImage *)image; - -- (void)showTouched:(BOOL)touched; - -- (void)reuse; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbView.m b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbView.m deleted file mode 100755 index 10c5c91cf..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbView.m +++ /dev/null @@ -1,93 +0,0 @@ -// -// ReaderThumbView.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderThumbView.h" - -@implementation ReaderThumbView -{ - NSOperation *_operation; - - NSUInteger _targetTag; -} - -#pragma mark - Properties - -@synthesize operation = _operation; -@synthesize targetTag = _targetTag; - -#pragma mark - ReaderThumbView instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) - { - self.autoresizesSubviews = NO; - self.userInteractionEnabled = NO; - self.contentMode = UIViewContentModeRedraw; - self.autoresizingMask = UIViewAutoresizingNone; - self.backgroundColor = [UIColor clearColor]; - - imageView = [[UIImageView alloc] initWithFrame:self.bounds]; - - imageView.autoresizesSubviews = NO; - imageView.userInteractionEnabled = NO; - imageView.autoresizingMask = UIViewAutoresizingNone; - imageView.contentMode = UIViewContentModeScaleAspectFit; - - [self addSubview:imageView]; - } - - return self; -} - -- (void)showImage:(UIImage *)image -{ - imageView.image = image; // Show image -} - -- (void)showTouched:(BOOL)touched -{ - // Implemented by ReaderThumbView subclass -} - -- (void)removeFromSuperview -{ - _targetTag = 0; // Clear target tag - - [self.operation cancel]; // Cancel operation - - [super removeFromSuperview]; // Remove view -} - -- (void)reuse -{ - _targetTag = 0; // Clear target tag - - [self.operation cancel]; // Cancel operation - - imageView.image = nil; // Release image -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbsView.h b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbsView.h deleted file mode 100755 index 6268770b2..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbsView.h +++ /dev/null @@ -1,68 +0,0 @@ -// -// ReaderThumbsView.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -#import "ReaderThumbView.h" - -@class ReaderThumbsView; - -@protocol ReaderThumbsViewDelegate <NSObject, UIScrollViewDelegate> - -@required // Delegate protocols - -- (NSUInteger)numberOfThumbsInThumbsView:(ReaderThumbsView *)thumbsView; - -- (id)thumbsView:(ReaderThumbsView *)thumbsView thumbCellWithFrame:(CGRect)frame; - -- (void)thumbsView:(ReaderThumbsView *)thumbsView updateThumbCell:(id)thumbCell forIndex:(NSInteger)index; - -- (void)thumbsView:(ReaderThumbsView *)thumbsView didSelectThumbWithIndex:(NSInteger)index; - -@optional // Delegate protocols - -- (void)thumbsView:(ReaderThumbsView *)thumbsView refreshThumbCell:(id)thumbCell forIndex:(NSInteger)index; - -- (void)thumbsView:(ReaderThumbsView *)thumbsView didPressThumbWithIndex:(NSInteger)index; - -@end - -@interface ReaderThumbsView : UIScrollView - -@property (nonatomic, weak, readwrite) id <ReaderThumbsViewDelegate> delegate; - -- (void)setThumbSize:(CGSize)thumbSize; - -- (void)reloadThumbsCenterOnIndex:(NSInteger)index; - -- (void)reloadThumbsContentOffset:(CGPoint)newContentOffset; - -- (void)refreshThumbWithIndex:(NSInteger)index; - -- (void)refreshVisibleThumbs; - -- (CGPoint)insetContentOffset; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbsView.m b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbsView.m deleted file mode 100755 index f2a59d5fb..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbsView.m +++ /dev/null @@ -1,545 +0,0 @@ -// -// ReaderThumbsView.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderThumbsView.h" - -@interface ReaderThumbsView () <UIScrollViewDelegate, UIGestureRecognizerDelegate> - -@end - -@implementation ReaderThumbsView -{ - CGPoint lastContentOffset; - - ReaderThumbView *touchedCell; - - NSMutableArray *thumbCellsQueue; - - NSMutableArray *thumbCellsVisible; - - NSInteger _thumbsX, _thumbsY, _thumbX; - - CGSize _thumbSize, _lastViewSize; - - NSUInteger _thumbCount; - - BOOL canUpdate; -} - -#pragma mark - Properties - -@synthesize delegate; - -#pragma mark - ReaderThumbsView instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) - { - self.scrollsToTop = NO; - self.autoresizesSubviews = NO; - self.delaysContentTouches = NO; - self.alwaysBounceVertical = YES; - self.contentMode = UIViewContentModeRedraw; - self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - self.backgroundColor = [UIColor clearColor]; - - [super setDelegate:self]; // Set the superclass UIScrollView delegate - - thumbCellsQueue = [NSMutableArray new]; thumbCellsVisible = [NSMutableArray new]; // Cell management arrays - - UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)]; - //tapGesture.numberOfTouchesRequired = 1; tapGesture.numberOfTapsRequired = 1; tapGesture.delegate = self; - [self addGestureRecognizer:tapGesture]; - - UILongPressGestureRecognizer *pressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handlePressGesture:)]; - pressGesture.minimumPressDuration = 0.8; //pressGesture.numberOfTouchesRequired = 1; pressGesture.delegate = self; - [self addGestureRecognizer:pressGesture]; - - lastContentOffset = CGPointMake(CGFLOAT_MIN, CGFLOAT_MIN); - } - - return self; -} - -- (void)requeueThumbCell:(ReaderThumbView *)tvCell -{ - [thumbCellsQueue addObject:tvCell]; - - [thumbCellsVisible removeObject:tvCell]; - - tvCell.tag = NSIntegerMin; tvCell.hidden = YES; - - [tvCell reuse]; // Reuse the cell -} - -- (void)requeueAllThumbCells -{ - if (thumbCellsVisible.count > 0) - { - NSArray *visible = [thumbCellsVisible copy]; - - for (ReaderThumbView *tvCell in visible) - { - [self requeueThumbCell:tvCell]; - } - } -} - -- (ReaderThumbView *)dequeueThumbCellWithFrame:(CGRect)frame -{ - ReaderThumbView *theCell = nil; - - if (thumbCellsQueue.count > 0) // Reuse existing cell - { - theCell = [thumbCellsQueue objectAtIndex:0]; - - [thumbCellsQueue removeObjectAtIndex:0]; // Dequeue it - - theCell.frame = frame; // Position the reused cell - } - else // Allocate a brand new thumb cell subclass for our use - { - theCell = [delegate thumbsView:self thumbCellWithFrame:frame]; - - //assert([theCell isKindOfClass:[ReaderThumbView class]]); - - theCell.tag = NSIntegerMin; theCell.hidden = YES; - - [self insertSubview:theCell atIndex:0]; // Add - } - - [thumbCellsVisible addObject:theCell]; - - return theCell; -} - -- (NSMutableIndexSet *)visibleIndexSetForContentOffset -{ - CGFloat minY = self.contentOffset.y; // Content offset - CGFloat maxY = (minY + self.bounds.size.height - 1.0f); - - NSInteger startRow = (minY / _thumbSize.height); // Start row - NSInteger finalRow = (maxY / _thumbSize.height); // Final row - - NSInteger startIndex = (startRow * _thumbsX); // Start index - NSInteger finalIndex = (finalRow * _thumbsX); // Final index - - finalIndex += (_thumbsX - 1); // Last index value in last row - - NSInteger maximumIndex = (_thumbCount - 1); // Maximum index value - - if (finalIndex > maximumIndex) finalIndex = maximumIndex; // Limit it - - NSRange indexRange = NSMakeRange(startIndex, (finalIndex - startIndex + 1)); - - return [NSMutableIndexSet indexSetWithIndexesInRange:indexRange]; -} - -- (ReaderThumbView *)thumbCellContainingPoint:(CGPoint)point -{ - ReaderThumbView *theCell = nil; - - for (ReaderThumbView *tvCell in thumbCellsVisible) - { - if (CGRectContainsPoint(tvCell.frame, point) == true) - { - theCell = tvCell; break; // Found it - } - } - - return theCell; -} - -- (CGRect)thumbCellFrameForIndex:(NSInteger)index -{ - CGRect thumbRect; thumbRect.size = _thumbSize; - - NSInteger thumbY = ((index / _thumbsX) * _thumbSize.height); // X, Y - - NSInteger thumbX = (((index % _thumbsX) * _thumbSize.width) + _thumbX); - - thumbRect.origin.x = thumbX; thumbRect.origin.y = thumbY; - - return thumbRect; -} - -- (void)updateContentSize:(NSUInteger)thumbCount -{ - canUpdate = NO; // Disable updates - - if (thumbCount > 0) // Have some thumbs - { - CGFloat bw = self.bounds.size.width; - - _thumbsX = (bw / _thumbSize.width); - - if (_thumbsX < 1) _thumbsX = 1; - - _thumbsY = (thumbCount / _thumbsX); - - if ((_thumbsX * _thumbsY) < thumbCount) _thumbsY++; - - CGFloat tw = (_thumbsX * _thumbSize.width); - CGFloat th = (_thumbsY * _thumbSize.height); - - if (tw < bw) - _thumbX = ((bw - tw) * 0.5f); - else - _thumbX = 0; // Reset - - if (tw < bw) tw = bw; // Limit - - [self setContentSize:CGSizeMake(tw, th)]; - } - else // Zero (0) thumbs - { - [self setContentSize:CGSizeZero]; - } - - canUpdate = YES; // Enable updates -} - -- (void)layoutSubviews -{ - if (CGSizeEqualToSize(_lastViewSize, CGSizeZero) == true) - { - _lastViewSize = self.bounds.size; // Initial view size - } - else - if (CGSizeEqualToSize(_lastViewSize, self.bounds.size) == false) - { - _lastViewSize = self.bounds.size; // Track the view size - - [self updateContentSize:_thumbCount]; // Update the content size - - NSMutableArray *requeueCells = [NSMutableArray array]; // Requeue cell list - - NSMutableIndexSet *visibleIndexSet = [self visibleIndexSetForContentOffset]; - - for (ReaderThumbView *tvCell in thumbCellsVisible) // Enumerate visible cells - { - NSInteger index = tvCell.tag; // Get the cell's index value - - if ([visibleIndexSet containsIndex:index] == YES) // Visible cell - { - tvCell.frame = [self thumbCellFrameForIndex:index]; // Frame - - [visibleIndexSet removeIndex:index]; // Remove from set - } - else // Add it to the list of cells to requeue - { - [requeueCells addObject:tvCell]; - } - } - - for (ReaderThumbView *tvCell in requeueCells) // Enumerate requeue cells - { - [self requeueThumbCell:tvCell]; // Requeue the thumb cell - } - - [visibleIndexSet enumerateIndexesUsingBlock: // Enumerate visible indexes - ^(NSUInteger index, BOOL *stop) - { - CGRect thumbRect = [self thumbCellFrameForIndex:index]; // Frame - - ReaderThumbView *tvCell = [self dequeueThumbCellWithFrame:thumbRect]; - - [delegate thumbsView:self updateThumbCell:tvCell forIndex:index]; - - tvCell.tag = index; tvCell.hidden = NO; // Tag and show it - } - ]; - } -} - -- (void)setThumbSize:(CGSize)thumbSize -{ - if (CGSizeEqualToSize(_thumbSize, CGSizeZero) == true) - { - if (CGSizeEqualToSize(thumbSize, CGSizeZero) == false) - { - _thumbSize = thumbSize; // Set the maximum thumb size - } - } -} - -- (void)reloadThumbsCenterOnIndex:(NSInteger)index -{ - assert(delegate != nil); // Check delegate - - assert(CGSizeEqualToSize(_thumbSize, CGSizeZero) == false); - - if (self.decelerating == YES) // Stop scroll view movement - { - [self setContentOffset:self.contentOffset animated:NO]; - } - - CGPoint newContentOffset = CGPointZero; // At top - - lastContentOffset = CGPointMake(CGFLOAT_MIN, CGFLOAT_MIN); - - [self requeueAllThumbCells]; // Start off fresh - - _thumbCount = 0; // Reset the thumb count to zero - - NSUInteger thumbCount = [delegate numberOfThumbsInThumbsView:self]; - - [self updateContentSize:thumbCount]; _thumbCount = thumbCount; - - if (thumbCount > 0) // Have some thumbs - { - NSInteger boundsHeight = self.bounds.size.height; - - NSInteger maxY = (self.contentSize.height - boundsHeight); - - NSInteger minY = 0; maxY--; if (maxY < minY) maxY = minY; // Limits - - if (index < 0) index = 0; else if (index > thumbCount) index = (thumbCount - 1); - - NSInteger thumbY = ((index / _thumbsX) * _thumbSize.height); // Thumb Y - - NSInteger offsetY = (thumbY - (boundsHeight / 2) + (_thumbSize.height / 2)); - - if (offsetY < minY) offsetY = minY; else if (offsetY > maxY) offsetY = maxY; - - newContentOffset.y = offsetY; // Calculated content offset Y position - } - - newContentOffset.y -= self.contentInset.top; // Content inset adjust - - if (CGPointEqualToPoint(self.contentOffset, newContentOffset) == false) - [self setContentOffset:newContentOffset animated:NO]; - else - [self scrollViewDidScroll:self]; - - [self flashScrollIndicators]; -} - -- (void)reloadThumbsContentOffset:(CGPoint)newContentOffset -{ - assert(delegate != nil); // Check delegate - - assert(CGSizeEqualToSize(_thumbSize, CGSizeZero) == false); - - if (self.decelerating == YES) // Stop scroll view movement - { - [self setContentOffset:self.contentOffset animated:NO]; - } - - lastContentOffset = CGPointMake(CGFLOAT_MIN, CGFLOAT_MIN); - - [self requeueAllThumbCells]; // Start off fresh - - _thumbCount = 0; // Reset the thumb count to zero - - NSUInteger thumbCount = [delegate numberOfThumbsInThumbsView:self]; - - [self updateContentSize:thumbCount]; _thumbCount = thumbCount; - - if (thumbCount > 0) // Have some thumbs - { - NSInteger boundsHeight = self.bounds.size.height; - - NSInteger maxY = (self.contentSize.height - boundsHeight); - - NSInteger minY = 0; maxY--; if (maxY < minY) maxY = minY; // Limits - - NSInteger offsetY = newContentOffset.y; // Requested content offset Y - - if (offsetY < minY) offsetY = minY; else if (offsetY > maxY) offsetY = maxY; - - newContentOffset.y = offsetY; newContentOffset.x = 0.0f; // Validated - } - else // Zero (0) thumbs - { - newContentOffset = CGPointZero; - } - - newContentOffset.y -= self.contentInset.top; // Content inset adjust - - if (CGPointEqualToPoint(self.contentOffset, newContentOffset) == false) - [self setContentOffset:newContentOffset animated:NO]; - else - [self scrollViewDidScroll:self]; - - [self flashScrollIndicators]; -} - -- (void)refreshThumbWithIndex:(NSInteger)index -{ - for (ReaderThumbView *tvCell in thumbCellsVisible) // Enumerate visible cells - { - if (tvCell.tag == index) // Found a visible thumb cell with the index value - { - if ([delegate respondsToSelector:@selector(thumbsView:refreshThumbCell:forIndex:)]) - { - [delegate thumbsView:self refreshThumbCell:tvCell forIndex:index]; // Refresh - } - - break; - } - } -} - -- (void)refreshVisibleThumbs -{ - for (ReaderThumbView *tvCell in thumbCellsVisible) // Enumerate visible cells - { - if ([delegate respondsToSelector:@selector(thumbsView:refreshThumbCell:forIndex:)]) - { - [delegate thumbsView:self refreshThumbCell:tvCell forIndex:tvCell.tag]; // Refresh - } - } -} - -- (CGPoint)insetContentOffset -{ - CGPoint insetContentOffset = self.contentOffset; // Offset - - insetContentOffset.y += self.contentInset.top; // Inset adjust - - return insetContentOffset; // Adjusted content offset -} - -#pragma mark - UIGestureRecognizer action methods - -- (void)handleTapGesture:(UITapGestureRecognizer *)recognizer -{ - if (recognizer.state == UIGestureRecognizerStateRecognized) // Handle the tap - { - CGPoint point = [recognizer locationInView:recognizer.view]; // Tap location - - ReaderThumbView *tvCell = [self thumbCellContainingPoint:point]; // Look for cell - - if (tvCell != nil) [delegate thumbsView:self didSelectThumbWithIndex:tvCell.tag]; - } -} - -- (void)handlePressGesture:(UILongPressGestureRecognizer *)recognizer -{ - if (recognizer.state == UIGestureRecognizerStateBegan) // Handle the press - { - if ([delegate respondsToSelector:@selector(thumbsView:didPressThumbWithIndex:)]) - { - CGPoint point = [recognizer locationInView:recognizer.view]; // Press location - - ReaderThumbView *tvCell = [self thumbCellContainingPoint:point]; // Look for cell - - if (tvCell != nil) [delegate thumbsView:self didPressThumbWithIndex:tvCell.tag]; - } - } -} - -#pragma mark - UIScrollViewDelegate methods - -- (void)scrollViewDidScroll:(UIScrollView *)scrollView -{ - if ((canUpdate == YES) && (_thumbCount > 0)) // Check flag and thumb count - { - if (CGPointEqualToPoint(scrollView.contentOffset, lastContentOffset) == false) - { - lastContentOffset = scrollView.contentOffset; // Work around a 'feature' - - CGRect visibleBounds = self.bounds; // Visible bounds in the scroll view - - NSMutableArray *requeueCells = [NSMutableArray array]; // Requeue cell list - - NSMutableIndexSet *visibleCellSet = [NSMutableIndexSet indexSet]; // Visible set - - for (ReaderThumbView *tvCell in thumbCellsVisible) // Enumerate visible cells - { - if (CGRectIntersectsRect(tvCell.frame, visibleBounds) == true) - [visibleCellSet addIndex:tvCell.tag]; - else - [requeueCells addObject:tvCell]; - } - - for (ReaderThumbView *tvCell in requeueCells) // Enumerate requeue cells - { - [self requeueThumbCell:tvCell]; // Requeue the thumb cell - } - - NSMutableIndexSet *visibleIndexSet = [self visibleIndexSetForContentOffset]; - - [visibleIndexSet enumerateIndexesUsingBlock: // Enumerate visible indexes - ^(NSUInteger index, BOOL *stop) - { - if ([visibleCellSet containsIndex:index] == NO) // Index not visible - { - CGRect thumbRect = [self thumbCellFrameForIndex:index]; // Frame - - ReaderThumbView *tvCell = [self dequeueThumbCellWithFrame:thumbRect]; - - [delegate thumbsView:self updateThumbCell:tvCell forIndex:index]; - - tvCell.tag = index; tvCell.hidden = NO; // Tag and show it - } - } - ]; - } - } -} - -#pragma mark - UIResponder instance methods - -- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event -{ - [super touchesBegan:touches withEvent:event]; // Message superclass - - if (touchedCell != nil) { [touchedCell showTouched:NO]; touchedCell = nil; } - - if (touches.count == 1) // Show selection on single touch - { - UITouch *touch = [touches anyObject]; // Get touch from set - - CGPoint point = [touch locationInView:touch.view]; // Touch location - - ReaderThumbView *tvCell = [self thumbCellContainingPoint:point]; // Look for cell - - if (tvCell != nil) { touchedCell = tvCell; [touchedCell showTouched:YES]; } - } -} - -- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event -{ - [super touchesCancelled:touches withEvent:event]; // Message superclass - - if (touchedCell != nil) { [touchedCell showTouched:NO]; touchedCell = nil; } -} - -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event -{ - [super touchesEnded:touches withEvent:event]; // Message superclass - - if (touchedCell != nil) { [touchedCell showTouched:NO]; touchedCell = nil; } -} - -- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event -{ - [super touchesMoved:touches withEvent:event]; // Message superclass -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderViewController.h b/Libraries external/VFR Pdf Reader/Sources/ReaderViewController.h deleted file mode 100755 index 3a54f5375..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderViewController.h +++ /dev/null @@ -1,48 +0,0 @@ -// -// ReaderViewController.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -#import "ReaderDocument.h" - -@class ReaderViewController; - -@protocol ReaderViewControllerDelegate <NSObject> - -@optional // Delegate protocols - -- (void)dismissReaderViewController:(ReaderViewController *)viewController; - -@end - -@interface ReaderViewController : UIViewController - -@property (nonatomic, weak, readwrite) id <ReaderViewControllerDelegate> delegate; - -- (instancetype)initWithReaderDocument:(ReaderDocument *)object; - -- (void)updateContentViews; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderViewController.m b/Libraries external/VFR Pdf Reader/Sources/ReaderViewController.m deleted file mode 100755 index b33a64553..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderViewController.m +++ /dev/null @@ -1,914 +0,0 @@ -// -// ReaderViewController.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderConstants.h" -#import "ReaderViewController.h" -#import "ThumbsViewController.h" -#import "ReaderMainToolbar.h" -#import "ReaderMainPagebar.h" -#import "ReaderContentView.h" -#import "ReaderThumbCache.h" -#import "ReaderThumbQueue.h" - -#import <MessageUI/MessageUI.h> - -@interface ReaderViewController () <UIScrollViewDelegate, UIGestureRecognizerDelegate, MFMailComposeViewControllerDelegate, UIDocumentInteractionControllerDelegate, - ReaderMainToolbarDelegate, ReaderMainPagebarDelegate, ReaderContentViewDelegate, ThumbsViewControllerDelegate> -@end - -@implementation ReaderViewController -{ - ReaderDocument *document; - - UIScrollView *theScrollView; - - ReaderMainToolbar *mainToolbar; - - ReaderMainPagebar *mainPagebar; - - NSMutableDictionary *contentViews; - - UIUserInterfaceIdiom userInterfaceIdiom; - - NSInteger currentPage, minimumPage, maximumPage; - - UIDocumentInteractionController *documentInteraction; - - UIPrintInteractionController *printInteraction; - - CGFloat scrollViewOutset; - - CGSize lastAppearSize; - - NSDate *lastHideTime; - - BOOL ignoreDidScroll; -} - -#pragma mark - Constants - -#define STATUS_HEIGHT 20.0f - -#define TOOLBAR_HEIGHT 44.0f -#define PAGEBAR_HEIGHT 48.0f - -#define SCROLLVIEW_OUTSET_SMALL 4.0f -#define SCROLLVIEW_OUTSET_LARGE 8.0f - -#define TAP_AREA_SIZE 48.0f - -#pragma mark - Properties - -@synthesize delegate; - -#pragma mark - ReaderViewController methods - -- (void)updateContentSize:(UIScrollView *)scrollView -{ - CGFloat contentHeight = scrollView.bounds.size.height; // Height - - CGFloat contentWidth = (scrollView.bounds.size.width * maximumPage); - - scrollView.contentSize = CGSizeMake(contentWidth, contentHeight); -} - -- (void)updateContentViews:(UIScrollView *)scrollView -{ - [self updateContentSize:scrollView]; // Update content size first - - [contentViews enumerateKeysAndObjectsUsingBlock: // Enumerate content views - ^(NSNumber *key, ReaderContentView *contentView, BOOL *stop) - { - NSInteger page = [key integerValue]; // Page number value - - CGRect viewRect = CGRectZero; viewRect.size = scrollView.bounds.size; - - viewRect.origin.x = (viewRect.size.width * (page - 1)); // Update X - - contentView.frame = CGRectInset(viewRect, scrollViewOutset, 0.0f); - } - ]; - - NSInteger page = currentPage; // Update scroll view offset to current page - - CGPoint contentOffset = CGPointMake((scrollView.bounds.size.width * (page - 1)), 0.0f); - - if (CGPointEqualToPoint(scrollView.contentOffset, contentOffset) == false) // Update - { - scrollView.contentOffset = contentOffset; // Update content offset - } - - [mainToolbar setBookmarkState:[document.bookmarks containsIndex:page]]; - - [mainPagebar updatePagebar]; // Update page bar -} - -- (void)addContentView:(UIScrollView *)scrollView page:(NSInteger)page -{ - CGRect viewRect = CGRectZero; viewRect.size = scrollView.bounds.size; - - viewRect.origin.x = (viewRect.size.width * (page - 1)); viewRect = CGRectInset(viewRect, scrollViewOutset, 0.0f); - - NSURL *fileURL = document.fileURL; NSString *phrase = document.password; NSString *guid = document.guid; // Document properties - - ReaderContentView *contentView = [[ReaderContentView alloc] initWithFrame:viewRect fileURL:fileURL page:page password:phrase]; // ReaderContentView - - contentView.message = self; [contentViews setObject:contentView forKey:[NSNumber numberWithInteger:page]]; [scrollView addSubview:contentView]; - - [contentView showPageThumb:fileURL page:page password:phrase guid:guid]; // Request page preview thumb -} - -- (void)layoutContentViews:(UIScrollView *)scrollView -{ - CGFloat viewWidth = scrollView.bounds.size.width; // View width - - CGFloat contentOffsetX = scrollView.contentOffset.x; // Content offset X - - NSInteger pageB = ((contentOffsetX + viewWidth - 1.0f) / viewWidth); // Pages - - NSInteger pageA = (contentOffsetX / viewWidth); pageB += 2; // Add extra pages - - if (pageA < minimumPage) pageA = minimumPage; if (pageB > maximumPage) pageB = maximumPage; - - NSRange pageRange = NSMakeRange(pageA, (pageB - pageA + 1)); // Make page range (A to B) - - NSMutableIndexSet *pageSet = [NSMutableIndexSet indexSetWithIndexesInRange:pageRange]; - - for (NSNumber *key in [contentViews allKeys]) // Enumerate content views - { - NSInteger page = [key integerValue]; // Page number value - - if ([pageSet containsIndex:page] == NO) // Remove content view - { - ReaderContentView *contentView = [contentViews objectForKey:key]; - - [contentView removeFromSuperview]; [contentViews removeObjectForKey:key]; - } - else // Visible content view - so remove it from page set - { - [pageSet removeIndex:page]; - } - } - - NSInteger pages = pageSet.count; - - if (pages > 0) // We have pages to add - { - NSEnumerationOptions options = 0; // Default - - if (pages == 2) // Handle case of only two content views - { - if ((maximumPage > 2) && ([pageSet lastIndex] == maximumPage)) options = NSEnumerationReverse; - } - else if (pages == 3) // Handle three content views - show the middle one first - { - NSMutableIndexSet *workSet = [pageSet mutableCopy]; options = NSEnumerationReverse; - - [workSet removeIndex:[pageSet firstIndex]]; [workSet removeIndex:[pageSet lastIndex]]; - - NSInteger page = [workSet firstIndex]; [pageSet removeIndex:page]; - - [self addContentView:scrollView page:page]; - } - - [pageSet enumerateIndexesWithOptions:options usingBlock: // Enumerate page set - ^(NSUInteger page, BOOL *stop) - { - [self addContentView:scrollView page:page]; - } - ]; - } -} - -- (void)handleScrollViewDidEnd:(UIScrollView *)scrollView -{ - CGFloat viewWidth = scrollView.bounds.size.width; // Scroll view width - - CGFloat contentOffsetX = scrollView.contentOffset.x; // Content offset X - - NSInteger page = (contentOffsetX / viewWidth); page++; // Page number - - if (page != currentPage) // Only if on different page - { - currentPage = page; document.pageNumber = [NSNumber numberWithInteger:page]; - - [contentViews enumerateKeysAndObjectsUsingBlock: // Enumerate content views - ^(NSNumber *key, ReaderContentView *contentView, BOOL *stop) - { - if ([key integerValue] != page) [contentView zoomResetAnimated:NO]; - } - ]; - - [mainToolbar setBookmarkState:[document.bookmarks containsIndex:page]]; - - [mainPagebar updatePagebar]; // Update page bar - } -} - -- (void)showDocumentPage:(NSInteger)page -{ - if (page != currentPage) // Only if on different page - { - if ((page < minimumPage) || (page > maximumPage)) return; - - currentPage = page; document.pageNumber = [NSNumber numberWithInteger:page]; - - CGPoint contentOffset = CGPointMake((theScrollView.bounds.size.width * (page - 1)), 0.0f); - - if (CGPointEqualToPoint(theScrollView.contentOffset, contentOffset) == true) - [self layoutContentViews:theScrollView]; - else - [theScrollView setContentOffset:contentOffset]; - - [contentViews enumerateKeysAndObjectsUsingBlock: // Enumerate content views - ^(NSNumber *key, ReaderContentView *contentView, BOOL *stop) - { - if ([key integerValue] != page) [contentView zoomResetAnimated:NO]; - } - ]; - - [mainToolbar setBookmarkState:[document.bookmarks containsIndex:page]]; - - [mainPagebar updatePagebar]; // Update page bar - } -} - -- (void)showDocument -{ - [self updateContentSize:theScrollView]; // Update content size first - - [self showDocumentPage:[document.pageNumber integerValue]]; // Show page - - document.lastOpen = [NSDate date]; // Update document last opened date -} - -- (void)closeDocument -{ - if (printInteraction != nil) [printInteraction dismissAnimated:NO]; - - [document archiveDocumentProperties]; // Save any ReaderDocument changes - - [[ReaderThumbQueue sharedInstance] cancelOperationsWithGUID:document.guid]; - - [[ReaderThumbCache sharedInstance] removeAllObjects]; // Empty the thumb cache - - if ([delegate respondsToSelector:@selector(dismissReaderViewController:)] == YES) - { - [delegate dismissReaderViewController:self]; // Dismiss the ReaderViewController - } - else // We have a "Delegate must respond to -dismissReaderViewController:" error - { - NSAssert(NO, @"Delegate must respond to -dismissReaderViewController:"); - } -} - -#pragma mark - UIViewController methods - -- (instancetype)initWithReaderDocument:(ReaderDocument *)object -{ - if ((self = [super initWithNibName:nil bundle:nil])) // Initialize superclass - { - if ((object != nil) && ([object isKindOfClass:[ReaderDocument class]])) // Valid object - { - userInterfaceIdiom = [UIDevice currentDevice].userInterfaceIdiom; // User interface idiom - - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; // Default notification center - - [notificationCenter addObserver:self selector:@selector(applicationWillResign:) name:UIApplicationWillTerminateNotification object:nil]; - - [notificationCenter addObserver:self selector:@selector(applicationWillResign:) name:UIApplicationWillResignActiveNotification object:nil]; - - scrollViewOutset = ((userInterfaceIdiom == UIUserInterfaceIdiomPad) ? SCROLLVIEW_OUTSET_LARGE : SCROLLVIEW_OUTSET_SMALL); - - [object updateDocumentProperties]; document = object; // Retain the supplied ReaderDocument object for our use - - [ReaderThumbCache touchThumbCacheWithGUID:object.guid]; // Touch the document thumb cache directory - } - else // Invalid ReaderDocument object - { - self = nil; - } - } - - return self; -} - -- (void)dealloc -{ - [[NSNotificationCenter defaultCenter] removeObserver:self]; -} - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - assert(document != nil); // Must have a valid ReaderDocument - - self.view.backgroundColor = [UIColor grayColor]; // Neutral gray - - UIView *fakeStatusBar = nil; CGRect viewRect = self.view.bounds; // View bounds - - if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) // iOS 7+ - { - if ([self prefersStatusBarHidden] == NO) // Visible status bar - { - CGRect statusBarRect = viewRect; statusBarRect.size.height = STATUS_HEIGHT; - fakeStatusBar = [[UIView alloc] initWithFrame:statusBarRect]; // UIView - fakeStatusBar.autoresizingMask = UIViewAutoresizingFlexibleWidth; - fakeStatusBar.backgroundColor = [UIColor blackColor]; - fakeStatusBar.contentMode = UIViewContentModeRedraw; - fakeStatusBar.userInteractionEnabled = NO; - - viewRect.origin.y += STATUS_HEIGHT; viewRect.size.height -= STATUS_HEIGHT; - } - } - - CGRect scrollViewRect = CGRectInset(viewRect, -scrollViewOutset, 0.0f); - theScrollView = [[UIScrollView alloc] initWithFrame:scrollViewRect]; // All - theScrollView.autoresizesSubviews = NO; theScrollView.contentMode = UIViewContentModeRedraw; - theScrollView.showsHorizontalScrollIndicator = NO; theScrollView.showsVerticalScrollIndicator = NO; - theScrollView.scrollsToTop = NO; theScrollView.delaysContentTouches = NO; theScrollView.pagingEnabled = YES; - theScrollView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); - theScrollView.backgroundColor = [UIColor clearColor]; theScrollView.delegate = self; - [self.view addSubview:theScrollView]; - - CGRect toolbarRect = viewRect; toolbarRect.size.height = TOOLBAR_HEIGHT; - mainToolbar = [[ReaderMainToolbar alloc] initWithFrame:toolbarRect document:document]; // ReaderMainToolbar - mainToolbar.delegate = self; // ReaderMainToolbarDelegate - //TWS [self.view addSubview:mainToolbar]; - - CGRect pagebarRect = self.view.bounds; pagebarRect.size.height = PAGEBAR_HEIGHT; - pagebarRect.origin.y = (self.view.bounds.size.height - pagebarRect.size.height); - mainPagebar = [[ReaderMainPagebar alloc] initWithFrame:pagebarRect document:document]; // ReaderMainPagebar - mainPagebar.delegate = self; // ReaderMainPagebarDelegate - [self.view addSubview:mainPagebar]; - - if (fakeStatusBar != nil) [self.view addSubview:fakeStatusBar]; // Add status bar background view - - UITapGestureRecognizer *singleTapOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)]; - singleTapOne.numberOfTouchesRequired = 1; singleTapOne.numberOfTapsRequired = 1; singleTapOne.delegate = self; - [self.view addGestureRecognizer:singleTapOne]; - - UITapGestureRecognizer *doubleTapOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)]; - doubleTapOne.numberOfTouchesRequired = 1; doubleTapOne.numberOfTapsRequired = 2; doubleTapOne.delegate = self; - [self.view addGestureRecognizer:doubleTapOne]; - - UITapGestureRecognizer *doubleTapTwo = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)]; - doubleTapTwo.numberOfTouchesRequired = 2; doubleTapTwo.numberOfTapsRequired = 2; doubleTapTwo.delegate = self; - [self.view addGestureRecognizer:doubleTapTwo]; - - [singleTapOne requireGestureRecognizerToFail:doubleTapOne]; // Single tap requires double tap to fail - - contentViews = [NSMutableDictionary new]; lastHideTime = [NSDate date]; - - minimumPage = 1; maximumPage = [document.pageCount integerValue]; -} - -- (void)viewWillAppear:(BOOL)animated -{ - [super viewWillAppear:animated]; - - if (CGSizeEqualToSize(lastAppearSize, CGSizeZero) == false) - { - if (CGSizeEqualToSize(lastAppearSize, self.view.bounds.size) == false) - { - [self updateContentViews:theScrollView]; // Update content views - } - - lastAppearSize = CGSizeZero; // Reset view size tracking - } - - //TWS (IOS7) - self.tabBarController.tabBar.hidden = YES; -} - -- (void)viewDidAppear:(BOOL)animated -{ - [super viewDidAppear:animated]; - - if (CGSizeEqualToSize(theScrollView.contentSize, CGSizeZero) == true) - { - [self performSelector:@selector(showDocument) withObject:nil afterDelay:0.0]; - } - -#if (READER_DISABLE_IDLE == TRUE) // Option - - [UIApplication sharedApplication].idleTimerDisabled = YES; - -#endif // end of READER_DISABLE_IDLE Option -} - -- (void)viewWillDisappear:(BOOL)animated -{ - [super viewWillDisappear:animated]; - - lastAppearSize = self.view.bounds.size; // Track view size - -#if (READER_DISABLE_IDLE == TRUE) // Option - - [UIApplication sharedApplication].idleTimerDisabled = NO; - -#endif // end of READER_DISABLE_IDLE Option -} - -- (void)viewDidDisappear:(BOOL)animated -{ - [super viewDidDisappear:animated]; -} - -- (void)viewDidUnload -{ -#ifdef DEBUG - NSLog(@"%s", __FUNCTION__); -#endif - - mainToolbar = nil; mainPagebar = nil; - - theScrollView = nil; contentViews = nil; lastHideTime = nil; - - documentInteraction = nil; printInteraction = nil; - - lastAppearSize = CGSizeZero; currentPage = 0; - - [super viewDidUnload]; -} - -- (BOOL)prefersStatusBarHidden -{ - return YES; -} - -- (UIStatusBarStyle)preferredStatusBarStyle -{ - return UIStatusBarStyleLightContent; -} - -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation -{ - return YES; -} - -- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration -{ - if (userInterfaceIdiom == UIUserInterfaceIdiomPad) if (printInteraction != nil) [printInteraction dismissAnimated:NO]; - - ignoreDidScroll = YES; -} - -- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration -{ - if (CGSizeEqualToSize(theScrollView.contentSize, CGSizeZero) == false) - { - [self updateContentViews:theScrollView]; lastAppearSize = CGSizeZero; - } -} - -- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation -{ - ignoreDidScroll = NO; -} - -- (void)updateContentViews -{ - if (currentPage > 0) { - [self updateContentViews:theScrollView]; - } -} - -- (void)didReceiveMemoryWarning -{ -#ifdef DEBUG - NSLog(@"%s", __FUNCTION__); -#endif - - [super didReceiveMemoryWarning]; -} - -#pragma mark - UIScrollViewDelegate methods - -- (void)scrollViewDidScroll:(UIScrollView *)scrollView -{ - if (ignoreDidScroll == NO) [self layoutContentViews:scrollView]; -} - -- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView -{ - [self handleScrollViewDidEnd:scrollView]; -} - -- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView -{ - [self handleScrollViewDidEnd:scrollView]; -} - -#pragma mark - UIGestureRecognizerDelegate methods - -- (BOOL)gestureRecognizer:(UIGestureRecognizer *)recognizer shouldReceiveTouch:(UITouch *)touch -{ - if ([touch.view isKindOfClass:[UIScrollView class]]) return YES; - - return NO; -} - -#pragma mark - UIGestureRecognizer action methods - -- (void)decrementPageNumber -{ - if ((maximumPage > minimumPage) && (currentPage != minimumPage)) - { - CGPoint contentOffset = theScrollView.contentOffset; // Offset - - contentOffset.x -= theScrollView.bounds.size.width; // View X-- - - [theScrollView setContentOffset:contentOffset animated:YES]; - } -} - -- (void)incrementPageNumber -{ - if ((maximumPage > minimumPage) && (currentPage != maximumPage)) - { - CGPoint contentOffset = theScrollView.contentOffset; // Offset - - contentOffset.x += theScrollView.bounds.size.width; // View X++ - - [theScrollView setContentOffset:contentOffset animated:YES]; - } -} - -- (void)handleSingleTap:(UITapGestureRecognizer *)recognizer -{ - if (recognizer.state == UIGestureRecognizerStateRecognized) - { - CGRect viewRect = recognizer.view.bounds; // View bounds - - CGPoint point = [recognizer locationInView:recognizer.view]; // Point - - CGRect areaRect = CGRectInset(viewRect, TAP_AREA_SIZE, 0.0f); // Area rect - - if (CGRectContainsPoint(areaRect, point) == true) // Single tap is inside area - { - NSNumber *key = [NSNumber numberWithInteger:currentPage]; // Page number key - - ReaderContentView *targetView = [contentViews objectForKey:key]; // View - - id target = [targetView processSingleTap:recognizer]; // Target object - - if (target != nil) // Handle the returned target object - { - if ([target isKindOfClass:[NSURL class]]) // Open a URL - { - NSURL *url = (NSURL *)target; // Cast to a NSURL object - - if (url.scheme == nil) // Handle a missing URL scheme - { - NSString *www = url.absoluteString; // Get URL string - - if ([www hasPrefix:@"www"] == YES) // Check for 'www' prefix - { - NSString *http = [[NSString alloc] initWithFormat:@"http://%@", www]; - - url = [NSURL URLWithString:http]; // Proper http-based URL - } - } - - if ([[UIApplication sharedApplication] openURL:url] == NO) - { - #ifdef DEBUG - NSLog(@"%s '%@'", __FUNCTION__, url); // Bad or unknown URL - #endif - } - } - else // Not a URL, so check for another possible object type - { - if ([target isKindOfClass:[NSNumber class]]) // Goto page - { - NSInteger number = [target integerValue]; // Number - - [self showDocumentPage:number]; // Show the page - } - } - } - else // Nothing active tapped in the target content view - { - if ([lastHideTime timeIntervalSinceNow] < -0.75) // Delay since hide - { - if ((mainToolbar.alpha < 1.0f) || (mainPagebar.alpha < 1.0f)) // Hidden - { - [mainToolbar showToolbar]; [mainPagebar showPagebar]; // Show - } - } - } - - return; - } - - CGRect nextPageRect = viewRect; - nextPageRect.size.width = TAP_AREA_SIZE; - nextPageRect.origin.x = (viewRect.size.width - TAP_AREA_SIZE); - - if (CGRectContainsPoint(nextPageRect, point) == true) // page++ - { - [self incrementPageNumber]; return; - } - - CGRect prevPageRect = viewRect; - prevPageRect.size.width = TAP_AREA_SIZE; - - if (CGRectContainsPoint(prevPageRect, point) == true) // page-- - { - [self decrementPageNumber]; return; - } - } -} - -- (void)handleDoubleTap:(UITapGestureRecognizer *)recognizer -{ - if (recognizer.state == UIGestureRecognizerStateRecognized) - { - CGRect viewRect = recognizer.view.bounds; // View bounds - - CGPoint point = [recognizer locationInView:recognizer.view]; // Point - - CGRect zoomArea = CGRectInset(viewRect, TAP_AREA_SIZE, TAP_AREA_SIZE); // Area - - if (CGRectContainsPoint(zoomArea, point) == true) // Double tap is inside zoom area - { - NSNumber *key = [NSNumber numberWithInteger:currentPage]; // Page number key - - ReaderContentView *targetView = [contentViews objectForKey:key]; // View - - switch (recognizer.numberOfTouchesRequired) // Touches count - { - case 1: // One finger double tap: zoom++ - { - [targetView zoomIncrement:recognizer]; break; - } - - case 2: // Two finger double tap: zoom-- - { - [targetView zoomDecrement:recognizer]; break; - } - } - - return; - } - - CGRect nextPageRect = viewRect; - nextPageRect.size.width = TAP_AREA_SIZE; - nextPageRect.origin.x = (viewRect.size.width - TAP_AREA_SIZE); - - if (CGRectContainsPoint(nextPageRect, point) == true) // page++ - { - [self incrementPageNumber]; return; - } - - CGRect prevPageRect = viewRect; - prevPageRect.size.width = TAP_AREA_SIZE; - - if (CGRectContainsPoint(prevPageRect, point) == true) // page-- - { - [self decrementPageNumber]; return; - } - } -} - -#pragma mark - ReaderContentViewDelegate methods - -- (void)contentView:(ReaderContentView *)contentView touchesBegan:(NSSet *)touches -{ - if ((mainToolbar.alpha > 0.0f) || (mainPagebar.alpha > 0.0f)) - { - if (touches.count == 1) // Single touches only - { - UITouch *touch = [touches anyObject]; // Touch info - - CGPoint point = [touch locationInView:self.view]; // Touch location - - CGRect areaRect = CGRectInset(self.view.bounds, TAP_AREA_SIZE, TAP_AREA_SIZE); - - if (CGRectContainsPoint(areaRect, point) == false) return; - } - - [mainToolbar hideToolbar]; [mainPagebar hidePagebar]; // Hide - - lastHideTime = [NSDate date]; // Set last hide time - } -} - -#pragma mark - ReaderMainToolbarDelegate methods - -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar doneButton:(UIButton *)button -{ -#if (READER_STANDALONE == FALSE) // Option - - [self closeDocument]; // Close ReaderViewController - -#endif // end of READER_STANDALONE Option -} - -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar thumbsButton:(UIButton *)button -{ -#if (READER_ENABLE_THUMBS == TRUE) // Option - - [[UIApplication sharedApplication] setStatusBarHidden:YES]; - - if (printInteraction != nil) [printInteraction dismissAnimated:NO]; - - ThumbsViewController *thumbsViewController = [[ThumbsViewController alloc] initWithReaderDocument:document]; - - thumbsViewController.title = self.title; thumbsViewController.delegate = self; // ThumbsViewControllerDelegate - - thumbsViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; - thumbsViewController.modalPresentationStyle = UIModalPresentationFullScreen; - - [self presentViewController:thumbsViewController animated:NO completion:NULL]; - -#endif // end of READER_ENABLE_THUMBS Option -} - -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar exportButton:(UIButton *)button -{ - if (printInteraction != nil) [printInteraction dismissAnimated:YES]; - - NSURL *fileURL = document.fileURL; // Document file URL - - documentInteraction = [UIDocumentInteractionController interactionControllerWithURL:fileURL]; - - documentInteraction.delegate = self; // UIDocumentInteractionControllerDelegate - - [documentInteraction presentOpenInMenuFromRect:button.bounds inView:button animated:YES]; -} - -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar printButton:(UIButton *)button -{ - if ([UIPrintInteractionController isPrintingAvailable] == YES) - { - NSURL *fileURL = document.fileURL; // Document file URL - - if ([UIPrintInteractionController canPrintURL:fileURL] == YES) - { - printInteraction = [UIPrintInteractionController sharedPrintController]; - - UIPrintInfo *printInfo = [UIPrintInfo printInfo]; - printInfo.duplex = UIPrintInfoDuplexLongEdge; - printInfo.outputType = UIPrintInfoOutputGeneral; - printInfo.jobName = document.fileName; - - printInteraction.printInfo = printInfo; - printInteraction.printingItem = fileURL; - printInteraction.showsPageRange = YES; - - if (userInterfaceIdiom == UIUserInterfaceIdiomPad) // Large device printing - { - [printInteraction presentFromRect:button.bounds inView:button animated:YES completionHandler: - ^(UIPrintInteractionController *pic, BOOL completed, NSError *error) - { - #ifdef DEBUG - if ((completed == NO) && (error != nil)) NSLog(@"%s %@", __FUNCTION__, error); - #endif - } - ]; - } - else // Handle printing on small device - { - [printInteraction presentAnimated:YES completionHandler: - ^(UIPrintInteractionController *pic, BOOL completed, NSError *error) - { - #ifdef DEBUG - if ((completed == NO) && (error != nil)) NSLog(@"%s %@", __FUNCTION__, error); - #endif - } - ]; - } - } - } -} - -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar emailButton:(UIButton *)button -{ - if ([MFMailComposeViewController canSendMail] == NO) return; - - if (printInteraction != nil) [printInteraction dismissAnimated:YES]; - - unsigned long long fileSize = [document.fileSize unsignedLongLongValue]; - - if (fileSize < 15728640ull) // Check attachment size limit (15MB) - { - NSURL *fileURL = document.fileURL; NSString *fileName = document.fileName; - - NSData *attachment = [NSData dataWithContentsOfURL:fileURL options:(NSDataReadingMapped|NSDataReadingUncached) error:nil]; - - if (attachment != nil) // Ensure that we have valid document file attachment data available - { - MFMailComposeViewController *mailComposer = [MFMailComposeViewController new]; - - [mailComposer addAttachmentData:attachment mimeType:@"application/pdf" fileName:fileName]; - - [mailComposer setSubject:fileName]; // Use the document file name for the subject - - mailComposer.modalTransitionStyle = UIModalTransitionStyleCoverVertical; - mailComposer.modalPresentationStyle = UIModalPresentationFormSheet; - - mailComposer.mailComposeDelegate = self; // MFMailComposeViewControllerDelegate - - [self presentViewController:mailComposer animated:YES completion:NULL]; - } - } -} - -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar markButton:(UIButton *)button -{ -#if (READER_BOOKMARKS == TRUE) // Option - - if (printInteraction != nil) [printInteraction dismissAnimated:YES]; - - if ([document.bookmarks containsIndex:currentPage]) // Remove bookmark - { - [document.bookmarks removeIndex:currentPage]; [mainToolbar setBookmarkState:NO]; - } - else // Add the bookmarked page number to the bookmark index set - { - [document.bookmarks addIndex:currentPage]; [mainToolbar setBookmarkState:YES]; - } - -#endif // end of READER_BOOKMARKS Option -} - -#pragma mark - MFMailComposeViewControllerDelegate methods - -- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error -{ -#ifdef DEBUG - if ((result == MFMailComposeResultFailed) && (error != NULL)) NSLog(@"%@", error); -#endif - - [self dismissViewControllerAnimated:YES completion:NULL]; -} - -#pragma mark - UIDocumentInteractionControllerDelegate methods - -- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller -{ - documentInteraction = nil; -} - -#pragma mark - ThumbsViewControllerDelegate methods - -- (void)thumbsViewController:(ThumbsViewController *)viewController gotoPage:(NSInteger)page -{ -#if (READER_ENABLE_THUMBS == TRUE) // Option - - [self showDocumentPage:page]; - -#endif // end of READER_ENABLE_THUMBS Option -} - -- (void)dismissThumbsViewController:(ThumbsViewController *)viewController -{ -#if (READER_ENABLE_THUMBS == TRUE) // Option - - [self dismissViewControllerAnimated:NO completion:NULL]; - -#endif // end of READER_ENABLE_THUMBS Option -} - -#pragma mark - ReaderMainPagebarDelegate methods - -- (void)pagebar:(ReaderMainPagebar *)pagebar gotoPage:(NSInteger)page -{ - [self showDocumentPage:page]; -} - -#pragma mark - UIApplication notification methods - -- (void)applicationWillResign:(NSNotification *)notification -{ - [document archiveDocumentProperties]; // Save any ReaderDocument changes - - if (userInterfaceIdiom == UIUserInterfaceIdiomPad) if (printInteraction != nil) [printInteraction dismissAnimated:NO]; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ThumbsMainToolbar.h b/Libraries external/VFR Pdf Reader/Sources/ThumbsMainToolbar.h deleted file mode 100755 index 8b3a5283a..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ThumbsMainToolbar.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// ThumbsMainToolbar.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -#import "UIXToolbarView.h" - -@class ThumbsMainToolbar; - -@protocol ThumbsMainToolbarDelegate <NSObject> - -@required // Delegate protocols - -- (void)tappedInToolbar:(ThumbsMainToolbar *)toolbar doneButton:(UIButton *)button; -- (void)tappedInToolbar:(ThumbsMainToolbar *)toolbar showControl:(UISegmentedControl *)control; - -@end - -@interface ThumbsMainToolbar : UIXToolbarView - -@property (nonatomic, weak, readwrite) id <ThumbsMainToolbarDelegate> delegate; - -- (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ThumbsMainToolbar.m b/Libraries external/VFR Pdf Reader/Sources/ThumbsMainToolbar.m deleted file mode 100755 index e7b742fa0..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ThumbsMainToolbar.m +++ /dev/null @@ -1,176 +0,0 @@ -// -// ThumbsMainToolbar.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderConstants.h" -#import "ThumbsMainToolbar.h" - -@implementation ThumbsMainToolbar - -#pragma mark - Constants - -#define BUTTON_X 8.0f -#define BUTTON_Y 8.0f - -#define BUTTON_SPACE 8.0f -#define BUTTON_HEIGHT 30.0f - -#define BUTTON_FONT_SIZE 15.0f -#define TEXT_BUTTON_PADDING 24.0f - -#define SHOW_CONTROL_WIDTH 78.0f -#define ICON_BUTTON_WIDTH 40.0f - -#define TITLE_FONT_SIZE 19.0f -#define TITLE_HEIGHT 28.0f - -#define COLOR_BAR [UIColor colorWithRed:(248.0f/255.0f) green:(248.0f/255.0f) blue:(248.0f/255.0f) alpha:1.0] -#define COLOR_ARANCIO [UIColor colorWithRed:241.0/255.0 green:90.0/255.0 blue:34.0/255.0 alpha:1.0] - - -#pragma mark - Properties - -@synthesize delegate; - -#pragma mark - ThumbsMainToolbar instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - return [self initWithFrame:frame title:nil]; -} - -- (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title -{ - if ((self = [super initWithFrame:frame])) - { - CGFloat viewWidth = self.bounds.size.width; // Toolbar view width - -#if (READER_FLAT_UI == TRUE) // Option - UIImage *buttonH = nil; UIImage *buttonN = nil; -#else - UIImage *buttonH = [[UIImage imageNamed:@"Reader-Button-H"] stretchableImageWithLeftCapWidth:5 topCapHeight:0]; - UIImage *buttonN = [[UIImage imageNamed:@"Reader-Button-N"] stretchableImageWithLeftCapWidth:5 topCapHeight:0]; -#endif // end of READER_FLAT_UI Option - - BOOL largeDevice = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad); - - const CGFloat buttonSpacing = BUTTON_SPACE; //const CGFloat iconButtonWidth = ICON_BUTTON_WIDTH; - - CGFloat titleX = BUTTON_X; CGFloat titleWidth = (viewWidth - (titleX + titleX)); - - CGFloat leftButtonX = BUTTON_X; // Left-side button start X position - - UIFont *doneButtonFont = [UIFont systemFontOfSize:BUTTON_FONT_SIZE]; - NSString *doneButtonText = NSLocalizedString(@"Done", @"button"); - //CGSize doneButtonSize = [doneButtonText sizeWithFont:doneButtonFont]; - CGSize doneButtonSize = [doneButtonText sizeWithAttributes:@{NSFontAttributeName: doneButtonFont}]; - CGFloat doneButtonWidth = (doneButtonSize.width + TEXT_BUTTON_PADDING); - - UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom]; - doneButton.frame = CGRectMake(leftButtonX, BUTTON_Y, doneButtonWidth, BUTTON_HEIGHT); - [doneButton setTitleColor:COLOR_ARANCIO forState:UIControlStateNormal]; - [doneButton setTitleColor:[UIColor colorWithWhite:1.0f alpha:1.0f] forState:UIControlStateHighlighted]; - [doneButton setTitle:doneButtonText forState:UIControlStateNormal]; doneButton.titleLabel.font = doneButtonFont; - [doneButton addTarget:self action:@selector(doneButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; - [doneButton setBackgroundImage:buttonH forState:UIControlStateHighlighted]; - [doneButton setBackgroundImage:buttonN forState:UIControlStateNormal]; - doneButton.autoresizingMask = UIViewAutoresizingNone; - //doneButton.backgroundColor = [UIColor grayColor]; - doneButton.exclusiveTouch = YES; - - [self addSubview:doneButton]; //leftButtonX += (doneButtonWidth + buttonSpacing); - - titleX += (doneButtonWidth + buttonSpacing); titleWidth -= (doneButtonWidth + buttonSpacing); - -#if (READER_BOOKMARKS == TRUE) // Option - - CGFloat showControlX = (viewWidth - (SHOW_CONTROL_WIDTH + buttonSpacing)); - - UIImage *thumbsImage = [UIImage imageNamed:@"Reader-Thumbs"]; - UIImage *bookmarkImage = [UIImage imageNamed:@"Reader-Mark-Y"]; - NSArray *buttonItems = [NSArray arrayWithObjects:thumbsImage, bookmarkImage, nil]; - - BOOL useTint = [self respondsToSelector:@selector(tintColor)]; // iOS 7 and up - - UISegmentedControl *showControl = [[UISegmentedControl alloc] initWithItems:buttonItems]; - showControl.frame = CGRectMake(showControlX, BUTTON_Y, SHOW_CONTROL_WIDTH, BUTTON_HEIGHT); - - showControl.tintColor = (useTint ? [UIColor blackColor] : [UIColor colorWithWhite:0.8f alpha:1.0f]); - showControl.tintColor = COLOR_ARANCIO; - - showControl.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin; - //showControl.segmentedControlStyle = UISegmentedControlStyleBar; - showControl.selectedSegmentIndex = 0; // Default segment index - showControl.exclusiveTouch = YES; - - [showControl addTarget:self action:@selector(showControlTapped:) forControlEvents:UIControlEventValueChanged]; - - [self addSubview:showControl]; - - titleWidth -= (SHOW_CONTROL_WIDTH + buttonSpacing); - -#endif // end of READER_BOOKMARKS Option - - if (largeDevice == YES) // Show document filename in toolbar - { - CGRect titleRect = CGRectMake(titleX, BUTTON_Y, titleWidth, TITLE_HEIGHT); - - UILabel *titleLabel = [[UILabel alloc] initWithFrame:titleRect]; - - titleLabel.textAlignment = NSTextAlignmentCenter; - titleLabel.font = [UIFont systemFontOfSize:TITLE_FONT_SIZE]; - titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth; - titleLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters; - titleLabel.textColor = [UIColor colorWithWhite:0.0f alpha:1.0f]; - titleLabel.backgroundColor = [UIColor clearColor]; - titleLabel.adjustsFontSizeToFitWidth = YES; - titleLabel.minimumScaleFactor = 0.75f; - titleLabel.text = title; -#if (READER_FLAT_UI == FALSE) // Option - titleLabel.shadowColor = [UIColor colorWithWhite:0.65f alpha:1.0f]; - titleLabel.shadowOffset = CGSizeMake(0.0f, 1.0f); -#endif // end of READER_FLAT_UI Option - - [self addSubview:titleLabel]; - } - } - - return self; -} - -#pragma mark - UISegmentedControl action methods - -- (void)showControlTapped:(UISegmentedControl *)control -{ - [delegate tappedInToolbar:self showControl:control]; -} - -#pragma mark - UIButton action methods - -- (void)doneButtonTapped:(UIButton *)button -{ - [delegate tappedInToolbar:self doneButton:button]; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ThumbsViewController.h b/Libraries external/VFR Pdf Reader/Sources/ThumbsViewController.h deleted file mode 100755 index db36a870d..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ThumbsViewController.h +++ /dev/null @@ -1,66 +0,0 @@ -// -// ThumbsViewController.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -#import "ThumbsMainToolbar.h" -#import "ReaderThumbsView.h" - -@class ReaderDocument; -@class ThumbsViewController; - -@protocol ThumbsViewControllerDelegate <NSObject> - -@required // Delegate protocols - -- (void)thumbsViewController:(ThumbsViewController *)viewController gotoPage:(NSInteger)page; - -- (void)dismissThumbsViewController:(ThumbsViewController *)viewController; - -@end - -@interface ThumbsViewController : UIViewController - -@property (nonatomic, weak, readwrite) id <ThumbsViewControllerDelegate> delegate; - -- (instancetype)initWithReaderDocument:(ReaderDocument *)object; - -@end - -#pragma mark - - -// -// ThumbsPageThumb class interface -// - -@interface ThumbsPageThumb : ReaderThumbView - -- (CGSize)maximumContentSize; - -- (void)showText:(NSString *)text; - -- (void)showBookmark:(BOOL)show; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ThumbsViewController.m b/Libraries external/VFR Pdf Reader/Sources/ThumbsViewController.m deleted file mode 100755 index 28a6010fe..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ThumbsViewController.m +++ /dev/null @@ -1,518 +0,0 @@ -// -// ThumbsViewController.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderConstants.h" -#import "ThumbsViewController.h" -#import "ReaderThumbRequest.h" -#import "ReaderThumbCache.h" -#import "ReaderDocument.h" - -#import <QuartzCore/QuartzCore.h> - -@interface ThumbsViewController () <ThumbsMainToolbarDelegate, ReaderThumbsViewDelegate> - -@end - -@implementation ThumbsViewController -{ - ReaderDocument *document; - - ThumbsMainToolbar *mainToolbar; - - ReaderThumbsView *theThumbsView; - - NSMutableArray *bookmarked; - - CGPoint thumbsOffset; - CGPoint markedOffset; - - BOOL updateBookmarked; - BOOL showBookmarked; -} - -#pragma mark - Constants - -#define STATUS_HEIGHT 20.0f - -#define TOOLBAR_HEIGHT 44.0f - -#define PAGE_THUMB_SMALL 160 -#define PAGE_THUMB_LARGE 256 - -#pragma mark - Properties - -@synthesize delegate; - -#pragma mark - UIViewController methods - -- (instancetype)initWithReaderDocument:(ReaderDocument *)object -{ - if ((self = [super initWithNibName:nil bundle:nil])) // Initialize superclass - { - if ((object != nil) && ([object isKindOfClass:[ReaderDocument class]])) // Valid object - { - updateBookmarked = YES; bookmarked = [NSMutableArray new]; // Bookmarked pages - - document = object; // Retain the ReaderDocument object for our use - } - else // Invalid ReaderDocument object - { - self = nil; - } - } - - return self; -} - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - assert(delegate != nil); assert(document != nil); - - self.view.backgroundColor = [UIColor grayColor]; // Neutral gray - - CGRect scrollViewRect = self.view.bounds; UIView *fakeStatusBar = nil; - - if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) // iOS 7+ - { - if ([self prefersStatusBarHidden] == NO) // Visible status bar - { - CGRect statusBarRect = self.view.bounds; // Status bar frame - statusBarRect.size.height = STATUS_HEIGHT; // Default status height - fakeStatusBar = [[UIView alloc] initWithFrame:statusBarRect]; // UIView - fakeStatusBar.autoresizingMask = UIViewAutoresizingFlexibleWidth; - fakeStatusBar.backgroundColor = [UIColor blackColor]; - fakeStatusBar.contentMode = UIViewContentModeRedraw; - fakeStatusBar.userInteractionEnabled = NO; - - scrollViewRect.origin.y += STATUS_HEIGHT; scrollViewRect.size.height -= STATUS_HEIGHT; - } - } - - NSString *toolbarTitle = [document.fileName stringByDeletingPathExtension]; - - CGRect toolbarRect = scrollViewRect; // Toolbar frame - toolbarRect.size.height = TOOLBAR_HEIGHT; // Default toolbar height - mainToolbar = [[ThumbsMainToolbar alloc] initWithFrame:toolbarRect title:toolbarTitle]; // ThumbsMainToolbar - mainToolbar.delegate = self; // ThumbsMainToolbarDelegate - [self.view addSubview:mainToolbar]; - - if (fakeStatusBar != nil) [self.view addSubview:fakeStatusBar]; // Add status bar background view - - UIEdgeInsets scrollViewInsets = UIEdgeInsetsZero; // Scroll view toolbar insets - - if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) // iPad - { - scrollViewRect.origin.y += TOOLBAR_HEIGHT; scrollViewRect.size.height -= TOOLBAR_HEIGHT; - } - else // Set UIScrollView insets for non-UIUserInterfaceIdiomPad case - { - scrollViewInsets.top = TOOLBAR_HEIGHT; - } - - theThumbsView = [[ReaderThumbsView alloc] initWithFrame:scrollViewRect]; // ReaderThumbsView - theThumbsView.contentInset = scrollViewInsets; theThumbsView.scrollIndicatorInsets = scrollViewInsets; - theThumbsView.delegate = self; // ReaderThumbsViewDelegate - [self.view insertSubview:theThumbsView belowSubview:mainToolbar]; - - if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) - { - CGRect viewRect = self.view.bounds; CGSize viewSize = viewRect.size; // View size - - CGFloat min = ((viewSize.width < viewSize.height) ? viewSize.width : viewSize.height); - - CGFloat thumbSize = ((min > 320.0f) ? floorf(min / 3.0f) : PAGE_THUMB_SMALL); - - [theThumbsView setThumbSize:CGSizeMake(thumbSize, thumbSize)]; - } - else // Set thumb size for large (iPad) devices - { - [theThumbsView setThumbSize:CGSizeMake(PAGE_THUMB_LARGE, PAGE_THUMB_LARGE)]; - } -} - -- (void)viewWillAppear:(BOOL)animated -{ - [super viewWillAppear:animated]; - - [theThumbsView reloadThumbsCenterOnIndex:([document.pageNumber integerValue] - 1)]; // Page -} - -- (void)viewDidAppear:(BOOL)animated -{ - [super viewDidAppear:animated]; -} - -- (void)viewWillDisappear:(BOOL)animated -{ - [super viewWillDisappear:animated]; -} - -- (void)viewDidDisappear:(BOOL)animated -{ - [super viewDidDisappear:animated]; -} - -- (void)viewDidUnload -{ -#ifdef DEBUG - NSLog(@"%s", __FUNCTION__); -#endif - - mainToolbar = nil; theThumbsView = nil; - - [super viewDidUnload]; -} - -- (BOOL)prefersStatusBarHidden -{ - return YES; -} - -- (UIStatusBarStyle)preferredStatusBarStyle -{ - return UIStatusBarStyleLightContent; -} - -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation -{ - return YES; -} - -/* -- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration -{ -} - -- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration -{ -} - -- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation -{ - //if (fromInterfaceOrientation == self.interfaceOrientation) return; -} -*/ - -- (void)didReceiveMemoryWarning -{ -#ifdef DEBUG - NSLog(@"%s", __FUNCTION__); -#endif - - [super didReceiveMemoryWarning]; -} - -#pragma mark - ThumbsMainToolbarDelegate methods - -- (void)tappedInToolbar:(ThumbsMainToolbar *)toolbar showControl:(UISegmentedControl *)control -{ - switch (control.selectedSegmentIndex) - { - case 0: // Show all page thumbs - { - showBookmarked = NO; // Show all thumbs - - markedOffset = [theThumbsView insetContentOffset]; - - [theThumbsView reloadThumbsContentOffset:thumbsOffset]; - - break; // We're done - } - - case 1: // Show bookmarked thumbs - { - showBookmarked = YES; // Only bookmarked - - thumbsOffset = [theThumbsView insetContentOffset]; - - if (updateBookmarked == YES) // Update bookmarked list - { - [bookmarked removeAllObjects]; // Empty the list first - - [document.bookmarks enumerateIndexesUsingBlock: // Enumerate - ^(NSUInteger page, BOOL *stop) - { - [bookmarked addObject:[NSNumber numberWithInteger:page]]; - } - ]; - - markedOffset = CGPointZero; updateBookmarked = NO; // Reset - } - - [theThumbsView reloadThumbsContentOffset:markedOffset]; - - break; // We're done - } - } -} - -- (void)tappedInToolbar:(ThumbsMainToolbar *)toolbar doneButton:(UIButton *)button -{ - [[UIApplication sharedApplication] setStatusBarHidden:NO]; - - [delegate dismissThumbsViewController:self]; // Dismiss thumbs display -} - -#pragma mark - UIThumbsViewDelegate methods - -- (NSUInteger)numberOfThumbsInThumbsView:(ReaderThumbsView *)thumbsView -{ - return (showBookmarked ? bookmarked.count : [document.pageCount integerValue]); -} - -- (id)thumbsView:(ReaderThumbsView *)thumbsView thumbCellWithFrame:(CGRect)frame -{ - return [[ThumbsPageThumb alloc] initWithFrame:frame]; -} - -- (void)thumbsView:(ReaderThumbsView *)thumbsView updateThumbCell:(ThumbsPageThumb *)thumbCell forIndex:(NSInteger)index -{ - CGSize size = [thumbCell maximumContentSize]; // Get the cell's maximum content size - - NSInteger page = (showBookmarked ? [[bookmarked objectAtIndex:index] integerValue] : (index + 1)); - - [thumbCell showText:[[NSString alloc] initWithFormat:@"%i", (int)page]]; // Page number place holder - - [thumbCell showBookmark:[document.bookmarks containsIndex:page]]; // Show bookmarked status - - NSURL *fileURL = document.fileURL; NSString *guid = document.guid; NSString *phrase = document.password; // Document info - - ReaderThumbRequest *thumbRequest = [ReaderThumbRequest newForView:thumbCell fileURL:fileURL password:phrase guid:guid page:page size:size]; - - UIImage *image = [[ReaderThumbCache sharedInstance] thumbRequest:thumbRequest priority:YES]; // Request the thumbnail - - if ([image isKindOfClass:[UIImage class]]) [thumbCell showImage:image]; // Show image from cache -} - -- (void)thumbsView:(ReaderThumbsView *)thumbsView refreshThumbCell:(ThumbsPageThumb *)thumbCell forIndex:(NSInteger)index -{ - NSInteger page = (showBookmarked ? [[bookmarked objectAtIndex:index] integerValue] : (index + 1)); - - [thumbCell showBookmark:[document.bookmarks containsIndex:page]]; // Show bookmarked status -} - -- (void)thumbsView:(ReaderThumbsView *)thumbsView didSelectThumbWithIndex:(NSInteger)index -{ - [[UIApplication sharedApplication] setStatusBarHidden:NO]; - - NSInteger page = (showBookmarked ? [[bookmarked objectAtIndex:index] integerValue] : (index + 1)); - - [delegate thumbsViewController:self gotoPage:page]; // Show the selected page - - [delegate dismissThumbsViewController:self]; // Dismiss thumbs display -} - -- (void)thumbsView:(ReaderThumbsView *)thumbsView didPressThumbWithIndex:(NSInteger)index -{ - NSInteger page = (showBookmarked ? [[bookmarked objectAtIndex:index] integerValue] : (index + 1)); - - if ([document.bookmarks containsIndex:page]) [document.bookmarks removeIndex:page]; else [document.bookmarks addIndex:page]; - - updateBookmarked = YES; [thumbsView refreshThumbWithIndex:index]; // Refresh page thumb -} - -@end - -#pragma mark - - -// -// ThumbsPageThumb class implementation -// - -@implementation ThumbsPageThumb -{ - UIView *backView; - - UIView *tintView; - - UILabel *textLabel; - - UIImageView *bookMark; - - CGSize maximumSize; - - CGRect defaultRect; -} - -#pragma mark - Constants - -#define CONTENT_INSET 8.0f - -#pragma mark - ThumbsPageThumb instance methods - -- (CGRect)markRectInImageView -{ - CGRect iconRect = bookMark.frame; iconRect.origin.y = (-2.0f); - - iconRect.origin.x = (imageView.bounds.size.width - bookMark.image.size.width - 8.0f); - - return iconRect; // Frame position rect inside of image view -} - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) - { - imageView.contentMode = UIViewContentModeCenter; - - defaultRect = CGRectInset(self.bounds, CONTENT_INSET, CONTENT_INSET); - - maximumSize = defaultRect.size; // Maximum thumb content size - - CGFloat newWidth = ((defaultRect.size.width / 4.0f) * 3.0f); - - CGFloat offsetX = ((defaultRect.size.width - newWidth) * 0.5f); - - defaultRect.size.width = newWidth; defaultRect.origin.x += offsetX; - - imageView.frame = defaultRect; // Update the image view frame - - CGFloat fontSize = (([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) ? 19.0f : 16.0f); - - textLabel = [[UILabel alloc] initWithFrame:defaultRect]; - - textLabel.autoresizesSubviews = NO; - textLabel.userInteractionEnabled = NO; - textLabel.contentMode = UIViewContentModeRedraw; - textLabel.autoresizingMask = UIViewAutoresizingNone; - textLabel.textAlignment = NSTextAlignmentCenter; - textLabel.font = [UIFont systemFontOfSize:fontSize]; - textLabel.textColor = [UIColor colorWithWhite:0.24f alpha:1.0f]; - textLabel.backgroundColor = [UIColor whiteColor]; - - [self insertSubview:textLabel belowSubview:imageView]; - - backView = [[UIView alloc] initWithFrame:defaultRect]; - - backView.autoresizesSubviews = NO; - backView.userInteractionEnabled = NO; - backView.contentMode = UIViewContentModeRedraw; - backView.autoresizingMask = UIViewAutoresizingNone; - backView.backgroundColor = [UIColor whiteColor]; - -#if (READER_SHOW_SHADOWS == TRUE) // Option - - backView.layer.shadowOffset = CGSizeMake(0.0f, 1.0f); - backView.layer.shadowRadius = 3.0f; backView.layer.shadowOpacity = 1.0f; - backView.layer.shadowPath = [UIBezierPath bezierPathWithRect:backView.bounds].CGPath; - -#endif // end of READER_SHOW_SHADOWS Option - - [self insertSubview:backView belowSubview:textLabel]; - - tintView = [[UIView alloc] initWithFrame:imageView.bounds]; - - tintView.hidden = YES; - tintView.autoresizesSubviews = NO; - tintView.userInteractionEnabled = NO; - tintView.contentMode = UIViewContentModeRedraw; - tintView.autoresizingMask = UIViewAutoresizingNone; - tintView.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.25f]; - - [imageView addSubview:tintView]; - - UIImage *image = [UIImage imageNamed:@"Reader-Mark-Y"]; - - bookMark = [[UIImageView alloc] initWithImage:image]; - - bookMark.hidden = YES; - bookMark.autoresizesSubviews = NO; - bookMark.userInteractionEnabled = NO; - bookMark.contentMode = UIViewContentModeCenter; - bookMark.autoresizingMask = UIViewAutoresizingNone; - bookMark.frame = [self markRectInImageView]; - - [imageView addSubview:bookMark]; - } - - return self; -} - -- (CGSize)maximumContentSize -{ - return maximumSize; -} - -- (void)showImage:(UIImage *)image -{ - NSInteger x = (self.bounds.size.width * 0.5f); - NSInteger y = (self.bounds.size.height * 0.5f); - - CGPoint location = CGPointMake(x, y); // Center point - - CGRect viewRect = CGRectZero; viewRect.size = image.size; - - textLabel.bounds = viewRect; textLabel.center = location; // Position - - imageView.bounds = viewRect; imageView.center = location; imageView.image = image; - - bookMark.frame = [self markRectInImageView]; // Position bookmark image - - tintView.frame = imageView.bounds; backView.bounds = viewRect; backView.center = location; - -#if (READER_SHOW_SHADOWS == TRUE) // Option - - backView.layer.shadowPath = [UIBezierPath bezierPathWithRect:backView.bounds].CGPath; - -#endif // end of READER_SHOW_SHADOWS Option -} - -- (void)reuse -{ - [super reuse]; // Reuse thumb view - - textLabel.text = nil; textLabel.frame = defaultRect; - - imageView.image = nil; imageView.frame = defaultRect; - - bookMark.hidden = YES; bookMark.frame = [self markRectInImageView]; - - tintView.hidden = YES; tintView.frame = imageView.bounds; backView.frame = defaultRect; - -#if (READER_SHOW_SHADOWS == TRUE) // Option - - backView.layer.shadowPath = [UIBezierPath bezierPathWithRect:backView.bounds].CGPath; - -#endif // end of READER_SHOW_SHADOWS Option -} - -- (void)showBookmark:(BOOL)show -{ - bookMark.hidden = (show ? NO : YES); -} - -- (void)showTouched:(BOOL)touched -{ - tintView.hidden = (touched ? NO : YES); -} - -- (void)showText:(NSString *)text -{ - textLabel.text = text; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/UIXToolbarView.h b/Libraries external/VFR Pdf Reader/Sources/UIXToolbarView.h deleted file mode 100755 index 5ca89bf4f..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/UIXToolbarView.h +++ /dev/null @@ -1,40 +0,0 @@ -// -// UIXToolbarView.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -@interface UIXToolbarView : UIView - -@end - -#pragma mark - - -// -// UIXToolbarShadow class interface -// - -@interface UIXToolbarShadow : UIView - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/UIXToolbarView.m b/Libraries external/VFR Pdf Reader/Sources/UIXToolbarView.m deleted file mode 100755 index 44829db37..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/UIXToolbarView.m +++ /dev/null @@ -1,131 +0,0 @@ -// -// UIXToolbarView.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderConstants.h" -#import "UIXToolbarView.h" - -#import <QuartzCore/QuartzCore.h> - -@implementation UIXToolbarView - -#pragma mark - Constants - -#define SHADOW_HEIGHT 4.0f - -#pragma mark - UIXToolbarView class methods - -+ (Class)layerClass -{ -#if (READER_FLAT_UI == FALSE) // Option - return [CAGradientLayer class]; -#else - return [CALayer class]; -#endif // end of READER_FLAT_UI Option -} - -#pragma mark - UIXToolbarView instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) - { - self.autoresizesSubviews = YES; - self.userInteractionEnabled = YES; - self.contentMode = UIViewContentModeRedraw; - self.autoresizingMask = UIViewAutoresizingFlexibleWidth; - - if ([self.layer isKindOfClass:[CAGradientLayer class]]) - { - self.backgroundColor = [UIColor clearColor]; - - CAGradientLayer *layer = (CAGradientLayer *)self.layer; - UIColor *liteColor = [UIColor colorWithWhite:0.92f alpha:0.8f]; - UIColor *darkColor = [UIColor colorWithWhite:0.32f alpha:0.8f]; - layer.colors = [NSArray arrayWithObjects:(id)liteColor.CGColor, (id)darkColor.CGColor, nil]; - - CGRect shadowRect = self.bounds; shadowRect.origin.y += shadowRect.size.height; shadowRect.size.height = SHADOW_HEIGHT; - - UIXToolbarShadow *shadowView = [[UIXToolbarShadow alloc] initWithFrame:shadowRect]; - - [self addSubview:shadowView]; // Add shadow to toolbar - } - else // Follow The Fuglyosity of Flat Fad - { - self.backgroundColor = [UIColor colorWithWhite:0.94f alpha:0.94f]; - - CGRect lineRect = self.bounds; lineRect.origin.y += lineRect.size.height; lineRect.size.height = 1.0f; - - UIView *lineView = [[UIView alloc] initWithFrame:lineRect]; - lineView.autoresizesSubviews = NO; - lineView.userInteractionEnabled = NO; - lineView.contentMode = UIViewContentModeRedraw; - lineView.autoresizingMask = UIViewAutoresizingFlexibleWidth; - lineView.backgroundColor = [UIColor colorWithWhite:0.64f alpha:0.94f]; - [self addSubview:lineView]; - } - } - - return self; -} - -@end - -#pragma mark - - -// -// UIXToolbarShadow class implementation -// - -@implementation UIXToolbarShadow - -#pragma mark - UIXToolbarShadow class methods - -+ (Class)layerClass -{ - return [CAGradientLayer class]; -} - -#pragma mark - UIXToolbarShadow instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) - { - self.autoresizesSubviews = NO; - self.userInteractionEnabled = NO; - self.contentMode = UIViewContentModeRedraw; - self.autoresizingMask = UIViewAutoresizingFlexibleWidth; - self.backgroundColor = [UIColor clearColor]; - - CAGradientLayer *layer = (CAGradientLayer *)self.layer; - UIColor *blackColor = [UIColor colorWithWhite:0.24f alpha:1.0f]; - UIColor *clearColor = [UIColor colorWithWhite:0.24f alpha:0.0f]; - layer.colors = [NSArray arrayWithObjects:(id)blackColor.CGColor, (id)clearColor.CGColor, nil]; - } - - return self; -} - -@end |