mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-21 20:49:36 +01:00
Lots of progress on layouts
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
cc24c81b0d
commit
419830d2bd
@ -107,17 +107,6 @@ class MainActivity : BaseActivity(), ActionBarProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.floatingActionButton)
|
|
||||||
fun onFloatingActionButtonClick() {
|
|
||||||
val bundle = Bundle()
|
|
||||||
bundle.putBoolean(BundleKeys.KEY_NEW_CONVERSATION, true)
|
|
||||||
router?.pushController(
|
|
||||||
RouterTransaction.with(ContactsController(bundle))
|
|
||||||
.pushChangeHandler(HorizontalChangeHandler())
|
|
||||||
.popChangeHandler(HorizontalChangeHandler()))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||||
fun checkIfWeAreSecure() {
|
fun checkIfWeAreSecure() {
|
||||||
val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
||||||
|
@ -30,11 +30,13 @@ import android.text.InputType
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
|
import android.widget.FrameLayout
|
||||||
import android.widget.ProgressBar
|
import android.widget.ProgressBar
|
||||||
import android.widget.RelativeLayout
|
import android.widget.RelativeLayout
|
||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
import androidx.core.view.MenuItemCompat
|
import androidx.core.view.MenuItemCompat
|
||||||
|
import androidx.core.widget.NestedScrollView
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
import androidx.work.Data
|
import androidx.work.Data
|
||||||
@ -132,7 +134,7 @@ class ContactsController : BaseController,
|
|||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
@BindView(R.id.generic_rv_layout)
|
@BindView(R.id.generic_rv_layout)
|
||||||
var genericRvLayout: CoordinatorLayout? = null
|
var genericRvLayout: FrameLayout? = null
|
||||||
|
|
||||||
private var credentials: String? = null
|
private var credentials: String? = null
|
||||||
private var currentUser: UserNgEntity? = null
|
private var currentUser: UserNgEntity? = null
|
||||||
|
@ -33,7 +33,6 @@ import android.view.inputmethod.InputMethodManager
|
|||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.appcompat.app.ActionBar
|
import androidx.appcompat.app.ActionBar
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||||
import com.bluelinelabs.conductor.ControllerChangeType
|
import com.bluelinelabs.conductor.ControllerChangeType
|
||||||
@ -44,11 +43,11 @@ import com.nextcloud.talk.R
|
|||||||
import com.nextcloud.talk.activities.MainActivity
|
import com.nextcloud.talk.activities.MainActivity
|
||||||
import com.nextcloud.talk.controllers.SwitchAccountController
|
import com.nextcloud.talk.controllers.SwitchAccountController
|
||||||
import com.nextcloud.talk.controllers.base.providers.ActionBarProvider
|
import com.nextcloud.talk.controllers.base.providers.ActionBarProvider
|
||||||
import com.nextcloud.talk.utils.FABAwareScrollingViewBehavior
|
|
||||||
import com.nextcloud.talk.utils.preferences.AppPreferences
|
import com.nextcloud.talk.utils.preferences.AppPreferences
|
||||||
import com.uber.autodispose.lifecycle.LifecycleScopeProvider
|
import com.uber.autodispose.lifecycle.LifecycleScopeProvider
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
import kotlinx.android.synthetic.main.search_layout.*
|
import kotlinx.android.synthetic.main.search_layout.*
|
||||||
|
import kotlinx.android.synthetic.main.search_layout.view.*
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
import org.koin.android.ext.android.inject
|
import org.koin.android.ext.android.inject
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@ -73,18 +72,6 @@ abstract class BaseController : ButterKnifeController(), ComponentCallbacks {
|
|||||||
return actionBarProvider?.supportActionBar
|
return actionBarProvider?.supportActionBar
|
||||||
}
|
}
|
||||||
|
|
||||||
protected val floatingActionButton: FloatingActionButton?
|
|
||||||
get() {
|
|
||||||
var floatingActionButton: FloatingActionButton? = null
|
|
||||||
activity?.let {
|
|
||||||
if (it is MainActivity) {
|
|
||||||
floatingActionButton = it.floatingActionButton
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return floatingActionButton
|
|
||||||
}
|
|
||||||
|
|
||||||
protected val appBar: AppBarLayout?
|
protected val appBar: AppBarLayout?
|
||||||
get() {
|
get() {
|
||||||
var appBarLayout: AppBarLayout? = null
|
var appBarLayout: AppBarLayout? = null
|
||||||
@ -124,22 +111,12 @@ abstract class BaseController : ButterKnifeController(), ComponentCallbacks {
|
|||||||
activity?.let {
|
activity?.let {
|
||||||
if (it is MainActivity) {
|
if (it is MainActivity) {
|
||||||
it.searchCardView.isVisible = value
|
it.searchCardView.isVisible = value
|
||||||
it.floatingActionButton.isVisible = value
|
|
||||||
it.inputEditText.hint = getSearchHint()
|
it.inputEditText.hint = getSearchHint()
|
||||||
|
|
||||||
val layoutParamsForContainer = it.container.layoutParams as CoordinatorLayout.LayoutParams
|
|
||||||
val layoutParams = it.toolbar.layoutParams as AppBarLayout.LayoutParams
|
|
||||||
if (value) {
|
if (value) {
|
||||||
layoutParamsForContainer.behavior = FABAwareScrollingViewBehavior()
|
|
||||||
layoutParams.scrollFlags = AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL or AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP or AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS
|
|
||||||
it.appBar.setBackgroundResource(R.color.transparent)
|
it.appBar.setBackgroundResource(R.color.transparent)
|
||||||
} else {
|
} else {
|
||||||
layoutParamsForContainer.behavior = AppBarLayout.ScrollingViewBehavior()
|
|
||||||
layoutParams.scrollFlags = 0
|
|
||||||
it.appBar.setBackgroundResource(R.color.colorPrimary)
|
it.appBar.setBackgroundResource(R.color.colorPrimary)
|
||||||
}
|
}
|
||||||
it.container.layoutParams = layoutParamsForContainer
|
|
||||||
it.toolbar.layoutParams = layoutParams
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,11 +27,11 @@ import com.nextcloud.talk.newarch.local.dao.UsersDao
|
|||||||
import com.nextcloud.talk.newarch.local.models.UserNgEntity
|
import com.nextcloud.talk.newarch.local.models.UserNgEntity
|
||||||
|
|
||||||
class UsersRepositoryImpl(private val usersDao: UsersDao) : UsersRepository {
|
class UsersRepositoryImpl(private val usersDao: UsersDao) : UsersRepository {
|
||||||
override fun getActiveUserLiveData(): LiveData<UserNgEntity> {
|
override fun getActiveUserLiveData(): LiveData<UserNgEntity?> {
|
||||||
return usersDao.getActiveUserLiveData().distinctUntilChanged()
|
return usersDao.getActiveUserLiveData().distinctUntilChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getActiveUser(): UserNgEntity {
|
override fun getActiveUser(): UserNgEntity? {
|
||||||
return usersDao.getActiveUser()
|
return usersDao.getActiveUser()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,9 +108,9 @@ fun createOkHttpClient(
|
|||||||
val httpClient = OkHttpClient.Builder()
|
val httpClient = OkHttpClient.Builder()
|
||||||
|
|
||||||
httpClient.retryOnConnectionFailure(true)
|
httpClient.retryOnConnectionFailure(true)
|
||||||
httpClient.connectTimeout(45, TimeUnit.SECONDS)
|
httpClient.connectTimeout(300, TimeUnit.SECONDS)
|
||||||
httpClient.readTimeout(45, TimeUnit.SECONDS)
|
httpClient.readTimeout(300, TimeUnit.SECONDS)
|
||||||
httpClient.writeTimeout(45, TimeUnit.SECONDS)
|
httpClient.writeTimeout(300, TimeUnit.SECONDS)
|
||||||
|
|
||||||
httpClient.cookieJar(JavaNetCookieJar(cookieManager))
|
httpClient.cookieJar(JavaNetCookieJar(cookieManager))
|
||||||
httpClient.cache(cache)
|
httpClient.cache(cache)
|
||||||
|
@ -24,7 +24,7 @@ import androidx.lifecycle.LiveData
|
|||||||
import com.nextcloud.talk.newarch.local.models.UserNgEntity
|
import com.nextcloud.talk.newarch.local.models.UserNgEntity
|
||||||
|
|
||||||
interface UsersRepository {
|
interface UsersRepository {
|
||||||
fun getActiveUserLiveData(): LiveData<UserNgEntity>
|
fun getActiveUserLiveData(): LiveData<UserNgEntity?>
|
||||||
fun getActiveUser(): UserNgEntity?
|
fun getActiveUser(): UserNgEntity?
|
||||||
fun getUsers(): List<UserNgEntity>
|
fun getUsers(): List<UserNgEntity>
|
||||||
fun getUserWithId(id: Long): UserNgEntity
|
fun getUserWithId(id: Long): UserNgEntity
|
||||||
|
@ -146,15 +146,18 @@ class LoginEntryViewModel constructor(
|
|||||||
private suspend fun getSignalingSettings() {
|
private suspend fun getSignalingSettings() {
|
||||||
getSignalingSettingsUseCase.invoke(ioScope, parametersOf(user), object : UseCaseResponse<SignalingSettingsOverall> {
|
getSignalingSettingsUseCase.invoke(ioScope, parametersOf(user), object : UseCaseResponse<SignalingSettingsOverall> {
|
||||||
override suspend fun onSuccess(result: SignalingSettingsOverall) {
|
override suspend fun onSuccess(result: SignalingSettingsOverall) {
|
||||||
user.signalingSettings = result.ocs.signalingSettings
|
withContext(Dispatchers.IO) {
|
||||||
val pushConfiguration = PushConfiguration()
|
user.signalingSettings = result.ocs.signalingSettings
|
||||||
val pushConfigurationStateWrapper = PushConfigurationStateWrapper(PushConfigurationState.PENDING, 0)
|
val pushConfiguration = PushConfiguration()
|
||||||
pushConfiguration.pushConfigurationStateWrapper = pushConfigurationStateWrapper
|
val pushConfigurationStateWrapper = PushConfigurationStateWrapper(PushConfigurationState.PENDING, 0)
|
||||||
usersRepository.insertUser(user)
|
pushConfiguration.pushConfigurationStateWrapper = pushConfigurationStateWrapper
|
||||||
setAdjustedUserAsActive()
|
usersRepository.insertUser(user)
|
||||||
registerForPush()
|
setAdjustedUserAsActive()
|
||||||
|
registerForPush()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override suspend fun onError(errorModel: ErrorModel?) {
|
override suspend fun onError(errorModel: ErrorModel?) {
|
||||||
state.postValue(LoginEntryStateWrapper(LoginEntryState.FAILED, LoginEntryStateClarification.SIGNALING_SETTINGS_FETCH_FAILED))
|
state.postValue(LoginEntryStateWrapper(LoginEntryState.FAILED, LoginEntryStateClarification.SIGNALING_SETTINGS_FETCH_FAILED))
|
||||||
}
|
}
|
||||||
@ -176,19 +179,23 @@ class LoginEntryViewModel constructor(
|
|||||||
val options = PushUtils(usersRepository).getMapForPushRegistrationWithServer(context, token)
|
val options = PushUtils(usersRepository).getMapForPushRegistrationWithServer(context, token)
|
||||||
registerPushWithServerUseCase.invoke(ioScope, parametersOf(user, options), object : UseCaseResponse<PushRegistrationOverall> {
|
registerPushWithServerUseCase.invoke(ioScope, parametersOf(user, options), object : UseCaseResponse<PushRegistrationOverall> {
|
||||||
override suspend fun onSuccess(result: PushRegistrationOverall) {
|
override suspend fun onSuccess(result: PushRegistrationOverall) {
|
||||||
user.pushConfiguration?.deviceIdentifier = result.ocs.data.deviceIdentifier
|
withContext(Dispatchers.IO) {
|
||||||
user.pushConfiguration?.deviceIdentifierSignature = result.ocs.data.signature
|
user.pushConfiguration?.deviceIdentifier = result.ocs.data.deviceIdentifier
|
||||||
user.pushConfiguration?.userPublicKey = result.ocs.data.publicKey
|
user.pushConfiguration?.deviceIdentifierSignature = result.ocs.data.signature
|
||||||
user.pushConfiguration?.pushConfigurationStateWrapper = PushConfigurationStateWrapper(PushConfigurationState.SERVER_REGISTRATION_DONE, null)
|
user.pushConfiguration?.userPublicKey = result.ocs.data.publicKey
|
||||||
usersRepository.updateUser(user)
|
user.pushConfiguration?.pushConfigurationStateWrapper = PushConfigurationStateWrapper(PushConfigurationState.SERVER_REGISTRATION_DONE, null)
|
||||||
registerForPushWithProxy()
|
usersRepository.updateUser(user)
|
||||||
|
registerForPushWithProxy()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun onError(errorModel: ErrorModel?) {
|
override suspend fun onError(errorModel: ErrorModel?) {
|
||||||
user.pushConfiguration?.pushConfigurationStateWrapper?.pushConfigurationState = PushConfigurationState.FAILED_WITH_SERVER_REGISTRATION
|
withContext(Dispatchers.IO) {
|
||||||
user.pushConfiguration?.pushConfigurationStateWrapper?.reason = errorModel?.code
|
user.pushConfiguration?.pushConfigurationStateWrapper?.pushConfigurationState = PushConfigurationState.FAILED_WITH_SERVER_REGISTRATION
|
||||||
usersRepository.updateUser(user)
|
user.pushConfiguration?.pushConfigurationStateWrapper?.reason = errorModel?.code
|
||||||
state.postValue(LoginEntryStateWrapper(LoginEntryState.OK, LoginEntryStateClarification.PUSH_REGISTRATION_WITH_SERVER_FAILED))
|
usersRepository.updateUser(user)
|
||||||
|
state.postValue(LoginEntryStateWrapper(LoginEntryState.OK, LoginEntryStateClarification.PUSH_REGISTRATION_WITH_SERVER_FAILED))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -199,9 +206,11 @@ class LoginEntryViewModel constructor(
|
|||||||
if (options != null) {
|
if (options != null) {
|
||||||
registerPushWithProxyUseCase.invoke(ioScope, parametersOf(user, options), object : UseCaseResponse<Any> {
|
registerPushWithProxyUseCase.invoke(ioScope, parametersOf(user, options), object : UseCaseResponse<Any> {
|
||||||
override suspend fun onSuccess(result: Any) {
|
override suspend fun onSuccess(result: Any) {
|
||||||
user.pushConfiguration?.pushConfigurationStateWrapper = PushConfigurationStateWrapper(PushConfigurationState.PROXY_REGISTRATION_DONE, null)
|
withContext(Dispatchers.IO) {
|
||||||
usersRepository.updateUser(user)
|
user.pushConfiguration?.pushConfigurationStateWrapper = PushConfigurationStateWrapper(PushConfigurationState.PROXY_REGISTRATION_DONE, null)
|
||||||
state.postValue(LoginEntryStateWrapper(LoginEntryState.OK, if (!updatingUser) LoginEntryStateClarification.ACCOUNT_CREATED else LoginEntryStateClarification.ACCOUNT_UPDATED))
|
usersRepository.updateUser(user)
|
||||||
|
state.postValue(LoginEntryStateWrapper(LoginEntryState.OK, if (!updatingUser) LoginEntryStateClarification.ACCOUNT_CREATED else LoginEntryStateClarification.ACCOUNT_UPDATED))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun onError(errorModel: ErrorModel?) {
|
override suspend fun onError(errorModel: ErrorModel?) {
|
||||||
@ -215,9 +224,11 @@ class LoginEntryViewModel constructor(
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
user.pushConfiguration?.pushConfigurationStateWrapper?.pushConfigurationState = PushConfigurationState.FAILED_WITH_PROXY_REGISTRATION
|
withContext(Dispatchers.IO) {
|
||||||
usersRepository.updateUser(user)
|
user.pushConfiguration?.pushConfigurationStateWrapper?.pushConfigurationState = PushConfigurationState.FAILED_WITH_PROXY_REGISTRATION
|
||||||
state.postValue(LoginEntryStateWrapper(LoginEntryState.OK, LoginEntryStateClarification.PUSH_REGISTRATION_WITH_PUSH_PROXY_FAILED))
|
usersRepository.updateUser(user)
|
||||||
|
state.postValue(LoginEntryStateWrapper(LoginEntryState.OK, LoginEntryStateClarification.PUSH_REGISTRATION_WITH_PUSH_PROXY_FAILED))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.lifecycle.observe
|
import androidx.lifecycle.observe
|
||||||
|
import butterknife.OnClick
|
||||||
import com.afollestad.materialdialogs.LayoutMode
|
import com.afollestad.materialdialogs.LayoutMode
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||||
@ -94,12 +95,12 @@ class ConversationsListView : BaseView() {
|
|||||||
|
|
||||||
view.apply {
|
view.apply {
|
||||||
recyclerView.initRecyclerView(SmoothScrollLinearLayoutManager(activity), adapter, false)
|
recyclerView.initRecyclerView(SmoothScrollLinearLayoutManager(activity), adapter, false)
|
||||||
swipeRefreshLayoutView.setOnRefreshListener {
|
/*swipeRefreshLayoutView.setOnRefreshListener {
|
||||||
view.swipeRefreshLayoutView.isRefreshing = false
|
view.swipeRefreshLayoutView.isRefreshing = false
|
||||||
viewModel.loadConversations()
|
viewModel.loadConversations()
|
||||||
}
|
}
|
||||||
|
|
||||||
swipeRefreshLayoutView.setColorSchemeResources(R.color.colorPrimary)
|
swipeRefreshLayoutView.setColorSchemeResources(R.color.colorPrimary)*/
|
||||||
}
|
}
|
||||||
|
|
||||||
activity?.inputEditText?.addTextChangedListener(DebouncingTextWatcher(lifecycle, ::setSearchQuery))
|
activity?.inputEditText?.addTextChangedListener(DebouncingTextWatcher(lifecycle, ::setSearchQuery))
|
||||||
@ -137,6 +138,16 @@ class ConversationsListView : BaseView() {
|
|||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.floatingActionButton)
|
||||||
|
fun onFloatingActionButtonClick() {
|
||||||
|
val bundle = Bundle()
|
||||||
|
bundle.putBoolean(BundleKeys.KEY_NEW_CONVERSATION, true)
|
||||||
|
router?.pushController(
|
||||||
|
RouterTransaction.with(ContactsController(bundle))
|
||||||
|
.pushChangeHandler(HorizontalChangeHandler())
|
||||||
|
.popChangeHandler(HorizontalChangeHandler()))
|
||||||
|
}
|
||||||
|
|
||||||
override fun onChangeStarted(changeHandler: ControllerChangeHandler, changeType: ControllerChangeType) {
|
override fun onChangeStarted(changeHandler: ControllerChangeHandler, changeType: ControllerChangeType) {
|
||||||
actionBar?.setIcon(null)
|
actionBar?.setIcon(null)
|
||||||
super.onChangeStarted(changeHandler, changeType)
|
super.onChangeStarted(changeHandler, changeType)
|
||||||
|
@ -22,9 +22,7 @@ package com.nextcloud.talk.newarch.features.conversationslist
|
|||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.*
|
||||||
import androidx.lifecycle.Transformations
|
|
||||||
import androidx.lifecycle.viewModelScope
|
|
||||||
import coil.Coil
|
import coil.Coil
|
||||||
import coil.api.get
|
import coil.api.get
|
||||||
import coil.transform.CircleCropTransformation
|
import coil.transform.CircleCropTransformation
|
||||||
@ -68,12 +66,21 @@ class ConversationsListViewModel constructor(
|
|||||||
if (networkStateLiveData.value != ConversationsListViewNetworkState.LOADING) {
|
if (networkStateLiveData.value != ConversationsListViewNetworkState.LOADING) {
|
||||||
networkStateLiveData.postValue(ConversationsListViewNetworkState.LOADING)
|
networkStateLiveData.postValue(ConversationsListViewNetworkState.LOADING)
|
||||||
}
|
}
|
||||||
loadConversations()
|
|
||||||
loadAvatar()
|
if (user != null) {
|
||||||
|
loadConversations()
|
||||||
|
loadAvatar()
|
||||||
|
}
|
||||||
|
|
||||||
filterLiveData.value = null
|
filterLiveData.value = null
|
||||||
Transformations.switchMap(filterLiveData) { filter ->
|
Transformations.switchMap(filterLiveData) { filter ->
|
||||||
conversationsRepository.getConversationsForUser(user.id!!, filter)
|
if (user != null) {
|
||||||
|
conversationsRepository.getConversationsForUser(user.id!!, filter)
|
||||||
|
} else {
|
||||||
|
liveData {
|
||||||
|
listOf<Conversation>()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,10 +29,10 @@ import com.nextcloud.talk.newarch.local.models.other.UserStatus
|
|||||||
abstract class UsersDao {
|
abstract class UsersDao {
|
||||||
// get active user
|
// get active user
|
||||||
@Query("SELECT * FROM users where status = 1")
|
@Query("SELECT * FROM users where status = 1")
|
||||||
abstract fun getActiveUser(): UserNgEntity
|
abstract fun getActiveUser(): UserNgEntity?
|
||||||
|
|
||||||
@Query("SELECT * FROM users WHERE status = 1")
|
@Query("SELECT * FROM users WHERE status = 1")
|
||||||
abstract fun getActiveUserLiveData(): LiveData<UserNgEntity>
|
abstract fun getActiveUserLiveData(): LiveData<UserNgEntity?>
|
||||||
|
|
||||||
@Query("DELETE FROM users WHERE id = :id")
|
@Query("DELETE FROM users WHERE id = :id")
|
||||||
abstract suspend fun deleteUserWithId(id: Long)
|
abstract suspend fun deleteUserWithId(id: Long)
|
||||||
|
@ -47,7 +47,7 @@ class GlobalService constructor(usersRepository: UsersRepository,
|
|||||||
private val getConversationUseCase: GetConversationUseCase) : KoinComponent {
|
private val getConversationUseCase: GetConversationUseCase) : KoinComponent {
|
||||||
private val applicationScope = CoroutineScope(Dispatchers.Default)
|
private val applicationScope = CoroutineScope(Dispatchers.Default)
|
||||||
private val previousUser: UserNgEntity? = null
|
private val previousUser: UserNgEntity? = null
|
||||||
val currentUserLiveData: LiveData<UserNgEntity> = usersRepository.getActiveUserLiveData()
|
val currentUserLiveData: LiveData<UserNgEntity?> = usersRepository.getActiveUserLiveData()
|
||||||
private var currentConversation: Conversation? = null
|
private var currentConversation: Conversation? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -13,22 +13,28 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.nextcloud.talk.utils;
|
package com.nextcloud.talk.utils.animations;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.cardview.widget.CardView;
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
import androidx.core.view.ViewCompat;
|
import androidx.core.view.ViewCompat;
|
||||||
|
|
||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
import com.nextcloud.talk.R;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class FABAwareScrollingViewBehavior extends AppBarLayout.ScrollingViewBehavior {
|
public class FABAwareScrollingViewBehavior extends AppBarLayout.ScrollingViewBehavior {
|
||||||
|
|
||||||
|
private boolean slidingDown = false;
|
||||||
|
private int searchBarHeight;
|
||||||
|
|
||||||
public FABAwareScrollingViewBehavior() {
|
public FABAwareScrollingViewBehavior() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,6 +42,14 @@ public class FABAwareScrollingViewBehavior extends AppBarLayout.ScrollingViewBeh
|
|||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void layoutChild(@NonNull CoordinatorLayout parent, @NonNull View child, int layoutDirection) {
|
||||||
|
if (child.getId() == R.id.searchCardView) {
|
||||||
|
searchBarHeight = child.getHeight();
|
||||||
|
}
|
||||||
|
super.layoutChild(parent, child, layoutDirection);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
|
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
|
||||||
return super.layoutDependsOn(parent, child, dependency) ||
|
return super.layoutDependsOn(parent, child, dependency) ||
|
||||||
@ -55,14 +69,16 @@ public class FABAwareScrollingViewBehavior extends AppBarLayout.ScrollingViewBeh
|
|||||||
public void onNestedScroll(final CoordinatorLayout coordinatorLayout, final View child,
|
public void onNestedScroll(final CoordinatorLayout coordinatorLayout, final View child,
|
||||||
final View target, final int dxConsumed, final int dyConsumed,
|
final View target, final int dxConsumed, final int dyConsumed,
|
||||||
final int dxUnconsumed, final int dyUnconsumed) {
|
final int dxUnconsumed, final int dyUnconsumed) {
|
||||||
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed,
|
//super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed,
|
||||||
dyUnconsumed);
|
// dyUnconsumed);
|
||||||
if (dyConsumed > 0) {
|
if (dyConsumed > 0) {
|
||||||
// User scrolled down -> hide the FAB
|
// User scrolled down -> hide the FAB
|
||||||
List<View> dependencies = coordinatorLayout.getDependencies(child);
|
List<View> dependencies = coordinatorLayout.getDependencies(child);
|
||||||
for (View view : dependencies) {
|
for (View view : dependencies) {
|
||||||
if (view instanceof FloatingActionButton) {
|
if (view instanceof FloatingActionButton) {
|
||||||
((FloatingActionButton) view).hide();
|
((FloatingActionButton) view).hide();
|
||||||
|
} else if (view.getId() == R.id.searchCardView) {
|
||||||
|
//slideUp(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (dyConsumed < 0) {
|
} else if (dyConsumed < 0) {
|
||||||
@ -71,8 +87,26 @@ public class FABAwareScrollingViewBehavior extends AppBarLayout.ScrollingViewBeh
|
|||||||
for (View view : dependencies) {
|
for (View view : dependencies) {
|
||||||
if (view instanceof FloatingActionButton) {
|
if (view instanceof FloatingActionButton) {
|
||||||
((FloatingActionButton) view).show();
|
((FloatingActionButton) view).show();
|
||||||
|
} else if (view.getId() == R.id.searchCardView) {
|
||||||
|
//slideDown(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void slideUp(View child) {
|
||||||
|
if (slidingDown) {
|
||||||
|
slidingDown = false;
|
||||||
|
child.clearAnimation();
|
||||||
|
child.animate().translationY(0).setDuration(200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void slideDown(View child) {
|
||||||
|
if (!slidingDown) {
|
||||||
|
slidingDown = true;
|
||||||
|
child.clearAnimation();
|
||||||
|
child.animate().translationY(searchBarHeight).setDuration(200);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -30,7 +30,9 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
import androidx.core.view.ViewCompat;
|
import androidx.core.view.ViewCompat;
|
||||||
|
|
||||||
public class ViewHidingBehaviourAnimation extends CoordinatorLayout.Behavior<View> {
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
|
|
||||||
|
public class ViewHidingBehaviourAnimation extends AppBarLayout.ScrollingViewBehavior {
|
||||||
|
|
||||||
private int height;
|
private int height;
|
||||||
private boolean slidingDown = false;
|
private boolean slidingDown = false;
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".activities.MainActivity"
|
tools:context=".activities.MainActivity"
|
||||||
android:animateLayoutChanges="true"
|
android:animateLayoutChanges="true"
|
||||||
android:background="@color/transparent">
|
android:fitsSystemWindows="true">
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:id="@+id/appBar"
|
android:id="@+id/appBar"
|
||||||
@ -45,25 +45,13 @@
|
|||||||
app:layout_scrollFlags="scroll|enterAlways|snap"
|
app:layout_scrollFlags="scroll|enterAlways|snap"
|
||||||
app:popupTheme="@style/appActionBarPopupMenu">
|
app:popupTheme="@style/appActionBarPopupMenu">
|
||||||
|
|
||||||
<include layout="@layout/search_layout"/>
|
<include layout="@layout/search_layout" />
|
||||||
</com.google.android.material.appbar.MaterialToolbar>
|
</com.google.android.material.appbar.MaterialToolbar>
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
<com.nextcloud.talk.newarch.utils.ChangeHandlerCoordinatorLayout
|
<com.bluelinelabs.conductor.ChangeHandlerFrameLayout
|
||||||
android:id="@+id/controller_container"
|
android:id="@+id/controller_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent" />
|
||||||
app:layout_behavior="com.nextcloud.talk.utils.FABAwareScrollingViewBehavior"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
||||||
android:id="@+id/floatingActionButton"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="bottom|end"
|
|
||||||
android:layout_margin="16dp"
|
|
||||||
app:backgroundTint="@color/colorPrimary"
|
|
||||||
app:srcCompat="@drawable/ic_add_white_24px"
|
|
||||||
app:tint="@color/white" />
|
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/generic_rv_layout"
|
android:id="@+id/generic_rv_layout"
|
||||||
@ -26,20 +26,22 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:animateLayoutChanges="true">
|
android:animateLayoutChanges="true">
|
||||||
|
|
||||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
|
||||||
android:id="@+id/swipeRefreshLayoutView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:visibility="visible"
|
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
|
||||||
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/recyclerView"
|
android:id="@+id/recyclerView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:listitem="@layout/rv_item_conversation_with_last_message" />
|
tools:listitem="@layout/rv_item_conversation_with_last_message" />
|
||||||
|
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/floatingActionButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:nestedScrollingEnabled="true"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
app:backgroundTint="@color/colorPrimary"
|
||||||
|
app:srcCompat="@drawable/ic_add_white_24px"
|
||||||
|
app:tint="@color/white" />
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</FrameLayout>
|
||||||
|
@ -37,8 +37,8 @@
|
|||||||
app:contentPaddingRight="16dp"
|
app:contentPaddingRight="16dp"
|
||||||
android:background="@color/transparent"
|
android:background="@color/transparent"
|
||||||
app:cardBackgroundColor="@color/transparent"
|
app:cardBackgroundColor="@color/transparent"
|
||||||
android:elevation="4dp"
|
android:elevation="2dp"
|
||||||
app:cardElevation="4dp"
|
app:cardElevation="2dp"
|
||||||
android:visibility="gone">
|
android:visibility="gone">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
|
@ -31,8 +31,6 @@
|
|||||||
<item name="android:textColor">@color/nc_incoming_text_default</item>
|
<item name="android:textColor">@color/nc_incoming_text_default</item>
|
||||||
<item name="android:popupMenuStyle">@style/appActionBarPopupMenu</item>
|
<item name="android:popupMenuStyle">@style/appActionBarPopupMenu</item>
|
||||||
<item name="actionOverflowMenuStyle">@style/appActionBarPopupMenu</item>
|
<item name="actionOverflowMenuStyle">@style/appActionBarPopupMenu</item>
|
||||||
<item name="android:statusBarColor">@color/colorPrimary</item>
|
|
||||||
<item name="actionBarStyle">@style/appActionBarStyle</item>
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="ErrorAppearance" parent="@android:style/TextAppearance">
|
<style name="ErrorAppearance" parent="@android:style/TextAppearance">
|
||||||
|
Loading…
Reference in New Issue
Block a user