mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 18:35:40 +03:00
Merge pull request #5056 from vector-im/feature/bma/fix_toolbar_title
Fix toolbar title
This commit is contained in:
commit
7aba03c60a
2 changed files with 26 additions and 18 deletions
|
@ -34,41 +34,49 @@ class ToolbarConfig(val activity: AppCompatActivity, val toolbar: MaterialToolba
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delegating property for [toolbar.title]
|
* Delegating property for [activity.supportActionBar?.title]
|
||||||
* */
|
*/
|
||||||
var title: CharSequence? by toolbar::title
|
var title: CharSequence?
|
||||||
|
set(value) {
|
||||||
|
setTitle(value)
|
||||||
|
}
|
||||||
|
get() = activity.supportActionBar?.title
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delegating property for [toolbar.subtitle]
|
* Delegating property for [activity.supportActionBar?.subtitle]
|
||||||
* */
|
*/
|
||||||
var subtitle: CharSequence? by toolbar::subtitle
|
var subtitle: CharSequence?
|
||||||
|
set(value) {
|
||||||
|
setSubtitle(value)
|
||||||
|
}
|
||||||
|
get() = activity.supportActionBar?.subtitle
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets toolbar's title text
|
* Sets toolbar's title text
|
||||||
* */
|
*/
|
||||||
fun setTitle(title: CharSequence?) = apply { toolbar.title = title }
|
fun setTitle(title: CharSequence?) = apply { activity.supportActionBar?.title = title }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets toolbar's title text using provided string resource
|
* Sets toolbar's title text using provided string resource
|
||||||
* */
|
*/
|
||||||
fun setTitle(@StringRes titleRes: Int) = apply { toolbar.setTitle(titleRes) }
|
fun setTitle(@StringRes titleRes: Int) = apply { activity.supportActionBar?.setTitle(titleRes) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets toolbar's subtitle text
|
* Sets toolbar's subtitle text
|
||||||
* */
|
*/
|
||||||
fun setSubtitle(subtitle: String?) = apply { toolbar.subtitle = subtitle }
|
fun setSubtitle(subtitle: CharSequence?) = apply { activity.supportActionBar?.subtitle = subtitle }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets toolbar's title text using provided string resource
|
* Sets toolbar's title text using provided string resource
|
||||||
* */
|
*/
|
||||||
fun setSubtitle(@StringRes subtitleRes: Int) = apply { toolbar.subtitle = activity.getString(subtitleRes) }
|
fun setSubtitle(@StringRes subtitleRes: Int) = apply { activity.supportActionBar?.setSubtitle(subtitleRes) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables/disables navigate back button
|
* Enables/disables navigate back button
|
||||||
*
|
*
|
||||||
* @param isAllowed defines if back button is enabled. Default [true]
|
* @param isAllowed defines if back button is enabled. Default [true]
|
||||||
* @param useCross defines if cross icon should be used instead of arrow. Default [false]
|
* @param useCross defines if cross icon should be used instead of arrow. Default [false]
|
||||||
* */
|
*/
|
||||||
fun allowBack(isAllowed: Boolean = true, useCross: Boolean = false) = apply {
|
fun allowBack(isAllowed: Boolean = true, useCross: Boolean = false) = apply {
|
||||||
activity.supportActionBar?.let {
|
activity.supportActionBar?.let {
|
||||||
it.setDisplayShowHomeEnabled(isAllowed)
|
it.setDisplayShowHomeEnabled(isAllowed)
|
||||||
|
|
|
@ -122,7 +122,7 @@ class SpaceManageRoomsFragment @Inject constructor(
|
||||||
views.addRoomToSpaceToolbar.isVisible = true
|
views.addRoomToSpaceToolbar.isVisible = true
|
||||||
vectorBaseActivity.startSupportActionMode(this)
|
vectorBaseActivity.startSupportActionMode(this)
|
||||||
} else {
|
} else {
|
||||||
toolbar?.title = "${state.selectedRooms.size} selected"
|
toolbar?.title = resources.getQuantityString(R.plurals.room_details_selected, state.selectedRooms.size, state.selectedRooms.size)
|
||||||
}
|
}
|
||||||
// views.addRoomToSpaceToolbar.isVisible = false
|
// views.addRoomToSpaceToolbar.isVisible = false
|
||||||
// views.addRoomToSpaceToolbar.startActionMode(this)
|
// views.addRoomToSpaceToolbar.startActionMode(this)
|
||||||
|
@ -171,10 +171,10 @@ class SpaceManageRoomsFragment @Inject constructor(
|
||||||
|
|
||||||
override fun onActionItemClicked(mode: ActionMode?, item: MenuItem?): Boolean {
|
override fun onActionItemClicked(mode: ActionMode?, item: MenuItem?): Boolean {
|
||||||
when (item?.itemId) {
|
when (item?.itemId) {
|
||||||
R.id.action_delete -> {
|
R.id.action_delete -> {
|
||||||
handleDeleteSelection()
|
handleDeleteSelection()
|
||||||
}
|
}
|
||||||
R.id.action_mark_as_suggested -> {
|
R.id.action_mark_as_suggested -> {
|
||||||
viewModel.handle(SpaceManageRoomViewAction.MarkAllAsSuggested(true))
|
viewModel.handle(SpaceManageRoomViewAction.MarkAllAsSuggested(true))
|
||||||
}
|
}
|
||||||
R.id.action_mark_as_not_suggested -> {
|
R.id.action_mark_as_not_suggested -> {
|
||||||
|
|
Loading…
Reference in a new issue