diff --git a/Resources/Legacy/Localization/ar.lproj/Localizable.strings b/Resources/Legacy/Localization/ar.lproj/Localizable.strings index 702a90a1..c56ab5d1 100644 --- a/Resources/Legacy/Localization/ar.lproj/Localizable.strings +++ b/Resources/Legacy/Localization/ar.lproj/Localizable.strings @@ -67,6 +67,7 @@ "EXPANDED_SIZE" = "حجم موسع"; "EXPERT" = "خبير"; "FAQ" = "الأسئلة الشائعة"; +"FAVORITES" = "المفضلة"; "FEATURED_PACKAGES" = "حزم مميزة"; "FILES" = "الملفات"; "FILESYSTEM_CONTENT" = "محتوى Filesystem "; diff --git a/Resources/Legacy/Localization/en.lproj/Localizable.strings b/Resources/Legacy/Localization/en.lproj/Localizable.strings index 9baea5e1..e53bbf79 100644 --- a/Resources/Legacy/Localization/en.lproj/Localizable.strings +++ b/Resources/Legacy/Localization/en.lproj/Localizable.strings @@ -67,6 +67,7 @@ "EXPANDED_SIZE" = "Expanded Size"; "EXPERT" = "Expert"; "FAQ" = "FAQ"; +"FAVORITES" = "Favorites"; "FEATURED_PACKAGES" = "Featured Packages"; "FILES" = "Files"; "FILESYSTEM_CONTENT" = "Filesystem Content"; diff --git a/Resources/Legacy/Localization/fr.lproj/Localizable.strings b/Resources/Legacy/Localization/fr.lproj/Localizable.strings index df04db8e..e75f1da8 100644 --- a/Resources/Legacy/Localization/fr.lproj/Localizable.strings +++ b/Resources/Legacy/Localization/fr.lproj/Localizable.strings @@ -67,6 +67,7 @@ "EXPANDED_SIZE" = "Taille décompressée"; "EXPERT" = "Expert"; "FAQ" = "FAQ"; +"FAVORITES" = "Favoris"; "FEATURED_PACKAGES" = "Paquets conseillés"; "FILES" = "Fichiers"; "FILESYSTEM_CONTENT" = "Contenu"; diff --git a/Source/Controllers/Database/Database.h b/Source/Controllers/Database/Database.h index e4f580cd..dcb24053 100644 --- a/Source/Controllers/Database/Database.h +++ b/Source/Controllers/Database/Database.h @@ -97,4 +97,7 @@ typedef std::map< unsigned long, _H > SourceMap; - (NSString *) mappedSectionForPointer:(const char *)pointer; +// new favorites list +- (NSArray *)currentFavorites; +- (void)addPackageToFavoritesList:(Package *)package; @end diff --git a/Source/Controllers/Database/Database.mm b/Source/Controllers/Database/Database.mm index 3a7faab7..4e05c81b 100644 --- a/Source/Controllers/Database/Database.mm +++ b/Source/Controllers/Database/Database.mm @@ -777,4 +777,19 @@ - (NSString *) mappedSectionForPointer:(const char *)section { } return *mapped; } +// new favorites list +- (NSArray *)currentFavorites { + return [[NSUserDefaults standardUserDefaults] objectForKey:@"FavoritesPackages"]; +} + +- (void)addPackageToFavoritesList:(Package *)package { + NSMutableArray *currentFavoritesMutable = [[NSMutableArray alloc] initWithArray:[self currentFavorites]]; + if (currentFavoritesMutable == nil) { + currentFavoritesMutable = [[NSMutableArray alloc] init]; + } + NSString *packageID = package.id; + [currentFavoritesMutable addObject:packageID]; + [[NSUserDefaults standardUserDefaults] setObject:[currentFavoritesMutable copy] forKey:@"FavoritesPackages"]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} @end diff --git a/Source/Legacy/iPhonePrivate.h b/Source/Legacy/iPhonePrivate.h index 8aa6cb37..d6ddfca1 100644 --- a/Source/Legacy/iPhonePrivate.h +++ b/Source/Legacy/iPhonePrivate.h @@ -242,6 +242,7 @@ static const UIActivityIndicatorViewStyle UIActivityIndicatorViewStyleWhiteTiny( @interface UIColor (Apple) + (UIColor *) pinStripeColor; ++ (UIColor *)systemDarkGreenColor; @end @interface UIControl (Apple) @@ -291,6 +292,16 @@ static const UIActivityIndicatorViewStyle UIActivityIndicatorViewStyleWhiteTiny( - (void) _updateHighlightColorsForView:(id)view highlighted:(BOOL)highlighted; @end +@class UITableViewRowAction; +@interface _UITableViewCellActionButton : UIButton +- (void)setAction:(UITableViewRowAction *)arg1; +@end + +@interface UITableViewRowAction (Apple) +- (void)_setButton:(_UITableViewCellActionButton *)arg1; +- (id)_button; +@end + @interface UITextField (Apple) - (UITextInputTraits *) textInputTraits; @end diff --git a/Source/Models/Packages/Package/Package.h b/Source/Models/Packages/Package/Package.h index 751317fb..24e8fa42 100644 --- a/Source/Models/Packages/Package/Package.h +++ b/Source/Models/Packages/Package/Package.h @@ -96,6 +96,7 @@ struct ParsedPackage { - (bool) setSubscribed:(bool)subscribed; - (BOOL) ignored; +- (bool)isFavorited; - (NSString *) latest; - (NSString *) installed; diff --git a/Source/Models/Packages/Package/Package.mm b/Source/Models/Packages/Package/Package.mm index 832b3f42..e250de0f 100644 --- a/Source/Models/Packages/Package/Package.mm +++ b/Source/Models/Packages/Package/Package.mm @@ -1013,6 +1013,10 @@ - (bool) isCommercial { return [self hasTag:@"cydia::commercial"]; } +- (bool)isFavorited { + + return [[database_ currentFavorites] containsObject:[self id]]; +} - (void) setIndex:(size_t)index { if (metadata_->index_ != index) metadata_->index_ = index; diff --git a/Source/UI/Packages/View Controllers/InstalledController.mm b/Source/UI/Packages/View Controllers/InstalledController.mm index 0ff6da33..f1002c70 100644 --- a/Source/UI/Packages/View Controllers/InstalledController.mm +++ b/Source/UI/Packages/View Controllers/InstalledController.mm @@ -37,6 +37,10 @@ - (void) useRecent { - (void) useFilter:(UISegmentedControl *)segmented { NSInteger selected([segmented selectedSegmentIndex]); + [self updateInstalledListIfNeeded:NO]; + if (selected == 3) { + return [self updateInstalledListIfNeeded:YES]; + } if (selected == 2) return [self useRecent]; bool simple(selected == 0); @@ -48,7 +52,9 @@ - (void) useFilter:(UISegmentedControl *)segmented { }]; [self setSorter:nullptr]; - } } + } + +} - (NSArray *) sectionsForPackages:(NSMutableArray *)packages { if (sectioned_) @@ -93,7 +99,10 @@ - (NSArray *) sectionsForPackages:(NSMutableArray *)packages { - (id) initWithDatabase:(Database *)database { if ((self = [super initWithDatabase:database title:UCLocalize("INSTALLED")]) != nil) { - UISegmentedControl *segmented([[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:UCLocalize("USER"), UCLocalize("EXPERT"), UCLocalize("RECENT"), nil]] autorelease]); + UISegmentedControl *segmented([[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:UCLocalize("USER"), UCLocalize("EXPERT"), UCLocalize("RECENT"), UCLocalize("FAVORITES"), nil]] autorelease]); + segmented.layer.cornerRadius = CGRectGetHeight(segmented.bounds) / 2; + segmented.layer.borderColor = [UIColor colorWithRed:138 green:89 blue:255 alpha: 1.0].CGColor; + segmented.layer.borderWidth = 1; [segmented setSelectedSegmentIndex:0]; [segmented setSegmentedControlStyle:UISegmentedControlStyleBar]; [[self navigationItem] setTitleView:segmented]; @@ -131,4 +140,4 @@ - (void) modeChanged:(UISegmentedControl *)segmented { [self reloadData]; } -@end \ No newline at end of file +@end diff --git a/Source/UI/Packages/View Controllers/PackageListController.h b/Source/UI/Packages/View Controllers/PackageListController.h index f1e27519..221ade2c 100644 --- a/Source/UI/Packages/View Controllers/PackageListController.h +++ b/Source/UI/Packages/View Controllers/PackageListController.h @@ -33,4 +33,5 @@ - (void) didSelectPackage:(Package *)package; +- (void)updateInstalledListIfNeeded:(BOOL)needed; @end diff --git a/Source/UI/Packages/View Controllers/PackageListController.mm b/Source/UI/Packages/View Controllers/PackageListController.mm index b9a1276a..8bdd189e 100644 --- a/Source/UI/Packages/View Controllers/PackageListController.mm +++ b/Source/UI/Packages/View Controllers/PackageListController.mm @@ -120,6 +120,11 @@ - (void) viewDidAppear:(BOOL)animated { [self deselectWithAnimation:animated]; } +- (void)updateInstalledListIfNeeded:(BOOL)needed { + if (needed == YES) { + // reload table with favorites tweaks + } +} - (void) didSelectPackage:(Package *)package { CYPackageController *view([[[CYPackageController alloc] initWithDatabase:database_ forPackage:[package id] withReferrer:[[self referrerURL] absoluteString]] autorelease]); [view setDelegate:delegate_]; @@ -178,6 +183,27 @@ - (NSInteger) tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NS return offset_[index]; } +- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)path { + + Package *package([self packageAtIndexPath:path]); + package = [database_ packageWithName:[package id]]; + + _UITableViewCellActionButton *favoritesButton = [_UITableViewCellActionButton buttonWithType:UIButtonTypeCustom]; + [favoritesButton setFrame:CGRectMake(0, 0, 40, ([self isSummarized] ? 38 : 73))]; + [favoritesButton setImage:[UIImage imageNamed:@"home7s"] forState:UIControlStateNormal]; + favoritesButton.imageView.contentMode = UIViewContentModeScaleAspectFit; + [favoritesButton setBackgroundColor:[UIColor systemDarkGreenColor]]; + UITableViewRowAction *addToFavoritesAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) { + + [tableView setEditing:NO animated:YES]; + [database_ addPackageToFavoritesList:package]; + + }]; + [addToFavoritesAction _setButton:favoritesButton]; + addToFavoritesAction.backgroundColor = [UIColor systemDarkGreenColor]; + return @[addToFavoritesAction]; +} + - (void) updateHeight { [list_ setRowHeight:([self isSummarized] ? 38 : 73)]; } @@ -374,4 +400,4 @@ - (void) clearData { [self resetCursor]; } -@end \ No newline at end of file +@end