Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Bark.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@
06CF784C21C7A51200A052D7 /* NotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06CF784B21C7A51200A052D7 /* NotificationService.swift */; };
06EE1FD326843E9300586708 /* BarkTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06EE1FD226843E9300586708 /* BarkTests.swift */; };
6AF9CC9B5F6CD2BF86509897 /* libPods-Bark.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E4EA0C04469BF7B418FF3CB7 /* libPods-Bark.a */; };
7AC5601E26E2ADDA0066AB40 /* NotificationDismissSettingManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AC5601D26E2ADDA0066AB40 /* NotificationDismissSettingManager.swift */; };
7AC5602026E2AE300066AB40 /* NotificationSettingCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AC5601F26E2AE300066AB40 /* NotificationSettingCell.swift */; };
7AC5602226E2AE400066AB40 /* NotificationSettingCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AC5602126E2AE400066AB40 /* NotificationSettingCellViewModel.swift */; };
7AC5602426E2B2130066AB40 /* NotificationDismissSettingManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AC5601D26E2ADDA0066AB40 /* NotificationDismissSettingManager.swift */; };
ACC117FABC6F8E44060B8D80 /* libPods-NotificationServiceExtension.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A24A28EB12CA35B953807C99 /* libPods-NotificationServiceExtension.a */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -258,6 +262,9 @@
14F0F73EC45A35FC2482F967 /* Pods_NotificationContentExtension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NotificationContentExtension.framework; sourceTree = BUILT_PRODUCTS_DIR; };
1CC985CE300A858FF65E166A /* Pods-Bark.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Bark.release.xcconfig"; path = "Pods/Target Support Files/Pods-Bark/Pods-Bark.release.xcconfig"; sourceTree = "<group>"; };
68049930BAF79AFBD8B109B8 /* Pods-NotificationServiceExtension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NotificationServiceExtension.release.xcconfig"; path = "Pods/Target Support Files/Pods-NotificationServiceExtension/Pods-NotificationServiceExtension.release.xcconfig"; sourceTree = "<group>"; };
7AC5601D26E2ADDA0066AB40 /* NotificationDismissSettingManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationDismissSettingManager.swift; sourceTree = "<group>"; };
7AC5601F26E2AE300066AB40 /* NotificationSettingCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationSettingCell.swift; sourceTree = "<group>"; };
7AC5602126E2AE400066AB40 /* NotificationSettingCellViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationSettingCellViewModel.swift; sourceTree = "<group>"; };
87D1222A4C6E7283974A44C6 /* Pods-Bark.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Bark.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Bark/Pods-Bark.debug.xcconfig"; sourceTree = "<group>"; };
A24A28EB12CA35B953807C99 /* libPods-NotificationServiceExtension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-NotificationServiceExtension.a"; sourceTree = BUILT_PRODUCTS_DIR; };
E4EA0C04469BF7B418FF3CB7 /* libPods-Bark.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Bark.a"; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -334,6 +341,8 @@
06C5952E248107F5006B98F3 /* iCloudStatusCell.swift */,
06C5953024811392006B98F3 /* ArchiveSettingCell.swift */,
06BBB8BB2567B3AD0076F63E /* ArchiveSettingCellViewModel.swift */,
7AC5601F26E2AE300066AB40 /* NotificationSettingCell.swift */,
7AC5602126E2AE400066AB40 /* NotificationSettingCellViewModel.swift */,
060481EF250F51CA00BC9799 /* SoundCell.swift */,
065BE44F2563D939002A8CA4 /* SoundCellViewModel.swift */,
062B98C2251B2762004562E7 /* BKButton.swift */,
Expand Down Expand Up @@ -419,6 +428,7 @@
0637FA7D20E0969800E80174 /* Client.swift */,
0667D193247D1BA0005DE2ED /* Date+Extension.swift */,
06C5953224811505006B98F3 /* ArchiveSettingManager.swift */,
7AC5601D26E2ADDA0066AB40 /* NotificationDismissSettingManager.swift */,
06BBB8C82567B6730076F63E /* Operators.swift */,
0633E809256A091B00ED0680 /* MJRefresh+Rx.swift */,
);
Expand Down Expand Up @@ -795,6 +805,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7AC5602426E2B2130066AB40 /* NotificationDismissSettingManager.swift in Sources */,
0632CE2320EC9098003FDF46 /* NotificationViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -807,6 +818,7 @@
06BBB896256518760076F63E /* NewServerViewModel.swift in Sources */,
06BBB8C92567B6730076F63E /* Operators.swift in Sources */,
0603706920E1F89500F4CA05 /* PreviewCardCell.swift in Sources */,
7AC5602026E2AE300066AB40 /* NotificationSettingCell.swift in Sources */,
06AE311C266F54A500B39FBB /* GroupTableViewCell.swift in Sources */,
0672CB06256903F700570C9D /* MessageListViewModel.swift in Sources */,
0633E80A256A091B00ED0680 /* MJRefresh+Rx.swift in Sources */,
Expand All @@ -829,6 +841,8 @@
06AE311E266F54CC00B39FBB /* GroupCellViewModel.swift in Sources */,
0637FA8620E0AB6600E80174 /* UIColor+Extension.swift in Sources */,
0637FA8A20E0D58800E80174 /* NewServerViewController.swift in Sources */,
7AC5602226E2AE400066AB40 /* NotificationSettingCellViewModel.swift in Sources */,
7AC5601E26E2ADDA0066AB40 /* NotificationDismissSettingManager.swift in Sources */,
067B2EB525693E38008B6BE1 /* MessageTableViewCellViewModel.swift in Sources */,
0637FA8220E09C4B00E80174 /* BarkNavigationController.swift in Sources */,
06AE3118266F4E2E00B39FBB /* GroupFilterViewController.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.000",
"green" : "0.000",
"red" : "0.000"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "1.000",
"green" : "1.000",
"red" : "1.000"
}
},
"idiom" : "universal"
},
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.000",
"green" : "0.000",
"red" : "0.000"
}
},
"idiom" : "iphone"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "1.000",
"green" : "1.000",
"red" : "1.000"
}
},
"idiom" : "iphone"
},
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.000",
"green" : "0.000",
"red" : "0.000"
}
},
"idiom" : "ipad"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "1.000",
"green" : "1.000",
"red" : "1.000"
}
},
"idiom" : "ipad"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
12 changes: 7 additions & 5 deletions Bark/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -11,10 +13,10 @@
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand Down
3 changes: 3 additions & 0 deletions Bark/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ iCloudSync = "Notification messages will be synced when iCloud is available";
defaultArchiveSettings = "Archive by default";
archiveNote = "When the isArchive parameter is not specified in the push request URL, whether to archive the notification message will be decided according to this setting";

defaultNotificationSettings = "Do not dismiss by default";
notificationNote = "Notification will not be dismissed after copy by default, change to dismiss notification after copy";

archiveNotificationMessageTitle = "Archive notification message";
archiveNotificationMessage = "Notification message will be archived when isArchive value is 1, and will not be archived when the value is 0.\nIf the isArchive parameter is not specified, the notification message will be archived according to the default settings";

Expand Down
3 changes: 3 additions & 0 deletions Bark/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ archiveNote = "当推送请求URL没有指定 isArchive 参数时,将按照此
archiveNotificationMessageTitle = "自动保存通知消息";
archiveNotificationMessage = "当设置 isArchive 值为 1 时,则会自动保存这条推送消息,设置为其他值时,则不会保存。\n如果不指定 isArchive 参数时,则按照默认设置保存消息,可以在 消息->设置->默认保存消息 更改默认保存设置";

defaultNotificationSettings = "默认不自动收回";
notificationNote = "通知在复制动作后不会自动收回,更改此设定以自动收回";

notificationSound = "推送铃声";
previewSound = "点击可预览";
setSounds = "可以为推送设置不同的铃声";
Expand Down
26 changes: 26 additions & 0 deletions Common/NotificationDismissSettingManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// NotificationDismissSettingManager.swift
// Bark
//
// Created by Jiawei Duan on 9/3/21.
// Copyright © 2021 Fin. All rights reserved.
//

import UIKit

class NotificationDismissSettingManager: NSObject {
static let shared = NotificationDismissSettingManager()
let defaults = UserDefaults.init(suiteName: "group.bark")
var willDismiss: Bool {
get {
return defaults?.value(forKey: "willDismiss") as? Bool ?? false

}
set{
defaults?.set(newValue, forKey: "willDismiss")
}
}
private override init(){
super.init()
}
}
6 changes: 6 additions & 0 deletions Controller/MessageSettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class MessageSettingsViewController: BaseViewController {
tableView.register(LabelCell.self, forCellReuseIdentifier: "\(LabelCell.self)")
tableView.register(iCloudStatusCell.self, forCellReuseIdentifier: "\(iCloudStatusCell.self)")
tableView.register(ArchiveSettingCell.self, forCellReuseIdentifier: "\(ArchiveSettingCell.self)")
tableView.register(NotificationSettingCell.self, forCellReuseIdentifier: "\(NotificationSettingCell.self)")
tableView.register(DetailTextCell.self, forCellReuseIdentifier: "\(DetailTextCell.self)")
tableView.register(SpacerCell.self, forCellReuseIdentifier: "\(SpacerCell.self)")

Expand Down Expand Up @@ -56,6 +57,11 @@ class MessageSettingsViewController: BaseViewController {
cell.bindViewModel(model: viewModel)
return cell
}
case .notificationSetting(let viewModel):
if let cell = tableView.dequeueReusableCell(withIdentifier: "\(NotificationSettingCell.self)") as? NotificationSettingCell {
cell.bindViewModel(model: viewModel)
return cell
}
case let .detail(title,text,textColor,_):
if let cell = tableView.dequeueReusableCell(withIdentifier: "\(DetailTextCell.self)") as? DetailTextCell {
cell.textLabel?.text = title
Expand Down
19 changes: 18 additions & 1 deletion Controller/MessageSettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class MessageSettingsViewModel: ViewModel, ViewModelType {
settings.append(.label(text: NSLocalizedString("defaultArchiveSettings")))
settings.append(.archiveSetting(viewModel: ArchiveSettingCellViewModel(on: ArchiveSettingManager.shared.isArchive)))
settings.append(.label(text: NSLocalizedString("archiveNote")))
settings.append(.notificationSetting(viewModel: NotificationSettingCellViewModel(on: NotificationDismissSettingManager.shared.willDismiss)))
settings.append(.label(text: NSLocalizedString("notificationNote")))


if let infoDict = Bundle.main.infoDictionary,
let runId = infoDict["GitHub Run Id"] as? String{
Expand Down Expand Up @@ -77,7 +80,19 @@ class MessageSettingsViewModel: ViewModel, ViewModelType {
.subscribe(onNext: { (on) in
ArchiveSettingManager.shared.isArchive = on
}).disposed(by: rx.disposeBag)


settings.compactMap { (item) -> NotificationSettingCellViewModel? in
if case let MessageSettingItem.notificationSetting(viewModel) = item {
return viewModel
}
return nil
}
.first?
.on
.subscribe(onNext: { (on) in
NotificationDismissSettingManager.shared.isArchive = on
}).disposed(by: rx.disposeBag)

let openUrl = input.itemSelected.compactMap { item -> URL? in
if case let MessageSettingItem.detail(_, _, _, url) = item {
return url
Expand All @@ -102,6 +117,8 @@ enum MessageSettingItem {
case iCloudStatus
// 默认保存
case archiveSetting(viewModel:ArchiveSettingCellViewModel)
// 默认不收回
case notificationSetting(viewModel:NotificationSettingCellViewModel)
// 带 详细按钮的 文本cell
case detail(title:String?, text:String?, textColor:UIColor?, url:URL?)
// 分隔线
Expand Down
41 changes: 41 additions & 0 deletions View/NotificationSettingCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// NotificationSettingCell.swift
// Bark
//
// Created by Jiawei Duan on 9/3/21.
// Copyright © 2021 Fin. All rights reserved.
//

import UIKit

class NotificationSettingCell: BaseTableViewCell {
let switchButton: UISwitch = {
let btn = UISwitch()
return btn
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.selectionStyle = .none

self.textLabel?.text = NSLocalizedString("defaultNotificationSettings")

contentView.addSubview(switchButton)
switchButton.snp.makeConstraints { (make) in
make.right.equalToSuperview().offset(-16)
make.centerY.equalToSuperview()
}
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func bindViewModel(model: ViewModel) {
super.bindViewModel(model: model)
guard let viewModel = model as? NotificationSettingCellViewModel else {
return
}
(self.switchButton.rx.isOn <-> viewModel.on)
.disposed(by: rx.reuseBag)
}
}

17 changes: 17 additions & 0 deletions View/NotificationSettingCellViewModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// NotificationSettingCellViewModel.swift
// Bark
//
// Created by Jiawei Duan on 9/3/21.
// Copyright © 2021 Fin. All rights reserved.
//

import Foundation
import RxCocoa
class NotificationSettingCellViewModel: ViewModel {
var on: BehaviorRelay<Bool>
init(on:Bool) {
self.on = BehaviorRelay<Bool>(value: on)
super.init()
}
}
9 changes: 7 additions & 2 deletions notificationContentExtension/NotificationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class NotificationViewController: UIViewController, UNNotificationContentExtensi

let noticeLabel:UILabel = {
let label = UILabel()
label.textColor = UIColor.black
label.textColor = UIColor.init(named: "notification_copy_color")
label.text = NSLocalizedString("Copy", comment: "")
label.font = UIFont.systemFont(ofSize: 16)
label.textAlignment = .center
Expand Down Expand Up @@ -62,8 +62,13 @@ class NotificationViewController: UIViewController, UNNotificationContentExtensi

self.preferredContentSize = CGSize(width: 0, height: 40)
self.noticeLabel.frame = CGRect(x: 0, y: 0, width: self.view.bounds.width, height: 40)
if NotificationDismissSettingManager.shared.willDismiss {
completion(.dismiss)
}
else {
completion(.doNotDismiss)
}

completion(.doNotDismiss)

}
}