Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use new components in ShareExtension as well
Signed-off-by: Marcel Müller <[email protected]>
  • Loading branch information
SystemKeeper committed Apr 17, 2023
commit b76eb7f164452a712fcc1895b68366ea00c9c041
7 changes: 3 additions & 4 deletions ShareExtension/ShareTableViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@

#import <UIKit/UIKit.h>

@class AvatarImageView;

extern NSString *const kShareCellIdentifier;
extern NSString *const kShareTableCellNibName;

extern CGFloat const kShareTableCellHeight;

@interface ShareAvatarImageView : UIImageView
@end

@interface ShareTableViewCell : UITableViewCell

@property (weak, nonatomic) IBOutlet ShareAvatarImageView *avatarImageView;
@property (weak, nonatomic) IBOutlet AvatarImageView *avatarImageView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;

@end
13 changes: 4 additions & 9 deletions ShareExtension/ShareTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,14 @@
#import "AFNetworking.h"
#import "AFImageDownloader.h"
#import "NCAppBranding.h"
#import "NCAvatarSessionManager.h"
#import "UIImageView+AFNetworking.h"

#import "NextcloudTalk-Swift.h"

NSString *const kShareCellIdentifier = @"ShareCellIdentifier";
NSString *const kShareTableCellNibName = @"ShareTableViewCell";

CGFloat const kShareTableCellHeight = 56.0f;

@implementation ShareAvatarImageView : UIImageView
@end

@implementation ShareTableViewCell

- (void)awakeFromNib {
Expand All @@ -52,11 +49,9 @@ - (void)prepareForReuse
[super prepareForReuse];

// Fix problem of rendering downloaded image in a reused cell
[self.avatarImageView cancelImageDownloadTask];
self.avatarImageView.image = nil;
self.avatarImageView.contentMode = UIViewContentModeCenter;

[self.avatarImageView cancelCurrentRequest];
self.avatarImageView.image = nil;

self.titleLabel.text = @"";
}

Expand Down
6 changes: 3 additions & 3 deletions ShareExtension/ShareTableViewCell.xib
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21678"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -27,7 +27,7 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="zQd-Is-7Kg" customClass="ShareAvatarImageView">
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="zQd-Is-7Kg" customClass="AvatarImageView" customModule="NextcloudTalk" customModuleProvider="target">
<rect key="frame" x="10" y="10" width="36" height="36"/>
<constraints>
<constraint firstAttribute="width" constant="36" id="Eos-so-7Gh"/>
Expand Down
53 changes: 4 additions & 49 deletions ShareExtension/ShareViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@

#import "NCAPIController.h"
#import "NCAppBranding.h"
#import "NCAvatarSessionManager.h"
#import "NCDatabaseManager.h"
#import "NCIntentController.h"
#import "NCRoom.h"
#import "NCUtils.h"
#import "PlaceholderView.h"
#import "ShareConfirmationViewController.h"
#import "ShareTableViewCell.h"
#import "UIImageView+AFNetworking.h"
#import "NCKeyChainController.h"
#import "NextcloudTalk-Swift.h"

@interface ShareViewController () <UISearchControllerDelegate, UISearchResultsUpdating, ShareConfirmationViewControllerDelegate>
{
Expand Down Expand Up @@ -132,15 +132,6 @@ - (void)viewDidLoad
[RLMRealmConfiguration setDefaultConfiguration:configuration];
}
_realm = [RLMRealm realmWithConfiguration:configuration error:&error];

// Setup image downloader
AFImageDownloader *imageDownloader = [[AFImageDownloader alloc]
initWithSessionManager:[NCAvatarSessionManager sharedInstance]
downloadPrioritization:AFImageDownloadPrioritizationFIFO
maximumActiveDownloads:4
imageCache:[[AFAutoPurgingImageCache alloc] init]];

[ShareAvatarImageView setSharedImageDownloader:imageDownloader];

if (self.extensionContext && self.extensionContext.intent && [self.extensionContext.intent isKindOfClass:[INSendMessageIntent class]]) {
INSendMessageIntent *intent = (INSendMessageIntent *)self.extensionContext.intent;
Expand Down Expand Up @@ -567,44 +558,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
}

cell.titleLabel.text = room.displayName;

// Set room image
switch (room.type) {
case kNCRoomTypeOneToOne:
{
NSURLRequest *request = [[NCAPIController sharedInstance] createAvatarRequestForUser:room.name withStyle:self.traitCollection.userInterfaceStyle andSize:96 usingAccount:_shareAccount];
[cell.avatarImageView setImageWithURLRequest:request placeholderImage:nil success:nil failure:nil];
[cell.avatarImageView setContentMode:UIViewContentModeScaleToFill];
}
break;

case kNCRoomTypeGroup:
[cell.avatarImageView setImage:[UIImage imageNamed:@"group-18"]];
break;

case kNCRoomTypePublic:
[cell.avatarImageView setImage:[UIImage imageNamed:@"public-18"]];
break;

case kNCRoomTypeChangelog:
[cell.avatarImageView setImage:[UIImage imageNamed:@"changelog"]];
[cell.avatarImageView setContentMode:UIViewContentModeScaleToFill];
break;

case kNCRoomTypeFormerOneToOne:
[cell.avatarImageView setImage:[UIImage imageNamed:@"user-18"]];
break;

default:
break;
}

// Set objectType image
if ([room.objectType isEqualToString:NCRoomObjectTypeFile]) {
[cell.avatarImageView setImage:[UIImage imageNamed:@"file-conv-18"]];
} else if ([room.objectType isEqualToString:NCRoomObjectTypeSharePassword]) {
[cell.avatarImageView setImage:[UIImage imageNamed:@"pass-conv-18"]];
}

[cell.avatarImageView setAvatarFor:room with:self.traitCollection.userInterfaceStyle using:_shareAccount];

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

Expand Down