正在查看: Rilo v2.0.21 应用的 WebViewCallActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Rilo v2.0.21 应用的 WebViewCallActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package app.callpe.ui.call;
import android.app.Activity;
import android.app.Dialog;
import android.app.PictureInPictureParams;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.Rational;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.webkit.JavascriptInterface;
import android.webkit.PermissionRequest;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.ProgressBar;
import androidx.activity.ComponentActivity;
import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContract;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.ViewModelLazy;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelStore;
import androidx.lifecycle.viewmodel.CreationExtras;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import app.callpe.App;
import app.callpe.common.agora.VideoCallEvent;
import app.callpe.common.agora.VideoCallEventType;
import app.callpe.common.utils.Constants;
import app.callpe.common.utils.Helper;
import app.callpe.common.utils.RxBus;
import app.callpe.common.utils.extensions.ActivityExtKt;
import app.callpe.common.utils.helper_functions.Utils;
import app.callpe.common.utils.helper_functions.VolumeManager;
import app.callpe.common.utils.sharedpref.PrefKeys;
import app.callpe.common.utils.sharedpref.SharedPref;
import app.callpe.data.model.ChatDetails;
import app.callpe.data.model.GiftRequestModel;
import app.callpe.data.model.VideoDetailModel;
import app.callpe.data.model.VideoMessageModel;
import app.callpe.databinding.ActivityWebViewVideoCallBinding;
import app.callpe.service.HeadsUpNotificationService;
import app.callpe.service.VideoCallService;
import app.callpe.ui.payment.PaymentDetailsActivity;
import app.callpe.ui.payment.WalletActivity;
import app.callpe.ui.user.StreamerReviewActivity;
import com.asynctaskcoffee.audiorecorder.R;
import com.facebook.internal.NativeProtocol;
import com.google.gson.Gson;
import com.permissionx.guolindev.databinding.PermissionxDefaultDialogLayoutBinding;
import com.permissionx.guolindev.databinding.PermissionxPermissionItemBinding;
import dagger.hilt.android.AndroidEntryPoint;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import javax.inject.Inject;
import kotlin.Lazy;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.ArraysKt;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Reflection;
import kotlin.text.StringsKt;
import org.json.JSONObject;
import timber.log.Timber;
@Metadata(d1 = {"\u0000\u0092\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010 \n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u000b\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0002\b\n\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\u0010\u0011\n\u0000\n\u0002\u0010\u0015\n\u0002\b\u0013\b\u0007\u0018\u00002\u00020\u0001:\u0001\\B\u0005¢\u0006\u0002\u0010\u0002J\b\u00103\u001a\u000204H\u0002J\b\u00105\u001a\u000204H\u0002J\b\u00106\u001a\u000204H\u0002J\u0012\u00107\u001a\u0002042\b\u00108\u001a\u0004\u0018\u00010\u0015H\u0002J\b\u00109\u001a\u000204H\u0002J\b\u0010:\u001a\u000204H\u0002J\b\u0010;\u001a\u000204H\u0016J\b\u0010<\u001a\u000204H\u0002J\u0012\u0010=\u001a\u0002042\b\u0010>\u001a\u0004\u0018\u00010?H\u0016J\b\u0010@\u001a\u000204H\u0014J\u0018\u0010A\u001a\u0002042\u0006\u0010B\u001a\u00020\u00122\u0006\u0010C\u001a\u00020DH\u0017J+\u0010E\u001a\u0002042\u0006\u0010F\u001a\u00020G2\f\u0010\u0019\u001a\b\u0012\u0004\u0012\u00020\u000b0H2\u0006\u0010I\u001a\u00020JH\u0016¢\u0006\u0002\u0010KJ\b\u0010L\u001a\u000204H\u0016J\b\u0010M\u001a\u000204H\u0016J\b\u0010N\u001a\u000204H\u0014J\u0016\u0010O\u001a\u00020\u00122\f\u0010\u0019\u001a\b\u0012\u0004\u0012\u00020\u000b0\u001aH\u0002J\b\u0010P\u001a\u000204H\u0002J\u0016\u0010Q\u001a\u0002042\f\u0010\u0019\u001a\b\u0012\u0004\u0012\u00020\u000b0\u001aH\u0002J\u0018\u0010R\u001a\u0002042\u0006\u0010S\u001a\u00020\u000b2\u0006\u0010T\u001a\u00020\u000bH\u0002J\b\u0010U\u001a\u000204H\u0003J\b\u0010V\u001a\u000204H\u0002J\u001b\u0010W\u001a\u0002042\f\u0010\u0019\u001a\b\u0012\u0004\u0012\u00020\u000b0HH\u0002¢\u0006\u0002\u0010XJ\b\u0010Y\u001a\u000204H\u0002J\b\u0010Z\u001a\u000204H\u0002J\b\u0010[\u001a\u000204H\u0002R\u0010\u0010\u0003\u001a\u0004\u0018\u00010\u0004X\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\u0005\u001a\u00020\u00048BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\u0006\u0010\u0007R\u000e\u0010\b\u001a\u00020\tX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\f\u001a\u0004\u0018\u00010\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\r\u001a\u0004\u0018\u00010\u000eX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u000f\u001a\u0004\u0018\u00010\u0010X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0011\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0013\u001a\u0004\u0018\u00010\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0014\u001a\u0004\u0018\u00010\u0015X\u0082\u000e¢\u0006\u0002\n\u0000R\u001c\u0010\u0016\u001a\u0010\u0012\f\u0012\n \u0018*\u0004\u0018\u00010\u00150\u00150\u0017X\u0082\u0004¢\u0006\u0002\n\u0000R\u0017\u0010\u0019\u001a\b\u0012\u0004\u0012\u00020\u000b0\u001a¢\u0006\b\n\u0000\u001a\u0004\b\u001b\u0010\u001cR\u001e\u0010\u001d\u001a\u00020\u001e8\u0006@\u0006X\u0087.¢\u0006\u000e\n\u0000\u001a\u0004\b\u001f\u0010 \"\u0004\b!\u0010\"R$\u0010#\u001a\u00020\u000b8\u0006@\u0006X\u0087.¢\u0006\u0014\n\u0000\u0012\u0004\b$\u0010\u0002\u001a\u0004\b%\u0010&\"\u0004\b'\u0010(R\u0010\u0010)\u001a\u0004\u0018\u00010*X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010+\u001a\u00020,X\u0082\u000e¢\u0006\u0002\n\u0000R\u001b\u0010-\u001a\u00020.8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b1\u00102\u001a\u0004\b/\u00100¨\u0006]"}, d2 = {"Lapp/callpe/ui/call/WebViewCallActivity;", "Lapp/callpe/ui/call/BaseWebCallActivity;", "()V", "_binding", "Lapp/callpe/databinding/ActivityWebViewVideoCallBinding;", "binding", "getBinding", "()Lapp/callpe/databinding/ActivityWebViewVideoCallBinding;", "broadcastReceiver", "Landroid/content/BroadcastReceiver;", "callType", "", "caller", "dialog", "Landroid/app/Dialog;", "disposable", "Lio/reactivex/disposables/Disposable;", "ended", "", "mChannel", "mServiceIntent", "Landroid/content/Intent;", "openSettingsLauncher", "Landroidx/activity/result/ActivityResultLauncher;", "kotlin.jvm.PlatformType", NativeProtocol.RESULT_ARGS_PERMISSIONS, "", "getPermissions", "()Ljava/util/List;", "rxBus", "Lapp/callpe/common/utils/RxBus;", "getRxBus", "()Lapp/callpe/common/utils/RxBus;", "setRxBus", "(Lapp/callpe/common/utils/RxBus;)V", "userId", "getUserId$annotations", "getUserId", "()Ljava/lang/String;", "setUserId", "(Ljava/lang/String;)V", "videoCallService", "Lapp/callpe/service/VideoCallService;", "videoId", "", "viewModel", "Lapp/callpe/ui/call/CallViewModel;", "getViewModel", "()Lapp/callpe/ui/call/CallViewModel;", "viewModel$delegate", "Lkotlin/Lazy;", "enablePip", "", "endCall", "fromCallNotification", "getVideoDetails", "intent", "initUI", "observeCallEndFromNotification", "onBackPressed", "onClicks", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onDestroy", "onPictureInPictureModeChanged", "isInPictureInPictureMode", "newConfig", "Landroid/content/res/Configuration;", "onRequestPermissionsResult", "requestCode", "", "", "grantResults", "", "(I[Ljava/lang/String;[I)V", "onStart", "onStop", "onUserLeaveHint", "permissionsGranted", "registerReceiver", "requestPermissionsIfNeeded", "sendDataToWebView", "function", NativeProtocol.WEB_DIALOG_PARAMS, "setupDefaultSettings", "showOnLockScreen", "showOpenSettingDialog", "([Ljava/lang/String;)V", "starServiceFunc", "stopServiceFunc", "unRegisterReceiver", "WebAppInterface", "app_riloRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
@AndroidEntryPoint
public final class WebViewCallActivity extends Hilt_WebViewCallActivity {
private ActivityWebViewVideoCallBinding _binding;
private String caller;
private Dialog dialog;
private Disposable disposable;
private boolean ended;
private String mChannel;
private Intent mServiceIntent;
private final ActivityResultLauncher<Intent> openSettingsLauncher;
@Inject
public RxBus rxBus;
@Inject
public String userId;
private VideoCallService videoCallService;
private final Lazy viewModel;
private String callType = Constants.VIDEO_CALL;
private long videoId = -1;
private final List<String> permissions = CollectionsKt.listOf(new String[]{"android.permission.CAMERA", "android.permission.RECORD_AUDIO"});
private final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String str;
String stringExtra;
CallViewModel viewModel;
ChatDetails chatDetails;
String stringExtra2;
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(intent, "intent");
Timber.e("Action %s", new Object[]{intent.getAction()});
String action = intent.getAction();
if (action != null) {
switch (action.hashCode()) {
case -1772611750:
str = Constants.VIDEO_CALL_FAILED;
break;
case -1148062919:
if (action.equals(Constants.MESSAGE_RECEIVED) && (stringExtra = intent.getStringExtra("chat")) != null) {
WebViewCallActivity webViewCallActivity = WebViewCallActivity.this;
VideoMessageModel videoMessageModel = (VideoMessageModel) new Gson().fromJson(stringExtra, VideoMessageModel.class);
if (videoMessageModel != null) {
Timber.e("message model " + videoMessageModel, new Object[0]);
if (Intrinsics.areEqual(videoMessageModel.getMessageType(), Constants.TEXT)) {
viewModel = webViewCallActivity.getViewModel();
VideoDetailModel videoDetails = viewModel.getVideoDetails();
if (videoDetails == null || (chatDetails = videoDetails.getChatDetails()) == null) {
return;
}
Long id = chatDetails.getId();
long entityId = videoMessageModel.getEntityId();
if (id != null && id.longValue() == entityId) {
webViewCallActivity.sendDataToWebView("handleMessage", stringExtra);
return;
}
return;
}
return;
}
return;
}
return;
case 31643316:
str = Constants.GIFT_RECEIVE;
break;
case 45045344:
if (!action.equals(Constants.GIFT_REQUEST) || WebViewCallActivity.this.getIsStreamer() || (stringExtra2 = intent.getStringExtra("gift")) == null) {
return;
}
WebViewCallActivity webViewCallActivity2 = WebViewCallActivity.this;
GiftRequestModel giftRequestModel = (GiftRequestModel) new Gson().fromJson(stringExtra2, GiftRequestModel.class);
if (giftRequestModel != null) {
String json = new Gson().toJson(giftRequestModel.getGift());
Intrinsics.checkNotNullExpressionValue(json, "Gson().toJson(it.gift)");
webViewCallActivity2.sendDataToWebView("handleGift", json);
return;
}
return;
case 1443141741:
if (action.equals(Constants.KILL_SCREEN)) {
WebViewCallActivity.this.finish();
return;
}
return;
case 1614559365:
str = PaymentDetailsActivity.PAYMENT_SUCCESS_EVENT;
break;
case 1886029520:
str = Constants.ENABLE_POPUP;
break;
default:
return;
}
action.equals(str);
}
}
};
public static void getUserId$annotations() {
}
private final void onClicks() {
}
public void onBackPressed() {
}
public WebViewCallActivity() {
final ComponentActivity componentActivity = (ComponentActivity) this;
final Function0 function0 = null;
this.viewModel = new ViewModelLazy(Reflection.getOrCreateKotlinClass(CallViewModel.class), new Function0<ViewModelStore>() {
{
super(0);
}
public final ViewModelStore m896invoke() {
return componentActivity.getViewModelStore();
}
}, new Function0<ViewModelProvider.Factory>() {
{
super(0);
}
public final ViewModelProvider.Factory m895invoke() {
return componentActivity.getDefaultViewModelProviderFactory();
}
}, new Function0<CreationExtras>() {
{
super(0);
}
public final CreationExtras m897invoke() {
CreationExtras creationExtras;
Function0 function02 = function0;
return (function02 == null || (creationExtras = (CreationExtras) function02.invoke()) == null) ? componentActivity.getDefaultViewModelCreationExtras() : creationExtras;
}
});
ActivityResultLauncher<Intent> registerForActivityResult = registerForActivityResult((ActivityResultContract) new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
public final void onActivityResult(Object obj) {
WebViewCallActivity.openSettingsLauncher$lambda$12(WebViewCallActivity.this, (ActivityResult) obj);
}
});
Intrinsics.checkNotNullExpressionValue(registerForActivityResult, "registerForActivityResul…missions)\n }\n }");
this.openSettingsLauncher = registerForActivityResult;
}
public final ActivityWebViewVideoCallBinding getBinding() {
ActivityWebViewVideoCallBinding activityWebViewVideoCallBinding = this._binding;
Intrinsics.checkNotNull(activityWebViewVideoCallBinding);
return activityWebViewVideoCallBinding;
}
public final CallViewModel getViewModel() {
return (CallViewModel) this.viewModel.getValue();
}
public final String getUserId() {
String str = this.userId;
if (str != null) {
return str;
}
Intrinsics.throwUninitializedPropertyAccessException("userId");
return null;
}
public final void setUserId(String str) {
Intrinsics.checkNotNullParameter(str, "<set-?>");
this.userId = str;
}
public final RxBus getRxBus() {
RxBus rxBus = this.rxBus;
if (rxBus != null) {
return rxBus;
}
Intrinsics.throwUninitializedPropertyAccessException("rxBus");
return null;
}
public final void setRxBus(RxBus rxBus) {
Intrinsics.checkNotNullParameter(rxBus, "<set-?>");
this.rxBus = rxBus;
}
public final List<String> getPermissions() {
return this.permissions;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this._binding = ActivityWebViewVideoCallBinding.inflate(getLayoutInflater());
fromCallNotification();
showOnLockScreen();
setContentView((View) getBinding().getRoot());
observeCallEndFromNotification();
getVideoDetails(getIntent());
initUI();
onClicks();
}
private final void initUI() {
if (permissionsGranted(this.permissions)) {
WebView webView = getBinding().webView;
webView.addJavascriptInterface(new WebAppInterface(), "AppInterface");
setupDefaultSettings();
webView.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onShowFileChooser(WebView webView2, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) {
return true;
}
@Override
public void onPermissionRequest(PermissionRequest request) {
if (request != null) {
request.grant(request.getResources());
}
}
});
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
ActivityWebViewVideoCallBinding binding;
super.onPageStarted(view, url, favicon);
binding = WebViewCallActivity.this.getBinding();
ProgressBar progressBar = binding.progress;
Intrinsics.checkNotNullExpressionValue(progressBar, "binding.progress");
progressBar.setVisibility(0);
}
@Override
public void onPageFinished(WebView view, String url) {
ActivityWebViewVideoCallBinding binding;
super.onPageFinished(view, url);
binding = WebViewCallActivity.this.getBinding();
ProgressBar progressBar = binding.progress;
Intrinsics.checkNotNullExpressionValue(progressBar, "binding.progress");
progressBar.setVisibility(8);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
CallViewModel viewModel;
long j;
Uri url;
String uri;
StringBuilder sb = new StringBuilder();
sb.append("New Url Detected: ");
sb.append(request != null ? request.getUrl() : null);
boolean z = false;
Timber.e(sb.toString(), new Object[0]);
if (request != null && (url = request.getUrl()) != null && (uri = url.toString()) != null && StringsKt.contains$default(uri, "/video/end", false, 2, (Object) null)) {
z = true;
}
if (z) {
viewModel = WebViewCallActivity.this.getViewModel();
j = WebViewCallActivity.this.videoId;
viewModel.videoCallEnd(j);
WebViewCallActivity.this.endCall();
}
return true;
}
});
String stringExtra = getIntent().getStringExtra(Constants.KEY_CALL_TYPE);
if (stringExtra == null) {
stringExtra = Constants.VIDEO_CALL;
} else {
Intrinsics.checkNotNullExpressionValue(stringExtra, "intent.getStringExtra(Co…) ?: Constants.VIDEO_CALL");
}
this.callType = stringExtra;
Context context = (Context) this;
String string = SharedPref.getString(context, PrefKeys.AUTH_TOKEN);
String string2 = SharedPref.getString(context, "RTC_PROVIDER");
Intrinsics.checkNotNullExpressionValue(string2, "getString(this@WebViewCa…y, PrefKeys.RTC_PROVIDER)");
String lowerCase = string2.toLowerCase(Locale.ROOT);
Intrinsics.checkNotNullExpressionValue(lowerCase, "this as java.lang.String).toLowerCase(Locale.ROOT)");
String str = SharedPref.getString(context, PrefKeys.RTC_WEB_LINK) + "?videoId=" + this.videoId + "&callType=" + this.callType + "&rtcProvider=" + lowerCase + "&token=" + string;
Timber.e("Url " + str, new Object[0]);
webView.loadUrl(str);
starServiceFunc();
return;
}
getViewModel().submitVideoCallErrorByVideoId(this.videoId, "Permission are not granted.");
requestPermissionsIfNeeded(this.permissions);
}
private final void setupDefaultSettings() {
WebView webView = getBinding().webView;
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setDatabaseEnabled(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
}
private final void showOnLockScreen() {
try {
if (Build.VERSION.SDK_INT == 30) {
SharedPref.setInt((Context) this, PrefKeys.USER_COUNT_IN_ROOM, 0);
}
getWindow().addFlags(69730304);
} catch (Exception e) {
Timber.e(e);
}
}
private final void observeCallEndFromNotification() {
try {
Observable observeOn = getRxBus().toObservable().observeOn(AndroidSchedulers.mainThread());
Consumer consumer = new Consumer() {
public final void accept(Object obj) {
WebViewCallActivity.observeCallEndFromNotification$lambda$2(WebViewCallActivity.this, obj);
}
};
final WebViewCallActivity$observeCallEndFromNotification$2 webViewCallActivity$observeCallEndFromNotification$2 = new Function1<Throwable, Unit>() {
public Object invoke(Object obj) {
invoke((Throwable) obj);
return Unit.INSTANCE;
}
public final void invoke(Throwable th) {
Timber.e(th, "Error in RxBus subscription", new Object[0]);
}
};
this.disposable = observeOn.subscribe(consumer, new Consumer() {
public final void accept(Object obj) {
WebViewCallActivity.observeCallEndFromNotification$lambda$3(webViewCallActivity$observeCallEndFromNotification$2, obj);
}
});
} catch (Exception e) {
Timber.e(e.toString(), new Object[0]);
}
}
public static final void observeCallEndFromNotification$lambda$2(WebViewCallActivity webViewCallActivity, Object obj) {
Intrinsics.checkNotNullParameter(webViewCallActivity, "this$0");
if ((obj instanceof VideoCallEvent) && ((VideoCallEvent) obj).getEvent() == VideoCallEventType.CALL_ENDED_FROM_NOTIFICATION) {
webViewCallActivity.getViewModel().videoCallEnd(webViewCallActivity.videoId);
webViewCallActivity.endCall();
}
}
public static final void observeCallEndFromNotification$lambda$3(Function1 function1, Object obj) {
Intrinsics.checkNotNullParameter(function1, "$tmp0");
function1.invoke(obj);
}
private final void fromCallNotification() {
SharedPref.setString((Context) this, PrefKeys.START_TIME, "");
boolean z = false;
HeadsUpNotificationService.INSTANCE.setServiceRunning(false);
try {
Intent intent = getIntent();
if (intent != null && intent.getBooleanExtra(Constants.CALL_SCREEN_NOTIFICATION, false)) {
z = true;
}
if (z) {
LocalBroadcastManager.getInstance((Context) this).sendBroadcast(new Intent(Constants.CALL_SCREEN_NOTIFICATION));
}
} catch (Exception e) {
Timber.e(e);
}
}
private final void getVideoDetails(Intent intent) {
Helper.cancelNotification((Context) this, VolumeManager.ON_DO_NOT_DISTURB_CALLBACK_CODE);
if (intent == null || intent.getExtras() == null) {
return;
}
this.caller = intent.getStringExtra(Constants.KEY_CALLER);
getViewModel().setCaller(this.caller);
String stringExtra = intent.getStringExtra(Constants.FCM_DATA);
if (stringExtra != null) {
VideoDetailModel videoDetailModel = (VideoDetailModel) new Gson().fromJson(stringExtra, VideoDetailModel.class);
getViewModel().setVideoDetails(videoDetailModel);
if (videoDetailModel != null) {
this.videoId = videoDetailModel.getId();
if (videoDetailModel.getId() != -1) {
intent.putExtra(Constants.KEY_CALLING_VIDEO_ID, videoDetailModel.getId());
}
setStreamer(Intrinsics.areEqual(String.valueOf(videoDetailModel.getStreamerId()), getUserId()));
}
}
}
@Metadata(d1 = {"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0003\b\u0086\u0004\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\u0012\u0010\u0003\u001a\u00020\u00042\b\u0010\u0005\u001a\u0004\u0018\u00010\u0006H\u0007J\u0012\u0010\u0007\u001a\u00020\u00042\b\u0010\u0005\u001a\u0004\u0018\u00010\u0006H\u0007J\u0012\u0010\b\u001a\u00020\u00042\b\u0010\u0005\u001a\u0004\u0018\u00010\u0006H\u0002¨\u0006\t"}, d2 = {"Lapp/callpe/ui/call/WebViewCallActivity$WebAppInterface;", "", "(Lapp/callpe/ui/call/WebViewCallActivity;)V", "onRechargeClicked", "", NativeProtocol.WEB_DIALOG_PARAMS, "", "onTimerUpdate", "topUpClick", "app_riloRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class WebAppInterface {
public WebAppInterface() {
}
@JavascriptInterface
public final void onRechargeClicked(String params) {
topUpClick(params);
}
@JavascriptInterface
public final void onTimerUpdate(String params) {
Timber.d("Processing onTimerUpdate: " + params, new Object[0]);
}
private final void topUpClick(String params) {
Timber.d("Processing TopUp Click: " + params, new Object[0]);
try {
String str = params;
if (!(str == null || str.length() == 0) && Intrinsics.areEqual(new JSONObject(params).getString("type"), "RECHARGE_CLICKED")) {
Dialog dialog = WebViewCallActivity.this.dialog;
if (dialog != null) {
dialog.dismiss();
}
Intent intent = new Intent(WebViewCallActivity.this.getApplicationContext(), (Class<?>) WalletActivity.class);
WebViewCallActivity webViewCallActivity = WebViewCallActivity.this;
intent.addFlags(268435456);
intent.putExtra("video_call_screen", true);
webViewCallActivity.startActivity(intent);
}
} catch (Exception e) {
Timber.e(e);
}
}
}
public final void sendDataToWebView(String function, String params) {
WebView webView;
ActivityWebViewVideoCallBinding activityWebViewVideoCallBinding = this._binding;
if (activityWebViewVideoCallBinding == null || (webView = activityWebViewVideoCallBinding.webView) == null) {
return;
}
String str = "javascript:" + function + '(' + params + ')';
Timber.e("gift data " + str, new Object[0]);
webView.evaluateJavascript(str, new ValueCallback() {
@Override
public final void onReceiveValue(Object obj) {
WebViewCallActivity.sendDataToWebView$lambda$5$lambda$4((String) obj);
}
});
}
public static final void sendDataToWebView$lambda$5$lambda$4(String str) {
Timber.d("JavaScript returned: " + str, new Object[0]);
}
public final void endCall() {
stopServiceFunc();
getBinding().webView.destroy();
getViewModel().setEnded(true);
getViewModel().getRxBus().send(new VideoCallEvent(VideoCallEventType.CALL_ENDED, null, this.caller, 2, null));
if (getIsStreamer() || this.ended) {
getViewModel().getRxBus().send(new VideoCallEvent(VideoCallEventType.CALL_ENDED, null, this.caller, 2, null));
finish();
return;
}
VideoDetailModel videoDetails = getViewModel().getVideoDetails();
if (videoDetails != null) {
this.ended = true;
Intent intent = new Intent((Context) this, (Class<?>) StreamerReviewActivity.class);
intent.putExtra(Constants.FCM_DATA, new Gson().toJson(videoDetails));
startActivity(intent);
finish();
return;
}
finish();
}
private final void starServiceFunc() {
Intent intent;
try {
VideoCallService videoCallService = new VideoCallService();
this.videoCallService = videoCallService;
Intent intent2 = new Intent((Context) this, videoCallService.getClass());
this.mServiceIntent = intent2;
intent2.putExtra(Constants.KEY_CALLING_CHANNEL, this.mChannel);
Intent intent3 = this.mServiceIntent;
if (intent3 != null) {
intent3.putExtra(Constants.KEY_CALLING_VIDEO_ID, this.videoId);
}
Intent intent4 = this.mServiceIntent;
if (intent4 != null) {
intent4.putExtra(Constants.KEY_AGORA_ACCESS_TOKEN, "");
}
Intent intent5 = this.mServiceIntent;
if (intent5 != null) {
intent5.putExtra(Constants.KEY_CALLER, this.caller);
}
String stringExtra = getIntent().getStringExtra(Constants.KEY_CALL_TYPE);
if (stringExtra == null) {
stringExtra = Constants.VIDEO_CALL;
} else {
Intrinsics.checkNotNullExpressionValue(stringExtra, "intent.getStringExtra(Co…) ?: Constants.VIDEO_CALL");
}
this.callType = stringExtra;
Intent intent6 = this.mServiceIntent;
if (intent6 != null) {
intent6.putExtra(Constants.KEY_CALL_TYPE, stringExtra);
}
VideoDetailModel videoDetails = getViewModel().getVideoDetails();
if (videoDetails != null && (intent = this.mServiceIntent) != null) {
intent.putExtra(Constants.FCM_DATA, new Gson().toJson(videoDetails));
}
if (!Utils.isMyServiceRunning(videoCallService.getClass(), (Activity) this)) {
startService(this.mServiceIntent);
Timber.d("Service started successfully", new Object[0]);
} else {
Timber.d("Service is already running", new Object[0]);
}
} catch (Exception e) {
getViewModel().submitVideoCallError("Video call service error " + e.getMessage());
Timber.e(e);
}
}
private final void stopServiceFunc() {
VideoCallService videoCallService = this.videoCallService;
if (videoCallService != null) {
this.mServiceIntent = new Intent((Context) this, videoCallService.getClass());
if (Utils.isMyServiceRunning(videoCallService.getClass(), (Activity) this)) {
stopService(this.mServiceIntent);
Timber.d("Service stopped!!", new Object[0]);
} else {
Timber.d("Service is already stopped!!", new Object[0]);
}
}
}
protected void onUserLeaveHint() {
super.onUserLeaveHint();
enablePip();
}
public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) {
Intrinsics.checkNotNullParameter(newConfig, "newConfig");
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);
getViewModel().setInPictureInPictureMode(isInPictureInPictureMode);
sendDataToWebView("handlePip", "{\"pip\":\"" + isInPictureInPictureMode + "\"}");
}
private final void enablePip() {
try {
Rational rational = new Rational(3, 4);
if (Build.VERSION.SDK_INT >= 26) {
if (getPackageManager().hasSystemFeature("android.software.picture_in_picture")) {
Timber.tag("PIP").e("*** Picture-in-Picture ***", new Object[0]);
enterPictureInPictureMode(new PictureInPictureParams.Builder().setAspectRatio(rational).setSourceRectHint(new Rect()).build());
} else {
Timber.tag("PIP").e("*** No support Picture-in-Picture ***", new Object[0]);
}
}
} catch (Exception e) {
Activity activity = (Activity) this;
String message = e.getMessage();
if (message == null) {
message = "";
}
ActivityExtKt.toast(activity, message);
}
}
private final void registerReceiver() {
LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance((Context) this);
Intrinsics.checkNotNullExpressionValue(localBroadcastManager, "getInstance(this)");
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Constants.VIDEO_CALL_FAILED);
intentFilter.addAction(Constants.MESSAGE_RECEIVED);
intentFilter.addAction(Constants.GIFT_REQUEST);
intentFilter.addAction(Constants.GIFT_RECEIVE);
intentFilter.addAction(Constants.KILL_SCREEN);
intentFilter.addAction(Constants.ENABLE_POPUP);
intentFilter.addAction(PaymentDetailsActivity.PAYMENT_SUCCESS_EVENT);
localBroadcastManager.registerReceiver(this.broadcastReceiver, intentFilter);
}
private final void unRegisterReceiver() {
LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance((Context) this);
Intrinsics.checkNotNullExpressionValue(localBroadcastManager, "getInstance(this)");
localBroadcastManager.unregisterReceiver(this.broadcastReceiver);
}
private final void requestPermissionsIfNeeded(List<String> permissions) {
ActivityCompat.requestPermissions((Activity) this, (String[]) permissions.toArray(new String[0]), 1010);
}
public static final void openSettingsLauncher$lambda$12(WebViewCallActivity webViewCallActivity, ActivityResult activityResult) {
Intrinsics.checkNotNullParameter(webViewCallActivity, "this$0");
Intrinsics.checkNotNullParameter(activityResult, "<anonymous parameter 0>");
if (webViewCallActivity.permissionsGranted(CollectionsKt.toList(webViewCallActivity.permissions))) {
webViewCallActivity.initUI();
} else {
webViewCallActivity.requestPermissionsIfNeeded(webViewCallActivity.permissions);
}
}
private final boolean permissionsGranted(List<String> permissions) {
Iterator<String> it = permissions.iterator();
boolean z = true;
while (it.hasNext()) {
if (ContextCompat.checkSelfPermission((Context) this, it.next()) != 0) {
z = false;
}
}
return z;
}
private final void showOpenSettingDialog(String[] permissions) {
Window window;
try {
Dialog dialog = this.dialog;
if (dialog != null) {
if (dialog != null && dialog.isShowing()) {
return;
}
}
getViewModel().submitVideoCallErrorByVideoId(this.videoId, "Permission are not granted.");
this.dialog = new Dialog((Context) this);
PermissionxDefaultDialogLayoutBinding inflate = PermissionxDefaultDialogLayoutBinding.inflate(LayoutInflater.from((Context) this));
Intrinsics.checkNotNullExpressionValue(inflate, "inflate(\n … )\n )");
Dialog dialog2 = this.dialog;
if (dialog2 != null) {
dialog2.setContentView(inflate.getRoot());
}
Dialog dialog3 = this.dialog;
if (dialog3 != null) {
dialog3.setCancelable(false);
}
String string = getString(2131952424);
Intrinsics.checkNotNullExpressionValue(string, "getString(R.string.permission_explain_camera_mic)");
if (permissions.length == 1) {
if (ArraysKt.contains(permissions, "android.permission.CAMERA")) {
string = getString(2131952423);
Intrinsics.checkNotNullExpressionValue(string, "this.getString(R.string.permission_explain_camera)");
} else if (ArraysKt.contains(permissions, "android.permission.RECORD_AUDIO")) {
string = getString(2131952425);
Intrinsics.checkNotNullExpressionValue(string, "this.getString(R.string.permission_explain_mic)");
}
}
inflate.positiveBtn.setText(getString(2131952579));
Button button = inflate.negativeBtn;
Intrinsics.checkNotNullExpressionValue(button, "binding.negativeBtn");
button.setVisibility(8);
inflate.messageText.setText(string);
for (String str : permissions) {
PermissionxPermissionItemBinding inflate2 = PermissionxPermissionItemBinding.inflate(getLayoutInflater(), inflate.permissionsLayout, false);
Intrinsics.checkNotNullExpressionValue(inflate2, "inflate(\n …, false\n )");
if (Intrinsics.areEqual(str, "android.permission.CAMERA")) {
inflate2.permissionText.setText(getString(2131952989));
inflate2.permissionIcon.setImageResource(2131231551);
} else if (Intrinsics.areEqual(str, "android.permission.RECORD_AUDIO")) {
inflate2.permissionText.setText("Microphone");
inflate2.permissionIcon.setImageResource(R.drawable.ic_mic);
}
inflate2.permissionIcon.setColorFilter(ContextCompat.getColor((Context) this, 2131100837), PorterDuff.Mode.SRC_ATOP);
inflate.permissionsLayout.addView(inflate2.getRoot());
}
inflate.positiveBtn.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewCallActivity.showOpenSettingDialog$lambda$13(WebViewCallActivity.this, view);
}
});
Dialog dialog4 = this.dialog;
if (dialog4 != null) {
dialog4.show();
}
Dialog dialog5 = this.dialog;
if (dialog5 == null || (window = dialog5.getWindow()) == null) {
return;
}
window.setBackgroundDrawable(new ColorDrawable(0));
} catch (Exception e) {
Timber.e(e);
}
}
public static final void showOpenSettingDialog$lambda$13(WebViewCallActivity webViewCallActivity, View view) {
Intrinsics.checkNotNullParameter(webViewCallActivity, "this$0");
Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
intent.setData(Uri.fromParts("package", webViewCallActivity.getPackageName(), null));
webViewCallActivity.openSettingsLauncher.launch(intent);
Dialog dialog = webViewCallActivity.dialog;
if (dialog != null) {
dialog.dismiss();
}
}
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
Intrinsics.checkNotNullParameter(permissions, NativeProtocol.RESULT_ARGS_PERMISSIONS);
Intrinsics.checkNotNullParameter(grantResults, "grantResults");
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == 1010) {
boolean permissionsGranted = permissionsGranted(this.permissions);
Timber.e("permission granted --- " + permissionsGranted, new Object[0]);
if (permissionsGranted) {
initUI();
return;
}
if (grantResults.length == 0) {
return;
}
ArrayList arrayList = new ArrayList();
int length = permissions.length;
for (int i = 0; i < length; i++) {
if (grantResults[i] != 0) {
arrayList.add(permissions[i]);
}
}
showOpenSettingDialog((String[]) arrayList.toArray(new String[0]));
}
}
@Override
protected void onDestroy() {
Dialog dialog;
super.onDestroy();
Dialog dialog2 = this.dialog;
if (dialog2 != null) {
if ((dialog2 != null && dialog2.isShowing()) && (dialog = this.dialog) != null) {
dialog.dismiss();
}
}
if (isFinishing()) {
endCall();
finish();
App.Companion.setVideoCallScreen(false);
}
}
@Override
public void onStart() {
super.onStart();
registerReceiver();
}
@Override
public void onStop() {
super.onStop();
unRegisterReceiver();
}
}