Merge pull request #2979 from vector-im/feature/bma/quick_fixes

Fixes before the release
This commit is contained in:
Benoit Marty 2021-03-10 17:21:06 +01:00 committed by GitHub
commit 944ee1d8c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 78 additions and 25 deletions

View File

@ -31,6 +31,7 @@
<w>signin</w>
<w>signout</w>
<w>signup</w>
<w>snackbar</w>
<w>ssss</w>
<w>sygnal</w>
<w>threepid</w>

View File

@ -12,11 +12,13 @@ Improvements 🙌:
- Add tooltip for room quick actions
- Pre-share session keys when opening a room or start typing (#2771)
- Sending is now queuing by room and not uniquely to the session
- Improve Snackbar duration (#2929)
Bugfix 🐛:
- Try to fix crash about UrlPreview (#2640)
- Be robust if Event.type is missing (#2946)
- Snappier message send status
- Fix MainActivity display (#2927)
Translations 🗣:
- All string resources and translations have been moved to the application module. Weblate project for the SDK will be removed.

View File

@ -32,8 +32,8 @@ import androidx.annotation.StringRes
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
import androidx.core.view.isVisible
import com.google.android.material.snackbar.Snackbar
import im.vector.app.R
import im.vector.app.core.platform.showOptimizedSnackbar
import im.vector.app.core.utils.copyToClipboard
import im.vector.app.features.themes.ThemeUtils
@ -116,7 +116,7 @@ fun TextView.copyOnLongClick() {
?.text
?.let { text ->
copyToClipboard(view.context, text, false)
Snackbar.make(view, view.resources.getString(R.string.copied_to_clipboard), Snackbar.LENGTH_SHORT).show()
view.showOptimizedSnackbar(view.resources.getString(R.string.copied_to_clipboard))
}
true
}

View File

@ -0,0 +1,32 @@
/*
* 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.core.platform
import android.view.View
import com.google.android.material.snackbar.Snackbar
private const val MIN_SNACKBAR_DURATION = 2000
private const val MAX_SNACKBAR_DURATION = 8000
private const val DURATION_PER_LETTER = 50
fun View.showOptimizedSnackbar(message: String) {
Snackbar.make(this, message, getDuration(message)).show()
}
private fun getDuration(message: String): Int {
return (message.length * DURATION_PER_LETTER).coerceIn(MIN_SNACKBAR_DURATION, MAX_SNACKBAR_DURATION)
}

View File

@ -597,9 +597,7 @@ abstract class VectorBaseActivity<VB: ViewBinding> : AppCompatActivity(), HasScr
* ========================================================================================== */
fun showSnackbar(message: String) {
getCoordinatorLayout()?.let {
Snackbar.make(it, message, Snackbar.LENGTH_SHORT).show()
}
getCoordinatorLayout()?.showOptimizedSnackbar(message)
}
fun showSnackbar(message: String, @StringRes withActionTitle: Int?, action: (() -> Unit)?) {

View File

@ -35,7 +35,6 @@ import androidx.lifecycle.ViewModelProvider
import androidx.viewbinding.ViewBinding
import com.airbnb.mvrx.BaseMvRxFragment
import com.bumptech.glide.util.Util.assertMainThread
import com.google.android.material.snackbar.Snackbar
import com.jakewharton.rxbinding3.view.clicks
import im.vector.app.R
import im.vector.app.core.di.DaggerScreenComponent
@ -193,10 +192,7 @@ abstract class VectorBaseFragment<VB: ViewBinding> : BaseMvRxFragment(), HasScre
}
protected fun showErrorInSnackbar(throwable: Throwable) {
vectorBaseActivity.getCoordinatorLayout()?.let {
Snackbar.make(it, errorFormatter.toHumanReadable(throwable), Snackbar.LENGTH_SHORT)
.show()
}
vectorBaseActivity.getCoordinatorLayout()?.showOptimizedSnackbar(errorFormatter.toHumanReadable(throwable))
}
protected fun showLoadingDialog(message: CharSequence? = null, cancelable: Boolean = false) {

View File

@ -31,7 +31,7 @@ import im.vector.app.core.error.ErrorFormatter
import im.vector.app.core.extensions.startSyncing
import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.core.utils.deleteAllFiles
import im.vector.app.databinding.FragmentLoadingBinding
import im.vector.app.databinding.ActivityMainBinding
import im.vector.app.features.home.HomeActivity
import im.vector.app.features.home.ShortcutsHandler
import im.vector.app.features.login.LoginActivity
@ -66,7 +66,7 @@ data class MainActivityArgs(
* This Activity, when started with argument, is also doing some cleanup when user signs out,
* clears cache, is logged out, or is soft logged out
*/
class MainActivity : VectorBaseActivity<FragmentLoadingBinding>(), UnlockedActivity {
class MainActivity : VectorBaseActivity<ActivityMainBinding>(), UnlockedActivity {
companion object {
private const val EXTRA_ARGS = "EXTRA_ARGS"
@ -81,7 +81,7 @@ class MainActivity : VectorBaseActivity<FragmentLoadingBinding>(), UnlockedActiv
}
}
override fun getBinding() = FragmentLoadingBinding.inflate(layoutInflater)
override fun getBinding() = ActivityMainBinding.inflate(layoutInflater)
private lateinit var args: MainActivityArgs

View File

@ -69,7 +69,6 @@ import com.airbnb.mvrx.Success
import com.airbnb.mvrx.args
import com.airbnb.mvrx.fragmentViewModel
import com.airbnb.mvrx.withState
import com.google.android.material.snackbar.Snackbar
import com.jakewharton.rxbinding3.view.focusChanges
import com.jakewharton.rxbinding3.widget.textChanges
import com.vanniktech.emoji.EmojiPopup
@ -90,6 +89,7 @@ import im.vector.app.core.glide.GlideRequests
import im.vector.app.core.intent.getFilenameFromUri
import im.vector.app.core.intent.getMimeTypeFromUri
import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.core.platform.showOptimizedSnackbar
import im.vector.app.core.resources.ColorProvider
import im.vector.app.core.ui.views.CurrentCallsView
import im.vector.app.core.ui.views.KnownCallsViewHolder
@ -370,7 +370,7 @@ class RoomDetailFragment @Inject constructor(
is RoomDetailViewEvents.OnNewTimelineEvents -> scrollOnNewMessageCallback.addNewTimelineEventIds(it.eventIds)
is RoomDetailViewEvents.ActionSuccess -> displayRoomDetailActionSuccess(it)
is RoomDetailViewEvents.ActionFailure -> displayRoomDetailActionFailure(it)
is RoomDetailViewEvents.ShowMessage -> showSnackWithMessage(it.message, Snackbar.LENGTH_LONG)
is RoomDetailViewEvents.ShowMessage -> showSnackWithMessage(it.message)
is RoomDetailViewEvents.NavigateToEvent -> navigateToEvent(it)
is RoomDetailViewEvents.FileTooBigError -> displayFileTooBigError(it)
is RoomDetailViewEvents.DownloadFileState -> handleDownloadFileState(it)
@ -1692,7 +1692,7 @@ class RoomDetailFragment @Inject constructor(
is EventSharedAction.Copy -> {
// I need info about the current selected message :/
copyToClipboard(requireContext(), action.content, false)
showSnackWithMessage(getString(R.string.copied_to_clipboard), Snackbar.LENGTH_SHORT)
showSnackWithMessage(getString(R.string.copied_to_clipboard))
}
is EventSharedAction.Redact -> {
promptConfirmationToRedactEvent(action)
@ -1736,7 +1736,7 @@ class RoomDetailFragment @Inject constructor(
is EventSharedAction.CopyPermalink -> {
val permalink = session.permalinkService().createPermalink(roomDetailArgs.roomId, action.eventId)
copyToClipboard(requireContext(), permalink, false)
showSnackWithMessage(getString(R.string.copied_to_clipboard), Snackbar.LENGTH_SHORT)
showSnackWithMessage(getString(R.string.copied_to_clipboard))
}
is EventSharedAction.Resend -> {
roomDetailViewModel.handle(RoomDetailAction.ResendMessage(action.eventId))
@ -1847,8 +1847,8 @@ class RoomDetailFragment @Inject constructor(
}
}
private fun showSnackWithMessage(message: String, duration: Int = Snackbar.LENGTH_SHORT) {
Snackbar.make(requireView(), message, duration).show()
private fun showSnackWithMessage(message: String) {
view?.showOptimizedSnackbar(message)
}
private fun showDialogWithMessage(message: String) {

View File

@ -23,7 +23,6 @@ import android.view.View
import android.view.ViewGroup
import com.airbnb.mvrx.activityViewModel
import com.airbnb.mvrx.withState
import com.google.android.material.snackbar.Snackbar
import com.jakewharton.rxbinding3.appcompat.queryTextChanges
import im.vector.app.R
import im.vector.app.core.extensions.cleanup
@ -31,6 +30,7 @@ import im.vector.app.core.extensions.configureWith
import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.extensions.trackItemsVisibilityChange
import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.core.platform.showOptimizedSnackbar
import im.vector.app.core.utils.toast
import im.vector.app.databinding.FragmentPublicRoomsBinding
import im.vector.app.features.permalink.NavigationInterceptor
@ -95,8 +95,7 @@ class PublicRoomsFragment @Inject constructor(
private fun handleViewEvents(viewEvents: RoomDirectoryViewEvents) {
when (viewEvents) {
is RoomDirectoryViewEvents.Failure -> {
Snackbar.make(views.coordinatorLayout, errorFormatter.toHumanReadable(viewEvents.throwable), Snackbar.LENGTH_SHORT)
.show()
views.coordinatorLayout.showOptimizedSnackbar(errorFormatter.toHumanReadable(viewEvents.throwable))
}
}.exhaustive
}

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- The background of this Activity is in the theme (so just added as tools here, for preview),
so we just add a ProgressBar here -->
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:background="@drawable/splash"
tools:context=".features.MainActivity">
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginTop="160dp"
android:indeterminate="true"
android:indeterminateTint="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -4,7 +4,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Note: Animation will be started in the code -->
<ImageView
android:id="@+id/animatedLogoImageView"
android:layout_width="72dp"
@ -18,9 +17,9 @@
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="@dimen/layout_vertical_margin_big"
android:indeterminate="true"
app:layout_constraintEnd_toEndOf="parent"