Commit 8dc117d8 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Shows create new channel view

parent a99b2e79
...@@ -9,6 +9,7 @@ import chat.rocket.android.db.model.ChatRoomEntity ...@@ -9,6 +9,7 @@ import chat.rocket.android.db.model.ChatRoomEntity
import chat.rocket.android.helper.UserHelper import chat.rocket.android.helper.UserHelper
import chat.rocket.android.infrastructure.LocalRepository import chat.rocket.android.infrastructure.LocalRepository
import chat.rocket.android.main.presentation.MainNavigator import chat.rocket.android.main.presentation.MainNavigator
import chat.rocket.android.server.domain.GetAccountsInteractor
import chat.rocket.android.server.domain.SettingsRepository import chat.rocket.android.server.domain.SettingsRepository
import chat.rocket.android.server.domain.useRealName import chat.rocket.android.server.domain.useRealName
import chat.rocket.android.server.domain.useSpecialCharsOnRoom import chat.rocket.android.server.domain.useSpecialCharsOnRoom
...@@ -16,10 +17,12 @@ import chat.rocket.android.server.infraestructure.ConnectionManager ...@@ -16,10 +17,12 @@ import chat.rocket.android.server.infraestructure.ConnectionManager
import chat.rocket.android.util.extension.launchUI import chat.rocket.android.util.extension.launchUI
import chat.rocket.android.util.retryDB import chat.rocket.android.util.retryDB
import chat.rocket.android.util.retryIO import chat.rocket.android.util.retryIO
import chat.rocket.common.RocketChatAuthException
import chat.rocket.common.RocketChatException import chat.rocket.common.RocketChatException
import chat.rocket.common.model.RoomType import chat.rocket.common.model.RoomType
import chat.rocket.common.model.User import chat.rocket.common.model.User
import chat.rocket.common.model.roomTypeOf import chat.rocket.common.model.roomTypeOf
import chat.rocket.common.util.ifNull
import chat.rocket.core.internal.realtime.createDirectMessage import chat.rocket.core.internal.realtime.createDirectMessage
import chat.rocket.core.internal.rest.me import chat.rocket.core.internal.rest.me
import chat.rocket.core.internal.rest.show import chat.rocket.core.internal.rest.show
...@@ -35,6 +38,7 @@ class ChatRoomsPresenter @Inject constructor( ...@@ -35,6 +38,7 @@ class ChatRoomsPresenter @Inject constructor(
private val strategy: CancelStrategy, private val strategy: CancelStrategy,
private val navigator: MainNavigator, private val navigator: MainNavigator,
@Named("currentServer") private val currentServer: String, @Named("currentServer") private val currentServer: String,
private val getAccountsInteractor: GetAccountsInteractor,
private val dbManager: DatabaseManager, private val dbManager: DatabaseManager,
manager: ConnectionManager, manager: ConnectionManager,
private val localRepository: LocalRepository, private val localRepository: LocalRepository,
...@@ -44,6 +48,33 @@ class ChatRoomsPresenter @Inject constructor( ...@@ -44,6 +48,33 @@ class ChatRoomsPresenter @Inject constructor(
private val client = manager.client private val client = manager.client
private val settings = settingsRepository.get(currentServer) private val settings = settingsRepository.get(currentServer)
fun toCreateChannel() = navigator.toCreateChannel()
fun getCurrentServerName() {
view.setupToolbar(currentServer)
}
fun getAllServers() {
launchUI(strategy) {
try {
view.setupServerListView(getAccountsInteractor.get())
} catch (exception: Exception) {
Timber.e(exception, "Error while getting all servers")
when (exception) {
// is RocketChatAuthException -> logout()
else -> {
exception.message?.let {
view.showMessage(it)
}.ifNull {
view.showGenericErrorMessage()
}
}
}
}
}
}
fun loadChatRoom(roomId: String) { fun loadChatRoom(roomId: String) {
launchUI(strategy) { launchUI(strategy) {
view.showLoadingRoom("") view.showLoadingRoom("")
...@@ -97,7 +128,8 @@ class ChatRoomsPresenter @Inject constructor( ...@@ -97,7 +128,8 @@ class ChatRoomsPresenter @Inject constructor(
suspend fun loadChatRoom(chatRoom: ChatRoomEntity, local: Boolean = false) { suspend fun loadChatRoom(chatRoom: ChatRoomEntity, local: Boolean = false) {
with(chatRoom) { with(chatRoom) {
val isDirectMessage = roomTypeOf(type) is RoomType.DirectMessage val isDirectMessage = roomTypeOf(type) is RoomType.DirectMessage
val roomName = if (settings.useSpecialCharsOnRoom() || (isDirectMessage && settings.useRealName())) { val roomName =
if (settings.useSpecialCharsOnRoom() || (isDirectMessage && settings.useRealName())) {
fullname ?: name fullname ?: name
} else { } else {
name name
......
...@@ -2,8 +2,24 @@ package chat.rocket.android.chatrooms.presentation ...@@ -2,8 +2,24 @@ package chat.rocket.android.chatrooms.presentation
import chat.rocket.android.core.behaviours.LoadingView import chat.rocket.android.core.behaviours.LoadingView
import chat.rocket.android.core.behaviours.MessageView import chat.rocket.android.core.behaviours.MessageView
import chat.rocket.android.server.domain.model.Account
interface ChatRoomsView : LoadingView, MessageView { interface ChatRoomsView : LoadingView, MessageView {
/**
* Setups the toolbar with the current logged in server name.
*
* @param serverName The current logged in server name to show on Toolbar.
*/
fun setupToolbar(serverName: String)
/**
* Setups the server list view with all server list.
*
* @param serverList The server list to show on server list.
*/
fun setupServerListView(serverList: List<Account>)
fun showLoadingRoom(name: CharSequence) fun showLoadingRoom(name: CharSequence)
fun hideLoadingRoom() fun hideLoadingRoom()
......
...@@ -30,6 +30,7 @@ import chat.rocket.android.chatrooms.viewmodel.Query ...@@ -30,6 +30,7 @@ import chat.rocket.android.chatrooms.viewmodel.Query
import chat.rocket.android.helper.ChatRoomsSortOrder import chat.rocket.android.helper.ChatRoomsSortOrder
import chat.rocket.android.helper.Constants import chat.rocket.android.helper.Constants
import chat.rocket.android.helper.SharedPreferenceHelper import chat.rocket.android.helper.SharedPreferenceHelper
import chat.rocket.android.server.domain.model.Account
import chat.rocket.android.util.extension.onQueryTextListener import chat.rocket.android.util.extension.onQueryTextListener
import chat.rocket.android.util.extensions.ifNotNullNotEmpty import chat.rocket.android.util.extensions.ifNotNullNotEmpty
import chat.rocket.android.util.extensions.inflate import chat.rocket.android.util.extensions.inflate
...@@ -38,6 +39,7 @@ import chat.rocket.android.util.extensions.ui ...@@ -38,6 +39,7 @@ import chat.rocket.android.util.extensions.ui
import chat.rocket.android.widget.DividerItemDecoration import chat.rocket.android.widget.DividerItemDecoration
import chat.rocket.core.internal.realtime.socket.model.State import chat.rocket.core.internal.realtime.socket.model.State
import dagger.android.support.AndroidSupportInjection import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.app_bar_chat_rooms.*
import kotlinx.android.synthetic.main.fragment_chat_rooms.* import kotlinx.android.synthetic.main.fragment_chat_rooms.*
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
...@@ -93,15 +95,20 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView { ...@@ -93,15 +95,20 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
presenter.getCurrentServerName()
setupListeners()
viewModel = ViewModelProviders.of(this, factory).get(ChatRoomsViewModel::class.java) viewModel = ViewModelProviders.of(this, factory).get(ChatRoomsViewModel::class.java)
subscribeUi() subscribeUi()
setupToolbar()
setupListeners()
analyticsManager.logScreenView(ScreenViewEvent.ChatRooms) analyticsManager.logScreenView(ScreenViewEvent.ChatRooms)
} }
override fun setupServerListView(serverList: List<Account>) {
// TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
private fun subscribeUi() { private fun subscribeUi() {
ui { ui {
val adapter = RoomsAdapter { room -> val adapter = RoomsAdapter { room ->
...@@ -184,6 +191,13 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView { ...@@ -184,6 +191,13 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
}) })
} }
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.action_new_channel -> presenter.toCreateChannel()
}
return super.onOptionsItemSelected(item)
}
private fun updateSort() { private fun updateSort() {
val sortType = SharedPreferenceHelper.getInt( val sortType = SharedPreferenceHelper.getInt(
Constants.CHATROOM_SORT_TYPE_KEY, Constants.CHATROOM_SORT_TYPE_KEY,
...@@ -269,11 +283,16 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView { ...@@ -269,11 +283,16 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
// } // }
} }
private fun setupToolbar() { override fun setupToolbar(serverName: String) {
(activity as AppCompatActivity?)?.supportActionBar?.title = getString(R.string.title_chats) (activity as AppCompatActivity).setSupportActionBar(toolbar)
text_server_name.text = serverName
} }
private fun setupListeners() { private fun setupListeners() {
text_server_name.setOnClickListener {
// TO DO
}
text_sort_by.setOnClickListener { text_sort_by.setOnClickListener {
SortByBottomSheetFragment() SortByBottomSheetFragment()
.show(activity?.supportFragmentManager, TAG) .show(activity?.supportFragmentManager, TAG)
......
...@@ -35,7 +35,6 @@ class CreateChannelPresenter @Inject constructor( ...@@ -35,7 +35,6 @@ class CreateChannelPresenter @Inject constructor(
view.disableUserInput() view.disableUserInput()
try { try {
client.createChannel(roomType, channelName, usersList, readOnly) client.createChannel(roomType, channelName, usersList, readOnly)
view.prepareToShowChatList()
view.showChannelCreatedSuccessfullyMessage() view.showChannelCreatedSuccessfullyMessage()
toChatList() toChatList()
} catch (exception: RocketChatException) { } catch (exception: RocketChatException) {
......
...@@ -28,12 +28,6 @@ interface CreateChannelView : LoadingView, MessageView { ...@@ -28,12 +28,6 @@ interface CreateChannelView : LoadingView, MessageView {
*/ */
fun hideSuggestionViewInProgress() fun hideSuggestionViewInProgress()
/**
* Shows the navigation drawer with the chat item checked before showing the chat list.
* This function is invoked after successfully created the channel.
*/
fun prepareToShowChatList()
/** /**
* Shows a message that a channel was successfully created. * Shows a message that a channel was successfully created.
*/ */
......
...@@ -9,7 +9,6 @@ import android.view.ViewGroup ...@@ -9,7 +9,6 @@ import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.ActionMode import androidx.appcompat.view.ActionMode
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.core.view.postDelayed
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
...@@ -32,6 +31,7 @@ import com.google.android.material.chip.Chip ...@@ -32,6 +31,7 @@ import com.google.android.material.chip.Chip
import dagger.android.support.AndroidSupportInjection import dagger.android.support.AndroidSupportInjection
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.CompositeDisposable
import kotlinx.android.synthetic.main.app_bar.*
import kotlinx.android.synthetic.main.fragment_create_channel.* import kotlinx.android.synthetic.main.fragment_create_channel.*
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import javax.inject.Inject import javax.inject.Inject
...@@ -165,20 +165,6 @@ class CreateChannelFragment : Fragment(), CreateChannelView, ActionMode.Callback ...@@ -165,20 +165,6 @@ class CreateChannelFragment : Fragment(), CreateChannelView, ActionMode.Callback
view_member_suggestion_loading.isVisible = false view_member_suggestion_loading.isVisible = false
} }
override fun prepareToShowChatList() {
with(activity as MainActivity) {
// setCheckedNavDrawerItem(R.id.menu_action_chats)
// openDrawer()
// getDrawerLayout().postDelayed(1000) {
// closeDrawer()
// createChannelPresenter.toChatList()
// }
}
}
override fun showChannelCreatedSuccessfullyMessage() { override fun showChannelCreatedSuccessfullyMessage() {
showMessage(getString(R.string.msg_channel_created_successfully)) showMessage(getString(R.string.msg_channel_created_successfully))
} }
...@@ -194,8 +180,14 @@ class CreateChannelFragment : Fragment(), CreateChannelView, ActionMode.Callback ...@@ -194,8 +180,14 @@ class CreateChannelFragment : Fragment(), CreateChannelView, ActionMode.Callback
} }
private fun setupToolBar() { private fun setupToolBar() {
(activity as AppCompatActivity?)?.supportActionBar?.title = with((activity as AppCompatActivity)) {
getString(R.string.title_create_channel) with(toolbar) {
setSupportActionBar(toolbar)
title = getString(R.string.title_create_channel)
setNavigationIcon(R.drawable.ic_arrow_back_white_24dp)
setNavigationOnClickListener { activity?.onBackPressed() }
}
}
} }
private fun setupViewListeners() { private fun setupViewListeners() {
......
...@@ -4,7 +4,6 @@ import androidx.lifecycle.LifecycleOwner ...@@ -4,7 +4,6 @@ import androidx.lifecycle.LifecycleOwner
import chat.rocket.android.core.lifecycle.CancelStrategy import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.dagger.scope.PerActivity import chat.rocket.android.dagger.scope.PerActivity
import chat.rocket.android.main.presentation.MainNavigator import chat.rocket.android.main.presentation.MainNavigator
import chat.rocket.android.main.presentation.MainView
import chat.rocket.android.main.ui.MainActivity import chat.rocket.android.main.ui.MainActivity
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
...@@ -13,16 +12,13 @@ import kotlinx.coroutines.Job ...@@ -13,16 +12,13 @@ import kotlinx.coroutines.Job
@Module @Module
class MainModule { class MainModule {
@Provides
@PerActivity
fun provideJob() = Job()
@Provides @Provides
@PerActivity @PerActivity
fun provideMainNavigator(activity: MainActivity) = MainNavigator(activity) fun provideMainNavigator(activity: MainActivity) = MainNavigator(activity)
@Provides @Provides
fun provideMainView(activity: MainActivity): MainView = activity @PerActivity
fun provideJob() = Job()
@Provides @Provides
fun provideLifecycleOwner(activity: MainActivity): LifecycleOwner = activity fun provideLifecycleOwner(activity: MainActivity): LifecycleOwner = activity
......
...@@ -14,6 +14,7 @@ import chat.rocket.android.server.ui.changeServerIntent ...@@ -14,6 +14,7 @@ import chat.rocket.android.server.ui.changeServerIntent
import chat.rocket.android.settings.ui.SettingsFragment import chat.rocket.android.settings.ui.SettingsFragment
import chat.rocket.android.settings.ui.TAG_SETTINGS_FRAGMENT import chat.rocket.android.settings.ui.TAG_SETTINGS_FRAGMENT
import chat.rocket.android.util.extensions.addFragment import chat.rocket.android.util.extensions.addFragment
import chat.rocket.android.util.extensions.addFragmentBackStack
import chat.rocket.android.webview.adminpanel.ui.AdminPanelWebViewFragment import chat.rocket.android.webview.adminpanel.ui.AdminPanelWebViewFragment
class MainNavigator(internal val activity: MainActivity) { class MainNavigator(internal val activity: MainActivity) {
...@@ -24,8 +25,14 @@ class MainNavigator(internal val activity: MainActivity) { ...@@ -24,8 +25,14 @@ class MainNavigator(internal val activity: MainActivity) {
} }
} }
fun toSettings() {
activity.addFragmentBackStack(TAG_SETTINGS_FRAGMENT, R.id.fragment_container) {
SettingsFragment.newInstance()
}
}
fun toCreateChannel() { fun toCreateChannel() {
activity.addFragment(TAG_CREATE_CHANNEL_FRAGMENT, R.id.fragment_container) { activity.addFragmentBackStack(TAG_CREATE_CHANNEL_FRAGMENT, R.id.fragment_container) {
CreateChannelFragment.newInstance() CreateChannelFragment.newInstance()
} }
} }
...@@ -36,12 +43,6 @@ class MainNavigator(internal val activity: MainActivity) { ...@@ -36,12 +43,6 @@ class MainNavigator(internal val activity: MainActivity) {
} }
} }
fun toSettings() {
activity.addFragment(TAG_SETTINGS_FRAGMENT, R.id.fragment_container) {
SettingsFragment.newInstance()
}
}
fun toAdminPanel(webPageUrl: String, userToken: String) { fun toAdminPanel(webPageUrl: String, userToken: String) {
activity.addFragment("AdminPanelWebViewFragment", R.id.fragment_container) { activity.addFragment("AdminPanelWebViewFragment", R.id.fragment_container) {
AdminPanelWebViewFragment.newInstance(webPageUrl, userToken) AdminPanelWebViewFragment.newInstance(webPageUrl, userToken)
......
package chat.rocket.android.main.presentation package chat.rocket.android.main.presentation
import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.db.DatabaseManagerFactory
import chat.rocket.android.infrastructure.LocalRepository
import chat.rocket.android.push.GroupedPush import chat.rocket.android.push.GroupedPush
import chat.rocket.android.server.domain.GetAccountsInteractor
import chat.rocket.android.server.domain.GetCurrentServerInteractor
import chat.rocket.android.server.domain.RefreshPermissionsInteractor import chat.rocket.android.server.domain.RefreshPermissionsInteractor
import chat.rocket.android.server.domain.RefreshSettingsInteractor import chat.rocket.android.server.domain.RefreshSettingsInteractor
import chat.rocket.android.server.domain.RemoveAccountInteractor
import chat.rocket.android.server.domain.TokenRepository
import chat.rocket.android.server.infraestructure.ConnectionManagerFactory import chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import chat.rocket.android.server.infraestructure.RocketChatClientFactory
import chat.rocket.android.server.presentation.CheckServerPresenter
import chat.rocket.android.util.extension.launchUI
import chat.rocket.common.RocketChatAuthException
import chat.rocket.common.util.ifNull
import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Named
class MainPresenter @Inject constructor( class MainPresenter @Inject constructor(
private val mainView: MainView, @Named("currentServer") private val currentServerUrl: String,
private val cancelStrategy: CancelStrategy,
private val mainNavigator: MainNavigator, private val mainNavigator: MainNavigator,
val getCurrentServerInteractor: GetCurrentServerInteractor,
private val groupedPush: GroupedPush,
private val getAccountsInteractor: GetAccountsInteractor,
rocketChatClientFactory: RocketChatClientFactory,
localRepository: LocalRepository,
removeAccountInteractor: RemoveAccountInteractor,
tokenRepository: TokenRepository,
private val connectionManagerFactory: ConnectionManagerFactory,
databaseManagerFactory: DatabaseManagerFactory,
private val refreshSettingsInteractor: RefreshSettingsInteractor, private val refreshSettingsInteractor: RefreshSettingsInteractor,
private val refreshPermissionsInteractor: RefreshPermissionsInteractor private val refreshPermissionsInteractor: RefreshPermissionsInteractor,
private val connectionManagerFactory: ConnectionManagerFactory,
private val groupedPush: GroupedPush
/*
private val navHeaderMapper: NavHeaderUiModelMapper,
private val saveAccountInteractor: SaveAccountInteractor,
private val getAccountsInteractor: GetAccountsInteractor,
private val groupedPush: GroupedPush,
serverInteractor: GetCurrentServerInteractor,
getSettingsInteractor: GetSettingsInteractor,
*/
) : CheckServerPresenter(
strategy = cancelStrategy,
factory = rocketChatClientFactory,
serverInteractor = getCurrentServerInteractor,
localRepository = localRepository,
removeAccountInteractor = removeAccountInteractor,
tokenRepository = tokenRepository,
managerFactory = connectionManagerFactory,
dbManagerFactory = databaseManagerFactory,
tokenView = mainView,
navigator = mainNavigator
) { ) {
fun clearNotificationsForChatRoom(chatRoomId: String?) {
if (chatRoomId == null) return
getCurrentServerInteractor.get()?.let { currentServer ->
groupedPush.hostToPushMessageList[currentServer].let { list ->
list?.removeAll { it.info.roomId == chatRoomId }
}
}
}
fun connect() { fun connect() {
getCurrentServerInteractor.get()?.let { currentServer -> refreshSettingsInteractor.refreshAsync(currentServerUrl)
refreshSettingsInteractor.refreshAsync(currentServer) refreshPermissionsInteractor.refreshAsync(currentServerUrl)
refreshPermissionsInteractor.refreshAsync(currentServer) connectionManagerFactory.create(currentServerUrl).connect()
connectionManagerFactory.create(currentServer).connect()
}
} }
fun getCurrentServerName() { fun clearNotificationsForChatRoom(chatRoomId: String?) {
getCurrentServerInteractor.get()?.let { currentServer -> if (chatRoomId == null) return
mainView.setupToolbar(currentServer)
}
}
fun getAllServers() { groupedPush.hostToPushMessageList[currentServerUrl].let { list ->
launchUI(cancelStrategy) { list?.removeAll { it.info.roomId == chatRoomId }
try {
mainView.setupServerListView(getAccountsInteractor.get())
} catch (exception: Exception) {
Timber.e(exception, "Error while getting all servers")
when (exception) {
is RocketChatAuthException -> logout()
else -> {
exception.message?.let {
mainView.showMessage(it)
}.ifNull {
mainView.showGenericErrorMessage()
}
}
}
}
} }
} }
fun showChatList(chatRoomId: String? = null) = mainNavigator.toChatList(chatRoomId) fun showChatList(chatRoomId: String? = null) = mainNavigator.toChatList(chatRoomId)
fun showSettings() = mainNavigator.toSettings()
fun logout() {
getCurrentServerInteractor.get()?.let { currentServer ->
setupConnectionInfo(currentServer)
}
}
} }
\ No newline at end of file
package chat.rocket.android.main.presentation
import chat.rocket.android.core.behaviours.MessageView
import chat.rocket.android.server.domain.model.Account
import chat.rocket.android.server.presentation.TokenView
interface MainView : TokenView, MessageView {
/**
* Setups the toolbar with the current logged in server name.
*
* @param serverName The current logged in server name to show on Toolbar.
*/
fun setupToolbar(serverName: String)
/**
* Setups the server list view with all server list.
*
* @param serverList The server list to show on server list.
*/
fun setupServerListView(serverList: List<Account>)
}
\ No newline at end of file
...@@ -8,21 +8,16 @@ import androidx.appcompat.app.AppCompatActivity ...@@ -8,21 +8,16 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.main.presentation.MainPresenter import chat.rocket.android.main.presentation.MainPresenter
import chat.rocket.android.main.presentation.MainView
import chat.rocket.android.push.refreshPushToken import chat.rocket.android.push.refreshPushToken
import chat.rocket.android.server.domain.model.Account
import chat.rocket.android.server.ui.INTENT_CHAT_ROOM_ID import chat.rocket.android.server.ui.INTENT_CHAT_ROOM_ID
import chat.rocket.android.util.extensions.showToast
import chat.rocket.android.util.invalidateFirebaseToken
import dagger.android.AndroidInjection import dagger.android.AndroidInjection
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.DispatchingAndroidInjector import dagger.android.DispatchingAndroidInjector
import dagger.android.HasActivityInjector import dagger.android.HasActivityInjector
import dagger.android.support.HasSupportFragmentInjector import dagger.android.support.HasSupportFragmentInjector
import kotlinx.android.synthetic.main.app_bar_main.*
import javax.inject.Inject import javax.inject.Inject
class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, class MainActivity : AppCompatActivity(), HasActivityInjector,
HasSupportFragmentInjector { HasSupportFragmentInjector {
@Inject @Inject
lateinit var activityDispatchingAndroidInjector: DispatchingAndroidInjector<Activity> lateinit var activityDispatchingAndroidInjector: DispatchingAndroidInjector<Activity>
...@@ -30,7 +25,6 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, ...@@ -30,7 +25,6 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector,
lateinit var fagmentDispatchingAndroidInjector: DispatchingAndroidInjector<Fragment> lateinit var fagmentDispatchingAndroidInjector: DispatchingAndroidInjector<Fragment>
@Inject @Inject
lateinit var presenter: MainPresenter lateinit var presenter: MainPresenter
private var chatRoomId: String? = null
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
AndroidInjection.inject(this) AndroidInjection.inject(this)
...@@ -38,17 +32,14 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, ...@@ -38,17 +32,14 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector,
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)
refreshPushToken() refreshPushToken()
chatRoomId = intent.getStringExtra(INTENT_CHAT_ROOM_ID)
with(presenter) { with(presenter) {
clearNotificationsForChatRoom(chatRoomId)
connect() connect()
getCurrentServerName() intent.getStringExtra(INTENT_CHAT_ROOM_ID).let {
getAllServers() clearNotificationsForChatRoom(it)
showChatList(chatRoomId) showChatList(it)
}
} }
setupListeners()
} }
override fun onResume() { override fun onResume() {
...@@ -62,30 +53,6 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, ...@@ -62,30 +53,6 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector,
override fun supportFragmentInjector(): AndroidInjector<Fragment> = override fun supportFragmentInjector(): AndroidInjector<Fragment> =
fagmentDispatchingAndroidInjector fagmentDispatchingAndroidInjector
override fun setupToolbar(serverName: String) {
setSupportActionBar(toolbar)
text_server_name.text = serverName
}
override fun setupServerListView(serverList: List<Account>) {
// TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun invalidateToken(token: String) = invalidateFirebaseToken(token)
override fun showMessage(resId: Int) = showToast(resId)
override fun showMessage(message: String) = showToast(message)
override fun showGenericErrorMessage() = showMessage(getString(R.string.msg_generic_error))
private fun clearAppNotifications() = private fun clearAppNotifications() =
(getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).cancelAll() (getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).cancelAll()
private fun setupListeners() {
text_server_name.setOnClickListener {
// SortByBottomSheetFragment().show(supportFragmentManager, TAG)
}
}
} }
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:theme="@style/AppTheme"
tools:context=".main.ui.MainActivity">
<include
android:id="@+id/layout_app_bar_main"
layout="@layout/app_bar_main" />
<FrameLayout
android:id="@+id/fragment_container" android:id="@+id/fragment_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent"
</LinearLayout> tools:context=".main.ui.MainActivity" />
\ No newline at end of file \ No newline at end of file
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/colorPrimary"> android:background="@color/colorPrimary"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
......
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".chatrooms.ui.ChatRoomsFragment"> tools:context=".chatrooms.ui.ChatRoomsFragment">
<include
android:id="@+id/layout_app_bar_chat_room"
layout="@layout/app_bar_chat_rooms"
app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/text_sort_by" android:id="@+id/text_sort_by"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -22,7 +27,7 @@ ...@@ -22,7 +27,7 @@
android:textStyle="normal" android:textStyle="normal"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toBottomOf="@+id/layout_app_bar_chat_room" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view" android:id="@+id/recycler_view"
...@@ -41,6 +46,7 @@ ...@@ -41,6 +46,7 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toBottomOf="@+id/text_sort_by"
tools:visibility="visible" /> tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
...@@ -4,10 +4,13 @@ ...@@ -4,10 +4,13 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="16dp"
android:focusableInTouchMode="true"
tools:context="createchannel.ui.CreateChannelFragment"> tools:context="createchannel.ui.CreateChannelFragment">
<include
android:id="@+id/layout_app_bar"
layout="@layout/app_bar"
app:layout_constraintTop_toTopOf="parent" />
<com.wang.avi.AVLoadingIndicatorView <com.wang.avi.AVLoadingIndicatorView
android:id="@+id/view_loading" android:id="@+id/view_loading"
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -18,23 +21,26 @@ ...@@ -18,23 +21,26 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toBottomOf="@+id/layout_app_bar"
tools:visibility="visible" /> tools:visibility="visible" />
<TextView <TextView
android:id="@+id/text_channel_type" android:id="@+id/text_channel_type"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="@string/msg_public_channel" android:text="@string/msg_public_channel"
android:textColor="@color/colorPrimaryText" android:textColor="@color/colorPrimaryText"
android:textSize="16sp" android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toBottomOf="@+id/layout_app_bar" />
<TextView <TextView
android:id="@+id/text_channel_type_description" android:id="@+id/text_channel_type_description"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="@string/msg_public_channel_description" android:text="@string/msg_public_channel_description"
android:textColor="@color/colorSecondaryText" android:textColor="@color/colorSecondaryText"
android:textSize="12sp" android:textSize="12sp"
...@@ -45,6 +51,7 @@ ...@@ -45,6 +51,7 @@
android:id="@+id/switch_channel_type" android:id="@+id/switch_channel_type"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
app:layout_constraintBottom_toBottomOf="@+id/text_channel_type_description" app:layout_constraintBottom_toBottomOf="@+id/text_channel_type_description"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/text_channel_type" /> app:layout_constraintTop_toTopOf="@+id/text_channel_type" />
...@@ -53,6 +60,8 @@ ...@@ -53,6 +60,8 @@
android:id="@+id/text_read_only" android:id="@+id/text_read_only"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:text="@string/msg_ready_only_channel" android:text="@string/msg_ready_only_channel"
android:textColor="@color/colorPrimaryText" android:textColor="@color/colorPrimaryText"
...@@ -64,6 +73,8 @@ ...@@ -64,6 +73,8 @@
android:id="@+id/text_read_only_description" android:id="@+id/text_read_only_description"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="@string/msg_ready_only_channel_description" android:text="@string/msg_ready_only_channel_description"
android:textColor="@color/colorSecondaryText" android:textColor="@color/colorSecondaryText"
android:textSize="12sp" android:textSize="12sp"
...@@ -74,6 +85,8 @@ ...@@ -74,6 +85,8 @@
android:id="@+id/switch_read_only" android:id="@+id/switch_read_only"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
app:layout_constraintBottom_toBottomOf="@+id/text_read_only_description" app:layout_constraintBottom_toBottomOf="@+id/text_read_only_description"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/text_read_only" /> app:layout_constraintTop_toTopOf="@+id/text_read_only" />
...@@ -81,7 +94,9 @@ ...@@ -81,7 +94,9 @@
<ImageView <ImageView
android:id="@+id/image_channel_icon" android:id="@+id/image_channel_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="22dp" android:layout_marginTop="22dp"
android:src="@drawable/ic_hashtag_black_12dp" android:src="@drawable/ic_hashtag_black_12dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
...@@ -91,6 +106,8 @@ ...@@ -91,6 +106,8 @@
android:id="@+id/text_channel_name" android:id="@+id/text_channel_name"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:backgroundTint="@color/colorDim" android:backgroundTint="@color/colorDim"
android:hint="@string/msg_channel_name" android:hint="@string/msg_channel_name"
android:inputType="text" android:inputType="text"
...@@ -107,6 +124,7 @@ ...@@ -107,6 +124,7 @@
android:id="@+id/image_invite_member" android:id="@+id/image_invite_member"
android:layout_width="14dp" android:layout_width="14dp"
android:layout_height="14dp" android:layout_height="14dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:src="@drawable/ic_at_black_20dp" android:src="@drawable/ic_at_black_20dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
...@@ -116,6 +134,8 @@ ...@@ -116,6 +134,8 @@
android:id="@+id/text_invite_members" android:id="@+id/text_invite_members"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:backgroundTint="@color/colorDim" android:backgroundTint="@color/colorDim"
android:hint="@string/msg_invite_members" android:hint="@string/msg_invite_members"
android:inputType="text" android:inputType="text"
......
...@@ -35,7 +35,7 @@ class AnswersAnalytics : Analytics { ...@@ -35,7 +35,7 @@ class AnswersAnalytics : Analytics {
override fun logMessageSent(event: SubscriptionTypeEvent, serverUrl: String) = override fun logMessageSent(event: SubscriptionTypeEvent, serverUrl: String) =
Answers.getInstance() Answers.getInstance()
.logCustom( .logCustom(
CustomEvent("message_actionsent") CustomEvent("message_sent")
.putCustomAttribute("subscription_type", event.subscriptionTypeName) .putCustomAttribute("subscription_type", event.subscriptionTypeName)
.putCustomAttribute("server", serverUrl) .putCustomAttribute("server", serverUrl)
) )
......
...@@ -56,7 +56,7 @@ ext { ...@@ -56,7 +56,7 @@ ext {
glide : '4.8.0', glide : '4.8.0',
glideTransformations : '4.0.0', glideTransformations : '4.0.0',
jitsi : '+', // TODO Avoid using + (https://github.com/jitsi/jitsi-meet/issues/3987) jitsi : '1.21.0',
// For testing // For testing
junit : '4.12', junit : '4.12',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment