Fixes Issue #6384: java.lang.NullPointerException in ReviewActivity (#6394)
Some checks failed
Android CI / Run tests and generate APK (push) Has been cancelled

* activity_review.xml: add new GUI elements to replace old ones

Before this commit, the info icon shared the same GUI element with the "Skip this image" text.
This made the Kotlin code to handle taps on the info icon difficult to write, and would crash
with a NPE when the user used a language that is read right to left and the info icon was pressed.

This commit creates new GUI elements. Notably, the info icon has it's own element. A LinearLayout
is used to place the skip button and the info icon button together. Kotlin code can now be
simplified and the NPE bug can be fixed.

* ReviewActivity.kt: simplify info icon code to work with some languages

Before this commit, if the language was set to a language that is read right to left,
pressing the info icon would crash the app with a NPE. This was because the Kotlin
code assumed that the icon would always be on the right of the skip button
(index 2 in the drawable array). When a right to left language was used, the icon
would be on the left and index 2 would be null.

This commit builds upon prior GUI changes. The info icon now has its own button.
Kotlin changes now remove the use of the drawable array to find the info icon and
instead directly references the new info icon button. The info icon button now works
properly for both left-to-right and right-to-left languages while maintaining correct
positioning.

* activity_review.xml: fix xml to be more readable

This commit moves around some lines in the XML to make it more readable.

* activity_review.xml: change button configuration

This change simplifies the button configuration XML and makes the info icon button slightly smaller

---------

Co-authored-by: Ritika Pahwa <83745993+RitikaPahwa4444@users.noreply.github.com>
Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
Jason-Whitmore 2025-09-04 23:36:47 -07:00 committed by GitHub
parent 81da5c9a1a
commit 730f314200
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 19 deletions

View file

@ -109,10 +109,8 @@ class ReviewActivity : BaseActivity() {
setUpMediaDetailFragment()
}
binding.skipImage.setOnTouchListener { _, event ->
if (event.action == MotionEvent.ACTION_UP &&
event.rawX >= (binding.skipImage.right - binding.skipImage.compoundDrawables[2].bounds.width())
) {
binding.skipImageInfo?.setOnTouchListener { _, event ->
if (event.action == MotionEvent.ACTION_UP) {
showSkipImageInfo()
true
} else {

View file

@ -24,22 +24,35 @@
android:id="@+id/toolbarBinding"
layout="@layout/toolbar" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/skip_image"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
<LinearLayout
android:id="@+id/skip_image_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:drawableEnd="@drawable/ic_info_outline_24dp"
android:drawablePadding="@dimen/medium_height"
android:drawableTint="@color/button_blue_dark"
android:paddingLeft="@dimen/medium_height"
android:paddingRight="@dimen/medium_height"
android:text="@string/skip_image"
android:textAllCaps="true"
android:textColor="@color/button_blue_dark"
android:textStyle="bold" />
android:orientation="horizontal"
android:gravity="center">
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/skip_image"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingHorizontal="@dimen/tiny_padding"
android:text="@string/skip_image"
android:textAllCaps="true"
android:textColor="@color/button_blue_dark"
android:textStyle="bold" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/skip_image_info"
style="@style/Widget.AppCompat.Button.Borderless"
android:tint="@color/button_blue_dark"
android:layout_width="@dimen/half_standard_height"
android:layout_height="@dimen/half_standard_height"
android:layout_marginStart="@dimen/small_gap"
android:src="@drawable/ic_info_outline_24dp" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"