Skip to content

Commit

Permalink
Beautify Filename added
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakey authored and Jakey committed Nov 22, 2018
1 parent 851d294 commit 603dcc0
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 59 deletions.
2 changes: 2 additions & 0 deletions ProfilesManager/Base.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"Warning" = "Warning";
"Are you sure delete selected items from disk? After delete operation can't rollback!" = "Are you sure delete selected items from disk? After delete operation can't rollback!";
"Are you sure move selected items to trash?" = "Are you sure move selected items to trash?"
"The profile installed by double click fileaname format is 'uuid+ext',it‘s very hard identify.\nare you sure rename profile filename? this will take 5 seconds!\nthe new filename is: " = "The profile installed by double click fileaname format is 'uuid+ext',it‘s very hard identify.\nare you sure rename profile filename? this will take 5 seconds!\nthe new filename is: ";
"The filename no need beautify" = "the filename no need beautify";
"Export" = "Export";
"Beautify Filename" = "Beautify Filename";
"Provision QuickLook Plug-in is already Installed" = "Provision QuickLook Plug-in is already Installed";
Expand Down
3 changes: 2 additions & 1 deletion ProfilesManager/Controller/ProfilesManagerViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
@interface ProfilesManagerViewController : NSViewController<NSOutlineViewDataSource,NSOutlineViewDelegate,NSMenuDelegate>
{
NSString *_profileDir;

NSString *_backupDir;

NSMenu *_itemMenu;
NSMenu *_certificateMenu;
NSMenu *_mainMenu;
Expand Down
135 changes: 82 additions & 53 deletions ProfilesManager/Controller/ProfilesManagerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#import "iAlert.h"
#import "PreviewViewController.h"
#import "PlistManager.h"

#import "DateManager.h"
//#include <unistd.h>
//#include <sys/types.h>
//#include <pwd.h>
Expand All @@ -32,10 +32,20 @@ @implementation ProfilesManagerViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do view setup here.
[self createDir];
[self treeViewBuilder];
}
- (void)createDir{
_profileDir = [NSString stringWithFormat:@"%@/Library/MobileDevice/Provisioning Profiles/", [[NSFileManager defaultManager] realHomeDirectory]];
_backupDir = [NSString stringWithFormat:@"%@/Library/MobileDevice/Provisioning Profiles Rename Backup/", [[NSFileManager defaultManager] realHomeDirectory]];
if(![[NSFileManager defaultManager] fileExistsAtPath:_backupDir]){
[[NSFileManager defaultManager] createDirectoryAtPath:_backupDir withIntermediateDirectories:YES attributes:nil error:nil];
}
if(![[NSFileManager defaultManager] fileExistsAtPath:_profileDir]){
[[NSFileManager defaultManager] createDirectoryAtPath:_profileDir withIntermediateDirectories:YES attributes:nil error:nil];
}
}
- (void)treeViewBuilder{
//当拖拽窗口大小,NSOutlineView frame自动更改时,Column宽等比增减
[self.treeView setColumnAutoresizingStyle:NSTableViewUniformColumnAutoresizingStyle];
//最后一行自动宽等比增减
Expand All @@ -55,8 +65,8 @@ - (void)viewDidLoad {
{
[iAlert showMessage:[error localizedDescription]
window:self.view.window completionHandler:^(NSModalResponse returnCode) {

}];
}];
}
}
[self loadProfileFilesWithSearchWord:_searchWord];
Expand All @@ -66,9 +76,7 @@ - (void)viewDidLoad {
[self presentViewControllerAsModalWindow:preview];
}
}];

}

- (void)loadProfileFilesWithSearchWord:(NSString*)searchWord {
_searchWord = searchWord;

Expand Down Expand Up @@ -287,14 +295,14 @@ - (void)menuWillOpen:(NSMenu *)menu
[exportItem setTag:1003];
[menu addItem:exportItem];
}
// NSMenuItem *renameItem = [menu itemWithTag:1004];
// if (!renameItem)
// {
// renameItem = [[NSMenuItem alloc] initWithTitle:JKLocalizedString(@"Beautify Filename",nil) action:@selector(renameItemClick:) keyEquivalent:@""];
// [renameItem setTarget:self];
// [renameItem setTag:1004];
// [menu addItem:renameItem];
// }
NSMenuItem *renameItem = [menu itemWithTag:1004];
if (!renameItem)
{
renameItem = [[NSMenuItem alloc] initWithTitle:JKLocalizedString(@"Beautify Filename",nil) action:@selector(renameItemClick:) keyEquivalent:@""];
[renameItem setTarget:self];
[renameItem setTag:1004];
[menu addItem:renameItem];
}
}
if(menu == _mainMenu){
NSMenuItem *refreshItem = [menu itemWithTag:2000];
Expand Down Expand Up @@ -428,25 +436,38 @@ - (void)showInFinder:(id)sender
NSArray *activateFileURLs =[self activateFileURLs];
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:activateFileURLs];
}
////beautify filename
//- (void)renameItemClick:(id)sender{
// NSInteger index = [self.treeView clickedRow];
// ProfilesNode *node = [self.treeView itemAtRow:index];
//
// iAlert *alert = [iAlert alertWithTitle:JKLocalizedString(@"Warning",nil) message:JKLocalizedString(@"are you sure rename profile filename ?",nil) style:NSAlertStyleWarning];
// [alert addCommonButtonWithTitle:JKLocalizedString(@"Ok", nil) handler:^(iAlertItem *item) {
//
// if (index == -1) return;
// if ([self renameFileAtPath:node.filePath toName:node.type]) {
// [self.treeView beginUpdates];
// [self.treeView reloadItem:node];
// [self.treeView endUpdates];
// }
// }];
//
// [alert addButtonWithTitle:JKLocalizedString(@"Cancle", nil)];
// [alert show:self.view.window];
//}
//beautify filename
- (void)renameItemClick:(id)sender{
NSInteger index = [self.treeView clickedRow];
ProfilesNode *node = [self.treeView itemAtRow:index];

if([node.filePath.lastPathComponent hasPrefix:node.type]){
[iAlert showMessage:JKLocalizedString(@"The filename no need beautify",nil) window:self.view.window completionHandler:^(NSModalResponse returnCode) {

}];
return;
}


NSString *msg = JKLocalizedString(@"The profile installed by double click fileaname format is 'uuid+ext',it‘s very hard identify.\nare you sure rename profile filename? this will take 5 seconds!\nthe new filename is: ",nil);

iAlert *alert = [iAlert alertWithTitle:JKLocalizedString(@"Warning",nil) message:[NSString stringWithFormat:@"%@%@",msg,node.type] style:NSAlertStyleWarning];
[alert addCommonButtonWithTitle:JKLocalizedString(@"Ok", nil) handler:^(iAlertItem *item) {

if (index == -1) return;
NSString *newPath = [self renameFileAtPath:node.filePath toName:node.type];
if (newPath && newPath.length>0) {
node.filePath = newPath;
node.key = [newPath lastPathComponent];
[self.treeView beginUpdates];
[self.treeView reloadItem:node];
[self.treeView endUpdates];
}
}];

[alert addButtonWithTitle:JKLocalizedString(@"Cancle", nil)];
[alert show:self.view.window];
}
//export Item to file
- (void)exportItemClick:(id)sender {
NSInteger index = [self.treeView clickedRow];
Expand Down Expand Up @@ -480,7 +501,7 @@ - (void)importItemClick:(id)sender{
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
[oPanel setCanChooseDirectories:YES];
[oPanel setDirectoryURL:[NSURL URLWithString:NSHomeDirectory()]];
[oPanel setAllowedFileTypes:@[@"mobileprovision", @"MOBILEPROVISION"]];
[oPanel setAllowedFileTypes:@[@"mobileprovision", @"MOBILEPROVISION",@"provisionprofile"]];

if ([oPanel runModal] == NSModalResponseOK) {
NSString *path =[[[oPanel URLs] objectAtIndex:0] path];
Expand Down Expand Up @@ -542,25 +563,33 @@ - (BOOL)deleteProfile:(NSString*)filePath option:(BOOL)completely {
return result;
}

//-(BOOL)renameFileAtPath:(NSString *)oldPath toName:(NSString *)toName {
// BOOL result = NO;
// NSError * error = nil;
// NSString *toPath = [[[oldPath stringByDeletingLastPathComponent] stringByAppendingPathComponent:toName] stringByAppendingPathExtension:@"mobileprovision"];
//
// NSString *tempFolder = [[oldPath stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"temp"];
// if (![[NSFileManager defaultManager] fileExistsAtPath:tempFolder]) {
// [[NSFileManager defaultManager] createDirectoryAtPath:tempFolder withIntermediateDirectories:YES attributes:nil error:nil];
// }
// NSString *tempPath = [tempFolder stringByAppendingPathComponent:oldPath.lastPathComponent];
//
// result = [[NSFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:oldPath] toURL:[NSURL fileURLWithPath:tempPath] error:&error];
//
// result = [[NSFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:tempPath] toURL:[NSURL fileURLWithPath:toPath] error:&error];
//
// if (error){ NSLog(@"重命名失败:%@",[error localizedDescription]);
//
// }
// return result;
//}
-(NSString *)renameFileAtPath:(NSString *)oldPath toName:(NSString *)toName {
BOOL result = NO;
NSError * error = nil;

NSString *ext = oldPath.pathExtension;

NSString *time = [[DateManager sharedManager] stringConvert_Y_M_D_H_M_FromDate:[NSDate date]];


NSString *toPath = [[[_backupDir stringByAppendingPathComponent:toName] stringByAppendingString:time] stringByAppendingPathExtension:ext];


NSString *newPath = [[_profileDir stringByAppendingPathComponent:toName] stringByAppendingPathExtension:ext];

result = [[NSFileManager defaultManager] moveItemAtPath:oldPath toPath:toPath error:&error];
//Provisioning Profiles文件比较特殊 直接改名会被系统自动删掉
sleep(5);
result = [[NSFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:toPath] toURL:[NSURL fileURLWithPath:newPath] error:&error];

if (error){
[iAlert showAlert:NSAlertStyleWarning title:@"" message:[error localizedDescription]];
NSLog(@"重命名失败:%@",[error localizedDescription]);
}
if(result){
return newPath;
}
return nil;
}

@end
2 changes: 1 addition & 1 deletion ProfilesManager/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.3</string>
<string>2.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
1 change: 1 addition & 0 deletions ProfilesManager/Manager/DateManager/DateManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
@interface DateManager : NSObject
+ (DateManager *)sharedManager;
- (NSString *)stringConvert_YMDHM_FromDate:(NSDate *)date;
- (NSString *)stringConvert_Y_M_D_H_M_FromDate:(NSDate *)date;
@end
4 changes: 4 additions & 0 deletions ProfilesManager/Manager/DateManager/DateManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ - (NSString *)stringConvert_YMDHM_FromDate:(NSDate *)date{
[_dateForrmatter setDateFormat:@"yyyy-MM-dd HH:mm"];
return [_dateForrmatter stringFromDate:date];
}
- (NSString *)stringConvert_Y_M_D_H_M_FromDate:(NSDate *)date{
[_dateForrmatter setDateFormat:@"yyyy-MM-dd-HH-mm"];
return [_dateForrmatter stringFromDate:date];
}
@end
2 changes: 2 additions & 0 deletions ProfilesManager/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"Warning" = "Warning";
"Are you sure delete selected items from disk? After delete operation can't rollback!" = "Are you sure delete selceted items from disk? After delete operation can't rollback!";
"Are you sure move selected items to trash?" = "Are you sure move selected items to trash?";
"The profile installed by double click fileaname format is 'uuid+ext',it‘s very hard identify.\nare you sure rename profile filename? this will take 5 seconds!\nthe new filename is: " = "The profile installed by double click fileaname format is 'uuid+ext',it‘s very hard identify.\nare you sure rename profile filename? this will take 5 seconds!\nthe new filename is: ";
"The filename no need beautify" = "the filename no need beautify";
"Export" = "Export";
"Beautify Filename" = "Beautify Filename";
"Provision QuickLook Plug-in is already Installed" = "Provision QuickLook Plug-in is already Installed";
Expand Down
2 changes: 2 additions & 0 deletions ProfilesManager/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"Warning" = "警告";
"Are you sure delete selected items from disk? After delete operation can't rollback!" = "确定将选中的所有文件从磁盘删除? 删除之后不可回滚!";
"Are you sure move selected items to trash?" = "确定将选中的所有文件移动到废纸篓么?";
"The profile installed by double click fileaname format is 'uuid+ext',it‘s very hard identify.\nare you sure rename profile filename? this will take 5 seconds!\nthe new filename is: " = "通过双击安装的Profie文件名格式为'uuid+ext',很难辨别。\n确定重命名配置文件么? 这将需要5秒!\n新文件名为:";
"The filename no need beautify" = "文件名不需要美化";
"Export" = "导出";
"Beautify Filename" = "美化文件名";
"Provision QuickLook Plug-in is already Installed" = "描述文件快速查看插件已经安装";
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
iOS Provisioning Profiles, .mobileprovision files manager tool for mac

## Features
### 2.4
- Right-click Item Beautify Filename 右键美化物理文件名,通过双击安装的描述文件名都是UUID,美化过后与AppStore描述文件名一致。

### 2.3
- onekey uninstall or install quicklook plug-in,support view the .ipa/.xcarchive/.appex/.mobileprovision/.provisionprofile files directly use the the blank space key. 点击左上角的快速预览按钮,安装插件。插件可以直接预览后缀为.ipa/.xcarchive/.appex/.mobileprovision/.provisionprofile的文件,在文件上空格即可.

Expand All @@ -15,11 +18,11 @@ iOS Provisioning Profiles, .mobileprovision files manager tool for mac

### 1.0
- tree look all profiles 树形查看电脑中所有描述文件
- export cer from profile 从描述文件中导出cer证书文件
- move to trash 移动到废纸篓
- show in finder 在finder中显示
- Right-click DeveloperCertificates field item export cer from profile 右键DeveloperCertificates字段里的内容从描述文件中导出cer证书文件
- Right-click Item move to trash 右键移动到废纸篓
- Right-click Item show in finder 右键在finder中显示
- drag muti files install 拖拽描述文件文件直接安装
- export profile 导出描述文件
- Right-click Item export profile 右键导出描述文件
- drag into and look ipa profile or plist directly 拖入ipa快速查看描述文件与info.plist信息


Expand Down

0 comments on commit 603dcc0

Please sign in to comment.