Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ dependencies {
transitive = true
}

implementation 'io.reactivex:rxjava:1.2.1'
implementation 'com.parse.bolts:bolts-tasks:1.4.0'

if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
Expand Down
182 changes: 108 additions & 74 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,77 +1,111 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="chat.rocket.reactnative">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
<uses-permission-sdk-23 android:name="android.permission.VIBRATE"/>

<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme"
android:networkSecurityConfig="@xml/network_security_config"
>
<activity
android:name="com.zoontek.rnbootsplash.RNBootSplashActivity"
android:theme="@style/BootTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
</intent-filter>
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="go.rocket.chat" />
<data android:scheme="rocketchat" android:host="room" />
<data android:scheme="rocketchat" android:host="auth" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<receiver
android:name=".ReplyBroadcast"
android:enabled="true"
android:exported="false" />
<receiver
android:name=".DismissNotification"
android:enabled="true"
android:exported="false" >
</receiver>
<activity
android:noHistory="true"
android:name=".share.ShareActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:label="@string/share_extension_name"
android:screenOrientation="portrait"
android:theme="@style/AppTheme" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
<meta-data
android:name="com.bugsnag.android.API_KEY"
android:value="${BugsnagAPIKey}" />
</application>
package="chat.rocket.reactnative">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

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

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

<application
android:name=".MainApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:theme="@style/AppTheme">

<receiver android:name="com.seventheta.notifications.BootBroadcastReceiver" android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>

<receiver android:name="com.seventheta.notifications.PackageUpdatedBroadcastReceiver" android:exported="false">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter>
</receiver>

<service android:name="com.seventheta.notifications.SocketService" android:stopWithTask="false" />

<service android:name="com.seventheta.notifications.SocketJobService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="true"
android:stopWithTask="false" />

<service android:name="com.seventheta.notifications.NotificationsDeliveryService"/>


<activity
android:name="com.zoontek.rnbootsplash.RNBootSplashActivity"
android:theme="@style/BootTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:exported="true"
android:label="@string/app_name"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.DOWNLOAD_COMPLETE" />
</intent-filter>
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="go.rocket.chat"
android:scheme="https" />
<data
android:host="room"
android:scheme="rocketchat" />
<data
android:host="auth"
android:scheme="rocketchat" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />

<receiver
android:name=".ReplyBroadcast"
android:enabled="true"
android:exported="false" />
<receiver
android:name=".DismissNotification"
android:enabled="true"
android:exported="false"></receiver>

<activity
android:name=".share.ShareActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:label="@string/share_extension_name"
android:noHistory="true"
android:screenOrientation="portrait"
android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
<meta-data
android:name="com.bugsnag.android.API_KEY"
android:value="${BugsnagAPIKey}" />
</application>

</manifest>
71 changes: 71 additions & 0 deletions android/app/src/main/java/chat/rocket/android_ddp/DDPClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package chat.rocket.android_ddp;

import androidx.annotation.Nullable;

import bolts.Task;
import bolts.TaskCompletionSource;
import chat.rocket.android_ddp.rx.RxWebSocketCallback;
import okhttp3.OkHttpClient;
import org.json.JSONArray;
import rx.Observable;

public class DDPClient {
// reference: https://github.com/eddflrs/meteor-ddp/blob/master/meteor-ddp.js

private final DDPClientImpl mImpl;

public DDPClient(OkHttpClient client) {
mImpl = new DDPClientImpl(this, client);
}

public Task<DDPClientCallback.Connect> connect(String url) {
return connect(url, null);
}

public Task<DDPClientCallback.Connect> connect(String url, String session) {
TaskCompletionSource<DDPClientCallback.Connect> task = new TaskCompletionSource<>();
mImpl.connect(task, url, session);
return task.getTask();
}

public Task<DDPClientCallback.Ping> ping(@Nullable String id) {
TaskCompletionSource<DDPClientCallback.Ping> task = new TaskCompletionSource<>();
mImpl.ping(task, id);
return task.getTask();
}

public Task<DDPClientCallback.RPC> rpc(String method, JSONArray params, String id,
long timeoutMs) {
TaskCompletionSource<DDPClientCallback.RPC> task = new TaskCompletionSource<>();
mImpl.rpc(task, method, params, id, timeoutMs);
return task.getTask();
}

public Task<DDPSubscription.Ready> sub(String id, String name, JSONArray params) {
TaskCompletionSource<DDPSubscription.Ready> task = new TaskCompletionSource<>();
mImpl.sub(task, name, params, id);
return task.getTask();
}

public Task<DDPSubscription.NoSub> unsub(String id) {
TaskCompletionSource<DDPSubscription.NoSub> task = new TaskCompletionSource<>();
mImpl.unsub(task, id);
return task.getTask();
}

public Observable<DDPSubscription.Event> getSubscriptionCallback() {
return mImpl.getDDPSubscription();
}

public Task<RxWebSocketCallback.Close> getOnCloseCallback() {
return mImpl.getOnCloseCallback();
}

public boolean isConnected() {
return mImpl.isConnected();
}

public void close() {
mImpl.close(1000, "closed by DDPClient#close()");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package chat.rocket.android_ddp;

import androidx.annotation.Nullable;

import org.json.JSONObject;

public class DDPClientCallback {
public static abstract class Base {
public DDPClient client;

public Base(DDPClient client) {
this.client = client;
}
}

public static abstract class BaseException extends Exception {
public DDPClient client;

public BaseException(DDPClient client) {
this.client = client;
}
}

public static class Connect extends Base {
public String session;

public Connect(DDPClient client, String session) {
super(client);
this.session = session;
}

public static class Failed extends BaseException {
public String version;

public Failed(DDPClient client, String version) {
super(client);
this.version = version;
}
}
}

public static class Ping extends Base {
@Nullable
public String id;

public Ping(DDPClient client, @Nullable String id) {
super(client);
this.id = id;
}

public static class Timeout extends BaseException {
public Timeout(DDPClient client) {
super(client);
}
}
}

public static class RPC extends Base {
public String id;
public String result;

public RPC(DDPClient client, String id, String result) {
super(client);
this.id = id;
this.result = result;
}

public static class Error extends BaseException {
public String id;
public JSONObject error;

public Error(DDPClient client, String id, JSONObject error) {
super(client);
this.id = id;
this.error = error;
}
}

public static class Timeout extends BaseException {
public Timeout(DDPClient client) {
super(client);
}
}
}
}
Loading