mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 01:45:52 +03:00
expanding the discovery polices on recieving a custom payload
- also meant updating the general link to discovery in order to manually pass the default arguments
This commit is contained in:
parent
728f34f53c
commit
7b5972e3cf
7 changed files with 63 additions and 21 deletions
|
@ -21,6 +21,7 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.airbnb.mvrx.args
|
||||
import com.airbnb.mvrx.fragmentViewModel
|
||||
import com.airbnb.mvrx.withState
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
@ -36,6 +37,7 @@ import im.vector.app.core.utils.openUrlInChromeCustomTab
|
|||
import im.vector.app.core.utils.showIdentityServerConsentDialog
|
||||
import im.vector.app.databinding.FragmentGenericRecyclerBinding
|
||||
import im.vector.app.features.discovery.change.SetIdentityServerFragment
|
||||
import im.vector.app.features.navigation.SettingsActivityPayload
|
||||
import im.vector.app.features.settings.VectorSettingsActivity
|
||||
import org.matrix.android.sdk.api.session.identity.SharedState
|
||||
import org.matrix.android.sdk.api.session.identity.ThreePid
|
||||
|
@ -53,6 +55,7 @@ class DiscoverySettingsFragment @Inject constructor(
|
|||
}
|
||||
|
||||
private val viewModel by fragmentViewModel(DiscoverySettingsViewModel::class)
|
||||
private val discoveryArgs: SettingsActivityPayload.DiscoverySettings by args()
|
||||
|
||||
lateinit var sharedViewModel: DiscoverySharedViewModel
|
||||
|
||||
|
@ -78,6 +81,9 @@ class DiscoverySettingsFragment @Inject constructor(
|
|||
}
|
||||
}.exhaustive
|
||||
}
|
||||
if (discoveryArgs.expandIdentityPolicies) {
|
||||
viewModel.handle(DiscoverySettingsAction.ExpandPolicyUrls)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
|
|
@ -19,7 +19,6 @@ package im.vector.app.features.navigation
|
|||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Parcelable
|
||||
import android.view.View
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.core.util.Pair
|
||||
|
@ -32,7 +31,6 @@ import im.vector.app.features.roomdirectory.RoomDirectoryData
|
|||
import im.vector.app.features.roomdirectory.roompreview.RoomPreviewData
|
||||
import im.vector.app.features.settings.VectorSettingsActivity
|
||||
import im.vector.app.features.share.SharedData
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import org.matrix.android.sdk.api.session.permalinks.PermalinkData
|
||||
import org.matrix.android.sdk.api.session.room.model.roomdirectory.PublicRoom
|
||||
import org.matrix.android.sdk.api.session.terms.TermsService
|
||||
|
@ -143,14 +141,3 @@ interface Navigator {
|
|||
|
||||
fun openCallTransfer(context: Context, callId: String)
|
||||
}
|
||||
|
||||
sealed interface SettingsActivityPayload : Parcelable {
|
||||
|
||||
@Parcelize object Root : SettingsActivityPayload
|
||||
@Parcelize object AdvancedSettings : SettingsActivityPayload
|
||||
@Parcelize object SecurityPrivacy : SettingsActivityPayload
|
||||
@Parcelize object SecurityPrivacyManageSessions : SettingsActivityPayload
|
||||
@Parcelize object General : SettingsActivityPayload
|
||||
@Parcelize object Notifications : SettingsActivityPayload
|
||||
@Parcelize object DiscoverySettings : SettingsActivityPayload
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 2021 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.features.navigation
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
sealed interface SettingsActivityPayload : Parcelable {
|
||||
|
||||
@Parcelize object Root : SettingsActivityPayload
|
||||
@Parcelize object AdvancedSettings : SettingsActivityPayload
|
||||
@Parcelize object SecurityPrivacy : SettingsActivityPayload
|
||||
@Parcelize object SecurityPrivacyManageSessions : SettingsActivityPayload
|
||||
@Parcelize object General : SettingsActivityPayload
|
||||
@Parcelize object Notifications : SettingsActivityPayload
|
||||
|
||||
@Parcelize
|
||||
data class DiscoverySettings(val expandIdentityPolicies: Boolean = false) : SettingsActivityPayload
|
||||
}
|
|
@ -44,6 +44,7 @@ class VectorPreferences @Inject constructor(private val context: Context) {
|
|||
const val SETTINGS_IDENTITY_SERVER_PREFERENCE_KEY = "SETTINGS_IDENTITY_SERVER_PREFERENCE_KEY"
|
||||
const val SETTINGS_APP_TERM_CONDITIONS_PREFERENCE_KEY = "SETTINGS_APP_TERM_CONDITIONS_PREFERENCE_KEY"
|
||||
const val SETTINGS_PRIVACY_POLICY_PREFERENCE_KEY = "SETTINGS_PRIVACY_POLICY_PREFERENCE_KEY"
|
||||
const val SETTINGS_DISCOVERY_PREFERENCE_KEY = "SETTINGS_DISCOVERY_PREFERENCE_KEY"
|
||||
|
||||
const val SETTINGS_NOTIFICATION_ADVANCED_PREFERENCE_KEY = "SETTINGS_NOTIFICATION_ADVANCED_PREFERENCE_KEY"
|
||||
const val SETTINGS_THIRD_PARTY_NOTICES_PREFERENCE_KEY = "SETTINGS_THIRD_PARTY_NOTICES_PREFERENCE_KEY"
|
||||
|
|
|
@ -18,7 +18,9 @@ package im.vector.app.features.settings
|
|||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import android.util.Log
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.preference.Preference
|
||||
|
@ -71,7 +73,7 @@ class VectorSettingsActivity : VectorBaseActivity<ActivityVectorSettingsBinding>
|
|||
if (isFirstCreation()) {
|
||||
// display the fragment
|
||||
|
||||
when (readPayload<SettingsActivityPayload>(SettingsActivityPayload.Root)) {
|
||||
when (val payload = readPayload<SettingsActivityPayload>(SettingsActivityPayload.Root)) {
|
||||
SettingsActivityPayload.General ->
|
||||
replaceFragment(R.id.vector_settings_page, VectorSettingsGeneralFragment::class.java, null, FRAGMENT_TAG)
|
||||
SettingsActivityPayload.AdvancedSettings ->
|
||||
|
@ -87,8 +89,9 @@ class VectorSettingsActivity : VectorBaseActivity<ActivityVectorSettingsBinding>
|
|||
requestHighlightPreferenceKeyOnResume(VectorPreferences.SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY)
|
||||
replaceFragment(R.id.vector_settings_page, VectorSettingsNotificationPreferenceFragment::class.java, null, FRAGMENT_TAG)
|
||||
}
|
||||
SettingsActivityPayload.DiscoverySettings -> {
|
||||
replaceFragment(R.id.vector_settings_page, DiscoverySettingsFragment::class.java, null, FRAGMENT_TAG)
|
||||
is SettingsActivityPayload.DiscoverySettings -> {
|
||||
Log.e("!!!", "SettingsActivityPayload.DiscoverySettings : $payload")
|
||||
replaceFragment(R.id.vector_settings_page, DiscoverySettingsFragment::class.java, payload, FRAGMENT_TAG)
|
||||
}
|
||||
else ->
|
||||
replaceFragment(R.id.vector_settings_page, VectorSettingsRootFragment::class.java, null, FRAGMENT_TAG)
|
||||
|
@ -154,10 +157,10 @@ class VectorSettingsActivity : VectorBaseActivity<ActivityVectorSettingsBinding>
|
|||
}
|
||||
}
|
||||
|
||||
fun <T : Fragment> navigateTo(fragmentClass: Class<T>) {
|
||||
fun <T : Fragment> navigateTo(fragmentClass: Class<T>, arguments: Bundle? = null) {
|
||||
supportFragmentManager.beginTransaction()
|
||||
.setCustomAnimations(R.anim.right_in, R.anim.fade_out, R.anim.fade_in, R.anim.right_out)
|
||||
.replace(R.id.vector_settings_page, fragmentClass, null)
|
||||
.replace(R.id.vector_settings_page, fragmentClass, arguments)
|
||||
.addToBackStack(null)
|
||||
.commit()
|
||||
}
|
||||
|
@ -170,7 +173,7 @@ class VectorSettingsActivity : VectorBaseActivity<ActivityVectorSettingsBinding>
|
|||
EXTRA_DIRECT_ACCESS_SECURITY_PRIVACY_MANAGE_SESSIONS -> SettingsActivityPayload.SecurityPrivacyManageSessions
|
||||
EXTRA_DIRECT_ACCESS_GENERAL -> SettingsActivityPayload.General
|
||||
EXTRA_DIRECT_ACCESS_NOTIFICATIONS -> SettingsActivityPayload.Notifications
|
||||
EXTRA_DIRECT_ACCESS_DISCOVERY_SETTINGS -> SettingsActivityPayload.DiscoverySettings
|
||||
EXTRA_DIRECT_ACCESS_DISCOVERY_SETTINGS -> SettingsActivityPayload.DiscoverySettings()
|
||||
else -> {
|
||||
Timber.w("Unknown directAccess: $directAccess defaulting to Root")
|
||||
SettingsActivityPayload.Root
|
||||
|
|
|
@ -38,6 +38,7 @@ import im.vector.app.R
|
|||
import im.vector.app.core.dialogs.GalleryOrCameraDialogHelper
|
||||
import im.vector.app.core.extensions.hideKeyboard
|
||||
import im.vector.app.core.extensions.hidePassword
|
||||
import im.vector.app.core.extensions.toMvRxBundle
|
||||
import im.vector.app.core.intent.getFilenameFromUri
|
||||
import im.vector.app.core.platform.SimpleTextWatcher
|
||||
import im.vector.app.core.preference.UserAvatarPreference
|
||||
|
@ -50,6 +51,8 @@ import im.vector.app.core.utils.toast
|
|||
import im.vector.app.databinding.DialogChangePasswordBinding
|
||||
import im.vector.app.features.MainActivity
|
||||
import im.vector.app.features.MainActivityArgs
|
||||
import im.vector.app.features.discovery.DiscoverySettingsFragment
|
||||
import im.vector.app.features.navigation.SettingsActivityPayload
|
||||
import im.vector.app.features.workers.signout.SignOutUiWorker
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -173,6 +176,15 @@ class VectorSettingsGeneralFragment @Inject constructor(
|
|||
mPasswordPreference.isVisible = false
|
||||
}
|
||||
|
||||
val discoveryPreference = findPreference<VectorPreference>(VectorPreferences.SETTINGS_DISCOVERY_PREFERENCE_KEY)!!
|
||||
discoveryPreference.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||
(requireActivity() as VectorSettingsActivity).navigateTo(
|
||||
DiscoverySettingsFragment::class.java,
|
||||
SettingsActivityPayload.DiscoverySettings().toMvRxBundle()
|
||||
)
|
||||
true
|
||||
}
|
||||
|
||||
// Advanced settings
|
||||
|
||||
// user account
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
app:fragment="im.vector.app.features.settings.threepids.ThreePidsSettingsFragment" />
|
||||
|
||||
<im.vector.app.core.preference.VectorPreference
|
||||
android:key="SETTINGS_DISCOVERY_PREFERENCE_KEY"
|
||||
android:persistent="false"
|
||||
android:summary="@string/settings_discovery_manage"
|
||||
android:title="@string/settings_discovery_category"
|
||||
app:fragment="im.vector.app.features.discovery.DiscoverySettingsFragment" />
|
||||
android:title="@string/settings_discovery_category" />
|
||||
|
||||
</im.vector.app.core.preference.VectorPreferenceCategory>
|
||||
|
||||
|
|
Loading…
Reference in a new issue