Skip to content

Commit

Permalink
v3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
manupillai308 committed May 29, 2021
1 parent ba2a272 commit e29225b
Show file tree
Hide file tree
Showing 24 changed files with 1,014 additions and 285 deletions.
11 changes: 8 additions & 3 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ import {createAppContainer, createSwitchNavigator} from 'react-navigation';
import {createStackNavigator} from 'react-navigation-stack';
import {setNavigator} from './src/navigationRef';
import ChatsScreen from './src/screens/ChatsScreen';
import CreateChat from './src/components/CreateChat';
import CreateChat from './src/screens/CreateChat';
import ChatDetail from './src/screens/ChatDetail';
import InitScreen from './src/screens/InitScreen';
import {Provider as DataProvider} from './src/contexts/DataContext';
import {Provider as ServerDataProvider} from './src/contexts/ServerDataContext';
import {Provider as ClientDataProvider} from './src/contexts/ClientDataContext';
import {Provider as OnlineProvider} from './src/contexts/OnlineClientContext';
import FlashMessage from "react-native-flash-message";
import CreateChatOnline from './src/screens/CreateChatOnline';


const mainFlow = createStackNavigator({
Chats: ChatsScreen,
Room: CreateChat,
OnlineRoom: CreateChatOnline,
ChatDetail,
},{
initialRouteName:'Chats'
Expand All @@ -32,8 +35,10 @@ export default (props) => {
return <DataProvider>
<ServerDataProvider>
<ClientDataProvider>
<App ref={(navigator) => { setNavigator(navigator)}}/>
<FlashMessage position="top" />
<OnlineProvider>
<App ref={(navigator) => { setNavigator(navigator)}}/>
<FlashMessage position="top" />
</OnlineProvider>
</ClientDataProvider>
</ServerDataProvider>
</DataProvider>
Expand Down
5 changes: 5 additions & 0 deletions OnlineClient.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {NativeModules} from 'react-native';

const {OnlineClient} = NativeModules;

export default OnlineClient;
10 changes: 7 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'
// apply plugin: 'com.google.gms.google-services'

import com.android.build.OutputFile

Expand Down Expand Up @@ -135,8 +135,8 @@ android {
applicationId "com.shhtalk"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 2
versionName "2.0"
versionCode 3
versionName "3.0"
}
splits {
abi {
Expand Down Expand Up @@ -211,6 +211,10 @@ dependencies {
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
implementation ('io.socket:socket.io-client:2.0.1') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
}

if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
Expand Down
48 changes: 0 additions & 48 deletions android/app/google-services.json

This file was deleted.

2 changes: 2 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
</service>
<service android:name="com.local_server.ClientService" android:enabled="true" android:exported="false">
</service>
<service android:name="com.online_client.OnlineService" android:enabled="true" android:exported="false">
</service>
<activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
22 changes: 22 additions & 0 deletions android/app/src/main/java/com/local_server/ClientService.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class ClientService extends Service {
public static DataInputStream din;
public static DataOutputStream dout;
private static Context context;
public static Notification msg_notification;
public static NotificationManager notificationManager;

private static final int SERVICE_NOTIFICATION_ID = 100100;

Expand Down Expand Up @@ -125,6 +127,7 @@ public void run() {
}
else{
ClientService.messages.add(msg);
ClientService.notificationManager.notify(0, ClientService.msg_notification);
}
}catch(SocketException e){
return;
Expand Down Expand Up @@ -169,6 +172,16 @@ public int onStartCommand(Intent intent, int flags, int startId) {
NotificationManager manager = getSystemService(NotificationManager.class);
manager.createNotificationChannel(channel);

ClientService.msg_notification = new Notification.Builder(this, CHANNEL_ID)
.setContentTitle("ShhTalk")
.setContentText("You have new messages")
.setSmallIcon(R.mipmap.ic_launcher) //R.drawable.icon
.setContentIntent(contentIntent)
.build();
ClientService.msg_notification.flags |= Notification.FLAG_AUTO_CANCEL;

ClientService.notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

Notification notification = new Notification.Builder(this, CHANNEL_ID)
// .setContentIntent(contentIntent)
.setOngoing(true)
Expand All @@ -178,6 +191,15 @@ public int onStartCommand(Intent intent, int flags, int startId) {
.build();
startForeground(SERVICE_NOTIFICATION_ID, notification);
}else{
ClientService.msg_notification = new NotificationCompat.Builder(this)
.setContentTitle("ShhTalk")
.setContentText("You have new messages")
.setSmallIcon(R.mipmap.ic_launcher) //R.drawable.icon
.setContentIntent(contentIntent)
.build();
ClientService.msg_notification.flags |= Notification.FLAG_AUTO_CANCEL;

ClientService.notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification = new NotificationCompat.Builder(this)
// .setContentIntent(contentIntent)
.setSmallIcon(R.mipmap.ic_launcher)
Expand Down
23 changes: 23 additions & 0 deletions android/app/src/main/java/com/local_server/ServerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public void run(){
}
else{
ServerService.messages.add(msg);
ServerService.notificationManager.notify(0, ServerService.msg_notification);
}
ServerService.lock.lock();
ServerService.broadcastMsg(this.socket.getInetAddress().toString(), msg);
Expand Down Expand Up @@ -205,6 +206,8 @@ public class ServerService extends Service {
public static volatile boolean exit;
public static ServerSocket socket;
public static ArrayList<String> names;
public static Notification msg_notification;
public static NotificationManager notificationManager;

private static final int SERVICE_NOTIFICATION_ID = 100100;

Expand Down Expand Up @@ -339,6 +342,16 @@ public int onStartCommand(Intent intent, int flags, int startId) {
NotificationManager manager = getSystemService(NotificationManager.class);
manager.createNotificationChannel(channel);

ServerService.msg_notification = new Notification.Builder(this, CHANNEL_ID)
.setContentTitle("ShhTalk Online")
.setContentText("You have new messages")
.setSmallIcon(R.mipmap.ic_launcher) //R.drawable.icon
.setContentIntent(contentIntent)
.build();
ServerService.msg_notification.flags |= Notification.FLAG_AUTO_CANCEL;

ServerService.notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

Notification notification = new Notification.Builder(this, CHANNEL_ID)
// .setContentIntent(contentIntent)
.setOngoing(true)
Expand All @@ -348,6 +361,16 @@ public int onStartCommand(Intent intent, int flags, int startId) {
.build();
startForeground(SERVICE_NOTIFICATION_ID, notification);
}else{
ServerService.msg_notification = new NotificationCompat.Builder(this)
.setContentTitle("ShhTalk")
.setContentText("You have new messages")
.setSmallIcon(R.mipmap.ic_launcher) //R.drawable.icon
.setContentIntent(contentIntent)
.build();
ServerService.msg_notification.flags |= Notification.FLAG_AUTO_CANCEL;

ServerService.notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

Notification notification = new NotificationCompat.Builder(this)
// .setContentIntent(contentIntent)
.setSmallIcon(R.mipmap.ic_launcher)
Expand Down
Loading

0 comments on commit e29225b

Please sign in to comment.