Quick calls integration with VK messenger app

This commit is contained in:
saoq
2023-01-10 19:21:24 +03:00
parent 4cb73d669a
commit 26b1db0900
2 changed files with 31 additions and 2 deletions
@@ -0,0 +1,27 @@
package ru.vtosters.lite.hooks;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.view.View;
import com.vtosters.lite.api.ExtendedUserProfile;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserID;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
public class CallsHook {
public static void forwardToVkIm(View view, ExtendedUserProfile p) {
try {
if (getGlobalContext().getPackageManager().getApplicationInfo("com.vk.im", 0).enabled) {
var link = "https://vk.com/call?id=" + getUserID(p);
var startCall = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
view.getContext().startActivity(startCall);
}
} catch (PackageManager.NameNotFoundException e) {
// FIXME: what if no google services?
// Show just toast without redirecting? Show alert with Yes/No before redirect?
var installVkIm = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.vk.im"));
view.getContext().startActivity(installVkIm);
}
}
}
@@ -952,9 +952,11 @@
.method public final b(Landroid/view/View;Lcom/vtosters/lite/api/ExtendedUserProfile;)V
.locals 8
const-string p0, "Звонки не поддерживаются в данном клиенте"
#const-string p0, "Звонки не поддерживаются в данном клиенте"
invoke-static {p0}, Lcom/vk/core/util/ToastUtils;->a(Ljava/lang/CharSequence;)V
#invoke-static {p0}, Lcom/vk/core/util/ToastUtils;->a(Ljava/lang/CharSequence;)V
invoke-static {p1, p2}, Lru/vtosters/lite/hooks/CallsHook;->forwardToVkIm(Landroid/view/View;Lcom/vtosters/lite/api/ExtendedUserProfile;)V
# .line 18
# new-instance v7, Lcom/vk/core/dialogs/actionspopup/ActionsPopup$b;