Skip to content

Commit 2976701

Browse files
committed
feat(CallPrivacy): add per-contact call blocking override via CustomPrivacy
1 parent c47d4fc commit 2976701

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

  • app/src/main/java/com/wmods/wppenhacer/xposed/features/privacy

app/src/main/java/com/wmods/wppenhacer/xposed/features/privacy/CallPrivacy.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,27 @@ class CallPrivacy(loader: ClassLoader, preferences: XSharedPreferences) :
114114

115115

116116
fun checkCallBlock(userJid: FMessageWpp.UserJid, type: PrivacyType?): Boolean {
117-
userJid.phoneNumber ?: return false
117+
val phoneNumber = userJid.phoneNumber ?: return false
118+
119+
val customprivacy = CustomPrivacy.getJSON(phoneNumber);
118120

119121
return when (type) {
120-
PrivacyType.ALL_BLOCKED -> true
121-
PrivacyType.ALL_PERMITTED -> false
122+
PrivacyType.ALL_BLOCKED -> customprivacy.optBoolean("BlockCall", true)
123+
PrivacyType.ALL_PERMITTED -> customprivacy.optBoolean("BlockCall", false)
122124
PrivacyType.ONLY_UNKNOWN -> {
123125
val waContact = WaContactWpp.getWaContactFromJid(userJid) ?: return true
124126
!waContact.isSavedContact()
125127
}
126128
PrivacyType.BACKLIST -> {
129+
if (customprivacy.optBoolean("BlockCall", false)) return true;
127130
val callBlockList = prefs.getString("call_block_contacts", "[]")!!
128131
val blockList = callBlockList.substring(1, callBlockList.length - 1).split(", ")
129132
.map { it.trim() }
130133
blockList.any { it.isNotEmpty() && it == userJid.phoneRawString }
131134
}
132135

133136
PrivacyType.WHITELIST -> {
137+
if (customprivacy.optBoolean("BlockCall", false)) return true;
134138
val callWhiteList = prefs.getString("call_white_contacts", "[]")!!
135139
val whiteList = callWhiteList.substring(1, callWhiteList.length - 1).split(", ")
136140
.map { it.trim() }

0 commit comments

Comments
 (0)