Skip to content

Commit

Permalink
Merge pull request #177 from twofas/feature/TF-1697
Browse files Browse the repository at this point in the history
[TF-1697] New widgets
  • Loading branch information
gmachnio authored Dec 30, 2024
2 parents f032ddb + 18cad24 commit f2fddeb
Show file tree
Hide file tree
Showing 75 changed files with 805 additions and 300 deletions.
Binary file modified TwoFAS/Content/Assets/Assets.car
Binary file not shown.
Binary file modified TwoFAS/Content/AssetsWatch/Assets.car
Binary file not shown.
Binary file modified TwoFAS/Content/Sources/IconDescriptionDatabaseImpl+Database0.swift
Binary file not shown.
Binary file modified TwoFAS/Content/Sources/IconDescriptionDatabaseImpl+Database1.swift
Binary file not shown.
Binary file modified TwoFAS/Content/Sources/IconDescriptionDatabaseImpl+Database2.swift
Binary file not shown.
Binary file modified TwoFAS/Content/Sources/IconDescriptionDatabaseImpl+Database3.swift
Binary file not shown.
Binary file modified TwoFAS/Content/Sources/IconDescriptionDatabaseImpl+Database4.swift
Binary file not shown.
Binary file modified TwoFAS/Content/Sources/IconDescriptionDatabaseImpl+Database5.swift
Binary file not shown.
Binary file modified TwoFAS/Content/Sources/IconDescriptionDatabaseImpl+Database6.swift
Binary file not shown.
Binary file modified TwoFAS/Content/Sources/IconDescriptionDatabaseImpl+Database7.swift
Binary file not shown.
Binary file modified TwoFAS/Content/Sources/IconDescriptionDatabaseImpl+Database8.swift
Binary file not shown.
Binary file modified TwoFAS/Content/Sources/IconDescriptionDatabaseImpl+Database9.swift
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
234 changes: 134 additions & 100 deletions TwoFAS/TwoFAS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions TwoFAS/TwoFAS/Other/Generated/T.generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ internal enum T {
internal static let backupIcloudCta = T.tr("Localizable", "introduction__backup_icloud_cta", fallback: "Learn more about backup")
/// 2FAS uses iCloud for secure backup and sync of your 2FA tokens. The **encrypted** backup data is stored in iCloud, accessible **only by the 2FAS app**. Additionally, this feature aids with token **recovery and syncing** across iOS devices.
///
/// It's enabled by default and can disabled at any time in the app's backup settings.
/// It's enabled by default and can be disabled at any time in the app's backup settings.
internal static let backupIcloudDescription = T.tr("Localizable", "introduction__backup_icloud_description", fallback: "2FAS uses iCloud for secure backup and sync of your 2FA tokens. The **encrypted** backup data is stored in iCloud, accessible **only by the 2FAS app**. Additionally, this feature aids with token **recovery and syncing** across iOS devices.\n\nIt's enabled by default and can be disabled at any time in the app's backup settings.")
/// Secure sync and backup
internal static let backupIcloudTitle = T.tr("Localizable", "introduction__backup_icloud_title", fallback: "Secure sync and backup")
Expand Down Expand Up @@ -912,8 +912,8 @@ internal enum T {
internal enum NewVersion {
/// A new version of 2FAS is available on Google Store. Update now!
internal static let newVersionMessageAndroid = T.tr("Localizable", "new_version__new_version_message_android", fallback: "A new version of 2FAS is available on Google Store. Update now!")
/// A new version of 2FAS is available on AppStore. Update now!
internal static let newVersionMessageIos = T.tr("Localizable", "new_version__new_version_message_ios", fallback: "A new version of 2FAS is available on AppStore. Update now!")
/// A new version of 2FAS is available on App Store. Update now!
internal static let newVersionMessageIos = T.tr("Localizable", "new_version__new_version_message_ios", fallback: "A new version of 2FAS is available on App Store. Update now!")
/// New version
internal static let newVersionTitle = T.tr("Localizable", "new_version__new_version_title", fallback: "New version")
/// Skip this version
Expand Down Expand Up @@ -1626,6 +1626,8 @@ internal enum T {
internal enum Widget {
/// My secured account
internal static let mySecuredAccount = T.tr("Localizable", "widget__my_secured_account", fallback: "My secured account")
/// Hold and select service to activate widget...
internal static let noSelectedServices = T.tr("Localizable", "widget__no_selected_services", fallback: "Hold and select service to activate widget...")
/// There are no services in the app available for selection
internal static let noServices = T.tr("Localizable", "widget__no_services", fallback: "There are no services in the app available for selection")
/// Widget functionality is not enabled in 2FAS Settings section
Expand All @@ -1634,6 +1636,10 @@ internal enum T {
internal static let notEnabledNoServices = T.tr("Localizable", "widget__not_enabled_no_services", fallback: "Widget functionality is not enabled in 2FAS Settings section and there are no services in the app available for selection")
/// Placeholder
internal static let placeholder = T.tr("Localizable", "widget__placeholder", fallback: "Placeholder")
/// Reveal your 2FAS tokens for 60 seconds
internal static let revealTokensLongMessage = T.tr("Localizable", "widget__reveal_tokens_long_message", fallback: "Reveal your 2FAS tokens for 60 seconds")
/// Reveal for 60 seconds
internal static let revealTokensShortMessage = T.tr("Localizable", "widget__reveal_tokens_short_message", fallback: "Reveal for 60 seconds")
/// Select Service you want to show on your 2FAS Widget
internal static let selectServiceIntentDescription = T.tr("Localizable", "widget__select_service_intent_description", fallback: "Select Service you want to show on your 2FAS Widget")
/// Service icon
Expand Down
Binary file modified TwoFAS/TwoFAS/Other/de.lproj/Localizable.strings
Binary file not shown.
Binary file modified TwoFAS/TwoFAS/Other/el.lproj/Localizable.strings
Binary file not shown.
Binary file modified TwoFAS/TwoFAS/Other/en.lproj/Localizable.strings
Binary file not shown.
Binary file modified TwoFAS/TwoFAS/Other/es.lproj/Localizable.strings
Binary file not shown.
Binary file modified TwoFAS/TwoFAS/Other/fr.lproj/Localizable.strings
Binary file not shown.
Binary file modified TwoFAS/TwoFAS/Other/id.lproj/Localizable.strings
Binary file not shown.
Binary file modified TwoFAS/TwoFAS/Other/it.lproj/Localizable.strings
Binary file not shown.
Binary file modified TwoFAS/TwoFAS/Other/ja.lproj/Localizable.strings
Binary file not shown.
Binary file modified TwoFAS/TwoFAS/Other/nl.lproj/Localizable.strings
Binary file not shown.
Binary file modified TwoFAS/TwoFAS/Other/pl.lproj/Localizable.strings
Binary file not shown.
Binary file modified TwoFAS/TwoFAS/Other/pt-PT.lproj/Localizable.strings
Binary file not shown.
Binary file modified TwoFAS/TwoFAS/Other/tr.lproj/Localizable.strings
Binary file not shown.
Binary file modified TwoFAS/TwoFAS/Other/uk.lproj/Localizable.strings
Binary file not shown.
Binary file modified TwoFAS/TwoFAS/Other/zh-Hans.lproj/Localizable.strings
Binary file not shown.
14 changes: 10 additions & 4 deletions TwoFAS/TwoFASAuth/Generated/T.generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -860,8 +860,8 @@ internal enum T {
internal static let backupIcloudCta = T.tr("Localizable", "introduction__backup_icloud_cta", fallback: "Learn more about backup")
/// 2FAS uses iCloud for secure backup and sync of your 2FA tokens. The **encrypted** backup data is stored in iCloud, accessible **only by the 2FAS app**. Additionally, this feature aids with token **recovery and syncing** across iOS devices.
///
/// It's enabled by default and can disabled at any time in the app's backup settings.
internal static let backupIcloudDescription = T.tr("Localizable", "introduction__backup_icloud_description", fallback: "2FAS uses iCloud for secure backup and sync of your 2FA tokens. The **encrypted** backup data is stored in iCloud, accessible **only by the 2FAS app**. Additionally, this feature aids with token **recovery and syncing** across iOS devices.\n\nIt's enabled by default and can disabled at any time in the app's backup settings.")
/// It's enabled by default and can be disabled at any time in the app's backup settings.
internal static let backupIcloudDescription = T.tr("Localizable", "introduction__backup_icloud_description", fallback: "2FAS uses iCloud for secure backup and sync of your 2FA tokens. The **encrypted** backup data is stored in iCloud, accessible **only by the 2FAS app**. Additionally, this feature aids with token **recovery and syncing** across iOS devices.\n\nIt's enabled by default and can be disabled at any time in the app's backup settings.")
/// Secure sync and backup
internal static let backupIcloudTitle = T.tr("Localizable", "introduction__backup_icloud_title", fallback: "Secure sync and backup")
/// Google Drive sync turned on successfully!
Expand Down Expand Up @@ -912,8 +912,8 @@ internal enum T {
internal enum NewVersion {
/// A new version of 2FAS is available on Google Store. Update now!
internal static let newVersionMessageAndroid = T.tr("Localizable", "new_version__new_version_message_android", fallback: "A new version of 2FAS is available on Google Store. Update now!")
/// A new version of 2FAS is available on AppStore. Update now!
internal static let newVersionMessageIos = T.tr("Localizable", "new_version__new_version_message_ios", fallback: "A new version of 2FAS is available on AppStore. Update now!")
/// A new version of 2FAS is available on App Store. Update now!
internal static let newVersionMessageIos = T.tr("Localizable", "new_version__new_version_message_ios", fallback: "A new version of 2FAS is available on App Store. Update now!")
/// New version
internal static let newVersionTitle = T.tr("Localizable", "new_version__new_version_title", fallback: "New version")
/// Skip this version
Expand Down Expand Up @@ -1626,6 +1626,8 @@ internal enum T {
internal enum Widget {
/// My secured account
internal static let mySecuredAccount = T.tr("Localizable", "widget__my_secured_account", fallback: "My secured account")
/// Hold and select service to activate widget...
internal static let noSelectedServices = T.tr("Localizable", "widget__no_selected_services", fallback: "Hold and select service to activate widget...")
/// There are no services in the app available for selection
internal static let noServices = T.tr("Localizable", "widget__no_services", fallback: "There are no services in the app available for selection")
/// Widget functionality is not enabled in 2FAS Settings section
Expand All @@ -1634,6 +1636,10 @@ internal enum T {
internal static let notEnabledNoServices = T.tr("Localizable", "widget__not_enabled_no_services", fallback: "Widget functionality is not enabled in 2FAS Settings section and there are no services in the app available for selection")
/// Placeholder
internal static let placeholder = T.tr("Localizable", "widget__placeholder", fallback: "Placeholder")
/// Reveal your 2FAS tokens for 60 seconds
internal static let revealTokensLongMessage = T.tr("Localizable", "widget__reveal_tokens_long_message", fallback: "Reveal your 2FAS tokens for 60 seconds")
/// Reveal for 60 seconds
internal static let revealTokensShortMessage = T.tr("Localizable", "widget__reveal_tokens_short_message", fallback: "Reveal for 60 seconds")
/// Select Service you want to show on your 2FAS Widget
internal static let selectServiceIntentDescription = T.tr("Localizable", "widget__select_service_intent_description", fallback: "Select Service you want to show on your 2FAS Widget")
/// Service icon
Expand Down
15 changes: 7 additions & 8 deletions TwoFAS/TwoFASWidget/AppIntent/AppIntentProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import TimeVerification

@available(iOS 17.0, macOS 14.0, watchOS 10.0, *)
struct AppIntentProvider: AppIntentTimelineProvider {
private let defaults = UserDefaults.standard
private let defaults = UserDefaults(suiteName: "group.twofas.com")
private let calendar = Calendar.current
typealias Intent = SelectService

Expand Down Expand Up @@ -129,7 +129,7 @@ struct AppIntentProvider: AppIntentTimelineProvider {
guard case Values.entry(let entryDescription) = value
else { return CodeEntry.Entry.placeholder() }

let showWithCode = !isLast && entryDescription.isValidSecret
let showWithCode = !isLast
let secondsToNewOne: Int = {
let period = entryDescription.period.rawValue
let currentSeconds: Int = calendar.component(.second, from: tokenDate)
Expand Down Expand Up @@ -204,19 +204,18 @@ struct AppIntentProvider: AppIntentTimelineProvider {
@available(iOS 17.0, macOS 14.0, watchOS 10.0, *)
extension AppIntentProvider {
private func clearDefaults() {
defaults.removeObject(forKey: CommonKeys.tapDate)
defaults.removeObject(forKey: CommonKeys.tapSecret)
defaults.synchronize()
defaults?.removeObject(forKey: CommonKeys.tapDate)
defaults?.removeObject(forKey: CommonKeys.tapSecret)
defaults?.synchronize()
}

private func handleClickableWidgets() -> (validSecret: Secret?, secondsLeft: Int) {
let validSecret: Secret?
let secondsLeft: Int

let dateValue = defaults.double(forKey: "tapDate")
if !dateValue.isZero {
if let dateValue = defaults?.double(forKey: "tapDate"), !dateValue.isZero {
let duration = Date().timeIntervalSince1970 - dateValue
if duration < 60.0, let storedSecret = defaults.string(forKey: "tapSecret") {
if duration < 60.0, let storedSecret = defaults?.string(forKey: "tapSecret") {
secondsLeft = 60 - Int(duration)
validSecret = storedSecret
} else {
Expand Down
8 changes: 4 additions & 4 deletions TwoFAS/TwoFASWidget/AppIntent/RevealTokenAppIntent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ struct RevealTokenAppIntent: AppIntent {

@MainActor
func perform() async throws -> some IntentResult {
let defaults = UserDefaults.standard
defaults.set(Date().timeIntervalSince1970, forKey: CommonKeys.tapDate)
defaults.set(secret, forKey: CommonKeys.tapSecret)
defaults.synchronize()
let defaults = UserDefaults(suiteName: "group.twofas.com")
defaults?.set(Date().timeIntervalSince1970, forKey: CommonKeys.tapDate)
defaults?.set(secret, forKey: CommonKeys.tapSecret)
defaults?.synchronize()

return .result()
}
Expand Down
4 changes: 2 additions & 2 deletions TwoFAS/TwoFASWidget/AppIntent/ServiceAppEntity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct ServiceAppEntity: AppEntity {
SelectedItems.list = identifiers
return AccessManager.serviceHandler.listAll(search: nil, exclude: [])
.flatMap({ $0.services })
.filter({ identifiers.contains($0.serviceID) && $0.period != .period10 })
.filter({ identifiers.contains($0.serviceID) })
.map({ service in
ServiceAppEntity(
id: service.serviceID,
Expand All @@ -57,7 +57,7 @@ struct ServiceAppEntity: AppEntity {
let all: [WidgetCategory] = AccessManager.serviceHandler.listAll(search: nil, exclude: [])
let sections = all.map({ category -> ItemSection<ServiceAppEntity> in
let services: [Item] = category.services
.filter({ !SelectedItems.list.contains($0.serviceID) && $0.period != .period10 })
.filter({ !SelectedItems.list.contains($0.serviceID) })
.map({ service in
let icon = service.icon.pngData()
let image: DisplayRepresentation.Image? = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.137",
"green" : "0.110",
"red" : "0.929"
"blue" : "0x22",
"green" : "0x1C",
"red" : "0xEC"
}
},
"idiom" : "universal"
Expand All @@ -23,9 +23,9 @@
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.137",
"green" : "0.110",
"red" : "0.898"
"blue" : "0x22",
"green" : "0x1C",
"red" : "0xE4"
}
},
"idiom" : "universal"
Expand Down
6 changes: 6 additions & 0 deletions TwoFAS/TwoFASWidget/Assets.xcassets/Colors/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xEA",
"green" : "0xE5",
"red" : "0xE5"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x9D",
"green" : "0x9D",
"red" : "0x9D"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x9D",
"green" : "0x9D",
"red" : "0x9D"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xED",
"green" : "0xED",
"red" : "0xED"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x35",
"green" : "0x35",
"red" : "0x35"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xFF",
"green" : "0xFF",
"red" : "0xFF"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xEA",
"green" : "0xEA",
"red" : "0xEA"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x00",
"green" : "0x00",
"red" : "0x00"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xFF",
"green" : "0xFF",
"red" : "0xFF"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit f2fddeb

Please sign in to comment.