Merge pull request #1027 from Saoqq/vk-im-calls-forward

Quick calls integration with VK messenger app
This commit is contained in:
gdlbo
2023-01-11 12:55:34 +03:00
committed by GitHub
2 changed files with 38 additions and 2 deletions
@@ -0,0 +1,34 @@
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;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
public class CallsHook {
public static void forwardToVkOffApps(View view, ExtendedUserProfile p) {
// FIXME: add com.vk.calls, right now it doesn't support intent
var callsAvailable = checkPackage("com.vk.im") || checkPackage("com.vkontakte.android");
if (!callsAvailable) {
sendToast("Установите VK мессенджер или официальный VK клиент");
return;
}
var link = "https://vk.com/call?id=" + getUserID(p);
var startCall = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
view.getContext().startActivity(startCall);
}
private static Boolean checkPackage(String packageName) {
try {
var pm = getGlobalContext().getPackageManager();
return pm.getApplicationInfo(packageName, 0).enabled;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
}
@@ -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;->forwardToVkOffApps(Landroid/view/View;Lcom/vtosters/lite/api/ExtendedUserProfile;)V
# .line 18
# new-instance v7, Lcom/vk/core/dialogs/actionspopup/ActionsPopup$b;