mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
re-enable watch app
This commit is contained in:
parent
f05da1bb7a
commit
dd2fced95f
107
Telegram/BUILD
107
Telegram/BUILD
@ -629,6 +629,7 @@ objc_library(
|
||||
"Watch/SSignalKit/**/*.m",
|
||||
"Watch/Bridge/**/*.m",
|
||||
"Watch/WatchCommonWatch/**/*.m",
|
||||
"Watch/App/**/*.m",
|
||||
"Watch/Extension/**/*.h",
|
||||
"Watch/SSignalKit/**/*.h",
|
||||
"Watch/Bridge/**/*.h",
|
||||
@ -639,6 +640,7 @@ objc_library(
|
||||
"-ITelegram/Watch",
|
||||
"-ITelegram/Watch/Extension",
|
||||
"-ITelegram/Watch/Bridge",
|
||||
"-ITelegram/Watch/App",
|
||||
],
|
||||
sdk_frameworks = [
|
||||
"WatchKit",
|
||||
@ -682,26 +684,6 @@ plist_fragment(
|
||||
"""
|
||||
)
|
||||
|
||||
plist_fragment(
|
||||
name = "WatchExtensionNSExtensionInfoPlist",
|
||||
extension = "plist",
|
||||
template =
|
||||
"""
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionAttributes</key>
|
||||
<dict>
|
||||
<key>WKAppBundleIdentifier</key>
|
||||
<string>{telegram_bundle_id}.watchkitapp</string>
|
||||
</dict>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.watchkit</string>
|
||||
</dict>
|
||||
""".format(
|
||||
telegram_bundle_id = telegram_bundle_id,
|
||||
)
|
||||
)
|
||||
|
||||
plist_fragment(
|
||||
name = "WatchAppCompanionInfoPlist",
|
||||
extension = "plist",
|
||||
@ -714,28 +696,6 @@ plist_fragment(
|
||||
)
|
||||
)
|
||||
|
||||
plist_fragment(
|
||||
name = "WatchExtensionInfoPlist",
|
||||
extension = "plist",
|
||||
template =
|
||||
"""
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>{telegram_bundle_id}.watchkitapp.watchkitextension</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>Swiftgram</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>WKExtensionDelegateClassName</key>
|
||||
<string>TGExtensionDelegate</string>
|
||||
""".format(
|
||||
telegram_bundle_id = telegram_bundle_id,
|
||||
)
|
||||
)
|
||||
|
||||
plist_fragment(
|
||||
name = "WatchAppInfoPlist",
|
||||
extension = "plist",
|
||||
@ -752,68 +712,25 @@ plist_fragment(
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
</array>
|
||||
<key>WKWatchKitApp</key>
|
||||
<true/>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>WKApplication</key>
|
||||
<true/>
|
||||
<key>WKCompanionAppBundleIdentifier</key>
|
||||
<string>{telegram_bundle_id}</string>
|
||||
<key>PrincipalClass</key>
|
||||
<string>TGExtensionDelegate</string>
|
||||
""".format(
|
||||
telegram_bundle_id = telegram_bundle_id,
|
||||
)
|
||||
)
|
||||
|
||||
watchos_extension(
|
||||
name = "TelegramWatchExtension",
|
||||
bundle_id = "{telegram_bundle_id}.watchkitapp.watchkitextension".format(
|
||||
telegram_bundle_id = telegram_bundle_id,
|
||||
),
|
||||
bundle_name = "TelegramWatchExtension",
|
||||
infoplists = [
|
||||
":WatchExtensionInfoPlist",
|
||||
":VersionInfoPlist",
|
||||
":BuildNumberInfoPlist",
|
||||
":AppNameInfoPlist",
|
||||
":WatchExtensionNSExtensionInfoPlist",
|
||||
],
|
||||
minimum_os_version = minimum_watchos_version,
|
||||
provisioning_profile = select({
|
||||
":disableProvisioningProfilesSetting": None,
|
||||
"//conditions:default": "@build_configuration//provisioning:WatchExtension.mobileprovision",
|
||||
}),
|
||||
resources = [
|
||||
":TelegramWatchExtensionResources",
|
||||
],
|
||||
strings = [
|
||||
":WatchAppStringResources",
|
||||
],
|
||||
deps = [
|
||||
":TelegramWatchLib",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
genrule(
|
||||
name = "StripWatchosStubBinary",
|
||||
cmd_bash =
|
||||
"""
|
||||
echo 'lipo -remove armv7k -remove arm64 -remove arm64e $$1/TelegramWatch.app/_WatchKitStub/WK -output $$1/TelegramWatch.app/_WatchKitStub/WK' > $(location StripWatchosStubBinary.sh)
|
||||
echo '' >> $(location StripWatchosStubBinary.sh)
|
||||
""",
|
||||
outs = [
|
||||
"StripWatchosStubBinary.sh",
|
||||
],
|
||||
executable = True,
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
]
|
||||
)
|
||||
|
||||
watchos_application(
|
||||
name = "TelegramWatchApp",
|
||||
bundle_id = "{telegram_bundle_id}.watchkitapp".format(
|
||||
telegram_bundle_id = telegram_bundle_id,
|
||||
),
|
||||
bundle_name = "TelegramWatch",
|
||||
extension = ":TelegramWatchExtension",
|
||||
infoplists = [
|
||||
":WatchAppInfoPlist",
|
||||
":VersionInfoPlist",
|
||||
@ -826,15 +743,19 @@ watchos_application(
|
||||
":disableProvisioningProfilesSetting": None,
|
||||
"//conditions:default": "@build_configuration//provisioning:WatchApp.mobileprovision",
|
||||
}),
|
||||
ipa_post_processor = ":StripWatchosStubBinary",
|
||||
resources = [
|
||||
":TelegramWatchAppResources",
|
||||
":TelegramWatchAppAssets",
|
||||
":TelegramWatchExtensionResources",
|
||||
],
|
||||
storyboards = [
|
||||
":TelegramWatchAppInterface",
|
||||
],
|
||||
strings = [
|
||||
":WatchAppStringResources",
|
||||
],
|
||||
deps = [
|
||||
":TelegramWatchLib",
|
||||
],
|
||||
)
|
||||
|
||||
@ -2163,7 +2084,7 @@ ios_application(
|
||||
}),
|
||||
watch_application = select({
|
||||
":disableExtensionsSetting": None,
|
||||
"//conditions:default": None#":TelegramWatchApp",
|
||||
"//conditions:default": ":TelegramWatchApp",
|
||||
}) if telegram_enable_watch else None,
|
||||
deps = [
|
||||
":Main",
|
||||
|
8
Telegram/Watch/App/main.m
Normal file
8
Telegram/Watch/App/main.m
Normal file
@ -0,0 +1,8 @@
|
||||
#import <WatchKit/WatchKit.h>
|
||||
#import "TGExtensionDelegate.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
@autoreleasepool {
|
||||
return WKApplicationMain(argc, argv, @"TGExtensionDelegate");
|
||||
}
|
||||
}
|
@ -240,7 +240,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
let hasActiveAudioSession = Promise<Bool>(false)
|
||||
|
||||
private let sharedContextPromise = Promise<SharedApplicationContext>()
|
||||
//private let watchCommunicationManagerPromise = Promise<WatchCommunicationManager?>()
|
||||
private let watchCommunicationManagerPromise = Promise<WatchCommunicationManager?>()
|
||||
|
||||
private var accountManager: AccountManager<TelegramAccountManagerTypes>?
|
||||
private var accountManagerState: AccountManagerState?
|
||||
@ -1028,7 +1028,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
return .single(nil)
|
||||
}
|
||||
}
|
||||
/*let watchTasks = self.context.get()
|
||||
let watchTasks = self.context.get()
|
||||
|> mapToSignal { context -> Signal<AccountRecordId?, NoError> in
|
||||
if let context = context, let watchManager = context.context.watchManager {
|
||||
let accountId = context.context.account.id
|
||||
@ -1047,7 +1047,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
} else {
|
||||
return .single(nil)
|
||||
}
|
||||
}*/
|
||||
}
|
||||
let wakeupManager = SharedWakeupManager(beginBackgroundTask: { name, expiration in
|
||||
let id = application.beginBackgroundTask(withName: name, expirationHandler: expiration)
|
||||
Logger.shared.log("App \(self.episodeId)", "Begin background task \(name): \(id)")
|
||||
@ -1059,7 +1059,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
application.endBackgroundTask(id)
|
||||
}, backgroundTimeRemaining: { application.backgroundTimeRemaining }, acquireIdleExtension: {
|
||||
return applicationBindings.pushIdleTimerExtension()
|
||||
}, activeAccounts: sharedContext.activeAccountContexts |> map { ($0.0?.account, $0.1.map { ($0.0, $0.1.account) }) }, liveLocationPolling: liveLocationPolling, watchTasks: .single(nil), inForeground: applicationBindings.applicationInForeground, hasActiveAudioSession: self.hasActiveAudioSession.get(), notificationManager: notificationManager, mediaManager: sharedContext.mediaManager, callManager: sharedContext.callManager, accountUserInterfaceInUse: { id in
|
||||
}, activeAccounts: sharedContext.activeAccountContexts |> map { ($0.0?.account, $0.1.map { ($0.0, $0.1.account) }) }, liveLocationPolling: liveLocationPolling, watchTasks: watchTasks /* MARK: Swiftgram */, inForeground: applicationBindings.applicationInForeground, hasActiveAudioSession: self.hasActiveAudioSession.get(), notificationManager: notificationManager, mediaManager: sharedContext.mediaManager, callManager: sharedContext.callManager, accountUserInterfaceInUse: { id in
|
||||
return sharedContext.accountUserInterfaceInUse(id)
|
||||
})
|
||||
let sharedApplicationContext = SharedApplicationContext(sharedContext: sharedContext, notificationManager: notificationManager, wakeupManager: wakeupManager)
|
||||
@ -1078,7 +1078,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
return .single(sharedApplicationContext)
|
||||
})
|
||||
|
||||
//let watchManagerArgumentsPromise = Promise<WatchManagerArguments?>()
|
||||
let watchManagerArgumentsPromise = Promise<WatchManagerArguments?>()
|
||||
|
||||
self.context.set(self.sharedContextPromise.get()
|
||||
|> deliverOnMainQueue
|
||||
@ -1117,7 +1117,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
|> deliverOnMainQueue
|
||||
|> map { accountAndSettings -> AuthorizedApplicationContext? in
|
||||
return accountAndSettings.flatMap { context, callListSettings in
|
||||
return AuthorizedApplicationContext(sharedApplicationContext: sharedApplicationContext, mainWindow: self.mainWindow, watchManagerArguments: .single(nil), context: context as! AccountContextImpl, accountManager: sharedApplicationContext.sharedContext.accountManager, showContactsTab: callListSettings.showContactsTab, showCallsTab: callListSettings.showTab, reinitializedNotificationSettings: {
|
||||
return AuthorizedApplicationContext(sharedApplicationContext: sharedApplicationContext, mainWindow: self.mainWindow, watchManagerArguments: watchManagerArgumentsPromise.get(), context: context as! AccountContextImpl, accountManager: sharedApplicationContext.sharedContext.accountManager, showContactsTab: callListSettings.showContactsTab, showCallsTab: callListSettings.showTab, reinitializedNotificationSettings: {
|
||||
let _ = (self.context.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { context in
|
||||
@ -1374,7 +1374,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
}).start()
|
||||
}))
|
||||
|
||||
/*self.watchCommunicationManagerPromise.set(watchCommunicationManager(context: self.context.get() |> flatMap { WatchCommunicationManagerContext(context: $0.context) }, allowBackgroundTimeExtension: { timeout in
|
||||
self.watchCommunicationManagerPromise.set(watchCommunicationManager(context: self.context.get() |> flatMap { WatchCommunicationManagerContext(context: $0.context) }, allowBackgroundTimeExtension: { timeout in
|
||||
let _ = (self.sharedContextPromise.get()
|
||||
|> take(1)).start(next: { sharedContext in
|
||||
sharedContext.wakeupManager.allowBackgroundTimeExtension(timeout: timeout)
|
||||
@ -1386,7 +1386,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
} else {
|
||||
watchManagerArgumentsPromise.set(.single(nil))
|
||||
}
|
||||
})*/
|
||||
})
|
||||
|
||||
self.resetBadge()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user