summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2014-05-17 18:44:26 -0700
committerJay Freeman (saurik) <saurik@saurik.com>2014-05-17 18:46:30 -0700
commit821b1a0cfad8b1f3cdb3b32b69694ab2cbf39473 (patch)
treef9adbd945b4188df75e61a39fe9b389b35fabd73
parent237c3d1c44503c9be4762b43a841b011f5faeebb (diff)
Add "sort by last updated" to InstalledController.
-rw-r--r--MobileCydia.mm32
1 files changed, 30 insertions, 2 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm
index 32031c4..ce62d77 100644
--- a/MobileCydia.mm
+++ b/MobileCydia.mm
@@ -3013,6 +3013,10 @@ struct PackageNameOrdering :
return source_ == (Source *) [NSNull null] ? nil : source_;
}
+- (uint32_t) updated {
+ return std::numeric_limits<uint32_t>::max() - updated_;
+}
+
- (uint32_t) rank {
return rank_;
}
@@ -7808,6 +7812,7 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi
/* Installed Controller {{{ */
@interface InstalledController : FilteredPackageListController {
+ bool sectioned_;
}
- (id) initWithDatabase:(Database *)database;
@@ -7825,18 +7830,41 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi
return [NSURL URLWithString:@"cydia://installed"];
}
+- (bool) showsSections {
+ return sectioned_;
+}
+
+- (void) useUpdated {
+ sectioned_ = false;
+
+@synchronized (self) {
+ [self setFilter:[](Package *package) {
+ return ![package uninstalled] && package->role_ < 7;
+ }];
+
+ [self setSorter:[](NSMutableArray *packages) {
+ [packages radixSortUsingSelector:@selector(updated)];
+ }];
+} }
+
- (void) useFilter:(UISegmentedControl *)segmented {
- bool simple([segmented selectedSegmentIndex] == 0);
+ NSInteger selected([segmented selectedSegmentIndex]);
+ if (selected == 2)
+ return [self useUpdated];
+ bool simple(selected == 0);
+ sectioned_ = true;
@synchronized (self) {
[self setFilter:[=](Package *package) {
return ![package uninstalled] && package->role_ <= (simple ? 1 : 3);
}];
+
+ [self setSorter:nullptr];
} }
- (id) initWithDatabase:(Database *)database {
if ((self = [super initWithDatabase:database title:UCLocalize("INSTALLED")]) != nil) {
- UISegmentedControl *segmented([[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:UCLocalize("SIMPLE"), UCLocalize("EXPERT"), nil]] autorelease]);
+ UISegmentedControl *segmented([[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:UCLocalize("SIMPLE"), UCLocalize("EXPERT"), UCLocalize("RECENT"), nil]] autorelease]);
[segmented setSelectedSegmentIndex:0];
[segmented setSegmentedControlStyle:UISegmentedControlStyleBar];
[[self navigationItem] setTitleView:segmented];