diff --git a/CHANGES.md b/CHANGES.md
index 2ade705d..ee6d2c8c 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -3,6 +3,7 @@ Changes in RiotX 0.2.1 (2019-XX-XX)
Features:
- Message Editing: View edit history
+ - Rooms filtering (#304)
Improvements:
- Handle click on redacted events: view source and create permalink
diff --git a/vector/src/main/AndroidManifest.xml b/vector/src/main/AndroidManifest.xml
index 7e5242ab..e0deced9 100644
--- a/vector/src/main/AndroidManifest.xml
+++ b/vector/src/main/AndroidManifest.xml
@@ -58,8 +58,10 @@
+
+
diff --git a/vector/src/main/java/im/vector/riotx/core/di/ScreenComponent.kt b/vector/src/main/java/im/vector/riotx/core/di/ScreenComponent.kt
index 611ee171..a42eec49 100644
--- a/vector/src/main/java/im/vector/riotx/core/di/ScreenComponent.kt
+++ b/vector/src/main/java/im/vector/riotx/core/di/ScreenComponent.kt
@@ -32,10 +32,14 @@ import im.vector.riotx.features.crypto.keysbackup.setup.KeysBackupSetupStep1Frag
import im.vector.riotx.features.crypto.keysbackup.setup.KeysBackupSetupStep2Fragment
import im.vector.riotx.features.crypto.keysbackup.setup.KeysBackupSetupStep3Fragment
import im.vector.riotx.features.crypto.verification.SASVerificationIncomingFragment
-import im.vector.riotx.features.home.*
+import im.vector.riotx.features.home.HomeActivity
+import im.vector.riotx.features.home.HomeDetailFragment
+import im.vector.riotx.features.home.HomeDrawerFragment
+import im.vector.riotx.features.home.HomeModule
import im.vector.riotx.features.home.group.GroupListFragment
import im.vector.riotx.features.home.room.detail.RoomDetailFragment
import im.vector.riotx.features.home.room.detail.timeline.action.*
+import im.vector.riotx.features.home.room.filtered.FilteredRoomsActivity
import im.vector.riotx.features.home.room.list.RoomListFragment
import im.vector.riotx.features.invite.VectorInviteView
import im.vector.riotx.features.login.LoginActivity
@@ -47,6 +51,7 @@ import im.vector.riotx.features.rageshake.RageShake
import im.vector.riotx.features.reactions.EmojiReactionPickerActivity
import im.vector.riotx.features.roomdirectory.PublicRoomsFragment
import im.vector.riotx.features.roomdirectory.RoomDirectoryActivity
+import im.vector.riotx.features.roomdirectory.createroom.CreateRoomActivity
import im.vector.riotx.features.roomdirectory.createroom.CreateRoomFragment
import im.vector.riotx.features.roomdirectory.picker.RoomDirectoryPickerFragment
import im.vector.riotx.features.roomdirectory.roompreview.RoomPreviewNoPreviewFragment
@@ -130,6 +135,10 @@ interface ScreenComponent {
fun inject(imageMediaViewerActivity: ImageMediaViewerActivity)
+ fun inject(filteredRoomsActivity: FilteredRoomsActivity)
+
+ fun inject(createRoomActivity: CreateRoomActivity)
+
fun inject(vectorInviteView: VectorInviteView)
fun inject(videoMediaViewerActivity: VideoMediaViewerActivity)
diff --git a/vector/src/main/java/im/vector/riotx/core/extensions/Activity.kt b/vector/src/main/java/im/vector/riotx/core/extensions/Activity.kt
index 75817779..b4afb569 100644
--- a/vector/src/main/java/im/vector/riotx/core/extensions/Activity.kt
+++ b/vector/src/main/java/im/vector/riotx/core/extensions/Activity.kt
@@ -23,8 +23,8 @@ fun AppCompatActivity.addFragment(fragment: Fragment, frameId: Int) {
supportFragmentManager.inTransaction { add(frameId, fragment) }
}
-fun AppCompatActivity.replaceFragment(fragment: Fragment, frameId: Int) {
- supportFragmentManager.inTransaction { replace(frameId, fragment) }
+fun AppCompatActivity.replaceFragment(fragment: Fragment, frameId: Int, tag: String? = null) {
+ supportFragmentManager.inTransaction { replace(frameId, fragment, tag) }
}
fun AppCompatActivity.addFragmentToBackstack(fragment: Fragment, frameId: Int, tag: String? = null) {
diff --git a/vector/src/main/java/im/vector/riotx/features/home/HomeActivity.kt b/vector/src/main/java/im/vector/riotx/features/home/HomeActivity.kt
index 67d1af4e..4ec2c0ad 100644
--- a/vector/src/main/java/im/vector/riotx/features/home/HomeActivity.kt
+++ b/vector/src/main/java/im/vector/riotx/features/home/HomeActivity.kt
@@ -41,6 +41,7 @@ import im.vector.riotx.core.platform.ToolbarConfigurable
import im.vector.riotx.core.platform.VectorBaseActivity
import im.vector.riotx.core.pushers.PushersManager
import im.vector.riotx.features.disclaimer.showDisclaimerDialog
+import im.vector.riotx.features.navigation.Navigator
import im.vector.riotx.features.notifications.NotificationDrawerManager
import im.vector.riotx.features.rageshake.VectorUncaughtExceptionHandler
import im.vector.riotx.features.workers.signout.SignOutViewModel
@@ -64,6 +65,7 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable {
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
@Inject lateinit var homeActivityViewModelFactory: HomeActivityViewModel.Factory
@Inject lateinit var homeNavigator: HomeNavigator
+ @Inject lateinit var navigator: Navigator
@Inject lateinit var vectorUncaughtExceptionHandler: VectorUncaughtExceptionHandler
@Inject lateinit var pushManager: PushersManager
@Inject lateinit var notificationDrawerManager: NotificationDrawerManager
@@ -192,6 +194,10 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable {
bugReporter.openBugReportScreen(this, false)
return true
}
+ R.id.menu_home_filter -> {
+ navigator.openRoomsFiltering(this)
+ return true
+ }
}
return true
diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailActivity.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailActivity.kt
index 9108f5d0..6ad9a61f 100644
--- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailActivity.kt
+++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailActivity.kt
@@ -35,7 +35,7 @@ class RoomDetailActivity : VectorBaseActivity(), ToolbarConfigurable {
super.onCreate(savedInstanceState)
if (isFirstCreation()) {
val roomDetailArgs: RoomDetailArgs = intent?.extras?.getParcelable(EXTRA_ROOM_DETAIL_ARGS)
- ?: return
+ ?: return
val roomDetailFragment = RoomDetailFragment.newInstance(roomDetailArgs)
replaceFragment(roomDetailFragment, R.id.roomDetailContainer)
}
diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/TimelineEventController.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/TimelineEventController.kt
index b6cf00a3..0b78f815 100644
--- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/TimelineEventController.kt
+++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/TimelineEventController.kt
@@ -18,7 +18,6 @@ package im.vector.riotx.features.home.room.detail.timeline
import android.os.Handler
import android.os.Looper
-import android.util.LongSparseArray
import android.view.View
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListUpdateCallback
@@ -84,7 +83,7 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Tim
}
private val collapsedEventIds = linkedSetOf()
- private val mergeItemCollapseStates = HashMap()
+ private val mergeItemCollapseStates = HashMap()
private val modelCache = arrayListOf()
private var currentSnapshot: List = emptyList()
@@ -178,16 +177,19 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Tim
}
override fun buildModels() {
- LoadingItem_()
+ val loaderAdded = LoadingItem_()
.id("forward_loading_item")
.addWhen(Timeline.Direction.FORWARDS)
val timelineModels = getModels()
add(timelineModels)
- LoadingItem_()
- .id("backward_loading_item")
- .addWhen(Timeline.Direction.BACKWARDS)
+ // Avoid displaying two loaders if there is no elements between them
+ if (!loaderAdded || timelineModels.isNotEmpty()) {
+ LoadingItem_()
+ .id("backward_loading_item")
+ .addWhen(Timeline.Direction.BACKWARDS)
+ }
}
// Timeline.LISTENER ***************************************************************************
@@ -310,9 +312,13 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Tim
}
}
- private fun LoadingItem_.addWhen(direction: Timeline.Direction) {
+ /**
+ * Return true if added
+ */
+ private fun LoadingItem_.addWhen(direction: Timeline.Direction): Boolean {
val shouldAdd = timeline?.hasMoreToLoad(direction) ?: false
addIf(shouldAdd, this@TimelineEventController)
+ return shouldAdd
}
fun searchPositionOfEvent(eventId: String): Int? {
diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/filtered/FilteredRoomFooterItem.kt b/vector/src/main/java/im/vector/riotx/features/home/room/filtered/FilteredRoomFooterItem.kt
new file mode 100644
index 00000000..0e916a0e
--- /dev/null
+++ b/vector/src/main/java/im/vector/riotx/features/home/room/filtered/FilteredRoomFooterItem.kt
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2019 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.riotx.features.home.room.filtered
+
+import android.widget.Button
+import com.airbnb.epoxy.EpoxyAttribute
+import com.airbnb.epoxy.EpoxyModelClass
+import im.vector.riotx.R
+import im.vector.riotx.core.epoxy.VectorEpoxyHolder
+import im.vector.riotx.core.epoxy.VectorEpoxyModel
+import im.vector.riotx.features.home.room.list.widget.FabMenuView
+
+@EpoxyModelClass(layout = R.layout.item_room_filter_footer)
+abstract class FilteredRoomFooterItem : VectorEpoxyModel() {
+
+ @EpoxyAttribute
+ var listener: FilteredRoomFooterItemListener? = null
+
+ override fun bind(holder: Holder) {
+ holder.createRoomButton.setOnClickListener { listener?.createRoom() }
+ holder.createDirectChat.setOnClickListener { listener?.createDirectChat() }
+ holder.openRoomDirectory.setOnClickListener { listener?.openRoomDirectory() }
+ }
+
+ class Holder : VectorEpoxyHolder() {
+ val createRoomButton by bind