mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-16 16:27:23 +02:00
adding some cross and check icons to checklist items
This commit is contained in:
parent
2d61509590
commit
0babf17c63
@ -51,7 +51,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:5.5.14'
|
implementation 'com.simplemobiletools:commons:5.5.15'
|
||||||
|
|
||||||
kapt 'androidx.room:room-compiler:2.0.0'
|
kapt 'androidx.room:room-compiler:2.0.0'
|
||||||
implementation 'androidx.room:room-runtime:2.0.0'
|
implementation 'androidx.room:room-runtime:2.0.0'
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package com.simplemobiletools.notes.pro.adapters
|
package com.simplemobiletools.notes.pro.adapters
|
||||||
|
|
||||||
import android.graphics.Paint
|
import android.graphics.Paint
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||||
|
import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
|
||||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.notes.pro.R
|
import com.simplemobiletools.notes.pro.R
|
||||||
@ -16,8 +18,12 @@ import java.util.*
|
|||||||
class ChecklistAdapter(activity: BaseSimpleActivity, var items: ArrayList<ChecklistItem>, val listener: RefreshRecyclerViewListener?,
|
class ChecklistAdapter(activity: BaseSimpleActivity, var items: ArrayList<ChecklistItem>, val listener: RefreshRecyclerViewListener?,
|
||||||
recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) {
|
recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) {
|
||||||
|
|
||||||
|
private lateinit var crossDrawable: Drawable
|
||||||
|
private lateinit var checkDrawable: Drawable
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setupDragListener(true)
|
setupDragListener(true)
|
||||||
|
initDrawables()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getActionMenuId() = R.menu.cab_delete_only
|
override fun getActionMenuId() = R.menu.cab_delete_only
|
||||||
@ -46,6 +52,12 @@ class ChecklistAdapter(activity: BaseSimpleActivity, var items: ArrayList<Checkl
|
|||||||
|
|
||||||
override fun getItemCount() = items.size
|
override fun getItemCount() = items.size
|
||||||
|
|
||||||
|
fun initDrawables() {
|
||||||
|
val res = activity.resources
|
||||||
|
crossDrawable = res.getColoredDrawableWithColor(R.drawable.ic_cross_big, res.getColor(R.color.theme_dark_red_primary_color))
|
||||||
|
checkDrawable = res.getColoredDrawableWithColor(R.drawable.ic_check_big, res.getColor(R.color.md_green_700))
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupView(view: View, checklistItem: ChecklistItem) {
|
private fun setupView(view: View, checklistItem: ChecklistItem) {
|
||||||
val isSelected = selectedKeys.contains(checklistItem.id)
|
val isSelected = selectedKeys.contains(checklistItem.id)
|
||||||
view.apply {
|
view.apply {
|
||||||
@ -61,6 +73,8 @@ class ChecklistAdapter(activity: BaseSimpleActivity, var items: ArrayList<Checkl
|
|||||||
alpha = 1f
|
alpha = 1f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checklist_image.setImageDrawable(if (checklistItem.isDone) checkDrawable else crossDrawable)
|
||||||
checklist_holder.isSelected = isSelected
|
checklist_holder.isSelected = isSelected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/checklist_holder"
|
android:id="@+id/checklist_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:foreground="@drawable/selector"
|
android:foreground="@drawable/selector">
|
||||||
android:padding="@dimen/activity_margin">
|
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
android:id="@+id/checklist_title"
|
android:id="@+id/checklist_title"
|
||||||
@ -18,6 +18,18 @@
|
|||||||
android:layout_marginLeft="@dimen/medium_margin"
|
android:layout_marginLeft="@dimen/medium_margin"
|
||||||
android:layout_marginTop="@dimen/medium_margin"
|
android:layout_marginTop="@dimen/medium_margin"
|
||||||
android:layout_marginRight="@dimen/medium_margin"
|
android:layout_marginRight="@dimen/medium_margin"
|
||||||
android:textSize="@dimen/bigger_text_size"/>
|
android:layout_toLeftOf="@+id/checklist_image"
|
||||||
|
android:paddingLeft="@dimen/activity_margin"
|
||||||
|
android:textSize="@dimen/bigger_text_size"
|
||||||
|
tools:text="Butter"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/checklist_image"
|
||||||
|
android:layout_width="@dimen/checklist_image_size"
|
||||||
|
android:layout_height="@dimen/checklist_image_size"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:padding="@dimen/normal_margin"
|
||||||
|
android:src="@drawable/ic_cross_big"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
3
app/src/main/res/values/dimens.xml
Normal file
3
app/src/main/res/values/dimens.xml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<resources>
|
||||||
|
<dimen name="checklist_image_size">64dp</dimen>
|
||||||
|
</resources>
|
@ -1,7 +1,7 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.3.10'
|
ext.kotlin_version = '1.3.11'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user