Merge pull request #1454 from Mike-Antonacci/improve-task-tap-areas

Improve task tap areas
This commit is contained in:
Phillip Thelen 2021-01-28 13:23:01 +01:00 committed by GitHub
commit b82f451cf5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 109 additions and 15 deletions

View file

@ -0,0 +1,69 @@
{
"project_info": {
"project_number": "786261551143",
"firebase_url": "https://habitica-3ad69.firebaseio.com",
"project_id": "habitica-3ad69",
"storage_bucket": "habitica-3ad69.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:786261551143:android:5a836986630180e50a0602",
"android_client_info": {
"package_name": "com.habitrpg.android.habitica"
}
},
"oauth_client": [
{
"client_id": "786261551143-i8c0j6s3p3sasfb2ov16sdl4du1anhvp.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyCx53gb7IXtpfeD_5NmICGGwPCsAzW9ybM"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "786261551143-i8c0j6s3p3sasfb2ov16sdl4du1anhvp.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:786261551143:android:6b6c6fdc44b197540a0602",
"android_client_info": {
"package_name": "com.habitrpg.android.habitica.debug"
}
},
"oauth_client": [
{
"client_id": "786261551143-i8c0j6s3p3sasfb2ov16sdl4du1anhvp.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyCx53gb7IXtpfeD_5NmICGGwPCsAzW9ybM"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "786261551143-i8c0j6s3p3sasfb2ov16sdl4du1anhvp.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}

View file

@ -40,12 +40,13 @@
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/caret_view"
android:layout_width="wrap_content"
android:layout_width="14dp"
android:layout_height="wrap_content"
android:src="@drawable/ic_keyboard_arrow_down_black_24dp"
android:layout_marginEnd="@dimen/spacing_large"/>
android:layout_marginEnd="@dimen/spacing_large"
android:src="@drawable/ic_keyboard_arrow_down_black_24dp" />
</LinearLayout>
<TextView android:id="@+id/description_view"
android:layout_width="match_parent"

View file

@ -238,12 +238,40 @@ abstract class BaseTaskViewHolder constructor(itemView: View, var scoreTaskFunc:
if (motionEvent != null) {
if (motionEvent.action != MotionEvent.ACTION_UP) return true
if (motionEvent.y <= mainTaskWrapper.height + 5.dpToPx(context)) {
if (motionEvent.x <= 60.dpToPx(context)) {
onLeftActionTouched()
return true
} else if ((itemView.width - motionEvent.x <= 60.dpToPx(context))) {
onRightActionTouched()
return true
if ((this.task?.checklist?.isNotEmpty() != true)) {
if (motionEvent.x <= 72.dpToPx(context)) {
onLeftActionTouched()
return true
} else if ((itemView.width - motionEvent.x <= 72.dpToPx(context))) {
onRightActionTouched()
return true
}
} else {
val checkboxHolder: ViewGroup = itemView.findViewById(R.id.checkBoxHolder)
if (mainTaskWrapper.height == checkboxHolder.height) {
if (motionEvent.x <= 72.dpToPx(context)) {
onLeftActionTouched()
return true
} else if ((itemView.width - motionEvent.x <= 72.dpToPx(context))) {
onRightActionTouched()
return true
}
} else {
if (motionEvent.y <= (checkboxHolder.height + 5.dpToPx(context))) {
if (motionEvent.x <= 72.dpToPx(context)) {
onLeftActionTouched()
return true
} else if ((itemView.width - motionEvent.x <= 72.dpToPx(context))) {
onRightActionTouched()
return true
}
} else if ((motionEvent.y > (checkboxHolder.height + 5.dpToPx(context)))) {
if (motionEvent.x <= 72.dpToPx(context)) {
onLeftActionTouched()
return true
}
}
}
}
}
}
@ -259,4 +287,4 @@ abstract class BaseTaskViewHolder constructor(itemView: View, var scoreTaskFunc:
this.openTaskDisabled = openTaskDisabled
this.taskActionsDisabled = taskActionsDisabled
}
}
}

View file

@ -2,11 +2,7 @@ package com.habitrpg.android.habitica.ui.viewHolders.tasks
import android.content.Context
import android.graphics.PorterDuff
import android.graphics.Rect
import android.view.LayoutInflater
import android.view.TouchDelegate
import android.view.View
import android.view.ViewGroup
import android.view.*
import android.widget.*
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.LinearLayoutManager