Error artwork (#1000)
* Add new Elephant Friend images. Use them in ListsActivity. * Add error images to AccountListFragment * Add error images to Timeline & Notifications fragment. Needs rework. * Introduce BackgroundMessageView. Use it in AccountList. * Use correct button style for BackgroundMessageView Co-Authored-By: charlag <charlag@tutanota.com> * Use BackgroundMessageView * Add BackgroundMessageView docs * Re-color and document elephants * Apply feedback, disable refresh when error is shown * Fix string typo
This commit is contained in:
parent
6e610b1d9d
commit
c0c73f5c06
13 changed files with 652 additions and 188 deletions
|
@ -0,0 +1,46 @@
|
|||
package com.keylesspalace.tusky.view
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import com.keylesspalace.tusky.R
|
||||
import com.keylesspalace.tusky.util.visible
|
||||
import kotlinx.android.synthetic.main.view_background_message.view.*
|
||||
|
||||
|
||||
/**
|
||||
* This view is used for screens with downloadable content which may fail.
|
||||
* Can show an image, text and button below them.
|
||||
*/
|
||||
class BackgroundMessageView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : LinearLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
init {
|
||||
View.inflate(context, R.layout.view_background_message, this)
|
||||
gravity = Gravity.CENTER_HORIZONTAL
|
||||
orientation = VERTICAL
|
||||
|
||||
if (isInEditMode) {
|
||||
setup(R.drawable.elephant_offline, R.string.error_network) {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup image, message and button.
|
||||
* If [clickListener] is `null` then the button will be hidden.
|
||||
*/
|
||||
fun setup(@DrawableRes imageRes: Int, @StringRes messageRes: Int,
|
||||
clickListener: ((v: View) -> Unit)?) {
|
||||
messageTextView.setText(messageRes)
|
||||
messageTextView.setCompoundDrawablesWithIntrinsicBounds(0, imageRes, 0, 0)
|
||||
button.setOnClickListener(clickListener)
|
||||
button.visible(clickListener != null)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue