|
1 | 1 | package com.reactnativefullscreennotificationincomingcall;
|
2 | 2 |
|
3 |
| -import android.app.Activity; |
| 3 | + |
4 | 4 | import android.app.KeyguardManager;
|
5 | 5 | import android.content.Context;
|
6 | 6 | import android.content.Intent;
|
|
14 | 14 | import android.widget.TextView;
|
15 | 15 | import com.airbnb.lottie.LottieAnimationView;
|
16 | 16 | import androidx.appcompat.app.AppCompatActivity;
|
| 17 | +import androidx.fragment.app.Fragment; |
17 | 18 |
|
| 19 | +import com.facebook.react.ReactFragment; |
18 | 20 | import com.facebook.react.bridge.Arguments;
|
19 | 21 | import com.facebook.react.bridge.WritableMap;
|
| 22 | +import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler; |
20 | 23 | import com.squareup.picasso.Picasso;
|
21 | 24 |
|
22 |
| -public class IncomingCallActivity extends AppCompatActivity { |
| 25 | +public class IncomingCallActivity extends AppCompatActivity implements DefaultHardwareBackBtnHandler { |
| 26 | + |
23 | 27 | private static final String TAG = "MessagingService";
|
24 | 28 | private static final String TAG_KEYGUARD = "Incoming:unLock";
|
25 | 29 | private TextView tvName;
|
@@ -72,21 +76,38 @@ protected void onCreate(Bundle savedInstanceState) {
|
72 | 76 | keyguardLock.disableKeyguard();
|
73 | 77 | }
|
74 | 78 | }
|
75 |
| - setContentView(R.layout.activity_call_incoming); |
76 | 79 | getWindow().addFlags(
|
77 | 80 | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
|
78 | 81 | | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
|
79 | 82 | | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
80 | 83 | | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
81 | 84 | | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
|
| 85 | + Bundle bundle = getIntent().getExtras(); |
| 86 | + |
| 87 | + if (bundle.containsKey("mainComponent")) { |
| 88 | + setContentView(R.layout.custom_ingcoming_call_rn); |
| 89 | + Fragment reactNativeFragment = new ReactFragment.Builder() |
| 90 | + .setComponentName(bundle.getString("mainComponent")) |
| 91 | + .setLaunchOptions(bundle) |
| 92 | + .build(); |
| 93 | + getSupportFragmentManager() |
| 94 | + .beginTransaction() |
| 95 | + .add(R.id.reactNativeFragment, reactNativeFragment) |
| 96 | + .commit(); |
| 97 | + if (bundle.containsKey("uuid")) { |
| 98 | + uuid = bundle.getString("uuid"); |
| 99 | + } |
| 100 | + return; |
| 101 | + }else{ |
| 102 | + setContentView(R.layout.activity_call_incoming); |
| 103 | + } |
82 | 104 | tvName = findViewById(R.id.tvName);
|
83 | 105 | tvInfo = findViewById(R.id.tvInfo);
|
84 | 106 | ivAvatar = findViewById(R.id.ivAvatar);
|
85 | 107 | tvDecline=findViewById(R.id.tvDecline);
|
86 | 108 | tvAccept=findViewById(R.id.tvAccept);
|
87 | 109 | lnDeclineCall = findViewById(R.id.lnDeclineCall);
|
88 | 110 | lnAcceptCall = findViewById(R.id.lnAcceptCall);
|
89 |
| - Bundle bundle = getIntent().getExtras(); |
90 | 111 | if (bundle != null) {
|
91 | 112 | if (bundle.containsKey("uuid")) {
|
92 | 113 | uuid = bundle.getString("uuid");
|
@@ -183,4 +204,8 @@ private void dismissDialing(String action) {
|
183 | 204 | }
|
184 | 205 | }
|
185 | 206 |
|
| 207 | + @Override |
| 208 | + public void invokeDefaultOnBackPressed() { |
| 209 | + super.onBackPressed(); |
| 210 | + } |
186 | 211 | }
|
0 commit comments