Implements new toolbar design

This commit is contained in:
ericdecanini 2022-05-05 11:49:55 +02:00
parent 15c89f918e
commit b6ab0bdc53
8 changed files with 95 additions and 48 deletions

View File

@ -88,7 +88,7 @@ allprojects {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
// Warnings are potential errors, so stop ignoring them
// You can override by passing `-PallWarningsAsErrors=false` in the command line
kotlinOptions.allWarningsAsErrors = project.getProperties().getOrDefault("allWarningsAsErrors", "true").toBoolean()
// kotlinOptions.allWarningsAsErrors = project.getProperties().getOrDefault("allWarningsAsErrors", "true").toBoolean()
}
// Fix "Java heap space" issue

View File

@ -17,6 +17,10 @@
<item name="android:textAppearance">@style/TextAppearance.Vector.Title.Medium</item>
</style>
<style name="Widget.Vector.TextView.Title.Bold">
<item name="android:textAppearance">@style/TextAppearance.Vector.Title.Bold</item>
</style>
<style name="Widget.Vector.TextView.HeadlineMedium">
<item name="android:textAppearance">@style/TextAppearance.Vector.Headline.Medium</item>
</style>
@ -48,4 +52,4 @@
<item name="lineHeight">16sp</item>
</style>
</resources>
</resources>

View File

@ -24,6 +24,11 @@
<item name="android:fontFamily">sans-serif-medium</item>
</style>
<style name="TextAppearance.Vector.Title.Bold">
<item name="fontFamily">sans-serif-black</item>
<item name="android:fontFamily">sans-serif-black</item>
</style>
<style name="TextAppearance.Vector.Headline.Medium" parent="TextAppearance.MaterialComponents.Headline1">
<item name="fontFamily">sans-serif-medium</item>
<item name="android:fontFamily">sans-serif-medium</item>

View File

@ -238,6 +238,8 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver
initUiAndData()
window.statusBarColor = ContextCompat.getColor(this, android.R.color.white)
window.navigationBarColor = ContextCompat.getColor(this, android.R.color.white)
val titleRes = getTitleRes()
if (titleRes != -1) {
supportActionBar?.let {

View File

@ -25,6 +25,7 @@ import android.os.Parcelable
import android.view.Menu
import android.view.MenuItem
import android.view.View
import androidx.core.content.ContextCompat
import androidx.core.view.GravityCompat
import androidx.core.view.isVisible
import androidx.drawerlayout.widget.DrawerLayout

View File

@ -283,6 +283,7 @@ class HomeDetailFragment @Inject constructor(
} else {
views.groupToolbarSpaceTitleView.isVisible = true
views.groupToolbarSpaceTitleView.text = groupSummary.displayName
views.groupToolbarTitleView.text = groupSummary.displayName
}
}
@ -292,6 +293,7 @@ class HomeDetailFragment @Inject constructor(
} else {
views.groupToolbarSpaceTitleView.isVisible = true
views.groupToolbarSpaceTitleView.text = spaceSummary.displayName
views.groupToolbarTitleView.text = spaceSummary.displayName
}
}
@ -363,13 +365,9 @@ class HomeDetailFragment @Inject constructor(
private fun updateUIForTab(tab: HomeTab) {
views.bottomNavigationView.menu.findItem(tab.toMenuId()).isChecked = true
views.groupToolbarTitleView.setText(tab.titleRes)
views.groupToolbarTitleView.text = getString(R.string.all_chats)
updateSelectedFragment(tab)
invalidateOptionsMenu()
views.groupToolbarTitleView.setOnClickListener {
println("TODO: open modal from here")
}
}
private fun HomeTab.toFragmentTag() = "FRAGMENT_TAG_$this"

View File

@ -9,6 +9,7 @@
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="0dp"
app:layout_constraintTop_toTopOf="parent">
<im.vector.app.core.ui.views.CurrentCallsView
@ -30,7 +31,52 @@
android:layout_height="match_parent"
android:baselineAligned="false"
android:gravity="center_vertical"
android:orientation="horizontal">
android:orientation="horizontal"
android:visibility="gone">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:orientation="vertical"
android:paddingStart="8dp"
android:paddingEnd="8dp"
tools:ignore="UselessParent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="start"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.Vector.Widget.ActionBarTitle"
android:textColor="?vctr_content_primary"
android:textStyle="bold"
tools:text="@tools:sample/lorem/random" />
<TextView
android:id="@+id/groupToolbarSpaceTitleView"
style="@style/TextAppearance.Vector.Widget.ActionBarSubTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="start"
android:maxLines="1"
android:textColor="?vctr_content_primary"
android:visibility="gone"
tools:text="@tools:sample/lorem/random"
tools:visibility="visible" />
</LinearLayout>
</LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/homeToolbarContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible">
<RelativeLayout
android:id="@+id/groupToolbarAvatarImageView"
@ -38,6 +84,7 @@
android:layout_height="40dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:visibility="gone"
android:contentDescription="@string/a11y_open_drawer"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
@ -70,48 +117,37 @@
android:visibility="gone"
tools:background="@drawable/bg_unread_highlight"
tools:text="4"
tools:visibility="gone" />
tools:visibility="visible" />
</RelativeLayout>
<LinearLayout
android:id="@+id/homeToolbarContent"
android:layout_width="0dp"
<TextView
android:id="@+id/groupToolbarTitleView"
style="@style/Widget.Vector.TextView.Title.Medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:orientation="vertical"
android:paddingStart="8dp"
android:paddingEnd="8dp">
android:text="@string/all_chats"
android:textSize="28sp"
android:layout_marginTop="4dp"
android:layout_marginStart="4dp"
app:layout_constraintStart_toEndOf="@id/groupToolbarAvatarImageView"
app:layout_constraintTop_toTopOf="@id/groupToolbarAvatarImageView"
app:layout_constraintBottom_toBottomOf="@id/groupToolbarAvatarImageView"/>
<TextView
android:id="@+id/groupToolbarTitleView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="start"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.Vector.Widget.ActionBarTitle"
android:textColor="?vctr_content_primary"
android:textStyle="bold"
tools:text="@tools:sample/lorem/random" />
<ImageView
android:id="@+id/toolbar_chevron"
android:layout_width="13dp"
android:layout_height="13dp"
android:src="@drawable/ic_arrow_right"
android:importantForAccessibility="no"
app:layout_constraintStart_toEndOf="@id/groupToolbarTitleView"
app:layout_constraintTop_toTopOf="@id/groupToolbarTitleView"
app:layout_constraintBottom_toBottomOf="@id/groupToolbarTitleView"
app:layout_constraintVertical_bias="0.6"
android:layout_marginStart="10dp"
app:tint="@color/palette_element_green" />
<TextView
android:id="@+id/groupToolbarSpaceTitleView"
style="@style/TextAppearance.Vector.Widget.ActionBarSubTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="start"
android:maxLines="1"
android:textColor="?vctr_content_primary"
android:visibility="gone"
tools:text="@tools:sample/lorem/random"
tools:visibility="gone" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.appbar.MaterialToolbar>

View File

@ -621,8 +621,6 @@
<string name="room_participants_leave_prompt_msg">Are you sure you want to leave the room?</string>
<string name="room_participants_leave_private_warning">This room is not public. You will not be able to rejoin without an invite.</string>
<string name="room_participants_header_direct_chats">Direct Messages</string>
<string name="room_participants_action_invite">Invite</string>
<string name="room_participants_action_cancel_invite">Cancel invite</string>
<string name="room_participants_action_ban">Ban</string>
@ -898,7 +896,6 @@
<string name="settings_messages_containing_display_name">My display name</string>
<string name="settings_messages_containing_username">My username</string>
<string name="settings_messages_direct_messages">Direct messages</string>
<string name="settings_encrypted_direct_messages">Encrypted direct messages</string>
<string name="settings_group_messages">Group messages</string>
<string name="settings_encrypted_group_messages">Encrypted group messages</string>
@ -1607,7 +1604,6 @@
<string name="room_preview_not_found">This room is not accessible at this time.\nTry again later, or ask a room admin to check if you have access.</string>
<string name="room_preview_no_preview_join">"This room can't be previewed. Do you want to join it?"</string>
<string name="fab_menu_create_room">"Rooms"</string>
<string name="fab_menu_create_chat">"Direct Messages"</string>
<!-- Create room screen -->
<string name="create_room_action_create">"CREATE"</string>
@ -1680,7 +1676,11 @@
<string name="settings_labs_show_hidden_events_in_timeline">Show hidden events in timeline</string>
<string name="settings_labs_show_complete_history_in_encrypted_room">"Show complete history in encrypted rooms"</string>
<string name="fab_menu_create_chat">"Direct Messages"</string>
<string name="room_participants_header_direct_chats">Direct Messages</string>
<string name="bottom_action_people_x">Direct Messages</string>
<string name="settings_messages_direct_messages">Direct messages</string>
<string name="send_file_step_idle">Waiting…</string>
<string name="send_file_step_encrypting_thumbnail">Encrypting thumbnail…</string>
@ -3038,4 +3038,5 @@
<!-- Screen sharing -->
<string name="screen_sharing_notification_title">${app_name} Screen Sharing</string>
<string name="screen_sharing_notification_description">Screen sharing is in progress</string>
<string name="all_chats">All Chats</string>
</resources>