@qusaieilouti99/call-manager 0.1.13 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,21 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
2
  <application>
3
+ <activity
4
+ android:name=".CallActivity"
5
+ android:exported="true"
6
+ android:showOnLockScreen="true"
7
+ android:turnScreenOn="true"
8
+ android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
9
+ android:screenOrientation="portrait"
10
+ android:launchMode="singleTop"
11
+ android:excludeFromRecents="true"
12
+ android:taskAffinity=""
13
+ android:windowSoftInputMode="adjustResize">
14
+ <intent-filter>
15
+ <action android:name="android.intent.action.VIEW"/>
16
+ <category android:name="android.intent.category.DEFAULT"/>
17
+ </intent-filter>
18
+ </activity>
3
19
  <service
4
20
  android:name=".MyConnectionService"
5
21
  android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"
@@ -0,0 +1,46 @@
1
+ package com.qusaieilouti99.callmanager
2
+
3
+ import android.app.Activity
4
+ import android.content.Intent
5
+ import android.graphics.Color
6
+ import android.os.Bundle
7
+ import android.view.View
8
+ import android.widget.Button
9
+ import android.widget.ImageView
10
+ import android.widget.TextView
11
+
12
+ class CallActivity : Activity() {
13
+ override fun onCreate(savedInstanceState: Bundle?) {
14
+ super.onCreate(savedInstanceState)
15
+ window.addFlags(
16
+ android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
17
+ android.view.WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or
18
+ android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
19
+ )
20
+ setContentView(R.layout.activity_call)
21
+
22
+ val callerName = intent.getStringExtra("callerName") ?: "Unknown"
23
+ val avatarView = findViewById<ImageView>(R.id.avatar)
24
+ val nameView = findViewById<TextView>(R.id.caller_name)
25
+ val answerBtn = findViewById<Button>(R.id.answer_btn)
26
+ val declineBtn = findViewById<Button>(R.id.decline_btn)
27
+
28
+ nameView.text = callerName
29
+ // Optionally set avatarView image
30
+
31
+ answerBtn.setOnClickListener {
32
+ // Start MainActivity (React Native)
33
+ val mainIntent = Intent(this, MainActivity::class.java)
34
+ mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
35
+ mainIntent.putExtra("incomingCall", true)
36
+ startActivity(mainIntent)
37
+ finish()
38
+ }
39
+
40
+ declineBtn.setOnClickListener {
41
+ // Stop ringtone, cancel notification, finish
42
+ CallNotificationHelper(this).cancelIncomingCallNotification()
43
+ finish()
44
+ }
45
+ }
46
+ }
@@ -7,7 +7,9 @@ import android.util.Log
7
7
 
8
8
  class CallNotificationActionReceiver : BroadcastReceiver() {
9
9
  override fun onReceive(context: Context, intent: Intent) {
10
+
10
11
  val callId = intent.getStringExtra("callId") ?: return
12
+ Log.d("CallNotificationActionReceiver", "onReceive called with action=${intent.action}, callId=$callId")
11
13
  val action = intent.action
12
14
 
13
15
  val app = context.applicationContext as? com.facebook.react.ReactApplication
@@ -17,12 +19,15 @@ class CallNotificationActionReceiver : BroadcastReceiver() {
17
19
 
18
20
  when (action) {
19
21
  "com.qusaieilouti99.callmanager.ANSWER_CALL" -> {
22
+ Log.d("CallNotificationActionReceiver", "Answer action received")
20
23
  bringAppToForeground(context)
21
24
  }
22
25
  "com.qusaieilouti99.callmanager.DECLINE_CALL" -> {
26
+ Log.d("CallNotificationActionReceiver", "Decline action received")
23
27
  module?.endCall(callId)
24
28
  }
25
29
  }
30
+
26
31
  // Cancel notification and stop ringtone
27
32
  CallNotificationHelper(context).cancelIncomingCallNotification()
28
33
  }
@@ -44,10 +44,11 @@ class CallNotificationHelper(private val context: Context) {
44
44
  context, 1, declineIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
45
45
  )
46
46
 
47
- // Full-screen intent to pop up the app/call UI
48
- val fullScreenIntent = context.packageManager.getLaunchIntentForPackage(context.packageName)?.apply {
47
+ // Full-screen intent to pop up the native call UI
48
+ val fullScreenIntent = Intent(context, CallActivity::class.java).apply {
49
49
  addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP)
50
50
  putExtra("callId", callId)
51
+ putExtra("callerName", callerName)
51
52
  }
52
53
  val fullScreenPendingIntent = PendingIntent.getActivity(
53
54
  context, 2, fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
@@ -64,8 +65,8 @@ class CallNotificationHelper(private val context: Context) {
64
65
  .setStyle(
65
66
  Notification.CallStyle.forIncomingCall(
66
67
  person,
67
- answerPendingIntent,
68
- declinePendingIntent
68
+ declinePendingIntent, // <-- Decline goes first!
69
+ answerPendingIntent // <-- Answer goes second!
69
70
  )
70
71
  )
71
72
  .setFullScreenIntent(fullScreenPendingIntent, true)
@@ -0,0 +1,4 @@
1
+ <shape xmlns:android="http://schemas.android.com/apk/res/android"
2
+ android:shape="oval">
3
+ <solid android:color="#444"/>
4
+ </shape>
@@ -0,0 +1,4 @@
1
+ <shape xmlns:android="http://schemas.android.com/apk/res/android"
2
+ android:shape="oval">
3
+ <solid android:color="#388E3C"/>
4
+ </shape>
@@ -0,0 +1,4 @@
1
+ <shape xmlns:android="http://schemas.android.com/apk/res/android"
2
+ android:shape="oval">
3
+ <solid android:color="#D32F2F"/>
4
+ </shape>
@@ -0,0 +1,55 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+ android:id="@+id/call_root"
4
+ android:layout_width="match_parent"
5
+ android:layout_height="match_parent"
6
+ android:background="#222"
7
+ android:orientation="vertical"
8
+ android:gravity="center"
9
+ android:padding="32dp">
10
+
11
+ <ImageView
12
+ android:id="@+id/avatar"
13
+ android:layout_width="96dp"
14
+ android:layout_height="96dp"
15
+ android:layout_marginBottom="24dp"
16
+ android:src="@android:drawable/sym_def_app_icon"
17
+ android:background="@drawable/circle_bg"
18
+ android:scaleType="centerCrop" />
19
+
20
+ <TextView
21
+ android:id="@+id/caller_name"
22
+ android:layout_width="wrap_content"
23
+ android:layout_height="wrap_content"
24
+ android:text="Caller Name"
25
+ android:textColor="#fff"
26
+ android:textSize="24sp"
27
+ android:textStyle="bold"
28
+ android:layout_marginBottom="48dp" />
29
+
30
+ <LinearLayout
31
+ android:layout_width="wrap_content"
32
+ android:layout_height="wrap_content"
33
+ android:orientation="horizontal"
34
+ android:gravity="center">
35
+
36
+ <Button
37
+ android:id="@+id/decline_btn"
38
+ android:layout_width="72dp"
39
+ android:layout_height="72dp"
40
+ android:backgroundTint="#D32F2F"
41
+ android:text="Decline"
42
+ android:textColor="#fff"
43
+ android:background="@drawable/circle_red"
44
+ android:layout_marginEnd="32dp" />
45
+
46
+ <Button
47
+ android:id="@+id/answer_btn"
48
+ android:layout_width="72dp"
49
+ android:layout_height="72dp"
50
+ android:backgroundTint="#388E3C"
51
+ android:text="Answer"
52
+ android:textColor="#fff"
53
+ android:background="@drawable/circle_green" />
54
+ </LinearLayout>
55
+ </LinearLayout>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qusaieilouti99/call-manager",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "call manager",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",