diff --git a/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt index fdfd44db4..1d1240bb4 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt @@ -97,6 +97,7 @@ import io.reactivex.schedulers.Schedulers import org.greenrobot.eventbus.Subscribe import org.greenrobot.eventbus.ThreadMode import org.parceler.Parcels +import java.lang.Long import java.util.Calendar import java.util.Collections import java.util.Locale @@ -106,7 +107,6 @@ import javax.inject.Inject class ConversationInfoActivity : BaseActivity(), FlexibleAdapter.OnItemClickListener { - private lateinit var binding: ActivityConversationInfoBinding @Inject @@ -166,18 +166,14 @@ class ConversationInfoActivity : if (databaseStorageModule == null) { databaseStorageModule = DatabaseStorageModule(conversationUser, conversationToken) } - - binding.notificationSettingsView.notificationSettings.setStorageModule(databaseStorageModule) - binding.webinarInfoView.webinarSettings.setStorageModule(databaseStorageModule) - binding.guestAccessView.guestAccessSettings.setStorageModule(databaseStorageModule) - + setUpNotificationSettings(databaseStorageModule!!) binding.deleteConversationAction.setOnClickListener { showDeleteConversationDialog() } binding.leaveConversationAction.setOnClickListener { leaveConversation() } binding.clearConversationHistory.setOnClickListener { showClearHistoryDialog() } binding.addParticipantsAction.setOnClickListener { addParticipants() } if (CapabilitiesUtilNew.hasSpreedFeatureCapability(conversationUser, "rich-object-list-media")) { - binding.showSharedItemsAction.setOnClickListener { showSharedItems() } + binding.sharedItemsButton.setOnClickListener { showSharedItems() } } else { binding.categorySharedItems.visibility = GONE } @@ -248,12 +244,12 @@ class ConversationInfoActivity : private fun themeSwitchPreferences() { binding.run { listOf( - binding.webinarInfoView.conversationInfoLobby, - binding.notificationSettingsView.callNotifications, - binding.notificationSettingsView.conversationInfoPriorityConversation, - binding.guestAccessView.guestAccessAllowSwitch, - binding.guestAccessView.guestAccessPasswordSwitch - ).forEach(viewThemeUtils.talk::colorSwitchPreference) + binding.webinarInfoView.lobbySwitch, + binding.notificationSettingsView.callNotificationsSwitch, + binding.notificationSettingsView.importantConversationSwitch, + binding.guestAccessView.allowGuestsSwitch, + binding.guestAccessView.passwordProtectionSwitch + ).forEach(viewThemeUtils.talk::colorSwitch) } } @@ -262,15 +258,28 @@ class ConversationInfoActivity : listOf( conversationInfoName, conversationDescription, - otherRoomOptions, + addToFavoritesButton, participantsListCategory, - ownOptions, + addParticipantsAction, + dangerZoneOptions, categorySharedItems, - categoryConversationSettings, - binding.guestAccessView.guestAccessCategory, - binding.webinarInfoView.conversationInfoWebinar, - binding.notificationSettingsView.notificationSettingsCategory - ).forEach(viewThemeUtils.talk::colorPreferenceCategory) + conversationSettings, + leaveConversationAction, + deleteConversationAction, + clearConversationHistory, + sharedItemsButton, + binding.guestAccessView.guestAccessSettings, + binding.guestAccessView.guestAccessSettingsAllowGuest, + binding.guestAccessView.guestAccessSettingsPasswordProtection, + binding.guestAccessView.shareConversationButton, + binding.guestAccessView.resendInvitationsButton, + binding.webinarInfoView.webinarSettings, + binding.webinarInfoView.webinarSettingsLobby, + binding.webinarInfoView.startTimeButton, + binding.notificationSettingsView.notificationSettings, + binding.notificationSettingsView.notificationSettingsImportantConversation, + binding.notificationSettingsView.notificationSettingsCallNotifications + ).forEach(viewThemeUtils.talk::ConversationInfoCardView) } } @@ -294,12 +303,12 @@ class ConversationInfoActivity : val isLobbyOpenToModeratorsOnly = conversation!!.lobbyState == Conversation.LobbyState.LOBBY_STATE_MODERATORS_ONLY - (binding?.webinarInfoView?.conversationInfoLobby?.findViewById(R.id.mp_checkable) as SwitchCompat) + (binding?.webinarInfoView?.lobbySwitch as SwitchCompat) .isChecked = isLobbyOpenToModeratorsOnly reconfigureLobbyTimerView() - binding?.webinarInfoView?.startTimePreferences?.setOnClickListener { + binding?.webinarInfoView?.startTimeButton?.setOnClickListener { MaterialDialog(this, BottomSheet(WRAP_CONTENT)).show { val currentTimeCalendar = Calendar.getInstance() if (conversation!!.lobbyTimer != null && conversation!!.lobbyTimer != 0L) { @@ -319,7 +328,7 @@ class ConversationInfoActivity : } } - (binding?.webinarInfoView?.conversationInfoLobby?.findViewById(R.id.mp_checkable) as SwitchCompat) + (binding?.webinarInfoView?.lobbySwitch as SwitchCompat) .setOnCheckedChangeListener { _, _ -> reconfigureLobbyTimerView() submitLobbyChanges() @@ -336,7 +345,7 @@ class ConversationInfoActivity : private fun reconfigureLobbyTimerView(dateTime: Calendar? = null) { val isChecked = - (binding?.webinarInfoView?.conversationInfoLobby?.findViewById(R.id.mp_checkable) as SwitchCompat) + (binding?.webinarInfoView?.lobbySwitch as SwitchCompat) .isChecked if (dateTime != null && isChecked) { @@ -355,28 +364,28 @@ class ConversationInfoActivity : if ( conversation!!.lobbyTimer != null && - conversation!!.lobbyTimer != java.lang.Long.MIN_VALUE && + conversation!!.lobbyTimer != Long.MIN_VALUE && conversation!!.lobbyTimer != 0L ) { - binding?.webinarInfoView?.startTimePreferences?.setSummary( + binding?.webinarInfoView?.startTimeButtonSummary?.text = ( dateUtils.getLocalDateTimeStringFromTimestamp( conversation!!.lobbyTimer!! * DateConstants.SECOND_DIVIDER ) - ) + ) } else { - binding?.webinarInfoView?.startTimePreferences?.setSummary(R.string.nc_manual) + binding?.webinarInfoView?.startTimeButtonSummary?.setText(R.string.nc_manual) } if (isChecked) { - binding?.webinarInfoView?.startTimePreferences?.visibility = VISIBLE + binding?.webinarInfoView?.startTimeButton?.visibility = VISIBLE } else { - binding?.webinarInfoView?.startTimePreferences?.visibility = GONE + binding?.webinarInfoView?.startTimeButton?.visibility = GONE } } fun submitLobbyChanges() { val state = if ( - (binding?.webinarInfoView?.conversationInfoLobby?.findViewById(R.id.mp_checkable) as SwitchCompat) + (binding?.webinarInfoView?.lobbySwitch as SwitchCompat) .isChecked ) { 1 @@ -679,7 +688,7 @@ class ConversationInfoActivity : } if (!isDestroyed) { - binding?.ownOptions?.visibility = VISIBLE + binding?.dangerZoneOptions?.visibility = VISIBLE setupWebinaryView() @@ -696,14 +705,14 @@ class ConversationInfoActivity : } if (Conversation.ConversationType.ROOM_SYSTEM == conversation!!.type) { - binding?.notificationSettingsView?.callNotifications?.visibility = GONE + binding?.notificationSettingsView?.callNotificationsSwitch?.visibility = GONE } if (conversation!!.notificationCalls === null) { - binding?.notificationSettingsView?.callNotifications?.visibility = GONE + binding?.notificationSettingsView?.callNotificationsSwitch?.visibility = GONE } else { - binding?.notificationSettingsView?.callNotifications?.value = - conversationCopy.notificationCalls == 1 + binding?.notificationSettingsView?.callNotificationsSwitch?.isChecked = + (conversationCopy.notificationCalls == 1) } getListOfParticipants() @@ -751,11 +760,21 @@ class ConversationInfoActivity : CapabilitiesUtilNew.hasSpreedFeatureCapability(conversationUser, "message-expiration") ) { databaseStorageModule?.setMessageExpiration(conversation!!.messageExpiration) - binding?.conversationInfoExpireMessages?.setStorageModule(databaseStorageModule) - binding?.conversationInfoExpireMessages?.visibility = VISIBLE + val value = databaseStorageModule!!.getString("conversation_settings_dropdown", "") + val pos = resources.getStringArray(R.array.message_expiring_values).indexOf(value) + val text = resources.getStringArray(R.array.message_expiring_descriptions)[pos] + binding.conversationSettingsDropdown.setText(text) + binding.conversationSettingsDropdown + .setSimpleItems(resources.getStringArray(R.array.message_expiring_descriptions)) + binding.conversationSettingsDropdown.setOnItemClickListener { _, _, position, _ -> + val value = resources.getStringArray(R.array.message_expiring_values)[position] + databaseStorageModule!!.saveString("conversation_settings_dropdown", value) + } + + binding?.conversationSettingsDropdown?.visibility = VISIBLE binding?.conversationInfoExpireMessagesExplanation?.visibility = VISIBLE } else { - binding?.categoryConversationSettings?.visibility = GONE + binding?.conversationSettings?.visibility = GONE } } @@ -765,40 +784,49 @@ class ConversationInfoActivity : conversationUser != null && CapabilitiesUtilNew.hasSpreedFeatureCapability(conversationUser, "notification-levels") ) { - binding?.notificationSettingsView?.conversationInfoMessageNotifications?.isEnabled = true - binding?.notificationSettingsView?.conversationInfoMessageNotifications?.alpha = 1.0f + binding?.notificationSettingsView?.conversationInfoMessageNotificationsDropdown?.isEnabled = true + binding?.notificationSettingsView?.conversationInfoMessageNotificationsDropdown?.alpha = 1.0f if (conversation!!.notificationLevel != Conversation.NotificationLevel.DEFAULT) { val stringValue: String = when (EnumNotificationLevelConverter().convertToInt(conversation!!.notificationLevel)) { - NOTIFICATION_LEVEL_ALWAYS -> "always" - NOTIFICATION_LEVEL_MENTION -> "mention" - NOTIFICATION_LEVEL_NEVER -> "never" - else -> "mention" + NOTIFICATION_LEVEL_ALWAYS -> resources.getString(R.string.nc_notify_me_always) + NOTIFICATION_LEVEL_MENTION -> resources.getString(R.string.nc_notify_me_mention) + NOTIFICATION_LEVEL_NEVER -> resources.getString(R.string.nc_notify_me_never) + else -> resources.getString(R.string.nc_notify_me_mention) } - binding?.notificationSettingsView?.conversationInfoMessageNotifications?.value = stringValue + binding?.notificationSettingsView?.conversationInfoMessageNotificationsDropdown?.setText( + stringValue + ) } else { setProperNotificationValue(conversation) } } else { - binding?.notificationSettingsView?.conversationInfoMessageNotifications?.isEnabled = false - binding?.notificationSettingsView?.conversationInfoMessageNotifications?.alpha = LOW_EMPHASIS_OPACITY + binding?.notificationSettingsView?.conversationInfoMessageNotificationsDropdown?.isEnabled = false + binding?.notificationSettingsView?.conversationInfoMessageNotificationsDropdown?.alpha = LOW_EMPHASIS_OPACITY setProperNotificationValue(conversation) } + binding?.notificationSettingsView?.conversationInfoMessageNotificationsDropdown + ?.setSimpleItems(resources.getStringArray(R.array.message_notification_levels)) } } private fun setProperNotificationValue(conversation: Conversation?) { if (conversation!!.type == Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) { - // hack to see if we get mentioned always or just on mention if (CapabilitiesUtilNew.hasSpreedFeatureCapability(conversationUser, "mention-flag")) { - binding?.notificationSettingsView?.conversationInfoMessageNotifications?.value = "always" + binding?.notificationSettingsView?.conversationInfoMessageNotificationsDropdown?.setText( + resources.getString(R.string.nc_notify_me_always) + ) } else { - binding?.notificationSettingsView?.conversationInfoMessageNotifications?.value = "mention" + binding?.notificationSettingsView?.conversationInfoMessageNotificationsDropdown?.setText( + resources.getString(R.string.nc_notify_me_mention) + ) } } else { - binding?.notificationSettingsView?.conversationInfoMessageNotifications?.value = "mention" + binding?.notificationSettingsView?.conversationInfoMessageNotificationsDropdown?.setText( + resources.getString(R.string.nc_notify_me_mention) + ) } } @@ -1169,6 +1197,29 @@ class ConversationInfoActivity : return true } + fun setUpNotificationSettings(module: DatabaseStorageModule) { + // set up listeners + binding.notificationSettingsView?.importantConversationSwitch?.setOnCheckedChangeListener { _, isChecked -> + module.saveBoolean("important_conversation_switch", isChecked) + } + + binding.notificationSettingsView?.callNotificationsSwitch?.setOnCheckedChangeListener { _, isChecked -> + module.saveBoolean("call_notifications_switch", isChecked) + } + + binding.notificationSettingsView?.conversationInfoMessageNotificationsDropdown?.setOnItemClickListener { + _, _, position, _ -> + val value = resources.getStringArray(R.array.message_notification_levels_entry_values)[position] + module.saveString("conversation_info_message_notifications_dropdown", value) + } + + binding.notificationSettingsView?.importantConversationSwitch?.isChecked = module + .getBoolean("important_conversation_switch", false) + + binding.notificationSettingsView?.callNotificationsSwitch?.isChecked = module + .getBoolean("call_notifications_switch", true) + } + companion object { private const val TAG = "ConversationInfo" private const val NOTIFICATION_LEVEL_ALWAYS: Int = 1 diff --git a/app/src/main/java/com/nextcloud/talk/conversationinfo/GuestAccessHelper.kt b/app/src/main/java/com/nextcloud/talk/conversationinfo/GuestAccessHelper.kt index b3e6f701a..018db1be3 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationinfo/GuestAccessHelper.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationinfo/GuestAccessHelper.kt @@ -35,18 +35,18 @@ class GuestAccessHelper( fun setupGuestAccess() { val guestAccessAllowSwitch = ( - binding.guestAccessView.guestAccessAllowSwitch.findViewById(R.id.mp_checkable) + binding.guestAccessView.allowGuestsSwitch as SwitchCompat ) val guestAccessPasswordSwitch = ( - binding.guestAccessView.guestAccessPasswordSwitch.findViewById(R.id.mp_checkable) + binding.guestAccessView.passwordProtectionSwitch as SwitchCompat ) if (conversation.canModerate(conversationUser)) { binding.guestAccessView.guestAccessSettings.visibility = View.VISIBLE } else { - return + binding.guestAccessView.guestAccessSettings.visibility = View.GONE } if (conversation.type == Conversation.ConversationType.ROOM_PUBLIC_CALL) { @@ -59,7 +59,7 @@ class GuestAccessHelper( guestAccessAllowSwitch.isChecked = false } - binding.guestAccessView.guestAccessAllowSwitch.setOnClickListener { + binding.guestAccessView.allowGuestsSwitch.setOnClickListener { conversationsRepository.allowGuests( conversation.token!!, !guestAccessAllowSwitch.isChecked @@ -67,7 +67,7 @@ class GuestAccessHelper( .observeOn(AndroidSchedulers.mainThread()).subscribe(AllowGuestsResultObserver()) } - binding.guestAccessView.guestAccessPasswordSwitch.setOnClickListener { + binding.guestAccessView.passwordProtectionSwitch.setOnClickListener { if (guestAccessPasswordSwitch.isChecked) { conversationsRepository.password("", conversation.token!!).subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()).subscribe(PasswordResultObserver(false)) @@ -76,11 +76,11 @@ class GuestAccessHelper( } } - binding.guestAccessView.guestAccessCopyUrl.setOnClickListener { + binding.guestAccessView.shareConversationButton.setOnClickListener { shareUrl() } - binding.guestAccessView.guestAccessResendInvitations.setOnClickListener { + binding.guestAccessView.resendInvitationsButton.setOnClickListener { conversationsRepository.resendInvitations(conversation.token!!).subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()).subscribe(ResendInvitationsObserver()) } @@ -180,7 +180,7 @@ class GuestAccessHelper( override fun onComplete() { ( - binding.guestAccessView.guestAccessAllowSwitch.findViewById(R.id.mp_checkable) + binding.guestAccessView.allowGuestsSwitch as SwitchCompat ).isChecked = allowGuestsResult.allow if (allowGuestsResult.allow) { @@ -194,17 +194,17 @@ class GuestAccessHelper( } private fun showAllOptions() { - binding.guestAccessView.guestAccessPasswordSwitch.visibility = View.VISIBLE - binding.guestAccessView.guestAccessCopyUrl.visibility = View.VISIBLE + binding.guestAccessView.guestAccessSettingsPasswordProtection.visibility = View.VISIBLE + binding.guestAccessView.shareConversationButton.visibility = View.VISIBLE if (conversationUser.capabilities?.spreedCapability?.features?.contains("sip-support") == true) { - binding.guestAccessView.guestAccessResendInvitations.visibility = View.VISIBLE + binding.guestAccessView.resendInvitationsButton.visibility = View.VISIBLE } } private fun hideAllOptions() { - binding.guestAccessView.guestAccessPasswordSwitch.visibility = View.GONE - binding.guestAccessView.guestAccessCopyUrl.visibility = View.GONE - binding.guestAccessView.guestAccessResendInvitations.visibility = View.GONE + binding.guestAccessView.guestAccessSettingsPasswordProtection.visibility = View.GONE + binding.guestAccessView.shareConversationButton.visibility = View.GONE + binding.guestAccessView.resendInvitationsButton.visibility = View.GONE } inner class PasswordResultObserver(private val setPassword: Boolean) : @@ -226,7 +226,7 @@ class GuestAccessHelper( override fun onComplete() { val guestAccessPasswordSwitch = ( - binding.guestAccessView.guestAccessPasswordSwitch.findViewById(R.id.mp_checkable) + binding.guestAccessView.passwordProtectionSwitch as SwitchCompat ) guestAccessPasswordSwitch.isChecked = passwordResult.passwordSet && setPassword diff --git a/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt b/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt index 7e24d1feb..dc3e11e73 100644 --- a/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt @@ -228,8 +228,8 @@ class SettingsActivity : BaseActivity() { startActivity(intent) } - themeCategories() - themeSwitchPreferences() + // themeCategories() + // themeSwitchPreferences() } private fun loadCapabilitiesAndUpdateSettings() { @@ -488,31 +488,31 @@ class SettingsActivity : BaseActivity() { } } - private fun themeSwitchPreferences() { - binding.run { - listOf( - settingsScreenLock, - settingsScreenSecurity, - settingsIncognitoKeyboard, - settingsPhoneBookIntegration, - settingsReadPrivacy, - settingsTypingStatus, - settingsProxyUseCredentials - ).forEach(viewThemeUtils.talk::colorSwitchPreference) - } - } - - private fun themeCategories() { - binding.run { - listOf( - settingsNotificationsCategory, - settingsAboutCategory, - settingsAdvancedCategory, - settingsAppearanceCategory, - settingsPrivacyCategory - ).forEach(viewThemeUtils.talk::colorPreferenceCategory) - } - } + // private fun themeSwitchPreferences() { + // binding.run { + // listOf( + // settingsScreenLock, + // settingsScreenSecurity, + // settingsIncognitoKeyboard, + // settingsPhoneBookIntegration, + // settingsReadPrivacy, + // settingsTypingStatus, + // settingsProxyUseCredentials + // ).forEach(viewThemeUtils.talk::colorSwitchPreference) + // } + // } + // + // private fun themeCategories() { + // binding.run { + // listOf( + // settingsNotificationsCategory, + // settingsAboutCategory, + // settingsAdvancedCategory, + // settingsAppearanceCategory, + // settingsPrivacyCategory + // ).forEach(viewThemeUtils.talk::colorPreferenceCategory) + // } + // } private fun setupProxyTypeSettings() { if (("No proxy" == appPreferences.proxyType) || appPreferences.proxyType == null) { diff --git a/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt b/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt index 30bc3fc43..0828ba3a8 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt @@ -40,8 +40,8 @@ import androidx.core.content.res.ResourcesCompat import androidx.core.graphics.ColorUtils import androidx.core.graphics.drawable.DrawableCompat import androidx.core.view.ViewCompat -import androidx.core.view.children import com.google.android.material.card.MaterialCardView +import com.google.android.material.materialswitch.MaterialSwitch import com.nextcloud.android.common.ui.theme.MaterialSchemes import com.nextcloud.android.common.ui.theme.ViewThemeUtilsBase import com.nextcloud.android.common.ui.theme.utils.AndroidXViewThemeUtils @@ -50,7 +50,6 @@ import com.nextcloud.talk.utils.DisplayUtils import com.nextcloud.talk.utils.DrawableUtils import com.vanniktech.emoji.EmojiTextView import com.yarolegovich.mp.MaterialPreferenceCategory -import com.yarolegovich.mp.MaterialSwitchPreference import javax.inject.Inject import kotlin.math.roundToInt @@ -146,12 +145,10 @@ class TalkSpecificViewThemeUtils @Inject constructor( } } - fun colorSwitchPreference(preference: MaterialSwitchPreference) { - val children = preference.children - val switch = children.find { it is SwitchCompat } + fun colorSwitch(preference: MaterialSwitch) { + val switch = preference as SwitchCompat if (switch != null) { - val switchCompat = (switch as SwitchCompat) - appcompat.colorSwitchCompat(switchCompat) + appcompat.colorSwitchCompat(switch) } } @@ -255,6 +252,35 @@ class TalkSpecificViewThemeUtils @Inject constructor( } } + fun ConversationInfoCardView(cardView: MaterialCardView) { + withScheme(cardView) { scheme -> + val background = cardView.context.getColor(R.color.bg_default) + cardView.backgroundTintList = + ColorStateList( + arrayOf( + intArrayOf(android.R.attr.state_checked), + intArrayOf(-android.R.attr.state_checked) + ), + intArrayOf( + scheme.primary, + background + ) + ) + cardView.setStrokeColor( + ColorStateList( + arrayOf( + intArrayOf(android.R.attr.state_checked), + intArrayOf(-android.R.attr.state_checked) + ), + intArrayOf( + scheme.primary, + background + ) + ) + ) + } + } + companion object { private val THEMEABLE_PLACEHOLDER_IDS = listOf( R.drawable.ic_mimetype_package_x_generic, diff --git a/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageFactory.java b/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageFactory.java deleted file mode 100644 index 181526a30..000000000 --- a/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Nextcloud Talk application - * - * @author Mario Danic - * Copyright (C) 2017-2018 Mario Danic - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.nextcloud.talk.utils.preferences.preferencestorage; - -import android.content.Context; - -import com.nextcloud.talk.data.user.model.User; -import com.yarolegovich.mp.io.StorageModule; - -public class DatabaseStorageFactory implements StorageModule.Factory { - private User conversationUser; - private String conversationToken; - - - public DatabaseStorageFactory(User conversationUser, String conversationToken) { - this.conversationUser = conversationUser; - this.conversationToken = conversationToken; - } - - @Override - public StorageModule create(Context context) { - return new DatabaseStorageModule(conversationUser, conversationToken); - } -} diff --git a/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.java b/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.java index 3b4d59cf5..4ad73d443 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.java +++ b/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.java @@ -24,7 +24,6 @@ package com.nextcloud.talk.utils.preferences.preferencestorage; -import android.os.Bundle; import android.text.TextUtils; import android.util.Log; @@ -37,9 +36,6 @@ import com.nextcloud.talk.models.json.generic.GenericOverall; import com.nextcloud.talk.utils.ApiUtils; import com.nextcloud.talk.utils.UserIdUtils; import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew; -import com.yarolegovich.mp.io.StorageModule; - -import java.util.Set; import javax.inject.Inject; @@ -51,7 +47,7 @@ import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; @AutoInjector(NextcloudTalkApplication.class) -public class DatabaseStorageModule implements StorageModule { +public class DatabaseStorageModule { private static final String TAG = "DatabaseStorageModule"; @Inject ArbitraryStorageManager arbitraryStorageManager; @@ -76,9 +72,8 @@ public class DatabaseStorageModule implements StorageModule { this.conversationToken = conversationToken; } - @Override public void saveBoolean(String key, boolean value) { - if ("call_notifications".equals(key)) { + if ("call_notifications_switch".equals(key)) { int apiVersion = ApiUtils.getConversationApiVersion(conversationUser, new int[]{4}); ncApi.notificationCalls(ApiUtils.getCredentials(conversationUser.getUsername(), conversationUser.getToken()), @@ -112,7 +107,7 @@ public class DatabaseStorageModule implements StorageModule { ); } - if (!"conversation_lobby".equals(key)) { + if (!"lobby_switch".equals(key)) { arbitraryStorageManager.storeStorageSetting(accountIdentifier, key, Boolean.toString(value), @@ -122,9 +117,8 @@ public class DatabaseStorageModule implements StorageModule { } } - @Override public void saveString(String key, String value) { - if ("message_expire_key".equals(key)) { + if ("conversation_settings_dropdown".equals(key)) { int apiVersion = ApiUtils.getConversationApiVersion(conversationUser, new int[]{4}); String trimmedValue = value.replace("expire_", ""); @@ -163,7 +157,7 @@ public class DatabaseStorageModule implements StorageModule { } }); - } else if ("message_notification_level".equals(key)) { + } else if ("conversation_info_message_notifications_dropdown".equals(key)) { if (CapabilitiesUtilNew.hasSpreedFeatureCapability(conversationUser, "notification-levels")) { if (!TextUtils.isEmpty(messageNotificationLevel) && !messageNotificationLevel.equals(value)) { int intValue; @@ -198,6 +192,7 @@ public class DatabaseStorageModule implements StorageModule { @Override public void onNext(GenericOverall genericOverall) { + Log.i(TAG, "onNext called"); messageNotificationLevel = value; } @@ -219,20 +214,8 @@ public class DatabaseStorageModule implements StorageModule { arbitraryStorageManager.storeStorageSetting(accountIdentifier, key, value, conversationToken); } } - - @Override - public void saveInt(String key, int value) { - arbitraryStorageManager.storeStorageSetting(accountIdentifier, key, Integer.toString(value), conversationToken); - } - - @Override - public void saveStringSet(String key, Set value) { - // unused atm - } - - @Override public boolean getBoolean(String key, boolean defaultVal) { - if ("conversation_lobby".equals(key)) { + if ("lobby_switch".equals(key)) { return lobbyValue; } else { return arbitraryStorageManager @@ -242,9 +225,8 @@ public class DatabaseStorageModule implements StorageModule { } } - @Override public String getString(String key, String defaultVal) { - if ("message_expire_key".equals(key)) { + if ("conversation_settings_dropdown".equals(key)) { switch (messageExpiration) { case 2419200: return "expire_2419200"; @@ -259,7 +241,7 @@ public class DatabaseStorageModule implements StorageModule { default: return "expire_0"; } - } else if ("message_notification_level".equals(key)) { + } else if ("conversation_info_message_notifications_dropdown".equals(key)) { return messageNotificationLevel; } else { return arbitraryStorageManager @@ -269,35 +251,6 @@ public class DatabaseStorageModule implements StorageModule { } } - @Override - public int getInt(String key, int defaultVal) { - return arbitraryStorageManager - .getStorageSetting(accountIdentifier, key, conversationToken) - .map(arbitraryStorage -> { - if (arbitraryStorage.getValue() != null) { - return Integer.parseInt(arbitraryStorage.getValue()); - } else { - return defaultVal; - } - }) - .blockingGet(defaultVal); - } - - @Override - public Set getStringSet(String key, Set defaultVal) { - return null; - } - - @Override - public void onSaveInstanceState(Bundle outState) { - // unused atm - } - - @Override - public void onRestoreInstanceState(Bundle savedState) { - // unused atm - } - public void setMessageExpiration(int messageExpiration) { this.messageExpiration = messageExpiration; } diff --git a/app/src/main/res/layout/activity_conversation_info.xml b/app/src/main/res/layout/activity_conversation_info.xml index daf7f7964..87ef63454 100644 --- a/app/src/main/res/layout/activity_conversation_info.xml +++ b/app/src/main/res/layout/activity_conversation_info.xml @@ -31,12 +31,14 @@ android:id="@+id/parent_container" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical"> + android:orientation="vertical" + tools:visibility="visible"> + + tools:visibility="gone" /> - + android:layout_height="match_parent"> + android:contentDescription="@string/avatar" + tools:src="@drawable/account_circle_48dp" /> - + - - + - + android:layout_marginTop="@dimen/standard_quarter_margin"> - + android:layout_height="match_parent" + android:orientation="horizontal" + android:padding="@dimen/standard_half_padding" + android:visibility="gone" + tools:visibility="gone"> - + - + + + + + + + + + android:layout_marginTop="@dimen/standard_quarter_margin" /> + android:layout_marginTop="@dimen/standard_quarter_margin" /> + android:layout_marginTop="@dimen/standard_quarter_margin" /> - + android:layout_marginTop="@dimen/standard_quarter_margin" + android:elevation="0dp"> - + android:layout_height="match_parent" + android:orientation="vertical" + > - + - + + + + + + + + + + + + + + + + + android:layout_marginTop="@dimen/standard_quarter_margin" + android:elevation="0dp"> - - + android:layout_height="match_parent" + android:orientation="vertical" + > - - + - + - + + + + + + + + + + + + - + android:layout_height="match_parent" + android:orientation="vertical"> - + - + - + + + + + + + + + + + + + + + + android:layout_marginTop="@dimen/standard_quarter_margin" + android:elevation="0dp"> - + android:layout_height="match_parent" + android:orientation="vertical" + > - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/item_guest_access_settings.xml b/app/src/main/res/layout/item_guest_access_settings.xml new file mode 100644 index 000000000..f70242833 --- /dev/null +++ b/app/src/main/res/layout/item_guest_access_settings.xml @@ -0,0 +1,211 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_notification_settings.xml b/app/src/main/res/layout/item_notification_settings.xml new file mode 100644 index 000000000..c215b833a --- /dev/null +++ b/app/src/main/res/layout/item_notification_settings.xml @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_webinar_info.xml b/app/src/main/res/layout/item_webinar_info.xml new file mode 100644 index 000000000..810ed20c3 --- /dev/null +++ b/app/src/main/res/layout/item_webinar_info.xml @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index cebc610ed..149b0be4b 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -88,5 +88,6 @@ 150dp 40dp + 30dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c678e2a93..382293b4a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -153,7 +153,6 @@ How to translate with transifex: Read status Share my typing-status and show the typing-status of others Typing status - Typing status is only available when using a high performance backend (HPB) 30 seconds 1 minute @@ -197,7 +196,6 @@ How to translate with transifex: New conversation Join with a link - List open conversations Join via web Mark as read Mark as unread @@ -206,10 +204,6 @@ How to translate with transifex: Forward to … - - No open conversations - No open conversations that you can join.\nEither there are no open conversations or you already joined all of them. - Select participants Add participants @@ -565,14 +559,6 @@ How to translate with transifex: Invalid password Do you want to reauthorize or delete this account? - App is outdated - The app is too old and no longer supported by this server. Please update. - Update - Switch account - Maintenance mode - Server is currently in maintenance mode. - Close app - Take a photo Switch camera @@ -685,8 +671,6 @@ How to translate with transifex: Translation failed Could not detect language Copy translated text - Filter Conversations - Mentioned - Unread + Danger Zone