Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

Commit

Permalink
Add dark theme fixes (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
vase4kin committed Apr 1, 2020
1 parent 50f61f5 commit de9b540
Show file tree
Hide file tree
Showing 24 changed files with 94 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem
import com.github.vase4kin.teamcityapp.R
import com.github.vase4kin.teamcityapp.home.view.HomeActivity
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.elevation.ElevationOverlayProvider
import com.google.android.material.floatingactionbutton.FloatingActionButton
import teamcityapp.libraries.utils.getThemeColor

Expand Down Expand Up @@ -99,8 +100,13 @@ class BottomNavigationViewImpl(
bottomNavigation.addItem(bottomNavItem)
}

val elevation =
activity.resources.getDimension(R.dimen.elevation_bottom_navigation)
val backgroundColor = ElevationOverlayProvider(activity).compositeOverlayIfNeeded(
activity.getThemeColor(R.attr.colorPrimarySurface), elevation
)
// Set bottom nav settings
bottomNavigation.defaultBackgroundColor = activity.getThemeColor(R.attr.colorPrimarySurface)
bottomNavigation.defaultBackgroundColor = backgroundColor
bottomNavigation.accentColor =
activity.getThemeColor(R.attr.colorOnPrimary)
bottomNavigation.inactiveColor =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import com.github.vase4kin.teamcityapp.base.list.view.SimpleSectionedRecyclerVie
import com.github.vase4kin.teamcityapp.buildlist.data.BuildListDataModel
import com.github.vase4kin.teamcityapp.buildlist.data.OnBuildListPresenterListener
import com.github.vase4kin.teamcityapp.onboarding.OnboardingManager
import com.google.android.material.elevation.ElevationOverlayProvider
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
import com.google.android.material.snackbar.Snackbar
import com.mugen.Mugen
Expand Down Expand Up @@ -279,7 +280,7 @@ open class BuildListViewImpl(
* {@inheritDoc}
*/
override fun showFilterBuildsPrompt(listener: OnboardingManager.OnPromptShownListener) {
val color = activity.getThemeColor(R.attr.colorPrimarySurface)
val color = getBackgroundColor()
MaterialTapTargetPrompt.Builder(activity)
.setTarget(R.id.filter_builds)
.setPrimaryText(R.string.title_onboarding_filter_builds)
Expand All @@ -301,7 +302,7 @@ open class BuildListViewImpl(
* {@inheritDoc}
*/
override fun showRunBuildPrompt(listener: OnboardingManager.OnPromptShownListener) {
val color = activity.getThemeColor(R.attr.colorPrimarySurface)
val color = getBackgroundColor()
MaterialTapTargetPrompt.Builder(activity)
.setTarget(floatingActionButton)
.setPrimaryText(R.string.title_onboarding_run_build)
Expand All @@ -327,7 +328,7 @@ open class BuildListViewImpl(
* {@inheritDoc}
*/
override fun showFavPrompt(listener: OnboardingManager.OnPromptShownListener) {
val color = activity.getThemeColor(R.attr.colorPrimarySurface)
val color = getBackgroundColor()
MaterialTapTargetPrompt.Builder(activity)
.setTarget(R.id.add_to_favorites)
.setPrimaryText(R.string.title_onboarding_add_fav)
Expand Down Expand Up @@ -387,6 +388,14 @@ open class BuildListViewImpl(
}
}

private fun getBackgroundColor(): Int {
val elevation =
activity.resources.getDimension(R.dimen.default_elevation)
return ElevationOverlayProvider(activity).compositeOverlayIfNeeded(
activity.getThemeColor(R.attr.colorPrimarySurface), elevation
)
}

/**
* Init sectionAdapter
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.github.vase4kin.teamcityapp.R
import com.github.vase4kin.teamcityapp.filter_bottom_sheet_dialog.filter.Filter
import com.github.vase4kin.teamcityapp.filter_bottom_sheet_dialog.view.FilterBottomSheetDialogFragment
import com.github.vase4kin.teamcityapp.onboarding.OnboardingManager
import com.google.android.material.elevation.ElevationOverlayProvider
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.android.material.snackbar.Snackbar
import teamcityapp.features.drawer.view.DrawerBottomSheetDialogFragment
Expand Down Expand Up @@ -132,7 +133,7 @@ class HomeViewImpl(private val activity: AppCompatActivity) : HomeView {
*/
override fun showNavigationDrawerPrompt(listener: OnboardingManager.OnPromptShownListener) {
// Creating prompt
val color = activity.getThemeColor(R.attr.colorPrimarySurface)
val color = getBackgroundColor()
val navigationDrawerPrompt = MaterialTapTargetPrompt.Builder(activity)
.setPrimaryText(R.string.title_onboarding_navigation_drawer)
.setSecondaryText(R.string.text_onboarding_navigation_drawer)
Expand All @@ -153,7 +154,7 @@ class HomeViewImpl(private val activity: AppCompatActivity) : HomeView {
* {@inheritDoc}
*/
override fun showAddFavPrompt(listener: OnboardingManager.OnPromptShownListener) {
val color = activity.getThemeColor(R.attr.colorPrimarySurface)
val color = getBackgroundColor()
MaterialTapTargetPrompt.Builder(activity)
.setTarget(fab)
.setPrimaryText(R.string.title_onboarding_add_fav)
Expand All @@ -172,7 +173,7 @@ class HomeViewImpl(private val activity: AppCompatActivity) : HomeView {
* {@inheritDoc}
*/
override fun showRunningBuildsFilterPrompt(listener: OnboardingManager.OnPromptShownListener) {
val color = activity.getThemeColor(R.attr.colorPrimarySurface)
val color = getBackgroundColor()
MaterialTapTargetPrompt.Builder(activity)
.setTarget(fab)
.setPrimaryText(R.string.title_onboarding_filter)
Expand All @@ -191,7 +192,7 @@ class HomeViewImpl(private val activity: AppCompatActivity) : HomeView {
* {@inheritDoc}
*/
override fun showBuildsQueueFilterPrompt(onPromptShown: () -> Unit) {
val color = activity.getThemeColor(R.attr.colorPrimarySurface)
val color = getBackgroundColor()
MaterialTapTargetPrompt.Builder(activity)
.setTarget(fab)
.setPrimaryText(R.string.title_onboarding_filter_queued)
Expand All @@ -210,7 +211,7 @@ class HomeViewImpl(private val activity: AppCompatActivity) : HomeView {
* {@inheritDoc}
*/
override fun showAgentsFilterPrompt(onPromptShown: () -> Unit) {
val color = activity.getThemeColor(R.attr.colorPrimarySurface)
val color = getBackgroundColor()
MaterialTapTargetPrompt.Builder(activity)
.setTarget(fab)
.setPrimaryText(R.string.title_onboarding_filter_agents)
Expand All @@ -225,6 +226,14 @@ class HomeViewImpl(private val activity: AppCompatActivity) : HomeView {
}.show()
}

private fun getBackgroundColor(): Int {
val elevation =
activity.resources.getDimension(R.dimen.default_elevation)
return ElevationOverlayProvider(activity).compositeOverlayIfNeeded(
activity.getThemeColor(R.attr.colorPrimarySurface), elevation
)
}

/**
* {@inheritDoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import com.github.vase4kin.teamcityapp.bottomsheet_dialog.view.BottomSheetDialog
import com.github.vase4kin.teamcityapp.navigation.api.BuildElement
import com.github.vase4kin.teamcityapp.onboarding.OnboardingManager
import com.github.vase4kin.teamcityapp.overview.data.OverviewDataModelImpl
import com.google.android.material.elevation.ElevationOverlayProvider
import io.supercharge.shimmerlayout.ShimmerLayout
import teamcityapp.libraries.utils.getThemeColor
import tr.xip.errorview.ErrorView
Expand Down Expand Up @@ -437,7 +438,7 @@ class OverviewViewImpl(
) {
// Creating prompt
val toolbar = activity.findViewById<Toolbar>(R.id.toolbar)
val color = activity.getThemeColor(R.attr.colorPrimarySurface)
val color = getBackgroundColor()
val promptBuilder = MaterialTapTargetPrompt.Builder(activity)
.setPrimaryText(R.string.title_onboarding_build_menu)
.setSecondaryText(secondaryText)
Expand All @@ -456,4 +457,12 @@ class OverviewViewImpl(
promptBuilder.show()
}, TIMEOUT_PROMPT.toLong())
}

private fun getBackgroundColor(): Int {
val elevation =
activity.resources.getDimension(R.dimen.default_elevation)
return ElevationOverlayProvider(activity).compositeOverlayIfNeeded(
activity.getThemeColor(R.attr.colorPrimarySurface), elevation
)
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_artifact_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">

<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/res/layout/activity_build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/container"
style="@style/Widget.MaterialComponents.AppBarLayout.PrimarySurface"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="0dp"
app:layout_scrollFlags="scroll|enterAlways|snap" />

<com.google.android.material.tabs.TabLayout
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_build_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">

<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_create_account.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">

<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
Expand All @@ -38,7 +38,7 @@
android:layout_height="wrap_content">

<LinearLayout
style="@style/ElevatedView"
style="@style/SurfaceView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_filter_builds.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">

<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
Expand All @@ -50,7 +50,7 @@
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<FrameLayout
style="@style/ElevatedView"
style="@style/SurfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent">

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">

<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
Expand All @@ -40,7 +40,7 @@
android:textColor="?attr/colorOnPrimarySurface"
tools:text="@string/home_drawer_item" />

</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.MaterialToolbar>

</com.google.android.material.appbar.AppBarLayout>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<ScrollView 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"
style="@style/ElevatedView"
style="@style/SurfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_navigation_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">

<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_run_build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">

<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" />
Expand All @@ -49,7 +49,7 @@
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<FrameLayout
style="@style/ElevatedView"
style="@style/SurfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent">

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/layout_skeleton_agent_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/ElevatedView"
style="@style/SurfaceView"
android:layout_width="match_parent"
android:layout_height="wrap_content">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/ElevatedView"
style="@style/SurfaceView"
android:layout_width="match_parent"
android:layout_height="wrap_content">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/ElevatedView"
style="@style/SurfaceView"
android:layout_width="match_parent"
android:layout_height="wrap_content">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/ElevatedView"
style="@style/SurfaceView"
android:layout_width="match_parent"
android:layout_height="wrap_content">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem
import com.danielstone.materialaboutlibrary.model.MaterialAboutCard
import com.danielstone.materialaboutlibrary.model.MaterialAboutList
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
import com.google.android.material.elevation.ElevationOverlayProvider
import dagger.android.support.AndroidSupportInjection
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
Expand All @@ -35,6 +36,7 @@ import io.reactivex.rxkotlin.subscribeBy
import io.reactivex.schedulers.Schedulers
import teamcityapp.features.about.repository.AboutRepository
import teamcityapp.libraries.chrome_tabs.ChromeCustomTabs
import teamcityapp.libraries.utils.getThemeColor
import teamcityapp.libraries.utils.getTintedDrawable
import javax.inject.Inject

Expand Down Expand Up @@ -102,6 +104,7 @@ class AboutFragment : MaterialAboutFragment() {
): MaterialAboutCard {
val serverInfo = MaterialAboutCard.Builder()
serverInfo.title(R.string.about_app_text_server_info)
serverInfo.cardColor(getBackgroundColor(requireActivity()))
serverInfo.addItem(
MaterialAboutActionItem.Builder()
.text(getString(R.string.about_version))
Expand Down Expand Up @@ -138,6 +141,7 @@ class AboutFragment : MaterialAboutFragment() {
): MaterialAboutList {
val appCardBuilder = MaterialAboutCard.Builder()
appCardBuilder.title(R.string.about_app_text_app)
.cardColor(getBackgroundColor(requireActivity()))
appCardBuilder.addItem(
MaterialAboutActionItem.Builder()
.text(getString(R.string.about_version))
Expand Down Expand Up @@ -181,6 +185,7 @@ class AboutFragment : MaterialAboutFragment() {

val miscCardBuilder = MaterialAboutCard.Builder()
miscCardBuilder.title(R.string.about_app_text_dev)
.cardColor(getBackgroundColor(requireActivity()))
miscCardBuilder
.addItem(MaterialAboutActionItem.Builder()
.text(R.string.about_app_text_source_code)
Expand Down Expand Up @@ -218,6 +223,7 @@ class AboutFragment : MaterialAboutFragment() {

val authorCardBuilder = MaterialAboutCard.Builder()
authorCardBuilder.title(R.string.about_app_text_contacts)
.cardColor(getBackgroundColor(requireActivity()))
authorCardBuilder.addItem(MaterialAboutActionItem.Builder()
.text(R.string.about_app_text_web)
.subText(R.string.about_app_url_web)
Expand Down Expand Up @@ -277,6 +283,14 @@ class AboutFragment : MaterialAboutFragment() {
}
}

private fun getBackgroundColor(activity: Activity): Int {
val elevation =
activity.resources.getDimension(R.dimen.default_elevation)
return ElevationOverlayProvider(activity).compositeOverlayIfNeeded(
activity.getThemeColor(R.attr.colorSurface), elevation
)
}

private fun openUrl(url: String) {
chromeCustomTabs.launchUrl(url)
}
Expand Down
Loading

0 comments on commit de9b540

Please sign in to comment.