Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(create-meeting): custom url for new meetings #137

Merged
merged 10 commits into from
Jan 15, 2021
17 changes: 17 additions & 0 deletions MeetingBar/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,23 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
openMeetingURL(nil, CreateMeetingLinks.outlook_office365)
case .outlook_live:
openMeetingURL(nil, CreateMeetingLinks.outlook_live)
case .url:
var url: String = Defaults[.createMeetingServiceUrl]

if !url.isEmpty, let checkedUrl = NSURL(string: url) {
if !url.starts(with: "http://") && !url.starts(with: "https://") {
url = "https://" + url
}

openMeetingURL(nil, URL(string: url)!)
leits marked this conversation as resolved.
Show resolved Hide resolved
} else {
let createUrlAlert = NSAlert()
createUrlAlert.messageText = "Cannot create new meeting"
createUrlAlert.informativeText = "The custom url \(url) is missing or not valid. Please enter a custom url in the app preferences."
createUrlAlert.alertStyle = NSAlert.Style.informational
createUrlAlert.addButton(withTitle: "OK")
createUrlAlert.runModal()
}
}
}

Expand Down
1 change: 1 addition & 0 deletions MeetingBar/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ enum CreateMeetingServices: String, Codable, CaseIterable {
case gcalendar = "Google Calendar"
case outlook_live = "Outlook Live"
case outlook_office365 = "Outlook Office365"
case url = "Custom url"
}

enum Links {
Expand Down
4 changes: 4 additions & 0 deletions MeetingBar/DefaultsKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ extension Defaults.Keys {

// Integrations
static let createMeetingService = Key<CreateMeetingServices>("createMeetingService", default: .zoom)

// custom url to create meetings
static let createMeetingServiceUrl = Key<String>("createMeetingServiceUrl", default: "")

static let useChromeForMeetLinks = Key<ChromeExecutable>("useChromeForMeetLinks", default: .defaultBrowser)
static let useChromeForHangoutsLinks = Key<ChromeExecutable>("useChromeForHangoutsLinks", default: .defaultBrowser)
static let useAppForZoomLinks = Key<Bool>("useAppForZoomLinks", default: false)
Expand Down
49 changes: 34 additions & 15 deletions MeetingBar/PreferencesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,47 @@ struct Configuration: View {
}.foregroundColor(.gray).font(.system(size: 12)).padding(.horizontal, 10)
Divider()
HStack {
Text("Create meetings in").frame(width: 150, alignment: .leading)
CreateMeetingServicePicker()
}.padding(.horizontal, 10)
Spacer()
}.padding()
}
}

struct CreateMeetingServicePicker: View {
@Default(.createMeetingService) var createMeetingService
@Default(.createMeetingServiceUrl) var createMeetingServiceUrl

var body: some View {
VStack(alignment: .leading) {
HStack {
Text("Create meetings via").frame(width: 150, alignment: .leading)
Picker(selection: $createMeetingService, label: Text("")) {
Text(CreateMeetingServices.meet.rawValue).tag(CreateMeetingServices.meet)
Text(CreateMeetingServices.zoom.rawValue).tag(CreateMeetingServices.zoom)
Text(CreateMeetingServices.teams.rawValue).tag(CreateMeetingServices.teams)
Text(CreateMeetingServices.hangouts.rawValue).tag(CreateMeetingServices.hangouts)
Text(CreateMeetingServices.gcalendar.rawValue).tag(CreateMeetingServices.gcalendar)
Text(CreateMeetingServices.outlook_live.rawValue).tag(CreateMeetingServices.outlook_live)
Text(CreateMeetingServices.outlook_office365.rawValue).tag(CreateMeetingServices.outlook_office365)
Text(CreateMeetingServices.url.rawValue).tag(CreateMeetingServices.url)
}.labelsHidden()
}


if createMeetingService == CreateMeetingServices.url {
HStack {
Text("Custom url").frame(width: 150, alignment: .leading)
TextField("Please enter a valid url", text: $createMeetingServiceUrl).textFieldStyle(RoundedBorderTextFieldStyle())
}
HStack {
Text("Tip: Google Meet supports choosing account via parameter, e.g. https://meet.google.com/new?authuser=1").foregroundColor(.gray).font(.system(size: 12))
}
}
}
}
}

struct Bookmark: View {
@Default(.bookmarkMeetingName) var bookmarkMeetingName
@Default(.bookmarkMeetingURL) var bookmarkMeetingURL
Expand Down Expand Up @@ -621,21 +654,7 @@ struct Bookmark: View {



struct CreateMeetingServicePicker: View {
@Default(.createMeetingService) var createMeetingService

var body: some View {
Picker(selection: $createMeetingService, label: Text("")) {
Text(CreateMeetingServices.meet.rawValue).tag(CreateMeetingServices.meet)
Text(CreateMeetingServices.zoom.rawValue).tag(CreateMeetingServices.zoom)
Text(CreateMeetingServices.teams.rawValue).tag(CreateMeetingServices.teams)
Text(CreateMeetingServices.hangouts.rawValue).tag(CreateMeetingServices.hangouts)
Text(CreateMeetingServices.gcalendar.rawValue).tag(CreateMeetingServices.gcalendar)
Text(CreateMeetingServices.outlook_live.rawValue).tag(CreateMeetingServices.outlook_live)
Text(CreateMeetingServices.outlook_office365.rawValue).tag(CreateMeetingServices.outlook_office365)
}.labelsHidden()
}
}

struct JoinEventNotificationPicker: View {
@Default(.joinEventNotification) var joinEventNotification
Expand Down
2 changes: 0 additions & 2 deletions MeetingBar/StatusBarItemControler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ class StatusBarItemControler: NSObject, NSMenuDelegate {
withTitle: dateTitle,
action: nil,
keyEquivalent: ""

)
titleItem.attributedTitle = NSAttributedString(string: dateTitle, attributes: [NSAttributedString.Key.font: NSFont.boldSystemFont(ofSize: 13)])
titleItem.isEnabled = false
Expand All @@ -291,7 +290,6 @@ class StatusBarItemControler: NSObject, NSMenuDelegate {
withTitle: "Nothing for \(title.lowercased())",
action: nil,
keyEquivalent: ""

)
item.isEnabled = false
}
Expand Down