mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-06-05 21:49:23 +02:00
adding an icon at the Recent calls listview
This commit is contained in:
@ -8,11 +8,13 @@ import com.bumptech.glide.Glide
|
|||||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.extensions.formatDateOrTime
|
import com.simplemobiletools.commons.extensions.formatDateOrTime
|
||||||
|
import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
|
||||||
import com.simplemobiletools.commons.extensions.getFormattedDuration
|
import com.simplemobiletools.commons.extensions.getFormattedDuration
|
||||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.dialer.R
|
import com.simplemobiletools.dialer.R
|
||||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.dialer.extensions.config
|
||||||
import com.simplemobiletools.dialer.models.RecentCall
|
import com.simplemobiletools.dialer.models.RecentCall
|
||||||
import kotlinx.android.synthetic.main.item_recent_call.view.*
|
import kotlinx.android.synthetic.main.item_recent_call.view.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@ -20,6 +22,9 @@ import java.util.*
|
|||||||
class RecentCallsAdapter(activity: SimpleActivity, var recentCalls: ArrayList<RecentCall>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
|
class RecentCallsAdapter(activity: SimpleActivity, var recentCalls: ArrayList<RecentCall>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
|
||||||
MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) {
|
MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) {
|
||||||
|
|
||||||
|
private val incomingCallIcon = activity.resources.getColoredDrawableWithColor(R.drawable.ic_incoming_call_vector, activity.config.textColor)
|
||||||
|
private val outgoingCallIcon = activity.resources.getColoredDrawableWithColor(R.drawable.ic_outgoing_call_vector, activity.config.textColor)
|
||||||
|
|
||||||
override fun getActionMenuId() = 0
|
override fun getActionMenuId() = 0
|
||||||
|
|
||||||
override fun prepareActionMode(menu: Menu) {}
|
override fun prepareActionMode(menu: Menu) {}
|
||||||
@ -66,6 +71,14 @@ class RecentCallsAdapter(activity: SimpleActivity, var recentCalls: ArrayList<Re
|
|||||||
item_recents_duration.text = call.duration.getFormattedDuration()
|
item_recents_duration.text = call.duration.getFormattedDuration()
|
||||||
|
|
||||||
SimpleContactsHelper(context).loadContactImage(call.photoUri, item_recents_image, call.name)
|
SimpleContactsHelper(context).loadContactImage(call.photoUri, item_recents_image, call.name)
|
||||||
|
|
||||||
|
val drawable = if (call.type == Calls.OUTGOING_TYPE) {
|
||||||
|
outgoingCallIcon
|
||||||
|
} else {
|
||||||
|
incomingCallIcon
|
||||||
|
}
|
||||||
|
|
||||||
|
item_recents_type.setImageDrawable(drawable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,14 +37,25 @@
|
|||||||
android:textSize="@dimen/bigger_text_size"
|
android:textSize="@dimen/bigger_text_size"
|
||||||
tools:text="John Doe" />
|
tools:text="John Doe" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/item_recents_type"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignTop="@+id/item_recents_date_time"
|
||||||
|
android:layout_alignBottom="@+id/item_recents_date_time"
|
||||||
|
android:layout_marginEnd="@dimen/tiny_margin"
|
||||||
|
android:layout_toEndOf="@+id/item_recents_image"
|
||||||
|
android:alpha="0.6"
|
||||||
|
android:paddingTop="@dimen/tiny_margin"
|
||||||
|
android:paddingBottom="@dimen/tiny_margin"
|
||||||
|
android:src="@drawable/ic_incoming_call_vector" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/item_recents_date_time"
|
android:id="@+id/item_recents_date_time"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/item_recents_name"
|
android:layout_below="@+id/item_recents_name"
|
||||||
android:layout_alignStart="@+id/item_recents_name"
|
android:layout_toEndOf="@+id/item_recents_type"
|
||||||
android:layout_toStartOf="@+id/item_recents_duration"
|
|
||||||
android:layout_toEndOf="@+id/item_recents_image"
|
|
||||||
android:alpha="0.6"
|
android:alpha="0.6"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textSize="@dimen/normal_text_size"
|
android:textSize="@dimen/normal_text_size"
|
||||||
@ -56,7 +67,9 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/item_recents_name"
|
android:layout_below="@+id/item_recents_name"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_toEndOf="@+id/item_recents_date_time"
|
||||||
android:alpha="0.6"
|
android:alpha="0.6"
|
||||||
|
android:gravity="end"
|
||||||
android:textSize="@dimen/normal_text_size"
|
android:textSize="@dimen/normal_text_size"
|
||||||
tools:text="00:10" />
|
tools:text="00:10" />
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user