From 676a3c4bdaf362d75627cf16158da936ad505309 Mon Sep 17 00:00:00 2001 From: enahum Date: Fri, 26 Jan 2018 18:50:08 -0300 Subject: [PATCH 1/3] Fix share extension (#1386) * Remove iOS extension garbage code * Fix Android Share Extension crash --- .../mattermost/rnbeta/MainApplication.java | 2 +- index.android.js | 11 ----- index.js | 7 +++ ios/Mattermost/AppDelegate.m | 30 ------------ .../android/extension_post/extension_post.js | 48 +++++++++++-------- 5 files changed, 36 insertions(+), 62 deletions(-) delete mode 100644 index.android.js diff --git a/android/app/src/main/java/com/mattermost/rnbeta/MainApplication.java b/android/app/src/main/java/com/mattermost/rnbeta/MainApplication.java index cf1904b39..01697db6d 100644 --- a/android/app/src/main/java/com/mattermost/rnbeta/MainApplication.java +++ b/android/app/src/main/java/com/mattermost/rnbeta/MainApplication.java @@ -78,7 +78,7 @@ public class MainApplication extends NavigationApplication implements INotificat @Override public String getJSMainModuleName() { - return "index.android"; + return "index"; } @Override diff --git a/index.android.js b/index.android.js deleted file mode 100644 index 3973260de..000000000 --- a/index.android.js +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -import {AppRegistry} from 'react-native'; - -/* eslint-disable no-unused-vars */ -import Mattermost from 'app/mattermost'; -import ShareExtension from 'share_extension/android'; - -AppRegistry.registerComponent('MattermostShare', () => ShareExtension); -const app = new Mattermost(); diff --git a/index.js b/index.js index 9fd56243b..b60030438 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,13 @@ // See License.txt for license information. /* eslint-disable no-unused-vars */ +import {AppRegistry, Platform} from 'react-native'; + import Mattermost from 'app/mattermost'; +import ShareExtension from 'share_extension/android'; + +if (Platform.OS === 'android') { + AppRegistry.registerComponent('MattermostShare', () => ShareExtension); +} const app = new Mattermost(); diff --git a/ios/Mattermost/AppDelegate.m b/ios/Mattermost/AppDelegate.m index b17397348..1f7db23b9 100644 --- a/ios/Mattermost/AppDelegate.m +++ b/ios/Mattermost/AppDelegate.m @@ -36,36 +36,6 @@ return YES; } --(void)application:(UIApplication *)application handleEventsForBackgroundURLSession:(nonnull NSString *)identifier completionHandler:(nonnull void (^)(void))completionHandler { - - NSUserDefaults *bucket = [[NSUserDefaults alloc] initWithSuiteName: @"group.com.mattermost"]; - NSString *credentialsString = [bucket objectForKey:@"credentials"]; - NSData *credentialsData = [credentialsString dataUsingEncoding:NSUTF8StringEncoding]; - NSDictionary *credentials = [NSJSONSerialization JSONObjectWithData:credentialsData options:NSJSONReadingMutableContainers error:nil]; - NSString *server = [credentials objectForKey:@"url"]; - NSString *token = [credentials objectForKey:@"token"]; - - NSDictionary *post = [NSDictionary dictionaryWithObjectsAndKeys:@"user_id", [bucket objectForKey:@"currentUserId"], @"message", @"Shit fuck", @"channel_id", @"zw43c5ttrjyu9dg7jnudwuz6bw"]; - NSData *postData = [NSJSONSerialization dataWithJSONObject:post options:NSJSONWritingPrettyPrinted error:nil]; - NSString* postAsString = [[NSString alloc] initWithData:postData encoding:NSUTF8StringEncoding]; - - NSURL *createUrl = [NSURL URLWithString:[server stringByAppendingString:@"/api/v4/posts"]]; - NSURLSessionConfiguration* config = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:@"backgroundSession-post"]; - config.sharedContainerIdentifier = @"group.com.mattermost"; - - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:createUrl cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:5.0]; - [request setHTTPMethod:@"POST"]; - [request setValue:[@"Bearer " stringByAppendingString:token] forHTTPHeaderField:@"Authorization"]; - [request setValue:@"application/json" forHTTPHeaderField:@"Accept"]; - [request setValue:@"application/json; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; - [request setHTTPBody:[postAsString dataUsingEncoding:NSUTF8StringEncoding]]; - NSURLSession *createSession = [NSURLSession sessionWithConfiguration:config]; - NSURLSessionDataTask *createTask = [createSession dataTaskWithRequest:request]; - [createTask resume]; - - completionHandler(); -} - // Required for orientation - (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { return [Orientation getOrientation]; diff --git a/share_extension/android/extension_post/extension_post.js b/share_extension/android/extension_post/extension_post.js index f9eb7ab77..383e97f90 100644 --- a/share_extension/android/extension_post/extension_post.js +++ b/share_extension/android/extension_post/extension_post.js @@ -87,24 +87,29 @@ export default class ExtensionPost extends PureComponent { ); - const headerRight = ( - - - - - - ); + + let headerRight = null; + + if (params.post) { + headerRight = ( + + + + + + ); + } return {headerLeft, headerRight, title}; }; @@ -130,8 +135,7 @@ export default class ExtensionPost extends PureComponent { componentDidMount() { this.props.navigation.setParams({ - close: this.onClose, - post: this.onPost + close: this.onClose }); this.auth(); } @@ -258,6 +262,10 @@ export default class ExtensionPost extends PureComponent { const text = []; const files = []; + this.props.navigation.setParams({ + post: this.onPost + }); + for (let i = 0; i < items.length; i++) { const item = items[i]; switch (item.type) { From f466b479baa939359feb1d2342c454c7063bad0c Mon Sep 17 00:00:00 2001 From: enahum Date: Fri, 26 Jan 2018 19:18:38 -0300 Subject: [PATCH 2/3] Bump iOS build number to 81 (#1387) --- ios/Mattermost.xcodeproj/project.pbxproj | 4 ++-- ios/Mattermost/Info.plist | 2 +- ios/MattermostShare/Info.plist | 2 +- ios/MattermostTests/Info.plist | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ios/Mattermost.xcodeproj/project.pbxproj b/ios/Mattermost.xcodeproj/project.pbxproj index a5f389144..bdfdae302 100644 --- a/ios/Mattermost.xcodeproj/project.pbxproj +++ b/ios/Mattermost.xcodeproj/project.pbxproj @@ -2400,7 +2400,7 @@ CODE_SIGN_ENTITLEMENTS = Mattermost/Mattermost.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; DEAD_CODE_STRIPPING = NO; DEVELOPMENT_TEAM = UQ8HT4Q2XM; ENABLE_BITCODE = NO; @@ -2449,7 +2449,7 @@ CODE_SIGN_ENTITLEMENTS = Mattermost/Mattermost.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; DEAD_CODE_STRIPPING = NO; DEVELOPMENT_TEAM = UQ8HT4Q2XM; ENABLE_BITCODE = NO; diff --git a/ios/Mattermost/Info.plist b/ios/Mattermost/Info.plist index e0592e1b9..0e7958018 100644 --- a/ios/Mattermost/Info.plist +++ b/ios/Mattermost/Info.plist @@ -34,7 +34,7 @@ CFBundleVersion - 80 + 81 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS diff --git a/ios/MattermostShare/Info.plist b/ios/MattermostShare/Info.plist index 9befe4534..4e9e402ca 100644 --- a/ios/MattermostShare/Info.plist +++ b/ios/MattermostShare/Info.plist @@ -23,7 +23,7 @@ CFBundleShortVersionString 1.6.0 CFBundleVersion - 80 + 81 NSAppTransportSecurity NSAllowsArbitraryLoads diff --git a/ios/MattermostTests/Info.plist b/ios/MattermostTests/Info.plist index 0c1168b61..e8fa092cf 100644 --- a/ios/MattermostTests/Info.plist +++ b/ios/MattermostTests/Info.plist @@ -19,6 +19,6 @@ CFBundleSignature ???? CFBundleVersion - 80 + 81 From 712e3019ebf5b7f025ea7c47ebb47709dcdd2dc2 Mon Sep 17 00:00:00 2001 From: enahum Date: Fri, 26 Jan 2018 19:25:55 -0300 Subject: [PATCH 3/3] Bump Android build number to 81 (#1388) --- android/app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 7e1c2eafc..2fbb0e576 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -106,7 +106,7 @@ android { applicationId "com.mattermost.rnbeta" minSdkVersion 21 targetSdkVersion 23 - versionCode 80 + versionCode 81 versionName "1.6.0" multiDexEnabled true ndk {