From 1ccde0427ec37b4ed388024a7a210d14943ecd95 Mon Sep 17 00:00:00 2001 From: Florin9doi Date: Sat, 25 Apr 2020 10:07:35 +0300 Subject: [PATCH] iOS Share PPSSPP --- UI/MiscScreens.cpp | 2 +- ios/ViewController.h | 1 + ios/ViewController.mm | 8 ++++++++ ios/main.mm | 3 +++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index ffe61126a0..f170edaf67 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -535,7 +535,7 @@ void CreditsScreen::CreateViews() { root_->Add(new Button("www.ppsspp.org", new AnchorLayoutParams(260, 64, 10, NONE, NONE, 10, false)))->OnClick.Handle(this, &CreditsScreen::OnPPSSPPOrg); root_->Add(new Button(cr->T("Privacy Policy"), new AnchorLayoutParams(260, 64, 10, NONE, NONE, 84, false)))->OnClick.Handle(this, &CreditsScreen::OnPrivacy); root_->Add(new Button(cr->T("Twitter @PPSSPP_emu"), new AnchorLayoutParams(260, 64, NONE, NONE, 10, rightYOffset + 84, false)))->OnClick.Handle(this, &CreditsScreen::OnTwitter); -#if PPSSPP_PLATFORM(ANDROID) +#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(IOS) root_->Add(new Button(cr->T("Share PPSSPP"), new AnchorLayoutParams(260, 64, NONE, NONE, 10, rightYOffset + 158, false)))->OnClick.Handle(this, &CreditsScreen::OnShare); #endif if (System_GetPropertyBool(SYSPROP_APP_GOLD)) { diff --git a/ios/ViewController.h b/ios/ViewController.h index 340ea79a79..d64d973c77 100644 --- a/ios/ViewController.h +++ b/ios/ViewController.h @@ -12,6 +12,7 @@ @interface ViewController : GLKViewController +- (void)shareText:(NSString *)text; - (void)shutdown; @end diff --git a/ios/ViewController.mm b/ios/ViewController.mm index 81c1960aee..73fd05c7fd 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -148,6 +148,14 @@ static LocationHelper *locationHelper; - (void)subtleVolume:(SubtleVolume *)volumeView didChange:(CGFloat)value { } +- (void)shareText:(NSString *)text { + NSArray *items = @[text]; + UIActivityViewController * viewController = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil]; + dispatch_async(dispatch_get_main_queue(), ^{ + [self presentViewController:viewController animated:YES completion:nil]; + }); +} + - (void)viewSafeAreaInsetsDidChange { if (@available(iOS 11.0, *)) { [super viewSafeAreaInsetsDidChange]; diff --git a/ios/main.mm b/ios/main.mm index 7d755013bd..b01e784113 100644 --- a/ios/main.mm +++ b/ios/main.mm @@ -114,6 +114,9 @@ void System_SendMessage(const char *command, const char *parameter) { // [sharedViewController shutdown]; // exit(0); // }); + } else if (!strcmp(command, "sharetext")) { + NSString *text = [NSString stringWithUTF8String:parameter]; + [sharedViewController shareText:text]; } else if (!strcmp(command, "camera_command")) { if (!strncmp(parameter, "startVideo", 10)) { int width = 0, height = 0;