Просмотр исходного кода

Fix #415, restore ability to copy log messages

Tanner Bennett лет назад: 5
Родитель
Сommit
8283e2a8e7

+ 3 - 1
Classes/GlobalStateExplorers/FileBrowser/FLEXFileBrowserController.m

@@ -360,7 +360,9 @@ typedef NS_ENUM(NSUInteger, FLEXFileBrowserSortAttribute) {
 
 #if FLEX_AT_LEAST_IOS13_SDK
 
-- (UIContextMenuConfiguration *)tableView:(UITableView *)tableView contextMenuConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath point:(CGPoint)point __IOS_AVAILABLE(13.0) {
+- (UIContextMenuConfiguration *)tableView:(UITableView *)tableView
+contextMenuConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath
+                                    point:(CGPoint)point __IOS_AVAILABLE(13.0) {
     __weak __typeof__(self) weakSelf = self;
     return [UIContextMenuConfiguration configurationWithIdentifier:nil
                                                    previewProvider:nil

+ 23 - 1
Classes/GlobalStateExplorers/SystemLog/FLEXSystemLogViewController.m

@@ -265,8 +265,30 @@ static BOOL my_os_log_shim_enabled(void *addr) {
 - (void)tableView:(UITableView *)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {
     if (action == @selector(copy:)) {
         // We usually only want to copy the log message itself, not any metadata associated with it.
-        UIPasteboard.generalPasteboard.string = self.logMessages.filteredList[indexPath.row].messageText;
+        UIPasteboard.generalPasteboard.string = self.logMessages.filteredList[indexPath.row].messageText ?: @"";
     }
 }
 
+#if FLEX_AT_LEAST_IOS13_SDK
+
+- (UIContextMenuConfiguration *)tableView:(UITableView *)tableView
+contextMenuConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath
+                                    point:(CGPoint)point __IOS_AVAILABLE(13.0) {
+    __weak __typeof__(self) weakSelf = self;
+    return [UIContextMenuConfiguration configurationWithIdentifier:nil
+                                                   previewProvider:nil
+                                                    actionProvider:^UIMenu *(NSArray<UIMenuElement *> *suggestedActions) {
+        UIAction *copy = [UIAction actionWithTitle:@"Copy"
+                                             image:nil
+                                        identifier:@"Copy"
+                                           handler:^(__kindof UIAction *action) {
+            // We usually only want to copy the log message itself, not any metadata associated with it.
+            UIPasteboard.generalPasteboard.string = weakSelf.logMessages.filteredList[indexPath.row].messageText ?: @"";
+        }];
+        return [UIMenu menuWithTitle:@"" image:nil identifier:nil options:UIMenuOptionsDisplayInline children:@[copy]];
+    }];
+}
+
+#endif
+
 @end