Skip to content

Commit

Permalink
Merge pull request #3998 from kiwix/Fixes#3991
Browse files Browse the repository at this point in the history
Fixed: The UI showing incorrect colors in night mode.
  • Loading branch information
kelson42 authored Oct 1, 2024
2 parents 701c9c1 + 2b796b0 commit 38400df
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.accessibility.AccessibilityChecks
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckResultUtils.matchesCheck
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckResultUtils.matchesViews
import com.google.android.apps.common.testing.accessibility.framework.checks.TouchTargetSizeCheck
import org.hamcrest.Matchers.allOf
import org.junit.After
import org.junit.Before
import org.junit.Rule
Expand All @@ -54,7 +59,15 @@ class DeepLinksTest : BaseActivityTest() {
private lateinit var sharedPreferenceUtil: SharedPreferenceUtil

init {
AccessibilityChecks.enable().setRunChecksFromRootView(true)
AccessibilityChecks.enable().apply {
setRunChecksFromRootView(true)
setSuppressingResultMatcher(
allOf(
matchesCheck(TouchTargetSizeCheck::class.java),
matchesViews(withContentDescription("More options"))
)
)
}
}

@Before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ import androidx.navigation.fragment.NavHostFragment
import androidx.preference.PreferenceManager
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.accessibility.AccessibilityChecks
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.internal.runner.junit4.statement.UiThreadStatement
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckResultUtils.matchesCheck
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckResultUtils.matchesViews
import com.google.android.apps.common.testing.accessibility.framework.checks.TouchTargetSizeCheck
import org.hamcrest.Matchers.allOf
import org.junit.After
import org.junit.Before
import org.junit.Rule
Expand Down Expand Up @@ -84,7 +89,17 @@ class DarkModeViewPainterTest : BaseActivityTest() {
}

init {
AccessibilityChecks.enable().setRunChecksFromRootView(true)
AccessibilityChecks.enable().apply {
setRunChecksFromRootView(true)
setSuppressingResultMatcher(
allOf(
matchesCheck(TouchTargetSizeCheck::class.java),
matchesViews(
withContentDescription("More options")
)
)
)
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ import androidx.lifecycle.Lifecycle
import androidx.preference.PreferenceManager
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.accessibility.AccessibilityChecks
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckResultUtils.matchesCheck
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckResultUtils.matchesViews
import com.google.android.apps.common.testing.accessibility.framework.checks.TouchTargetSizeCheck
import leakcanary.LeakAssertions
import org.hamcrest.Matchers.allOf
import org.junit.Before
import org.junit.Rule
import org.junit.Test
Expand Down Expand Up @@ -81,7 +86,17 @@ class TopLevelDestinationTest : BaseActivityTest() {
}

init {
AccessibilityChecks.enable().setRunChecksFromRootView(true)
AccessibilityChecks.enable().apply {
setRunChecksFromRootView(true)
setSuppressingResultMatcher(
allOf(
matchesCheck(TouchTargetSizeCheck::class.java),
matchesViews(
withContentDescription("More options")
)
)
)
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ import androidx.preference.PreferenceManager
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.accessibility.AccessibilityChecks
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.internal.runner.junit4.statement.UiThreadStatement
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckResultUtils.matchesCheck
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckResultUtils.matchesViews
import com.google.android.apps.common.testing.accessibility.framework.checks.DuplicateClickableBoundsCheck
import com.google.android.apps.common.testing.accessibility.framework.checks.TouchTargetSizeCheck
import leakcanary.LeakAssertions
import org.hamcrest.Matchers.allOf
import org.hamcrest.Matchers.anyOf
import org.junit.After
import org.junit.Before
import org.junit.Rule
Expand Down Expand Up @@ -96,9 +99,15 @@ class NoteFragmentTest : BaseActivityTest() {
AccessibilityChecks.enable().apply {
setRunChecksFromRootView(true)
setSuppressingResultMatcher(
allOf(
matchesCheck(DuplicateClickableBoundsCheck::class.java),
matchesViews(ViewMatchers.withId(R.id.get_zim_nearby_device))
anyOf(
allOf(
matchesCheck(DuplicateClickableBoundsCheck::class.java),
matchesViews(ViewMatchers.withId(R.id.get_zim_nearby_device))
),
allOf(
matchesCheck(TouchTargetSizeCheck::class.java),
matchesViews(withContentDescription("More options"))
)
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ import androidx.navigation.fragment.NavHostFragment
import androidx.preference.PreferenceManager
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.accessibility.AccessibilityChecks
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckResultUtils.matchesCheck
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckResultUtils.matchesViews
import com.google.android.apps.common.testing.accessibility.framework.checks.TouchTargetSizeCheck
import org.hamcrest.Matchers.allOf
import org.junit.Before
import org.junit.Rule
import org.junit.Test
Expand Down Expand Up @@ -87,7 +92,17 @@ class LibkiwixBookmarkTest : BaseActivityTest() {
}

init {
AccessibilityChecks.enable().setRunChecksFromRootView(true)
AccessibilityChecks.enable().apply {
setRunChecksFromRootView(true)
setSuppressingResultMatcher(
allOf(
matchesCheck(TouchTargetSizeCheck::class.java),
matchesViews(
withContentDescription("More options")
)
)
)
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ import androidx.lifecycle.Lifecycle
import androidx.preference.PreferenceManager
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.accessibility.AccessibilityChecks
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.internal.runner.junit4.statement.UiThreadStatement
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckResultUtils.matchesCheck
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckResultUtils.matchesViews
import com.google.android.apps.common.testing.accessibility.framework.checks.TouchTargetSizeCheck
import leakcanary.LeakAssertions
import org.hamcrest.Matchers.allOf
import org.junit.After
import org.junit.Before
import org.junit.Rule
Expand Down Expand Up @@ -87,7 +92,17 @@ class NavigationHistoryTest : BaseActivityTest() {
}

init {
AccessibilityChecks.enable().setRunChecksFromRootView(true)
AccessibilityChecks.enable().apply {
setRunChecksFromRootView(true)
setSuppressingResultMatcher(
allOf(
matchesCheck(TouchTargetSizeCheck::class.java),
matchesViews(
withContentDescription("More options")
)
)
)
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@ import androidx.lifecycle.Lifecycle
import androidx.preference.PreferenceManager
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.accessibility.AccessibilityChecks
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.internal.runner.junit4.statement.UiThreadStatement
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckResultUtils.matchesCheck
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckResultUtils.matchesViews
import com.google.android.apps.common.testing.accessibility.framework.checks.TouchTargetSizeCheck
import leakcanary.LeakAssertions
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.ResponseBody
import org.hamcrest.Matchers.allOf
import org.junit.After
import org.junit.Before
import org.junit.Rule
Expand Down Expand Up @@ -85,7 +90,17 @@ class KiwixReaderFragmentTest : BaseActivityTest() {
}

init {
AccessibilityChecks.enable().setRunChecksFromRootView(true)
AccessibilityChecks.enable().apply {
setRunChecksFromRootView(true)
setSuppressingResultMatcher(
allOf(
matchesCheck(TouchTargetSizeCheck::class.java),
matchesViews(
withContentDescription("More options")
)
)
)
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ import androidx.lifecycle.Lifecycle
import androidx.preference.PreferenceManager
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.accessibility.AccessibilityChecks
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.internal.runner.junit4.statement.UiThreadStatement
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckResultUtils.matchesCheck
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckResultUtils.matchesViews
import com.google.android.apps.common.testing.accessibility.framework.checks.TouchTargetSizeCheck
import org.hamcrest.Matchers.allOf
import org.junit.After
import org.junit.Assert
import org.junit.Before
Expand Down Expand Up @@ -86,7 +91,17 @@ class ZimFileReaderWithSplittedZimFileTest : BaseActivityTest() {
}

init {
AccessibilityChecks.enable().setRunChecksFromRootView(true)
AccessibilityChecks.enable().apply {
setRunChecksFromRootView(true)
setSuppressingResultMatcher(
allOf(
matchesCheck(TouchTargetSizeCheck::class.java),
matchesViews(
withContentDescription("More options")
)
)
)
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.preference.PreferenceManager
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.accessibility.AccessibilityChecks
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.internal.runner.junit4.statement.UiThreadStatement
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
Expand All @@ -39,6 +40,7 @@ import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.ResponseBody
import org.hamcrest.Matchers.allOf
import org.hamcrest.Matchers.anyOf
import org.junit.After
import org.junit.Before
import org.junit.Rule
Expand Down Expand Up @@ -109,9 +111,17 @@ class SearchFragmentTest : BaseActivityTest() {
AccessibilityChecks.enable().apply {
setRunChecksFromRootView(true)
setSuppressingResultMatcher(
allOf(
matchesCheck(TouchTargetSizeCheck::class.java),
matchesViews(ViewMatchers.withId(id.menu_searchintext))
anyOf(
allOf(
matchesCheck(TouchTargetSizeCheck::class.java),
matchesViews(ViewMatchers.withId(id.menu_searchintext))
),
allOf(
matchesCheck(TouchTargetSizeCheck::class.java),
matchesViews(
withContentDescription("More options")
)
)
)
)
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/fragment_destination_download.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@

<androidx.cardview.widget.CardView
android:id="@+id/onlineLibraryProgressLayout"
style="@style/ThemeOverlay.MaterialComponents.Dialog.Alert"
android:layout_width="140dp"
android:layout_height="100dp"
android:layout_margin="16dp"
Expand Down Expand Up @@ -99,7 +100,7 @@
android:layout_marginTop="8dp"
android:gravity="center"
android:text="@string/reaching_remote_library"
android:textColor="@color/mine_shaft_gray900"
android:textAppearance="?textAppearanceSubtitle1"
android:textSize="10sp"
tools:ignore="SmallSp" />
</LinearLayout>
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/res/layout/layout_donation_bottom_sheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/ThemeOverlay.MaterialComponents.Dialog.Alert"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
Expand All @@ -43,13 +44,12 @@

<TextView
android:id="@+id/titleText"
style="@style/TextAppearance.M3.Sys.Typescale.TitleMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/fullscreen_control_button_margin"
android:text="@string/donation_dialog_title"
android:textSize="16sp"
android:textAppearance="@style/TextAppearance.M3.Sys.Typescale.TitleMedium"
android:textColor="@color/mine_shaft_gray900"
app:layout_constraintStart_toEndOf="@id/heart_icon"
app:layout_constraintTop_toTopOf="@+id/heart_icon" />

Expand All @@ -69,7 +69,7 @@
android:layout_height="wrap_content"
android:padding="@dimen/activity_horizontal_margin"
android:text="@string/rate_dialog_neutral"
android:textColor="@color/denim_blue800"
android:textColor="?attr/colorPrimary"
app:layout_constraintEnd_toStartOf="@+id/donateButton"
app:layout_constraintTop_toBottomOf="@id/descriptionText" />

Expand All @@ -79,7 +79,7 @@
android:layout_height="wrap_content"
android:padding="@dimen/activity_horizontal_margin"
android:text="@string/make_donation"
android:textColor="@color/denim_blue800"
android:textColor="?attr/colorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/descriptionText" />
</androidx.constraintlayout.widget.ConstraintLayout>
Expand Down

0 comments on commit 38400df

Please sign in to comment.