diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index a798c5a..8e91554 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -14,10 +14,15 @@ + + diff --git a/android/app/src/main/java/com/unichat/MainActivity.java b/android/app/src/main/java/com/unichat/MainActivity.java index 1dd7f84..2c564c7 100644 --- a/android/app/src/main/java/com/unichat/MainActivity.java +++ b/android/app/src/main/java/com/unichat/MainActivity.java @@ -1,15 +1,36 @@ package com.unichat; import com.facebook.react.ReactActivity; +import android.os.Bundle; +import android.os.CountDownTimer; +import android.graphics.Color; public class MainActivity extends ReactActivity { /** - * Returns the name of the main component registered from JavaScript. - * This is used to schedule rendering of the component. + * Returns the name of the main component registered from JavaScript. This is + * used to schedule rendering of the component. */ @Override protected String getMainComponentName() { return "Unichat"; } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Set the Android background to white after 8 seconds + // to fix the splashscreen flash when the keyboard is shown + new CountDownTimer(8000, 1000) { + + public void onTick(long millisUntilFinished) { + } + + public void onFinish() { + getWindow().getDecorView().setBackgroundColor(Color.WHITE); + } + + }.start(); + } } diff --git a/android/app/src/main/res/drawable-hdpi/icon.png b/android/app/src/main/res/drawable-hdpi/icon.png new file mode 100644 index 0000000..4ac6b65 Binary files /dev/null and b/android/app/src/main/res/drawable-hdpi/icon.png differ diff --git a/android/app/src/main/res/drawable-hdpi/logo_notification.png b/android/app/src/main/res/drawable-hdpi/logo_notification.png new file mode 100644 index 0000000..ee13a02 Binary files /dev/null and b/android/app/src/main/res/drawable-hdpi/logo_notification.png differ diff --git a/android/app/src/main/res/drawable-ldpi/icon.png b/android/app/src/main/res/drawable-ldpi/icon.png new file mode 100644 index 0000000..d4485d4 Binary files /dev/null and b/android/app/src/main/res/drawable-ldpi/icon.png differ diff --git a/android/app/src/main/res/drawable-mdpi/icon.png b/android/app/src/main/res/drawable-mdpi/icon.png new file mode 100644 index 0000000..e80e631 Binary files /dev/null and b/android/app/src/main/res/drawable-mdpi/icon.png differ diff --git a/android/app/src/main/res/drawable-mdpi/logo_notification.png b/android/app/src/main/res/drawable-mdpi/logo_notification.png new file mode 100644 index 0000000..e5957c7 Binary files /dev/null and b/android/app/src/main/res/drawable-mdpi/logo_notification.png differ diff --git a/android/app/src/main/res/drawable-xhdpi/icon.png b/android/app/src/main/res/drawable-xhdpi/icon.png new file mode 100644 index 0000000..8386db4 Binary files /dev/null and b/android/app/src/main/res/drawable-xhdpi/icon.png differ diff --git a/android/app/src/main/res/drawable-xhdpi/logo_notification.png b/android/app/src/main/res/drawable-xhdpi/logo_notification.png new file mode 100644 index 0000000..0c32a37 Binary files /dev/null and b/android/app/src/main/res/drawable-xhdpi/logo_notification.png differ diff --git a/android/app/src/main/res/drawable-xxhdpi/icon.png b/android/app/src/main/res/drawable-xxhdpi/icon.png new file mode 100644 index 0000000..017a55d Binary files /dev/null and b/android/app/src/main/res/drawable-xxhdpi/icon.png differ diff --git a/android/app/src/main/res/drawable-xxhdpi/logo_notification.png b/android/app/src/main/res/drawable-xxhdpi/logo_notification.png new file mode 100644 index 0000000..09f701e Binary files /dev/null and b/android/app/src/main/res/drawable-xxhdpi/logo_notification.png differ diff --git a/android/app/src/main/res/drawable-xxxhdpi/icon.png b/android/app/src/main/res/drawable-xxxhdpi/icon.png new file mode 100644 index 0000000..c4b6dbb Binary files /dev/null and b/android/app/src/main/res/drawable-xxxhdpi/icon.png differ diff --git a/android/app/src/main/res/drawable-xxxhdpi/logo_notification.png b/android/app/src/main/res/drawable-xxxhdpi/logo_notification.png new file mode 100644 index 0000000..da9aaef Binary files /dev/null and b/android/app/src/main/res/drawable-xxxhdpi/logo_notification.png differ diff --git a/android/app/src/main/res/drawable/background_splash.xml b/android/app/src/main/res/drawable/background_splash.xml new file mode 100644 index 0000000..5d9ce38 --- /dev/null +++ b/android/app/src/main/res/drawable/background_splash.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/icon.png b/android/app/src/main/res/drawable/icon.png new file mode 100644 index 0000000..8386db4 Binary files /dev/null and b/android/app/src/main/res/drawable/icon.png differ diff --git a/android/app/src/main/res/drawable/logo.png b/android/app/src/main/res/drawable/logo.png new file mode 100644 index 0000000..edb7d89 Binary files /dev/null and b/android/app/src/main/res/drawable/logo.png differ diff --git a/android/app/src/main/res/drawable/logo_notification.png b/android/app/src/main/res/drawable/logo_notification.png new file mode 100644 index 0000000..ee13a02 Binary files /dev/null and b/android/app/src/main/res/drawable/logo_notification.png differ diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index a2f5908..0000000 Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png deleted file mode 100644 index 1b52399..0000000 Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index ff10afd..0000000 Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png deleted file mode 100644 index 115a4c7..0000000 Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index dcd3cd8..0000000 Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png deleted file mode 100644 index 459ca60..0000000 Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 8ca12fe..0000000 Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png deleted file mode 100644 index 8e19b41..0000000 Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index b824ebd..0000000 Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png deleted file mode 100644 index 4c19a13..0000000 Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..6cbd7f2 --- /dev/null +++ b/android/app/src/main/res/values/colors.xml @@ -0,0 +1,5 @@ + + + #FFF + #007AFF + diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml index 319eb0c..71a68f8 100644 --- a/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values/styles.xml @@ -3,6 +3,8 @@ diff --git a/functions/index.js b/functions/index.js index 35ace51..8bdcfca 100644 --- a/functions/index.js +++ b/functions/index.js @@ -33,9 +33,12 @@ return (exports.sendPushNotification = functions.firestore title: contactName, body: content, sound: "default", - android_channel_id: "main-channel", - collapseKey: "unichat", - group: "unichat" + priority: "high", + icon: "logo_notification", + android_channel_id: "unichat", + large_icon: "logo_notification", + show_in_foreground: "true", + content_available: "true" } } diff --git a/src/Screens/Conversas/conversas.js b/src/Screens/Conversas/conversas.js index cc4db38..40825ce 100644 --- a/src/Screens/Conversas/conversas.js +++ b/src/Screens/Conversas/conversas.js @@ -40,12 +40,27 @@ export default class Conversas extends Component { } async componentDidMount() { + this.mounted = true this.listener = this.ref.onSnapshot(async () => { const username = await AsyncStorage.getItem("@username") const profileImageUrl = await AsyncStorage.getItem("@profileImageUrl") - this.setState({ myName: username, myPicture: profileImageUrl }) + if (this.mounted) + this.setState({ myName: username, myPicture: profileImageUrl }) }) + const { navigation } = this.props + + const channel = new firebase.notifications.Android.Channel( + "unichat", + "Unichat channel", + firebase.notifications.Android.Importance.Max + ) + .setDescription("My app channel") + .setVibrationPattern([500]) + .setLockScreenVisibility(firebase.notifications.Android.Visibility.Public) + + firebase.notifications().android.createChannel(channel) + const notificationOpen = await firebase .notifications() .getInitialNotification() @@ -53,6 +68,11 @@ export default class Conversas extends Component { const { notification } = notificationOpen const { conversaId } = notification.data notification.android.setGroup("unichat") + notification.android.setPriority( + firebase.notifications.Android.Priority.High + ) + notification.android.setChannelId("unichat") + notification.android.setVibrate([500]) this.ref .collection("conversas") .doc(conversaId) @@ -83,6 +103,7 @@ export default class Conversas extends Component { } componentWillUnmount() { + this.mounted = false BackHandler.removeEventListener("hardwareBackPress", this.handleBackPress) this.unsubscribe() this.listener()