Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
Merge pull request #180 from ES2-UFPI/neto#IconAndSplashScreen
Browse files Browse the repository at this point in the history
Set icon app, create splash screen and more...
  • Loading branch information
sosolidkk authored Jun 4, 2019
2 parents bb638b8 + 83a0fdc commit c5ffd7d
Show file tree
Hide file tree
Showing 31 changed files with 75 additions and 8 deletions.
9 changes: 7 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:icon="@drawable/icon"
android:allowBackup="false"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/logo_notification" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/notification_color" />
<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
Expand Down
25 changes: 23 additions & 2 deletions android/app/src/main/java/com/unichat/MainActivity.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
Binary file added android/app/src/main/res/drawable-hdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/app/src/main/res/drawable-ldpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/app/src/main/res/drawable-mdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/app/src/main/res/drawable-xhdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions android/app/src/main/res/drawable/background_splash.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/primary" />
<item
android:width="200dp"
android:height="200dp"
android:drawable="@drawable/logo"
android:gravity="center"
/>
</layer-list>
Binary file added android/app/src/main/res/drawable/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/app/src/main/res/drawable/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Binary file not shown.
Binary file not shown.
Binary file removed android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions android/app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<color name="primary">#FFF</color>
<color name="notification_color">#007AFF</color>
</resources>
2 changes: 2 additions & 0 deletions android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:windowBackground">@drawable/background_splash</item>
<item name="android:statusBarColor">@color/primary</item>
</style>

</resources>
9 changes: 6 additions & 3 deletions functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

Expand Down
23 changes: 22 additions & 1 deletion src/Screens/Conversas/conversas.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,39 @@ 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()
if (notificationOpen) {
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)
Expand Down Expand Up @@ -83,6 +103,7 @@ export default class Conversas extends Component {
}

componentWillUnmount() {
this.mounted = false
BackHandler.removeEventListener("hardwareBackPress", this.handleBackPress)
this.unsubscribe()
this.listener()
Expand Down

0 comments on commit c5ffd7d

Please sign in to comment.