diff --git a/UI/IAPScreen.cpp b/UI/IAPScreen.cpp index 3f9af0c258..c280fc9d5b 100644 --- a/UI/IAPScreen.cpp +++ b/UI/IAPScreen.cpp @@ -30,8 +30,8 @@ void IAPScreen::CreateViews() { appTitle->Add(new ShinyIcon(ImageID("I_ICONGOLD"), new LinearLayoutParams(64, 64))); appTitle->Add(new TextView("PPSSPP Gold", new LinearLayoutParams(1.0f, G_VCENTER))); + leftColumnItems->Add(appTitle); if (!bought) { - leftColumnItems->Add(appTitle); leftColumnItems->Add(new Spacer(20.0f)); leftColumnItems->Add(new TextView(di->T("GoldOverview1", "Buy PPSSPP Gold to support development!")))->SetAlign(FLAG_WRAP_TEXT); leftColumnItems->Add(new Spacer(10.0f)); diff --git a/ios/IAPManager.h b/ios/IAPManager.h index 2daf4e2649..f3b952c3c1 100644 --- a/ios/IAPManager.h +++ b/ios/IAPManager.h @@ -13,7 +13,7 @@ - (void)restorePurchasesWithRequestID:(int)requestID; - (BOOL)isGoldUnlocked; - (void)startObserving; -- (void)updateIcon; +- (void)updateIcon:(bool)force; @end diff --git a/ios/IAPManager.mm b/ios/IAPManager.mm index 4a0a566c2e..f31af7c4f3 100644 --- a/ios/IAPManager.mm +++ b/ios/IAPManager.mm @@ -1,5 +1,6 @@ #import "IAPManager.h" #import +#import "ViewControllerCommon.h" #include "Common/System/Request.h" #include "Common/Log.h" @@ -129,13 +130,17 @@ [[NSUserDefaults standardUserDefaults] synchronize]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [self updateIcon]; + [self updateIcon:true]; }); NSLog(@"[IAPManager] Gold unlocked!"); } -- (void)updateIcon { +static bool SafeStringEqual(NSString *a, NSString *b) { + return (a == b) || [a isEqualToString:b]; +} + +- (void)updateIcon:(bool)force { NSString *desiredIcon = nil; if ([self isGoldUnlocked]) { desiredIcon = @"GoldIcon"; @@ -151,24 +156,24 @@ NSLog(@"Current icon name: %@", [[UIApplication sharedApplication] alternateIconName]); if (desiredIcon) { - NSLog(@"IAPManager about to update icon to %@", desiredIcon); + NSLog(@"IAPManager about to update icon to %@ (force=%d)", desiredIcon, (int)force); } else { - NSLog(@"IAPManager about to reset the icon"); + NSLog(@"IAPManager about to reset the icon (force=%d)", (int)force); } - // Useful to set to true for debugging. - const bool force = false; if ([[UIApplication sharedApplication] supportsAlternateIcons]) { - if (force || ![[UIApplication sharedApplication].alternateIconName isEqualToString:desiredIcon]) { + if (force || !SafeStringEqual([UIApplication sharedApplication].alternateIconName, desiredIcon)) { // Name not matching, do the update. [[UIApplication sharedApplication] setAlternateIconName:desiredIcon completionHandler:^(NSError * _Nullable error) { if (error) { NSLog(@"[IAPManager] Failed to set Gold icon to %@: %@", desiredIcon, error.localizedDescription); + [sharedViewController hideKeyboard]; } else { NSLog(@"Icon update succeeded."); NSLog(@"Current icon name: %@", [[UIApplication sharedApplication] alternateIconName]); // Here we need to call hideKeyboard. + [sharedViewController hideKeyboard]; } }]; NSLog(@"Icon update to %@ dispatched, waiting for response.", desiredIcon); diff --git a/ios/ViewController.mm b/ios/ViewController.mm index fb77bb7da8..974bf3cede 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -244,7 +244,7 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) { [IAPManager sharedIAPManager]; // Kick off the IAPManager early. NSLog(@"Metal viewDidAppear. updating icon"); dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [[IAPManager sharedIAPManager] updateIcon]; + [[IAPManager sharedIAPManager] updateIcon:false]; [self hideKeyboard]; }); #endif // IOS_APP_STORE diff --git a/ios/ViewControllerMetal.mm b/ios/ViewControllerMetal.mm index 00def774ce..adf107489c 100644 --- a/ios/ViewControllerMetal.mm +++ b/ios/ViewControllerMetal.mm @@ -491,7 +491,7 @@ void VulkanRenderLoop(IOSVulkanContext *graphicsContext, CAMetalLayer *metalLaye [IAPManager sharedIAPManager]; // Kick off the IAPManager early. NSLog(@"Metal viewDidAppear. updating icon"); dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [[IAPManager sharedIAPManager] updateIcon]; + [[IAPManager sharedIAPManager] updateIcon:false]; [self hideKeyboard]; }); #endif // IOS_APP_STORE