Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Update Android components and try push workarounds #501 OT-779
Browse files Browse the repository at this point in the history
Fixed MethodChannels.java typo
Updated gradle
Update libs
Added more push callback for debugging
  • Loading branch information
Boehrsi committed May 18, 2020
1 parent 63a7ef6 commit f42ea9b
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 11 deletions.
6 changes: 3 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ flutter {
}

dependencies {
implementation 'com.google.crypto.tink:apps-webpush:1.3.0-rc1'
implementation 'com.google.firebase:firebase-core:17.2.1'
implementation 'com.google.crypto.tink:apps-webpush:1.3.0'
implementation 'com.google.firebase:firebase-messaging:20.1.6'
implementation 'org.bouncycastle:bcprov-jdk16:1.46'

testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13'

androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Expand Down
6 changes: 4 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@

<uses-permission android:name="android.permission.VIBRATE" />

<!-- TODO this entry is a temporary hack to be able to try stuff with the FirebaseMessagingPlugin - See https://github.com/FirebaseExtended/flutterfire/issues/1754 for more information -->
<application
android:name=".MainApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
tools:replace="android:label">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
<!-- Specify that the launch screen should continue being displayed until Flutter renders its first frame. -->
<meta-data
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* OPEN-XCHANGE legal information
*
* All intellectual property rights in the Software are protected by
* international copyright laws.
*
*
* In some countries OX, OX Open-Xchange and open xchange
* as well as the corresponding Logos OX Open-Xchange and OX are registered
* trademarks of the OX Software GmbH group of companies.
* The use of the Logos is not covered by the Mozilla Public License 2.0 (MPL 2.0).
* Instead, you are allowed to use these Logos according to the terms and
* conditions of the Creative Commons License, Version 2.5, Attribution,
* Non-commercial, ShareAlike, and the interpretation of the term
* Non-commercial applicable to the aforementioned license is published
* on the web site https://www.open-xchange.com/terms-and-conditions/.
*
* Please make sure that third-party modules and libraries are used
* according to their respective licenses.
*
* Any modifications to this package must retain all copyright notices
* of the original copyright holder(s) for the original code used.
*
* After any such modifications, the original and derivative code shall remain
* under the copyright of the copyright holder(s) and/or original author(s) as stated here:
* https://www.open-xchange.com/legal/. The contributing author shall be
* given Attribution for the derivative code and a license granting use.
*
* Copyright (C) 2016-2020 OX Software GmbH
* Mail: [email protected]
*
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the Mozilla Public License 2.0
* for more details.
*/

package com.openxchange.oxcoi;

import io.flutter.app.FlutterApplication;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback;
import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin;
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService;

// TODO this whole class is a temporary hack to be able to try stuff with the FirebaseMessagingPlugin - See https://github.com/FirebaseExtended/flutterfire/issues/1754 for more information
public class MainApplication extends FlutterApplication implements PluginRegistrantCallback {
@Override
public void onCreate() {
super.onCreate();
FlutterFirebaseMessagingService.setPluginRegistrant(this);
}

@Override
public void registerWith(PluginRegistry registry) {
FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,54 @@
package com.openxchange.oxcoi;
/*
* OPEN-XCHANGE legal information
*
* All intellectual property rights in the Software are protected by
* international copyright laws.
*
*
* In some countries OX, OX Open-Xchange and open xchange
* as well as the corresponding Logos OX Open-Xchange and OX are registered
* trademarks of the OX Software GmbH group of companies.
* The use of the Logos is not covered by the Mozilla Public License 2.0 (MPL 2.0).
* Instead, you are allowed to use these Logos according to the terms and
* conditions of the Creative Commons License, Version 2.5, Attribution,
* Non-commercial, ShareAlike, and the interpretation of the term
* Non-commercial applicable to the aforementioned license is published
* on the web site https://www.open-xchange.com/terms-and-conditions/.
*
* Please make sure that third-party modules and libraries are used
* according to their respective licenses.
*
* Any modifications to this package must retain all copyright notices
* of the original copyright holder(s) for the original code used.
*
* After any such modifications, the original and derivative code shall remain
* under the copyright of the copyright holder(s) and/or original author(s) as stated here:
* https://www.open-xchange.com/legal/. The contributing author shall be
* given Attribution for the derivative code and a license granting use.
*
* Copyright (C) 2016-2020 OX Software GmbH
* Mail: [email protected]
*
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the Mozilla Public License 2.0
* for more details.
*/

package com.openxchange.oxcoi;

class MethodChannels {

abstract static class Security {
static final String NAME = "oxcoi.security";

abstract static class Methods {
static final String DECRYPT = "'decrypt'";
static final String DECRYPT = "decrypt";
}

abstract static class Arguments {
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.google.gms:google-services:4.3.3'
}
}
Expand Down
4 changes: 2 additions & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Nov 28 13:37:47 CET 2019
#Wed Apr 29 13:11:03 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
12 changes: 11 additions & 1 deletion lib/src/push/push_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,17 @@ import 'package:ox_coi/src/push/push_bloc.dart';
import 'package:ox_coi/src/push/push_event_state.dart';
import 'package:ox_coi/src/security/security_manager.dart';

final _logger = Logger("push_manager");

Future<void> onBackgroundMessage(Map<String, dynamic> message) {
//TODO: Add functionality
_logger.info("onBackgroundMessage $message");
return Future(null);
}

class PushManager {
final _firebaseMessaging = FirebaseMessaging();
final _notificationManager = DisplayNotificationManager();
final _logger = Logger("push_manager");

BuildContext _buildContext;
PushBloc _pushBloc;
Expand All @@ -83,11 +90,13 @@ class PushManager {
final decryptedContent = await decryptAsync(notificationData.content);
if (_isValidationPush(decryptedContent)) {
final validation = _getPushValidation(decryptedContent).validation;
_logger.info("Validation message with state validation: $validation received");
_pushBloc.add(ValidateMetadata(validation: validation));
} else {
final pushChatMessage = _getPushChatMessage(decryptedContent);
final fromEmail = pushChatMessage.fromEmail;
final body = "I sent you a new chat message"; // TODO replace decrypt
_logger.info("Chat message received from: $fromEmail");
await _notificationManager.showNotificationFromPushAsync(fromEmail, body);
}
}
Expand All @@ -103,6 +112,7 @@ class PushManager {
_logger.info("onLaunch $message");
return Future(null);
},
onBackgroundMessage: onBackgroundMessage,
);
_firebaseMessaging.requestNotificationPermissions(const IosNotificationSettings(sound: true, badge: true, alert: true));
}
Expand Down

0 comments on commit f42ea9b

Please sign in to comment.