mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
More IAP improvements
This commit is contained in:
+1
-1
@@ -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));
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
- (void)restorePurchasesWithRequestID:(int)requestID;
|
||||
- (BOOL)isGoldUnlocked;
|
||||
- (void)startObserving;
|
||||
- (void)updateIcon;
|
||||
- (void)updateIcon:(bool)force;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
+12
-7
@@ -1,5 +1,6 @@
|
||||
#import "IAPManager.h"
|
||||
#import <UIKit/UIKit.h>
|
||||
#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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user