Skip to content

Commit

Permalink
Fix dynamic color backgrounds
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Dec 27, 2023
1 parent 6908fd5 commit 57cd3e7
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ class UserPreferences(private val context: Context) : IDeclinationPreferences {
_theme = value
}

val useDynamicColors = false
val useDynamicColors by BooleanPreference(
cache,
context.getString(R.string.pref_use_dynamic_colors),
false
)

// Calibration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.setPadding
import com.kylecorry.andromeda.core.system.Resources
import com.kylecorry.trail_sense.R
import com.kylecorry.trail_sense.shared.CustomUiUtils.getColorOnPrimary
import com.kylecorry.trail_sense.shared.CustomUiUtils.getPrimaryColor

class TileButton(context: Context, attrs: AttributeSet?) : ConstraintLayout(context, attrs) {
Expand Down Expand Up @@ -51,10 +52,10 @@ class TileButton(context: Context, attrs: AttributeSet?) : ConstraintLayout(cont
Resources.getPrimaryColor(icon.context)
)
textView.setTextColor(
Resources.color(icon.context, R.color.colorSecondary)
Resources.getColorOnPrimary(icon.context)
)
icon.imageTintList = ColorStateList.valueOf(
Resources.color(icon.context, R.color.colorSecondary)
Resources.getColorOnPrimary(icon.context)
)
} else {
textView.setTextColor(Resources.androidTextColorSecondary(icon.context))
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?android:colorBackgroundFloating"
android:background="?attr/colorBackgroundFloating"
app:itemIconTint="@drawable/selector"
app:itemTextColor="?attr/colorOnSurface"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_navigator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
android:id="@+id/ruler"
android:layout_width="80dp"
android:layout_height="0dp"
android:background="?android:colorBackgroundFloating"
android:background="?attr/colorBackgroundFloating"
android:elevation="4dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
Expand All @@ -124,7 +124,7 @@
android:focusable="true"
android:tint="?android:textColorSecondary"
android:visibility="invisible"
app:backgroundTint="?android:colorBackgroundFloating"
app:backgroundTint="?attr/colorBackgroundFloating"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/linear_compass"
app:srcCompat="@drawable/ic_camera" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_map_calibration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
android:id="@+id/map_calibration_bottom_panel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?android:colorBackgroundFloating"
android:background="?attr/colorBackgroundFloating"
android:orientation="vertical"
android:padding="16dp"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_tool_battery.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
android:layout_marginTop="16dp"
android:layout_marginEnd="32dp"
android:drawable="@drawable/ic_battery"
android:drawableTint="?android:colorBackgroundFloating"
android:drawableTint="?attr/colorBackgroundFloating"
android:progress="0"
app:horizontal="false"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_tool_ruler.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
android:id="@+id/ruler"
android:layout_width="80dp"
android:layout_height="0dp"
android:background="?android:colorBackgroundFloating"
android:background="?attr/colorBackgroundFloating"
android:elevation="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/fragment_tool_triangulate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:background="@drawable/rounded_rectangle"
android:backgroundTint="?attr/colorSurface">
android:backgroundTint="?attr/colorBackgroundFloating">

<LinearLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -193,7 +193,7 @@
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:background="@drawable/rounded_rectangle"
android:backgroundTint="?attr/colorSurface">
android:backgroundTint="?attr/colorBackgroundFloating">

<LinearLayout
android:layout_width="match_parent"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/view_beacon_destination.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:id="@+id/navigation_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorSurface"
android:background="?attr/colorBackgroundFloating"
android:orientation="vertical">

<View
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:background="@drawable/rounded_rectangle"
android:backgroundTint="?android:colorBackgroundFloating"
android:backgroundTint="?attr/colorBackgroundFloating"
android:paddingLeft="8dp"
android:paddingTop="4dp"
android:paddingRight="8dp"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/view_map_distance_sheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorSurface"
android:background="?attr/colorBackgroundFloating"
android:orientation="vertical">

<com.kylecorry.ceres.toolbar.CeresToolbar
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/view_play_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:id="@+id/play_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorSurface"
android:background="?attr/colorBackgroundFloating"
android:gravity="center"
android:orientation="horizontal"
android:padding="16dp">
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/view_tile_button.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
android:padding="32dp"
android:elevation="2dp"
android:scaleType="fitCenter"
app:backgroundTint="?android:colorBackgroundFloating"
app:backgroundTint="?attr/colorBackgroundFloating"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,7 @@
<string name="pref_clinometer_use_ar" translatable="false">pref_clinometer_use_ar</string>
<string name="clinometer_augmented_reality">Clinometer augmented reality</string>
<string name="clinometer_augmented_reality_description">Visualize angles with your camera</string>
<string name="pref_use_dynamic_colors" translatable="false">pref_use_dynamic_colors</string>
<plurals name="map_group_summary">
<item quantity="one">%d map</item>
<item quantity="other">%d maps</item>
Expand Down
9 changes: 2 additions & 7 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<!--Primary color-->
<item name="colorPrimary">@color/orange_40</item>
<item name="colorOnPrimary">@color/orange_10</item>
<item name="colorAccent">?attr/colorPrimary</item>

<!--Containers-->
<item name="colorPrimaryContainer">@color/orange_40_transparent</item>
Expand All @@ -16,12 +17,6 @@
<item name="colorOnSecondaryContainer">?attr/colorOnPrimaryContainer</item>
<item name="colorOnTertiaryContainer">?attr/colorOnPrimaryContainer</item>

<!--Surface tint-->
<item name="elevationOverlayEnabled">false</item>
<!-- TODO: Surface color does not work with dynamic theme-->
<item name="colorSurface">?attr/colorBackgroundFloating</item>

<item name="colorAccent">?attr/colorPrimary</item>
<item name="bottomSheetDialogTheme">@style/AppBottomSheetDialogTheme</item>
<item name="alertDialogTheme">@style/AlertDialogTheme</item>
<item name="materialButtonStyle">@style/ThemeOverlay.App.ElevatedButton</item>
Expand Down Expand Up @@ -89,7 +84,7 @@

<style name="SearchViewTheme" parent="Widget.AppCompat.SearchView">
<item name="android:background">@drawable/rounded_rectangle</item>
<item name="android:backgroundTint">?attr/colorSurface</item>
<item name="android:backgroundTint">?attr/colorBackgroundFloating</item>
<item name="android:padding">0dp</item>
<item name="android:elevation">2dp</item>
<item name="queryBackground">@android:color/transparent</item>
Expand Down

0 comments on commit 57cd3e7

Please sign in to comment.