mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Fixes Issue #6384: java.lang.NullPointerException in ReviewActivity (#6394)
Some checks failed
Android CI / Run tests and generate APK (push) Has been cancelled
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:
parent
81da5c9a1a
commit
730f314200
2 changed files with 30 additions and 19 deletions
|
|
@ -109,10 +109,8 @@ class ReviewActivity : BaseActivity() {
|
||||||
setUpMediaDetailFragment()
|
setUpMediaDetailFragment()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.skipImage.setOnTouchListener { _, event ->
|
binding.skipImageInfo?.setOnTouchListener { _, event ->
|
||||||
if (event.action == MotionEvent.ACTION_UP &&
|
if (event.action == MotionEvent.ACTION_UP) {
|
||||||
event.rawX >= (binding.skipImage.right - binding.skipImage.compoundDrawables[2].bounds.width())
|
|
||||||
) {
|
|
||||||
showSkipImageInfo()
|
showSkipImageInfo()
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,12 @@
|
||||||
android:id="@+id/toolbarBinding"
|
android:id="@+id/toolbarBinding"
|
||||||
layout="@layout/toolbar" />
|
layout="@layout/toolbar" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/skip_image_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatButton
|
<androidx.appcompat.widget.AppCompatButton
|
||||||
android:id="@+id/skip_image"
|
android:id="@+id/skip_image"
|
||||||
|
|
@ -31,16 +37,23 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:drawableEnd="@drawable/ic_info_outline_24dp"
|
android:paddingHorizontal="@dimen/tiny_padding"
|
||||||
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:text="@string/skip_image"
|
||||||
android:textAllCaps="true"
|
android:textAllCaps="true"
|
||||||
android:textColor="@color/button_blue_dark"
|
android:textColor="@color/button_blue_dark"
|
||||||
android:textStyle="bold" />
|
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
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue