add setting for call integration

(cherry picked from commit 86ef2baacabb6a65db733ecc3e3387317521abe4)
This commit is contained in:
Daniel Gultsch 2024-12-04 09:27:36 +01:00 committed by Arne
parent 0a5d19333d
commit 1e0e7cc9cd
7 changed files with 37 additions and 12 deletions

View file

@ -48,6 +48,7 @@ public class AppSettings {
public static final String LARGE_FONT = "large_font";
public static final String SHOW_LINK_PREVIEWS = "show_link_previews";
public static final String SHOW_AVATARS = "show_avatars";
public static final String CALL_INTEGRATION = "call_integration";
private static final String ACCEPT_INVITES_FROM_STRANGERS = "accept_invites_from_strangers";
private static final String INSTALLATION_ID = "im.conversations.android.install_id";
@ -123,6 +124,10 @@ public class AppSettings {
return getBooleanPreference(SHOW_AVATARS, R.bool.show_avatars);
}
public boolean isCallIntegration() {
return getBooleanPreference(CALL_INTEGRATION, R.bool.call_integration);
}
public boolean isUseTor() {
return getBooleanPreference(USE_TOR, R.bool.use_tor);
}

View file

@ -12,22 +12,19 @@ import android.telecom.CallEndpoint;
import android.telecom.Connection;
import android.telecom.DisconnectCause;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import eu.siacs.conversations.AppSettings;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.ui.util.MainThreadExecutor;
import eu.siacs.conversations.xmpp.Jid;
import eu.siacs.conversations.xmpp.jingle.JingleConnectionManager;
import eu.siacs.conversations.xmpp.jingle.Media;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@ -46,7 +43,7 @@ public class CallIntegration extends Connection {
* SecurityException
*/
private static final List<String> BROKEN_DEVICE_MODELS =
Arrays.asList("gtaxlwifi", "a5y17lte", "YT-X705F");
Arrays.asList("gtaxlwifi", "a5y17lte", "YT-X705F", "HWAGS2");
/**
* all Realme devices at least up to and including Android 11 are broken
@ -530,13 +527,17 @@ public class CallIntegration extends Connection {
return selfManaged(context);
}
public static boolean selfManaged(final Context context) {
public static boolean selfManagedAvailable(final Context context) {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
&& Build.VERSION.SDK_INT < 35
&& hasSystemFeature(context)
&& isDeviceModelSupported();
}
public static boolean selfManaged(final Context context) {
return selfManagedAvailable(context) && new AppSettings(context).isCallIntegration();
}
public static boolean hasSystemFeature(final Context context) {
final var packageManager = context.getPackageManager();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
@ -564,7 +565,7 @@ public class CallIntegration extends Connection {
}
// SailfishOS's AppSupport do not support Call Integration
if (Build.MODEL.endsWith("(AppSupport)")) {
return false;
return false;
}
return true;
}

View file

@ -10,7 +10,6 @@ import android.os.Bundle;
import android.provider.Settings;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -18,10 +17,10 @@ import androidx.preference.Preference;
import androidx.preference.ListPreference;
import com.google.common.base.Optional;
import eu.siacs.conversations.AppSettings;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.services.CallIntegration;
import eu.siacs.conversations.services.NotificationService;
import eu.siacs.conversations.ui.activity.result.PickRingtone;
import eu.siacs.conversations.utils.Compatibility;
@ -68,13 +67,15 @@ public class NotificationsSettingsFragment extends XmppPreferenceFragment {
final var notificationLed = findPreference(AppSettings.NOTIFICATION_LED);
final var chatRequests = (ListPreference) findPreference("chat_requests");
final var foregroundService = findPreference(AppSettings.KEEP_FOREGROUND_SERVICE);
final var callIntegration = findPreference(AppSettings.CALL_INTEGRATION);
if (messageNotificationSettings == null
|| fullscreenNotification == null
|| notificationRingtone == null
|| notificationHeadsUp == null
|| notificationVibrate == null
|| notificationLed == null
|| foregroundService == null) {
|| foregroundService == null
|| callIntegration == null) {
throw new IllegalStateException("The preference resource file is missing preferences");
}
if (Compatibility.runsTwentySix()) {
@ -98,6 +99,7 @@ public class NotificationsSettingsFragment extends XmppPreferenceFragment {
if (!sharedPreferences.getBoolean("notifications_from_strangers", true) && sharedPreferences.getString("chat_requests", null) == null) {
chatRequests.setValue("strangers");
}
callIntegration.setVisible(CallIntegration.selfManagedAvailable(requireContext()));
}
@Override

View file

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="@android:color/white"
android:pathData="M240,920Q207,920 183.5,896.5Q160,873 160,840L160,120Q160,87 183.5,63.5Q207,40 240,40L640,40Q673,40 696.5,63.5Q720,87 720,120L720,280L640,280L640,240L240,240L240,720L640,720L640,680L720,680L720,840Q720,873 696.5,896.5Q673,920 640,920L240,920ZM240,800L240,840Q240,840 240,840Q240,840 240,840L640,840Q640,840 640,840Q640,840 640,840L640,800L240,800ZM598,640L428,470L484,414L598,528L824,302L880,358L598,640ZM240,160L640,160L640,120Q640,120 640,120Q640,120 640,120L240,120Q240,120 240,120Q240,120 240,120L240,160ZM240,160L240,120Q240,120 240,120Q240,120 240,120L240,120Q240,120 240,120Q240,120 240,120L240,160ZM240,800L240,800L240,840Q240,840 240,840Q240,840 240,840L240,840Q240,840 240,840Q240,840 240,840L240,800Z" />
</vector>

View file

@ -64,4 +64,5 @@
<string name="default_dns_server_ipv6">[2a07:e340::2]</string>
<bool name="default_custom_tab">true</bool>
<integer name="automatic_backup">86400</integer>
<bool name="call_integration">true</bool>
</resources>

View file

@ -1392,4 +1392,6 @@
<string name="all_accounts">All accounts</string>
<string name="is_requesting_to_speak">is requesting to speak</string>
<string name="open">Open</string>
<string name="pref_call_integration">Call integration</string>
<string name="pref_call_integration_summary">Calls from this app interact with regular phone calls, such as ending one call when another starts.</string>
</resources>

View file

@ -39,8 +39,6 @@
android:key="led"
android:summary="@string/pref_led_summary"
android:title="@string/pref_led" />
<Preference
android:icon="@drawable/ic_phone_24dp"
android:key="call_ringtone"
@ -58,6 +56,12 @@
android:key="fullscreen_notification"
android:summary="@string/pref_fullscreen_notification_summary"
android:title="@string/pref_fullscreen_notification" />
<SwitchPreferenceCompat
android:defaultValue="@bool/call_integration"
android:icon="@drawable/ic_mobile_friendly_24dp"
android:key="call_integration"
android:summary="@string/pref_call_integration_summary"
android:title="@string/pref_call_integration" />
<ListPreference
android:defaultValue="@integer/grace_period"
android:entries="@array/grace_periods"