mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-02-03 09:17:34 +01:00
show phone number and date at Recents too
This commit is contained in:
parent
71f3e8cb0c
commit
29c59f498a
@ -481,7 +481,9 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||
|
||||
if (refreshTabsMask and RECENTS_TAB_MASK != 0) {
|
||||
ContactsHelper(this).getRecents {
|
||||
recents_fragment?.updateRecentCalls(it)
|
||||
runOnUiThread {
|
||||
recents_fragment?.updateRecentCalls(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import android.view.Menu
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.views.FastScroller
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
import com.simplemobiletools.contacts.R
|
||||
@ -62,6 +63,17 @@ class RecentCallsAdapter(activity: SimpleActivity, var recentCalls: ArrayList<Re
|
||||
text = recentCall.name ?: recentCall.number
|
||||
setTextColor(textColor)
|
||||
}
|
||||
|
||||
recent_call_number.apply {
|
||||
beVisibleIf(recentCall.name != null)
|
||||
text = recentCall.number
|
||||
setTextColor(textColor)
|
||||
}
|
||||
|
||||
recent_call_date_time.apply {
|
||||
text = recentCall.date.toString()
|
||||
setTextColor(textColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,13 +9,9 @@ import com.simplemobiletools.contacts.models.RecentCall
|
||||
import kotlinx.android.synthetic.main.fragment_layout.view.*
|
||||
|
||||
class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) {
|
||||
override fun fabClicked() {
|
||||
finishActMode()
|
||||
}
|
||||
override fun fabClicked() {}
|
||||
|
||||
override fun placeholderClicked() {
|
||||
|
||||
}
|
||||
override fun placeholderClicked() {}
|
||||
|
||||
fun updateRecentCalls(recentCalls: ArrayList<RecentCall>) {
|
||||
if (activity == null || activity!!.isActivityDestroyed()) {
|
||||
@ -33,6 +29,8 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
||||
addVerticalDividers(true)
|
||||
fragment_list.adapter = this
|
||||
}
|
||||
|
||||
fragment_fastscroller.setViews(fragment_list) {}
|
||||
} else {
|
||||
(currAdapter as RecentCallsAdapter).updateItems(recentCalls)
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ import com.simplemobiletools.contacts.R
|
||||
import com.simplemobiletools.contacts.extensions.*
|
||||
import com.simplemobiletools.contacts.models.*
|
||||
import com.simplemobiletools.contacts.overloads.times
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
class ContactsHelper(val activity: Activity) {
|
||||
private val BATCH_SIZE = 100
|
||||
@ -1326,7 +1328,6 @@ class ContactsHelper(val activity: Activity) {
|
||||
CallLog.Calls._ID,
|
||||
CallLog.Calls.NUMBER,
|
||||
CallLog.Calls.DATE,
|
||||
CallLog.Calls.DURATION,
|
||||
CallLog.Calls.CACHED_NAME,
|
||||
CallLog.Calls.TYPE
|
||||
)
|
||||
@ -1341,10 +1342,11 @@ class ContactsHelper(val activity: Activity) {
|
||||
val id = cursor.getIntValue(CallLog.Calls._ID)
|
||||
val number = cursor.getStringValue(CallLog.Calls.NUMBER)
|
||||
val date = cursor.getLongValue(CallLog.Calls.DATE)
|
||||
val duration = cursor.getIntValue(CallLog.Calls.DURATION)
|
||||
val name = cursor.getStringValue(CallLog.Calls.CACHED_NAME)
|
||||
val type = cursor.getIntValue(CallLog.Calls.TYPE)
|
||||
val recentCall = RecentCall(id, number, date, duration, name, type)
|
||||
|
||||
val formattedDate = SimpleDateFormat("dd.MM.yyyy, HH:mm", Locale.getDefault()).format(Date(date))
|
||||
val recentCall = RecentCall(id, number, formattedDate, name, type)
|
||||
calls.add(recentCall)
|
||||
} while (cursor.moveToNext())
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
package com.simplemobiletools.contacts.models
|
||||
|
||||
data class RecentCall(var id: Int, var number: String, var date: Long, var duration: Int, var name: String?, var type: Int)
|
||||
data class RecentCall(var id: Int, var number: String, var date: String, var name: String?, var type: Int)
|
||||
|
@ -13,19 +13,40 @@
|
||||
<RelativeLayout
|
||||
android:id="@+id/recent_call_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="@dimen/contact_item_height"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/recent_call_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/contact_item_height"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:textSize="@dimen/big_text_size"
|
||||
tools:text="John Doe"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/recent_call_number"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/recent_call_name"
|
||||
android:layout_toLeftOf="@+id/recent_call_date_time"
|
||||
android:maxLines="1"
|
||||
android:textSize="@dimen/bigger_text_size"
|
||||
tools:text="0123 456 789"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/recent_call_date_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@+id/recent_call_name"
|
||||
android:gravity="right"
|
||||
android:maxLines="1"
|
||||
android:textSize="@dimen/bigger_text_size"
|
||||
tools:text="Today, 17:00"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</FrameLayout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user