Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoe0929 committed Jun 25, 2024
2 parents bebb929 + df46b06 commit b84645c
Show file tree
Hide file tree
Showing 370 changed files with 10,149 additions and 62 deletions.
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/🐰-issue-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: "\U0001F430 issue template"
about: zoe의 새로운 이슈 추가
title: "[Feat]"
labels: "\U0001F430지희"
assignees: Zoe0929

---

## 💡 About
<!--무엇에 관한 이슈인지 소개해주세요.-->
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/😎-issue-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: "✈️ issue template"
about: 의 새로운 이슈 추가
title: "[Feat]"
labels: "😎선우"
assignees: kim-seonwoo

---

## 💡 About
<!--무엇에 관한 이슈인지 소개해주세요.-->
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/🙊-issue-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: "🙊 issue template"
about: 보연의 새로운 이슈 추가
title: "[Feat]"
labels: "🙊보연"
assignees: boyeon0119

---

## 💡 About
<!--무엇에 관한 이슈인지 소개해주세요.-->
21 changes: 21 additions & 0 deletions .github/auto_assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Set to true to add reviewers to pull requests
addReviewers: true

# Set to true to add assignees to pull requests
addAssignees: author

# A list of reviewers to be added to pull requests (GitHub user name)
reviewers:
- Zoe0929
- kim-seonwoo

# A number of reviewers added to the pull request
# Set 0 to add all the reviewers (default: 0)
numberOfReviewers: 2


# A number of assignees to add to the pull request
# Set to 0 to add all of the assignees.
# Uses numberOfReviewers if unset.
numberOfAssignees: 1

55 changes: 47 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
# Created by https://www.toptal.com/developers/gitignore/api/macos,swift,swiftpackagemanager
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,swift,swiftpackagemanager

*.xcconfig

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### Swift ###
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
Expand Down Expand Up @@ -35,32 +74,26 @@ timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
# *.xcodeproj
#
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
# .swiftpm

.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Expand All @@ -71,7 +104,6 @@ Dependencies/
.accio/

# fastlane
#
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
Expand All @@ -83,8 +115,15 @@ fastlane/screenshots/**/*.png
fastlane/test_output

# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/

### SwiftPackageManager ###
Packages
xcuserdata
*.xcodeproj


# End of https://www.toptal.com/developers/gitignore/api/macos,swift,swiftpackagemanager
12 changes: 12 additions & 0 deletions HMH_iOS/DeviceActivityMonitor/DeviceActivityMonitor.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.family-controls</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>group.HMH</string>
</array>
</dict>
</plist>
103 changes: 103 additions & 0 deletions HMH_iOS/DeviceActivityMonitor/DeviceActivityMonitorExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
//
// DeviceActivityMonitorExtension.swift
// DeviceMonitor
//
// Created by 지희의 MAC on 1/4/24.
//
//

import DeviceActivity
import ManagedSettings
import Foundation
import UserNotifications

import SwiftUI
import FamilyControls

// Optionally override any of the functions below.
// Make sure that your class name matches the NSExtensionPrincipalClass in your Info.plist.
class DeviceActivityMonitorExtension: DeviceActivityMonitor {

@AppStorage(AppStorageKey.selectionApp.rawValue, store: UserDefaults(suiteName: APP_GROUP_NAME))
var selectionApps = FamilyActivitySelection()

@StateObject var screenTimeVM = ScreenTimeViewModel()

let store = ManagedSettingsStore()
let userNotiCenter = UNUserNotificationCenter.current()

override func intervalDidStart(for activity: DeviceActivityName) {
super.intervalDidStart(for: activity)
}

override func intervalDidEnd(for activity: DeviceActivityName) {
super.intervalDidEnd(for: activity)
store.shield.applications = nil
}

//threshold에 도착하면 행동한다
override func eventDidReachThreshold(_ event: DeviceActivityEvent.Name, activity: DeviceActivityName) {
store.shield.applications = selectionApps.applicationTokens // 이러면 다른 앱도 잠김
Task {
await screenTimeVM.handleSetBlockApplication()
}
let notiContent = UNMutableNotificationContent()
notiContent.title = "하면함"
notiContent.body = "이용 시간이 종료 되었습니다."
notiContent.userInfo = ["token": ""] // 푸시 받을때 오는 데이터

// 알림이 trigger되는 시간 설정
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false)

let request = UNNotificationRequest(
identifier: UUID().uuidString,
content: notiContent,
trigger: trigger
)

self.userNotiCenter.add(request) { (error) in
print(#function, error as Any)
}

}

override func intervalWillStartWarning(for activity: DeviceActivityName) {
super.intervalWillStartWarning(for: activity)

// Handle the warning before the interval starts.
}

override func intervalWillEndWarning(for activity: DeviceActivityName) {
super.intervalWillEndWarning(for: activity)
//NotificationManager.shared.scheduleNotification()

// Handle the warning before the interval ends.

}

//threshold 시간이 되면 경고를 준다
override func eventWillReachThresholdWarning(_ event: DeviceActivityEvent.Name, activity: DeviceActivityName) {
super.eventWillReachThresholdWarning(event, activity: activity)
//store.shield.applicationCategories = ShieldSettings.ActivityCategoryPolicy.all()
let notiContent = UNMutableNotificationContent()
notiContent.title = "하면함"
notiContent.body = "이용 시간이 종료되었습니다. 곧 어플이 잠깁니다."
notiContent.userInfo = ["status": ""] // 푸시 받을때 오는 데이터

// 알림이 trigger되는 시간 설정
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false)

let request = UNNotificationRequest(
identifier: UUID().uuidString,
content: notiContent,
trigger: trigger
)

userNotiCenter.add(request) { (error) in
print(#function, error as Any)
}

//NotificationManager.shared.scheduleNotification()

}
}
13 changes: 13 additions & 0 deletions HMH_iOS/DeviceActivityMonitor/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.deviceactivity.monitor-extension</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).DeviceActivityMonitorExtension</string>
</dict>
</dict>
</plist>
41 changes: 41 additions & 0 deletions HMH_iOS/HMH-iOS-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BASE_URL</key>
<string>$(BASE_URL)</string>
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>com.HMH.dailyTask</string>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>kakao$(KAKAO_API_KEY)</string>
</array>
</dict>
</array>
<key>KAKAO_API_KEY</key>
<string>$(KAKAO_API_KEY)</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>kakaokompassauth</string>
<string>kakaolink</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UIAppFonts</key>
<array>
<string>Pretendard-Regular.otf</string>
<string>Pretendard-SemiBold.otf</string>
<string>Pretendard-Medium.otf</string>
</array>
</dict>
</plist>
54 changes: 54 additions & 0 deletions HMH_iOS/HMHDeviceActivityReport/ActivityModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// ActivityModel.swift
// HMHDeviceActivityReport
//
// Created by 이지희 on 5/12/24.
//

import Foundation

import ManagedSettings

struct ActivityReport {
let totalDuration: Int
let titleState: [String]
var remainTime: Int
var totalGoalTime: Int
let apps: [AppDeviceActivity]
}

struct ChallengeActivity {
let totalDuration: TimeInterval
let apps: [AppDeviceActivity]
}

struct AppDeviceActivity: Identifiable {
var id: String
var displayName: String
var duration: TimeInterval
var remainTime: TimeInterval
var numberOfPickups: Int
var token: ApplicationToken?
}

struct TotalActivityModel: Identifiable {
var id: String
var totalTime: Int
var remainTime: Int
var totalGoalTime: Int
var titleState: [String]
}

extension TimeInterval {
/// TimeInterval 타입 값을 00:00 형식의 String으로 변환해주는 메서드
func toString() -> String {
let time = NSInteger(self)
let minutes = (time / 60) % 60
let hours = (time / 3600)
if hours < 1{
return String(format: "%d분", minutes)
} else {
return String(format: "%d시간 %d분", hours, minutes)
}
}
}
Loading

0 comments on commit b84645c

Please sign in to comment.