2890 show warning on missing description (#2919)
* issue 2890: Show a warning icon if media description is missing * issue 2890: Remove disturbing additional signs * issue 2890: Add another icon; use a snackbar; change wording; use orange as color * issue 2890: Remove now unneeded new resource * issue 2890: Use a toast (also) to avoid elevation problems * issue 2890: Use snackbar with elevation again; refactor a bit
This commit is contained in:
parent
615c7adc86
commit
2accfd0712
5 changed files with 45 additions and 11 deletions
|
@ -188,7 +188,7 @@ class ComposeActivity :
|
|||
Log.w("ComposeActivity", "Edit image cancelled by user")
|
||||
} else {
|
||||
Log.w("ComposeActivity", "Edit image failed: " + result.error)
|
||||
displayTransientError(R.string.error_image_edit_failed)
|
||||
displayTransientMessage(R.string.error_image_edit_failed)
|
||||
}
|
||||
viewModel.cropImageItemOld = null
|
||||
}
|
||||
|
@ -470,9 +470,9 @@ class ComposeActivity :
|
|||
lifecycleScope.launch {
|
||||
viewModel.uploadError.collect { throwable ->
|
||||
if (throwable is UploadServerError) {
|
||||
displayTransientError(throwable.errorMessage)
|
||||
displayTransientMessage(throwable.errorMessage)
|
||||
} else {
|
||||
displayTransientError(R.string.error_media_upload_sending)
|
||||
displayTransientMessage(R.string.error_media_upload_sending)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -500,6 +500,9 @@ class ComposeActivity :
|
|||
binding.composeScheduleView.setListener(this)
|
||||
binding.atButton.setOnClickListener { atButtonClicked() }
|
||||
binding.hashButton.setOnClickListener { hashButtonClicked() }
|
||||
binding.descriptionMissingWarningButton.setOnClickListener {
|
||||
displayTransientMessage(R.string.hint_media_description_missing)
|
||||
}
|
||||
|
||||
val textColor = ThemeUtils.getColor(this, android.R.attr.textColorTertiary)
|
||||
|
||||
|
@ -656,15 +659,15 @@ class ComposeActivity :
|
|||
super.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
private fun displayTransientError(errorMessage: String) {
|
||||
val bar = Snackbar.make(binding.activityCompose, errorMessage, Snackbar.LENGTH_LONG)
|
||||
private fun displayTransientMessage(message: String) {
|
||||
val bar = Snackbar.make(binding.activityCompose, message, Snackbar.LENGTH_LONG)
|
||||
// necessary so snackbar is shown over everything
|
||||
bar.view.elevation = resources.getDimension(R.dimen.compose_activity_snackbar_elevation)
|
||||
bar.setAnchorView(R.id.composeBottomBar)
|
||||
bar.show()
|
||||
}
|
||||
private fun displayTransientError(@StringRes stringId: Int) {
|
||||
displayTransientError(getString(stringId))
|
||||
private fun displayTransientMessage(@StringRes stringId: Int) {
|
||||
displayTransientMessage(getString(stringId))
|
||||
}
|
||||
|
||||
private fun toggleHideMedia() {
|
||||
|
@ -674,6 +677,7 @@ class ComposeActivity :
|
|||
private fun updateSensitiveMediaToggle(markMediaSensitive: Boolean, contentWarningShown: Boolean) {
|
||||
if (viewModel.media.value.isEmpty()) {
|
||||
binding.composeHideMediaButton.hide()
|
||||
binding.descriptionMissingWarningButton.hide()
|
||||
} else {
|
||||
binding.composeHideMediaButton.show()
|
||||
@ColorInt val color = if (contentWarningShown) {
|
||||
|
@ -691,6 +695,15 @@ class ComposeActivity :
|
|||
}
|
||||
}
|
||||
binding.composeHideMediaButton.drawable.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN)
|
||||
|
||||
var oneMediaWithoutDescription = false
|
||||
for (media in viewModel.media.value) {
|
||||
if (media.description == null || media.description.isEmpty()) {
|
||||
oneMediaWithoutDescription = true
|
||||
break
|
||||
}
|
||||
}
|
||||
binding.descriptionMissingWarningButton.visibility = if (oneMediaWithoutDescription) View.VISIBLE else View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -760,7 +773,7 @@ class ComposeActivity :
|
|||
binding.emojiView.adapter?.let {
|
||||
if (it.itemCount == 0) {
|
||||
val errorMessage = getString(R.string.error_no_custom_emojis, accountManager.activeAccount!!.domain)
|
||||
Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT).show()
|
||||
displayTransientMessage(errorMessage)
|
||||
} else {
|
||||
if (emojiBehavior.state == BottomSheetBehavior.STATE_HIDDEN || emojiBehavior.state == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||
emojiBehavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||
|
@ -980,7 +993,7 @@ class ComposeActivity :
|
|||
val photoFile: File = try {
|
||||
createNewImageFile(this)
|
||||
} catch (ex: IOException) {
|
||||
displayTransientError(R.string.error_media_upload_opening)
|
||||
displayTransientMessage(R.string.error_media_upload_opening)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1050,7 +1063,7 @@ class ComposeActivity :
|
|||
is VideoOrImageException -> getString(R.string.error_media_upload_image_or_video)
|
||||
else -> getString(R.string.error_media_upload_opening)
|
||||
}
|
||||
displayTransientError(errorString)
|
||||
displayTransientMessage(errorString)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M16.83,14H18v-2h-3.17l-1,-1H18V9h-6.17l-1,-1H18V6H8.83l-4,-4H20c1.1,0 2,0.9 2,2v15.17L16.83,14zM2.1,2.1L0.69,3.51L2,4.83V16c0,1.1 0.9,2 2,2h11.17l5.31,5.31l1.41,-1.41L2.1,2.1zM6,9h0.17l2,2H6V9zM6,14v-2h3.17l2,2H6z"/>
|
||||
</vector>
|
|
@ -25,7 +25,7 @@
|
|||
<Spinner
|
||||
android:id="@+id/composePostLanguageButton"
|
||||
style="@style/TuskyImageButton"
|
||||
android:layout_width="56dp"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:padding="0dp"
|
||||
|
@ -58,9 +58,23 @@
|
|||
android:textColor="?android:textColorTertiary"
|
||||
android:textSize="?attr/status_text_large"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/descriptionMissingWarningButton"
|
||||
style="@style/TuskyImageButton"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:contentDescription="@string/hint_media_description_missing"
|
||||
android:padding="8dp"
|
||||
app:srcCompat="@drawable/ic_missing_description_24dp"
|
||||
app:tint="@color/tusky_orange_light"
|
||||
app:tooltipText="@string/hint_media_description_missing"
|
||||
android:visibility="invisible" />
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/composeMainScrollView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/compose_activity_scrollview_height"
|
||||
android:layout_marginTop="?attr/actionBarSize"
|
||||
|
|
|
@ -131,6 +131,7 @@
|
|||
<string name="hint_display_name">Anzeigename</string>
|
||||
<string name="hint_note">Über mich</string>
|
||||
<string name="hint_search">Suchen …</string>
|
||||
<string name="hint_media_description_missing">Medien sollten Beschreibungen haben.</string>
|
||||
<string name="search_no_results">Keine Ergebnisse</string>
|
||||
<string name="label_quick_reply">Antworten …</string>
|
||||
<string name="label_avatar">Profilbild</string>
|
||||
|
|
|
@ -195,6 +195,7 @@
|
|||
<string name="hint_display_name">Display name</string>
|
||||
<string name="hint_note">Bio</string>
|
||||
<string name="hint_search">Search…</string>
|
||||
<string name="hint_media_description_missing">Media should have a description.</string>
|
||||
|
||||
<string name="search_no_results">No results</string>
|
||||
|
||||
|
|
Loading…
Reference in a new issue