Merge pull request #146 from tylinux/main

Let App list show icon and version
This commit is contained in:
Lars Fröder 2022-09-12 15:14:48 +02:00 committed by GitHub
commit 92e4981ac0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 5 deletions

View File

@ -2,6 +2,10 @@
#import "TSApplicationsManager.h"
@interface UIImage ()
+ (UIImage *)_applicationIconImageForBundleIdentifier:(NSString *)id format:(NSInteger)format scale:(double)scale;
@end
@implementation TSAppTableViewController
- (void)reloadTable
@ -15,7 +19,6 @@
- (void)loadView
{
[super loadView];
[self.tableView registerClass:UITableViewCell.class forCellReuseIdentifier:@"ApplicationCell"];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reloadTable)
name:@"ApplicationsChanged"
@ -81,16 +84,27 @@
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ApplicationCell" forIndexPath:indexPath];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ApplicationCell"];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"ApplicationCell"];
}
NSString* appPath = [[TSApplicationsManager sharedInstance] installedAppPaths][indexPath.row];
NSString* appId = [[TSApplicationsManager sharedInstance] appIdForAppPath:appPath];
NSString* appVersion = [[TSApplicationsManager sharedInstance] versionStringForAppPath:appPath];
// Configure the cell...
cell.textLabel.text = [[TSApplicationsManager sharedInstance] displayNameForAppPath:appPath];
cell.detailTextLabel.text = appVersion;
cell.imageView.image = [UIImage _applicationIconImageForBundleIdentifier:appId format:10 scale:2.0];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 80.0f;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if(editingStyle == UITableViewCellEditingStyleDelete)

View File

@ -12,6 +12,7 @@
- (NSDictionary*)infoDictionaryForAppPath:(NSString*)appPath;
- (NSString*)appIdForAppPath:(NSString*)appPath;
- (NSString*)displayNameForAppPath:(NSString*)appPath;
- (NSString*)versionStringForAppPath:(NSString*)appPath;
- (NSError*)errorForCode:(int)code;
- (int)installIpa:(NSString*)pathToIpa force:(BOOL)force log:(NSString**)logOut;

View File

@ -57,6 +57,11 @@
return displayName;
}
- (NSString*)versionStringForAppPath:(NSString*)appPath
{
return [self infoDictionaryForAppPath:appPath][@"CFBundleShortVersionString"];
}
- (NSError*)errorForCode:(int)code
{
NSString* errorDescription = @"Unknown Error";