Commit 3bd8b747 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Disable ephemeral messages beta feature unless manually enabled in chat settings

parent e00b5f13
Pipeline #12127 passed with stages
in 6 minutes and 4 seconds
......@@ -1124,6 +1124,10 @@ public class ChatMessagesFragment extends Fragment
if (!mChatRoom.hasCapability(ChatRoomCapabilities.Encrypted.toInt())) {
builder.removeItem(R.id.chat_room_participants_devices);
builder.removeItem(R.id.chat_room_ephemeral_messages);
} else {
if (!LinphonePreferences.instance().isEphemeralMessagesEnabled()) {
builder.removeItem(R.id.chat_room_ephemeral_messages);
}
}
builder.setCallback(
......
......@@ -29,7 +29,9 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import org.linphone.LinphoneManager;
import org.linphone.R;
import org.linphone.core.ChatRoom;
import org.linphone.core.tools.Log;
import org.linphone.mediastream.Version;
import org.linphone.settings.widget.BasicSetting;
......@@ -45,6 +47,7 @@ public class ChatSettingsFragment extends SettingsFragment {
private BasicSetting mAndroidNotificationSettings;
private ListSetting mAutoDownloadIncomingFilesPolicy;
private SwitchSetting mHideEmptyRooms, mHideRemovedProxiesRooms, mMakeDownloadedImagesPublic;
private SwitchSetting mEnableEphemeralBeta;
@Nullable
@Override
......@@ -85,6 +88,9 @@ public class ChatSettingsFragment extends SettingsFragment {
mHideRemovedProxiesRooms =
mRootView.findViewById(R.id.pref_android_app_hide_chat_rooms_from_removed_proxies);
mEnableEphemeralBeta =
mRootView.findViewById(R.id.pref_android_app_enable_ephemeral_messages_beta);
}
private void setListeners() {
......@@ -166,6 +172,19 @@ public class ChatSettingsFragment extends SettingsFragment {
LinphonePreferences.instance().setHideRemovedProxiesChatRooms(newValue);
}
});
mEnableEphemeralBeta.setListener(
new SettingListenerBase() {
@Override
public void onBoolValueChanged(boolean newValue) {
LinphonePreferences.instance().enableEphemeralMessages(newValue);
if (!newValue) {
for (ChatRoom room : LinphoneManager.getCore().getChatRooms()) {
room.enableEphemeral(false);
}
}
}
});
}
private void updateValues() {
......@@ -184,6 +203,9 @@ public class ChatSettingsFragment extends SettingsFragment {
mHideRemovedProxiesRooms.setChecked(
LinphonePreferences.instance().hideRemovedProxiesChatRooms());
mEnableEphemeralBeta.setChecked(
LinphonePreferences.instance().isEphemeralMessagesEnabled());
setListeners();
}
......
......@@ -1312,4 +1312,14 @@ public class LinphonePreferences {
if (getConfig() == null) return;
getConfig().setBool("misc", "hide_chat_rooms_from_removed_proxies", hide);
}
public void enableEphemeralMessages(boolean enable) {
if (getConfig() == null) return;
getConfig().setBool("app", "ephemeral", enable);
}
public boolean isEphemeralMessagesEnabled() {
if (getConfig() == null) return true;
return getConfig().getBool("app", "ephemeral", false);
}
}
......@@ -60,6 +60,12 @@
linphone:title="@string/pref_android_app_hide_chat_rooms_from_removed_proxies_title"
linphone:subtitle="@string/pref_android_app_hide_chat_rooms_from_removed_proxies_desc" />
<org.linphone.settings.widget.SwitchSetting
android:id="@+id/pref_android_app_enable_ephemeral_messages_beta"
android:layout_width="match_parent"
android:layout_height="wrap_content"
linphone:title="@string/pref_android_app_enable_ephemeral_messages_beta" />
</LinearLayout>
</ScrollView>
\ No newline at end of file
......@@ -502,6 +502,7 @@
<string name="pref_android_app_hide_chat_rooms_from_removed_proxies_desc">If you have missing chat rooms, try to uncheck this setting</string>
<string name="pref_android_app_make_downloaded_images_visible_in_native_gallery_title">Make downloaded images visible in native gallery</string>
<string name="pref_android_app_make_downloaded_images_visible_in_native_gallery_desc">Images in ephemeral messages won\'t be</string>
<string name="pref_android_app_enable_ephemeral_messages_beta">Enable ephemeral messages (beta)</string>
<!-- Network settings -->
<string name="pref_network_title">Network</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment