Adding reachability preference (wifi only vs wifi + cellular).

This commit is contained in:
Samuel Clay 2013-09-04 15:56:37 -07:00
parent 9b5216d1c2
commit 0d1e96d81a
7 changed files with 39 additions and 13 deletions

View file

@ -352,6 +352,7 @@
- (void)startOfflineQueue;
- (void)startOfflineFetchStories;
- (void)startOfflineFetchImages;
- (BOOL)isReachabileForOffline;
- (void)queueReadStories:(NSDictionary *)feedsStories;
- (void)flushQueuedReadStories:(BOOL)forceCheck withCallback:(void(^)())callback;
- (void)syncQueuedReadStories:(FMDatabase *)db withStories:(NSDictionary *)hashes withCallback:(void(^)())callback;

View file

@ -2313,6 +2313,20 @@
[offlineQueue addOperation:operationFetchImages];
}
- (BOOL)isReachabileForOffline {
Reachability *reachability = [Reachability reachabilityForInternetConnection];
NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus];
NSString *connection = [[NSUserDefaults standardUserDefaults]
stringForKey:@"offline_download_connection"];
NSLog(@"Reachable via: %d / %d", remoteHostStatus == ReachableViaWWAN, remoteHostStatus == ReachableViaWiFi);
if ([connection isEqualToString:@"wifi"] && remoteHostStatus != ReachableViaWiFi) {
return NO;
}
return YES;
}
- (void)queueReadStories:(NSDictionary *)feedsStories {
[self.database inTransaction:^(FMDatabase *db, BOOL *rollback) {

View file

@ -52,6 +52,15 @@
});
return NO;
}
if (![appDelegate isReachabileForOffline]) {
dispatch_async(dispatch_get_main_queue(), ^{
[appDelegate.feedsViewController showDoneNotifier];
[appDelegate.feedsViewController hideNotifier];
});
return NO;
}
NSMutableArray *downloadRequests = [NSMutableArray array];
for (NSArray *urlArray in urls) {

View file

@ -34,8 +34,10 @@
}
if (![[[NSUserDefaults standardUserDefaults]
objectForKey:@"offline_allowed"] boolValue]) {
BOOL offlineAllowed = [[[NSUserDefaults standardUserDefaults]
objectForKey:@"offline_allowed"] boolValue];
if (!offlineAllowed ||
![appDelegate isReachabileForOffline]) {
dispatch_async(dispatch_get_main_queue(), ^{
[appDelegate.feedsViewController showDoneNotifier];
[appDelegate.feedsViewController hideNotifier];

View file

@ -5,7 +5,7 @@
<key>application-identifier</key>
<string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>
<key>get-task-allow</key>
<false/>
<true/>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>

View file

@ -49,7 +49,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.4.3</string>
<string>2.4.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
@ -78,7 +78,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>2.4.3</string>
<string>2.4.4</string>
<key>FacebookAppID</key>
<string>230426707030569</string>
<key>LSRequiresIPhoneOS</key>

View file

@ -2658,8 +2658,8 @@
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_ENTITLEMENTS = Entitlements.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution: NewsBlur, Inc.";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: NewsBlur, Inc.";
CODE_SIGN_IDENTITY = "iPhone Developer: Samuel Clay (G9HFWP68T7)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Samuel Clay (G9HFWP68T7)";
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
@ -2682,8 +2682,8 @@
"-all_load",
);
PRODUCT_NAME = NewsBlur;
PROVISIONING_PROFILE = "EE8BC292-FFF2-41A0-AE29-C4B39D6A2C5A";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "EE8BC292-FFF2-41A0-AE29-C4B39D6A2C5A";
PROVISIONING_PROFILE = "";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
TARGETED_DEVICE_FAMILY = "1,2";
VALID_ARCHS = armv7;
"WARNING_CFLAGS[arch=*]" = "-Wall";
@ -2697,8 +2697,8 @@
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_ENTITLEMENTS = Entitlements.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution: NewsBlur, Inc.";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: NewsBlur, Inc.";
CODE_SIGN_IDENTITY = "iPhone Developer: Samuel Clay (G9HFWP68T7)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Samuel Clay (G9HFWP68T7)";
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = NewsBlur_Prefix.pch;
@ -2718,8 +2718,8 @@
"-all_load",
);
PRODUCT_NAME = NewsBlur;
PROVISIONING_PROFILE = "EE8BC292-FFF2-41A0-AE29-C4B39D6A2C5A";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "EE8BC292-FFF2-41A0-AE29-C4B39D6A2C5A";
PROVISIONING_PROFILE = "";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VALID_ARCHS = armv7;