Disable ephemeral messages beta feature unless manually enabled in chat settings
This commit is contained in:
parent
e00b5f1369
commit
3bd8b74786
5 changed files with 43 additions and 0 deletions
|
@ -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>
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue