mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 17:35:54 +03:00
Make other sessions view dynamic.
This commit is contained in:
parent
32d7516dcb
commit
740b69d48c
5 changed files with 65 additions and 6 deletions
|
@ -37,6 +37,7 @@ import im.vector.app.core.resources.DrawableProvider
|
|||
import im.vector.app.databinding.FragmentSettingsDevicesBinding
|
||||
import im.vector.app.features.crypto.recover.SetupMode
|
||||
import im.vector.app.features.crypto.verification.VerificationBottomSheet
|
||||
import im.vector.app.features.settings.devices.v2.filter.DeviceManagerFilterType
|
||||
import im.vector.app.features.settings.devices.v2.list.NUMBER_OF_OTHER_DEVICES_TO_RENDER
|
||||
import im.vector.app.features.settings.devices.v2.list.OtherSessionsView
|
||||
import im.vector.app.features.settings.devices.v2.list.SESSION_IS_MARKED_AS_INACTIVE_AFTER_DAYS
|
||||
|
@ -260,6 +261,11 @@ class VectorSettingsDevicesFragment :
|
|||
}
|
||||
|
||||
override fun onViewAllOtherSessionsClicked() {
|
||||
viewNavigator.navigateToOtherSessions(requireActivity())
|
||||
viewNavigator.navigateToOtherSessions(
|
||||
context = requireActivity(),
|
||||
titleResourceId = R.string.device_manager_sessions_other_title,
|
||||
defaultFilter = DeviceManagerFilterType.ALL_SESSIONS,
|
||||
includeCurrentSession = false
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package im.vector.app.features.settings.devices.v2
|
||||
|
||||
import android.content.Context
|
||||
import im.vector.app.features.settings.devices.v2.filter.DeviceManagerFilterType
|
||||
import im.vector.app.features.settings.devices.v2.othersessions.OtherSessionsActivity
|
||||
import im.vector.app.features.settings.devices.v2.overview.SessionOverviewActivity
|
||||
import javax.inject.Inject
|
||||
|
@ -27,7 +28,14 @@ class VectorSettingsDevicesViewNavigator @Inject constructor() {
|
|||
context.startActivity(SessionOverviewActivity.newIntent(context, deviceId))
|
||||
}
|
||||
|
||||
fun navigateToOtherSessions(context: Context) {
|
||||
context.startActivity(OtherSessionsActivity.newIntent(context))
|
||||
fun navigateToOtherSessions(
|
||||
context: Context,
|
||||
titleResourceId: Int,
|
||||
defaultFilter: DeviceManagerFilterType,
|
||||
includeCurrentSession: Boolean,
|
||||
) {
|
||||
context.startActivity(
|
||||
OtherSessionsActivity.newIntent(context, titleResourceId, defaultFilter, includeCurrentSession)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,9 +20,11 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import com.airbnb.mvrx.Mavericks
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.core.extensions.addFragment
|
||||
import im.vector.app.core.platform.SimpleFragmentActivity
|
||||
import im.vector.app.features.settings.devices.v2.filter.DeviceManagerFilterType
|
||||
|
||||
@AndroidEntryPoint
|
||||
class OtherSessionsActivity : SimpleFragmentActivity() {
|
||||
|
@ -35,14 +37,22 @@ class OtherSessionsActivity : SimpleFragmentActivity() {
|
|||
if (isFirstCreation()) {
|
||||
addFragment(
|
||||
container = views.container,
|
||||
fragmentClass = OtherSessionsFragment::class.java
|
||||
fragmentClass = OtherSessionsFragment::class.java,
|
||||
params = intent.getParcelableExtra(Mavericks.KEY_ARG)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newIntent(context: Context): Intent {
|
||||
return Intent(context, OtherSessionsActivity::class.java)
|
||||
fun newIntent(
|
||||
context: Context,
|
||||
titleResourceId: Int,
|
||||
defaultFilter: DeviceManagerFilterType,
|
||||
includeCurrentSession: Boolean,
|
||||
): Intent {
|
||||
return Intent(context, OtherSessionsActivity::class.java).apply {
|
||||
putExtra(Mavericks.KEY_ARG, OtherSessionsArgs(titleResourceId, defaultFilter, includeCurrentSession))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2022 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.settings.devices.v2.othersessions
|
||||
|
||||
import android.os.Parcelable
|
||||
import im.vector.app.features.settings.devices.v2.filter.DeviceManagerFilterType
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class OtherSessionsArgs(
|
||||
val titleResourceId: Int,
|
||||
val defaultFilter: DeviceManagerFilterType,
|
||||
val includeCurrentSession: Boolean,
|
||||
) : Parcelable
|
|
@ -22,6 +22,7 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import androidx.core.view.isVisible
|
||||
import com.airbnb.mvrx.Success
|
||||
import com.airbnb.mvrx.args
|
||||
import com.airbnb.mvrx.fragmentViewModel
|
||||
import com.airbnb.mvrx.withState
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
@ -46,6 +47,7 @@ class OtherSessionsFragment :
|
|||
OtherSessionsView.Callback {
|
||||
|
||||
private val viewModel: OtherSessionsViewModel by fragmentViewModel()
|
||||
private val args: OtherSessionsArgs by args()
|
||||
|
||||
@Inject lateinit var colorProvider: ColorProvider
|
||||
|
||||
|
@ -57,6 +59,7 @@ class OtherSessionsFragment :
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
views.otherSessionsToolbar.title = getString(args.titleResourceId)
|
||||
setupToolbar(views.otherSessionsToolbar).allowBack()
|
||||
observeViewEvents()
|
||||
initFilterView()
|
||||
|
@ -85,6 +88,10 @@ class OtherSessionsFragment :
|
|||
}
|
||||
|
||||
views.deviceListOtherSessions.callback = this
|
||||
|
||||
if (args.defaultFilter != DeviceManagerFilterType.ALL_SESSIONS) {
|
||||
viewModel.handle(OtherSessionsAction.FilterDevices(args.defaultFilter))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBottomSheetResult(resultCode: Int, data: Any?) {
|
||||
|
|
Loading…
Reference in a new issue