Make webrtc calling default

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2017-03-06 12:10:26 -08:00
parent b110c8a2cb
commit 1e02d70052
3 changed files with 10 additions and 32 deletions

View File

@ -18,13 +18,7 @@
android:key="pref_system_emoji"
android:title="@string/preferences_advanced__use_system_emoji"
android:summary="@string/preferences_advanced__disable_signal_built_in_emoji_support" />
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_webrtc_calling"
android:title="@string/preferences_advanced__video_calling_beta"
android:summary="@string/preferences_advanced__enable_support_for_next_generation_video_and_voice_calls"/>
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_turn_only"

View File

@ -34,6 +34,7 @@ import org.thoughtcrime.securesms.dependencies.RedPhoneCommunicationModule;
import org.thoughtcrime.securesms.dependencies.SignalCommunicationModule;
import org.thoughtcrime.securesms.jobs.CreateSignedPreKeyJob;
import org.thoughtcrime.securesms.jobs.GcmRefreshJob;
import org.thoughtcrime.securesms.jobs.RefreshAttributesJob;
import org.thoughtcrime.securesms.jobs.persistence.EncryptingJobSerializer;
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirementProvider;
import org.thoughtcrime.securesms.jobs.requirements.MediaNetworkRequirementProvider;
@ -87,6 +88,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
initializeSignedPreKeyCheck();
initializePeriodicTasks();
initializeCircumvention();
initializeSetVideoCapable();
if (Build.VERSION.SDK_INT >= 11) {
PeerConnectionFactory.initializeAndroidGlobals(this, true, true, true);
@ -164,6 +166,13 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
}
}
private void initializeSetVideoCapable() {
if (!TextSecurePreferences.isWebrtcCallingEnabled(this)) {
TextSecurePreferences.setWebrtcCallingEnabled(this, true);
jobManager.add(new RefreshAttributesJob(this));
}
}
private void initializeCircumvention() {
new AsyncTask<Void, Void, Void>() {
@Override

View File

@ -71,7 +71,6 @@ public class AdvancedPreferenceFragment extends PreferenceFragment {
((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.preferences__advanced);
initializePushMessagingToggle();
initializeWebrtcCallingToggle();
}
@Override
@ -98,18 +97,6 @@ public class AdvancedPreferenceFragment extends PreferenceFragment {
preference.setOnPreferenceChangeListener(new PushMessagingClickListener());
}
private void initializeWebrtcCallingToggle() {
if (TextSecurePreferences.isGcmDisabled(getContext())) {
getPreferenceScreen().removePreference(findPreference(TextSecurePreferences.WEBRTC_CALLING_PREF));
} else if (Build.VERSION.SDK_INT >= 11) {
this.findPreference(TextSecurePreferences.WEBRTC_CALLING_PREF)
.setOnPreferenceChangeListener(new WebRtcClickListener());
} else {
this.findPreference(TextSecurePreferences.WEBRTC_CALLING_PREF)
.setEnabled(false);
}
}
private void initializeIdentitySelection() {
ContactIdentityManager identity = ContactIdentityManager.getInstance(getActivity());
@ -172,18 +159,6 @@ public class AdvancedPreferenceFragment extends PreferenceFragment {
}
}
private class WebRtcClickListener implements Preference.OnPreferenceChangeListener {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
TextSecurePreferences.setWebrtcCallingEnabled(getContext(), (Boolean)newValue);
ApplicationContext.getInstance(getContext())
.getJobManager()
.add(new RefreshAttributesJob(getContext()));
return true;
}
}
private class PushMessagingClickListener implements Preference.OnPreferenceChangeListener {
private static final int SUCCESS = 0;
private static final int NETWORK_ERROR = 1;