diff --git a/README.md b/README.md
index b233149..7a51062 100644
--- a/README.md
+++ b/README.md
@@ -84,7 +84,7 @@ useEffect(() => {
}, []);
```
-In `index.js` or anywhere firebase background handler lies:
+In `index.js` or anywhere firebase background handler lies:
```javascript
import messaging from '@react-native-firebase/messaging';
@@ -95,13 +95,13 @@ messaging().setBackgroundMessageHandler(async remoteMessage => {
// Receive remote message
if (remoteMessage?.notification?.title === 'Incoming Call') {
// Display incoming call activity.
- IncomingCall.display(
- 'callUUIDv4', // Call UUID v4
- 'Quocs', // Username
- 'https://avatars3.githubusercontent.com/u/16166195', // Avatar URL
- 'Incomming Call', // Info text
- 20000 // Timeout for end call after 20s
- );
+ IncomingCall.display({
+ uuid: 'callUUIDv4', // Call UUID v4
+ name: 'Quocs', // Username
+ avatar: 'https://avatars3.githubusercontent.com/u/16166195', // Avatar URL
+ info: 'Incomming Call', // Info text
+ timeout: 20000 // Timeout for end call after 20s
+ });
} else if (remoteMessage?.notification?.title === 'Missed Call') {
// Terminate incoming activity. Should be called when call expired.
IncomingCall.dismiss();
diff --git a/android/src/main/java/com/incomingcall/IncomingCallModule.java b/android/src/main/java/com/incomingcall/IncomingCallModule.java
index 97858a9..d5b5e47 100644
--- a/android/src/main/java/com/incomingcall/IncomingCallModule.java
+++ b/android/src/main/java/com/incomingcall/IncomingCallModule.java
@@ -11,6 +11,7 @@
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.Promise;
+import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
@@ -34,26 +35,28 @@ public String getName() {
}
@ReactMethod
- public void display(String uuid, String name, String avatar, String info, int timeout) {
+ public void display(ReadableMap options) {
if (UnlockScreenActivity.active) {
return;
}
if (reactContext != null) {
Bundle bundle = new Bundle();
- bundle.putString("uuid", uuid);
- bundle.putString("name", name);
- bundle.putString("avatar", avatar);
- bundle.putString("info", info);
- bundle.putInt("timeout", timeout);
+ bundle.putString("uuid", options.getString("uuid"));
+ bundle.putString("name", options.getString("name"));
+ bundle.putString("avatar", options.getString("avatar"));
+ bundle.putString("info", options.getString("info"));
+ bundle.putString("font", options.getString("font"));
+ bundle.putString("source", options.getString("source"));
+ bundle.putInt("timeout", options.getInt("timeout"));
Intent i = new Intent(reactContext, UnlockScreenActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP);
i.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED +
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD +
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
-
+
i.putExtras(bundle);
reactContext.startActivity(i);
-
+
}
}
diff --git a/android/src/main/java/com/incomingcall/UnlockScreenActivity.java b/android/src/main/java/com/incomingcall/UnlockScreenActivity.java
index 2c2c71a..8a71124 100755
--- a/android/src/main/java/com/incomingcall/UnlockScreenActivity.java
+++ b/android/src/main/java/com/incomingcall/UnlockScreenActivity.java
@@ -14,6 +14,7 @@
import android.content.Context;
import android.media.MediaPlayer;
import android.provider.Settings;
+import android.graphics.Typeface;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
@@ -38,6 +39,7 @@ public class UnlockScreenActivity extends AppCompatActivity implements UnlockScr
private static final String TAG = "MessagingService";
private TextView tvName;
private TextView tvInfo;
+ private TextView tvSource;
private ImageView ivAvatar;
private Integer timeout = 0;
private String uuid = "";
@@ -81,6 +83,7 @@ protected void onCreate(Bundle savedInstanceState) {
tvName = findViewById(R.id.tvName);
tvInfo = findViewById(R.id.tvInfo);
+ tvSource = findViewById(R.id.tvSource);
ivAvatar = findViewById(R.id.ivAvatar);
Bundle bundle = getIntent().getExtras();
@@ -96,6 +99,17 @@ protected void onCreate(Bundle savedInstanceState) {
String info = bundle.getString("info");
tvInfo.setText(info);
}
+ if (bundle.containsKey("font")) {
+ String font = bundle.getString("font");
+ Typeface tf = Typeface.createFromAsset(getAssets(), font);
+ tvName.setTypeface(tf);
+ tvInfo.setTypeface(tf);
+ tvSource.setTypeface(tf);
+ }
+ if (bundle.containsKey("source")) {
+ String source = bundle.getString("source");
+ tvSource.setText(source);
+ }
if (bundle.containsKey("avatar")) {
String avatar = bundle.getString("avatar");
if (avatar != null) {
diff --git a/android/src/main/res/layout/activity_call_incoming.xml b/android/src/main/res/layout/activity_call_incoming.xml
index a0e1555..b82612d 100644
--- a/android/src/main/res/layout/activity_call_incoming.xml
+++ b/android/src/main/res/layout/activity_call_incoming.xml
@@ -17,8 +17,7 @@
>
+
+
@@ -81,7 +84,7 @@
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
- android:layout_marginBottom="60dp"
+ style="@style/buttonWrapper"
>
-
\ No newline at end of file
+
diff --git a/android/src/main/res/values/styles.xml b/android/src/main/res/values/styles.xml
new file mode 100644
index 0000000..ba9b11d
--- /dev/null
+++ b/android/src/main/res/values/styles.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/example/App.js b/example/App.js
index bf7f46c..a0e779f 100644
--- a/example/App.js
+++ b/example/App.js
@@ -68,12 +68,12 @@ export function handleRemoteMessage(remoteMessage, isHeadless) {
}
});
} else {
- IncomingCall.display(
- callUUID,
- 'Quocs',
- 'https://avatars3.githubusercontent.com/u/16166195',
- 'Incomming Call'
- );
+ IncomingCall.display({
+ uuid: callUUID,
+ name: 'Quocs',
+ avatar: 'https://avatars3.githubusercontent.com/u/16166195',
+ info: 'Incomming Call'
+ });
DeviceEventEmitter.addListener('endCall', payload => {
// End call action here
console.log('endCall', payload);