Commit 02db53bb authored by CZ1004's avatar CZ1004

Merge branch 'Advertisement' of…

Merge branch 'Advertisement' of http://gitlab.zhangxindiet.com/ShuMing/phonemanager into Advertisement

* 'Advertisement' of http://gitlab.zhangxindiet.com/ShuMing/phonemanager:
  权限页面
parents 267472f1 32a0013f
......@@ -106,6 +106,12 @@ class CompressController : BaseViewController {
/// 获取当前页面数据
func getViewData(){
if PhotoAndVideoMananger.mananger.permissionStatus == .denied{
loadPermissView(CGRect(x: 0, y: 200, width: ScreenW, height: 450))
return
}
self.resourceData.removeAll()
let datas = Singleton.shared.resourceModel
if datas.count > 0 {
......
......@@ -137,7 +137,7 @@ class HomeInfoViewController:BaseViewController {
// 没有订阅
let view : AdvTipDeleteView = AdvTipDeleteView(frame: self.view.bounds)
view.dataSource = array as! [AssetModel]
view.dataSource = array
// 获取当前免费次数
let freeCount = AdvManager.shared.defaultFreeTimes
......@@ -152,7 +152,7 @@ class HomeInfoViewController:BaseViewController {
}else {
// 获取次数对应的删除照片数量
var freeDeleteCount = AdvManager.shared.advDeleteResouceDic[freeCount]!
let tempArray = array as! [AssetModel]
let tempArray = array
if freeCount > 1 {
// 如果是前两次,可以免费删除5张照片
if tempArray.count > freeDeleteCount {
......@@ -166,7 +166,7 @@ class HomeInfoViewController:BaseViewController {
}else {
// 如果小于直接删除
HomePayViewController.show {
deleteOp(imgs: array as! [AssetModel],isAfterAdv: false)
deleteOp(imgs: array,isAfterAdv: false)
}
}
......@@ -247,6 +247,7 @@ class HomeInfoViewController:BaseViewController {
label.textColor = UIColor(red: 0.2, green: 0.2, blue: 0.2, alpha: 1)
label.font = UIFont.systemFont(ofSize: 16, weight: .bold)
label.textAlignment = .center
label.isHidden = true
return label
}()
......@@ -367,7 +368,11 @@ class HomeInfoViewController:BaseViewController {
//设置空白页
func setDefaultPage(){
DispatchQueue.main.async {
if PhotoAndVideoMananger.mananger.permissionStatus == .denied{
self.loadPermissView()
}else{
if self.ids?.count == 0 {
if self.type == .SimilarVideos{
self.defaultImageView.image = UIImage(named: "img_vedio_defpage")
......@@ -384,6 +389,7 @@ class HomeInfoViewController:BaseViewController {
}
}
}
}
@objc func seletedAllBtnClick() {
......@@ -400,3 +406,14 @@ class HomeInfoViewController:BaseViewController {
}
}
extension UIViewController{
func loadPermissView(_ frame:CGRect = CGRect(x: 0, y: 100+kSafeAreaInsets.top, width: ScreenW, height: 450)){
let permissionView = Bundle.main.loadNibNamed("PMPermissionView", owner: nil)?.last as! PMPermissionView
permissionView.frame = frame
self.view.addSubview(permissionView)
}
}
......@@ -185,6 +185,9 @@ class HomePhotosDetailViewController : BaseViewController {
//设置空白页
func setDefaultPage(){
DispatchQueue.main.async {
if PhotoAndVideoMananger.mananger.permissionStatus == .denied{
self.loadPermissView()
}else{
if self.resourceData.count == 0 {
self.defaultImageView.isHidden = false
self.defaultTipLabel.isHidden = false
......@@ -199,6 +202,8 @@ class HomePhotosDetailViewController : BaseViewController {
self.deleteButton.isHidden = false
}
}
}
}
override func viewDidLoad() {
......
......@@ -518,6 +518,9 @@ extension HomeVideoDetailController:WaterfallMutiSectionDelegate,UICollectionVie
func setDefaultPage(){
DispatchQueue.main.async {
if PhotoAndVideoMananger.mananger.permissionStatus == .denied{
self.loadPermissView()
}else{
if self.resourceData.count == 0 {
self.defaultImageView.isHidden = false
self.defaultTipLabel.isHidden = false
......@@ -533,6 +536,7 @@ extension HomeVideoDetailController:WaterfallMutiSectionDelegate,UICollectionVie
}
}
}
}
func updateCurrentPageWhenDeleteAny(){
......
......@@ -281,6 +281,7 @@ class HomeViewController:BaseViewController {
Singleton.shared.startCountdown {}
if !isShowCharge {
NotificationManager().configNotifications()
return
}
......
......@@ -19,7 +19,7 @@ class HomeInfoView :UIView{
var callBack:callBack<Any> = {text in}
var deleteCallBack:callBack<Any> = {array in }
var deleteCallBack:callBack<[AssetModel]> = {array in }
lazy var tableView:UITableView = {
......
......@@ -25,5 +25,4 @@ class PMPermissionView: UIView {
}
}
}
}
......@@ -11,28 +11,29 @@
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="EwM-B0-fXo" customClass="PMPermissionView" customModule="PhoneManager" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="529" height="489"/>
<rect key="frame" x="0.0" y="0.0" width="543" height="449"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_queshengtu" translatesAutoresizingMaskIntoConstraints="NO" id="qhV-IF-vsx">
<rect key="frame" x="170" y="100" width="189" height="189"/>
<rect key="frame" x="177" y="100" width="189" height="189"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Access permission is required to start scan" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ci8-h6-fiE">
<rect key="frame" x="22" y="297" width="485" height="20"/>
<rect key="frame" x="22" y="297" width="499" height="20"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="16"/>
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="e8v-Xy-wvP">
<rect key="frame" x="24" y="320" width="480" height="38.333333333333314"/>
<string key="text">Phone Manager We need access to all the photos
in your photo library</string>
<fontDescription key="fontDescription" type="boldSystem" pointSize="16"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Phone Manager We need access to all the photos in your photo library" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="e8v-Xy-wvP">
<rect key="frame" x="109" y="320" width="325" height="38.333333333333314"/>
<constraints>
<constraint firstAttribute="width" constant="325" id="7Q3-fW-f7G"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.40000000000000002" green="0.40000000000000002" blue="0.40000000000000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fRi-wi-J8I">
<rect key="frame" x="170" y="371.33333333333331" width="189" height="46"/>
<rect key="frame" x="177" y="371.33333333333331" width="189" height="46"/>
<color key="backgroundColor" red="0.0" green="0.50980392159999999" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="46" id="2ml-bk-VZ7"/>
......@@ -57,16 +58,15 @@ in your photo library</string>
<constraint firstItem="fRi-wi-J8I" firstAttribute="centerX" secondItem="qhV-IF-vsx" secondAttribute="centerX" id="06a-VZ-yHW"/>
<constraint firstItem="ci8-h6-fiE" firstAttribute="leading" secondItem="Z86-W8-437" secondAttribute="leading" constant="22" id="2pS-Hl-sgb"/>
<constraint firstItem="ci8-h6-fiE" firstAttribute="centerX" secondItem="qhV-IF-vsx" secondAttribute="centerX" id="Fv3-iO-5BI"/>
<constraint firstItem="e8v-Xy-wvP" firstAttribute="leading" secondItem="Z86-W8-437" secondAttribute="leading" constant="24" id="Ygj-Ix-aYR"/>
<constraint firstItem="e8v-Xy-wvP" firstAttribute="centerX" secondItem="ci8-h6-fiE" secondAttribute="centerX" id="OZD-Bq-U2s"/>
<constraint firstItem="qhV-IF-vsx" firstAttribute="top" secondItem="EwM-B0-fXo" secondAttribute="top" constant="100" id="fx5-wC-f0q"/>
<constraint firstItem="fRi-wi-J8I" firstAttribute="top" secondItem="e8v-Xy-wvP" secondAttribute="bottom" constant="13" id="jys-rP-uUI"/>
<constraint firstItem="Z86-W8-437" firstAttribute="trailing" secondItem="e8v-Xy-wvP" secondAttribute="trailing" constant="25" id="p6c-uL-oEh"/>
<constraint firstItem="e8v-Xy-wvP" firstAttribute="top" secondItem="ci8-h6-fiE" secondAttribute="bottom" constant="3" id="tgi-kq-3Ap"/>
<constraint firstItem="ci8-h6-fiE" firstAttribute="top" secondItem="qhV-IF-vsx" secondAttribute="bottom" constant="8" id="uKW-kw-KCJ"/>
<constraint firstItem="Z86-W8-437" firstAttribute="trailing" secondItem="ci8-h6-fiE" secondAttribute="trailing" constant="22" id="wMs-cZ-eGL"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="284.73282442748092" y="-315.14084507042253"/>
<point key="canvasLocation" x="295.41984732824426" y="-329.22535211267609"/>
</view>
</objects>
<resources>
......
......@@ -58,7 +58,7 @@
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XPg-Ph-1k0">
<rect key="frame" x="15" y="876" width="410" height="46"/>
<rect key="frame" x="15" y="870" width="410" height="46"/>
<color key="backgroundColor" red="0.0" green="0.50980392156862742" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="46" id="DDB-jE-Azu"/>
......@@ -82,7 +82,7 @@
<constraint firstAttribute="trailing" secondItem="OOD-68-wMD" secondAttribute="trailing" constant="25" id="Vcx-gz-lAI"/>
<constraint firstItem="XMa-dY-JFG" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" constant="40" id="a0g-kE-ugQ"/>
<constraint firstItem="LIQ-mA-CKi" firstAttribute="leading" secondItem="5sP-3G-R5V" secondAttribute="leading" id="cqt-w5-eff"/>
<constraint firstItem="fnl-2z-Ty3" firstAttribute="bottom" secondItem="XPg-Ph-1k0" secondAttribute="bottom" id="dX6-cv-Gto" customClass="ScreenHeightRatioConstraint" customModule="PhoneManager" customModuleProvider="target"/>
<constraint firstItem="fnl-2z-Ty3" firstAttribute="bottom" secondItem="XPg-Ph-1k0" secondAttribute="bottom" constant="6" id="dX6-cv-Gto" customClass="ScreenHeightRatioConstraint" customModule="PhoneManager" customModuleProvider="target"/>
<constraint firstItem="dRr-c6-YoB" firstAttribute="top" secondItem="5sP-3G-R5V" secondAttribute="bottom" constant="20" id="eD3-DG-qkC" customClass="ScreenHeightRatioConstraint" customModule="PhoneManager" customModuleProvider="target"/>
<constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="5sP-3G-R5V" secondAttribute="trailing" constant="53" id="h2C-hf-maH"/>
<constraint firstItem="OOD-68-wMD" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" constant="25" id="jJ3-Yj-u0w"/>
......
......@@ -29,7 +29,7 @@
</constraints>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ybT-3z-Wb2">
<rect key="frame" x="15" y="852" width="400" height="46"/>
<rect key="frame" x="15" y="846" width="400" height="46"/>
<color key="backgroundColor" red="0.0" green="0.50980392159999999" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="46" id="4Qc-vw-6p8"/>
......@@ -62,7 +62,7 @@
<constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="VkR-UI-FBK" secondAttribute="trailing" constant="25" id="4JU-rc-hns"/>
<constraint firstItem="ybT-3z-Wb2" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" constant="15" id="IIW-NA-SQU"/>
<constraint firstItem="QGK-yy-jOF" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="Kee-LL-a9m"/>
<constraint firstItem="fnl-2z-Ty3" firstAttribute="bottom" secondItem="ybT-3z-Wb2" secondAttribute="bottom" id="NWj-ld-9UY"/>
<constraint firstItem="fnl-2z-Ty3" firstAttribute="bottom" secondItem="ybT-3z-Wb2" secondAttribute="bottom" constant="6" id="NWj-ld-9UY"/>
<constraint firstItem="VkR-UI-FBK" firstAttribute="top" secondItem="h8I-lL-ELV" secondAttribute="bottom" constant="18" id="aYz-ey-Yc7"/>
<constraint firstItem="QGK-yy-jOF" firstAttribute="top" secondItem="fnl-2z-Ty3" secondAttribute="top" constant="46" id="cHD-Cc-XiT"/>
<constraint firstItem="h8I-lL-ELV" firstAttribute="top" secondItem="QGK-yy-jOF" secondAttribute="bottom" constant="55" id="dDM-Pu-5g1"/>
......
......@@ -40,7 +40,7 @@
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="KHL-A7-P8d">
<rect key="frame" x="15" y="772" width="363" height="46"/>
<rect key="frame" x="15" y="766" width="363" height="46"/>
<color key="backgroundColor" red="0.0" green="0.50980392159999999" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="46" id="bCa-jh-IT1"/>
......@@ -61,7 +61,7 @@
<constraint firstAttribute="trailing" secondItem="KHL-A7-P8d" secondAttribute="trailing" constant="15" id="MaN-MT-FnY"/>
<constraint firstItem="dcU-ld-SUp" firstAttribute="top" secondItem="OpM-5k-AoO" secondAttribute="bottom" constant="80" id="Okf-QC-Jrn" customClass="ScreenHeightRatioConstraint" customModule="PhoneManager" customModuleProvider="target"/>
<constraint firstItem="KHL-A7-P8d" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" constant="15" id="Rl4-Mh-CiF"/>
<constraint firstItem="fnl-2z-Ty3" firstAttribute="bottom" secondItem="KHL-A7-P8d" secondAttribute="bottom" id="SCz-tZ-pgH"/>
<constraint firstItem="fnl-2z-Ty3" firstAttribute="bottom" secondItem="KHL-A7-P8d" secondAttribute="bottom" constant="6" id="SCz-tZ-pgH"/>
<constraint firstItem="dcU-ld-SUp" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="USR-RC-nO5"/>
<constraint firstItem="LeZ-aM-wDE" firstAttribute="top" secondItem="dcU-ld-SUp" secondAttribute="bottom" constant="18" id="Zga-Sv-DYE" customClass="ScreenHeightRatioConstraint" customModule="PhoneManager" customModuleProvider="target"/>
<constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="LeZ-aM-wDE" secondAttribute="trailing" constant="25" id="lAh-or-e83"/>
......
......@@ -10,18 +10,18 @@ class NotificationManager {
func configNotifications(){
if let secondlaunch = UserDefaults.standard.value(forKey: "notifications_is_secondlaunch") as? Bool{
if secondlaunch{
Print("二次启动,获取通知权限")
// if let secondlaunch = UserDefaults.standard.value(forKey: "notifications_is_secondlaunch") as? Bool{
// if secondlaunch{
// Print("二次启动,获取通知权限")
// scheduleLocalNotifications()
// }
// }else{
// UserDefaults.standard.setValue(true, forKey: "notifications_is_secondlaunch")
// UserDefaults.standard.synchronize()
// Print("启动第一次,记录下")
// }
scheduleLocalNotifications()
}
}else{
UserDefaults.standard.setValue(true, forKey: "notifications_is_secondlaunch")
UserDefaults.standard.synchronize()
Print("启动第一次,记录下")
}
}
// 调度本地通知
func scheduleLocalNotifications() {
......
......@@ -55,6 +55,8 @@ class PhotoAndVideoMananger {
var ids:[String] = []
var permissionStatus:PHAuthorizationStatus = .notDetermined
// 定义
private let hashDistance = 100
......@@ -91,10 +93,12 @@ class PhotoAndVideoMananger {
class func getPrivacy(suc:@escaping callBack<Any> = {text in}) {
PHPhotoLibrary.requestAuthorization { status in
PhotoAndVideoMananger.mananger.permissionStatus = status
switch status {
case .authorized:
// 用户授权访问照片库,可以继续操作
Print("用户授权访问照片库,可以继续操作")
suc(PrivacyType.authorized)
case .denied:
Print("用户拒绝访问或者权限受限")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment