mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
show phone number and date at Recents too
This commit is contained in:
@ -481,11 +481,13 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
|||||||
|
|
||||||
if (refreshTabsMask and RECENTS_TAB_MASK != 0) {
|
if (refreshTabsMask and RECENTS_TAB_MASK != 0) {
|
||||||
ContactsHelper(this).getRecents {
|
ContactsHelper(this).getRecents {
|
||||||
|
runOnUiThread {
|
||||||
recents_fragment?.updateRecentCalls(it)
|
recents_fragment?.updateRecentCalls(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun getAllFragments() = arrayListOf(contacts_fragment, favorites_fragment, groups_fragment)
|
private fun getAllFragments() = arrayListOf(contacts_fragment, favorites_fragment, groups_fragment)
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import android.view.Menu
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||||
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.views.FastScroller
|
import com.simplemobiletools.commons.views.FastScroller
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.contacts.R
|
import com.simplemobiletools.contacts.R
|
||||||
@ -62,6 +63,17 @@ class RecentCallsAdapter(activity: SimpleActivity, var recentCalls: ArrayList<Re
|
|||||||
text = recentCall.name ?: recentCall.number
|
text = recentCall.name ?: recentCall.number
|
||||||
setTextColor(textColor)
|
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.*
|
import kotlinx.android.synthetic.main.fragment_layout.view.*
|
||||||
|
|
||||||
class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) {
|
class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) {
|
||||||
override fun fabClicked() {
|
override fun fabClicked() {}
|
||||||
finishActMode()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun placeholderClicked() {
|
override fun placeholderClicked() {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fun updateRecentCalls(recentCalls: ArrayList<RecentCall>) {
|
fun updateRecentCalls(recentCalls: ArrayList<RecentCall>) {
|
||||||
if (activity == null || activity!!.isActivityDestroyed()) {
|
if (activity == null || activity!!.isActivityDestroyed()) {
|
||||||
@ -33,6 +29,8 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||||||
addVerticalDividers(true)
|
addVerticalDividers(true)
|
||||||
fragment_list.adapter = this
|
fragment_list.adapter = this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fragment_fastscroller.setViews(fragment_list) {}
|
||||||
} else {
|
} else {
|
||||||
(currAdapter as RecentCallsAdapter).updateItems(recentCalls)
|
(currAdapter as RecentCallsAdapter).updateItems(recentCalls)
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@ import com.simplemobiletools.contacts.R
|
|||||||
import com.simplemobiletools.contacts.extensions.*
|
import com.simplemobiletools.contacts.extensions.*
|
||||||
import com.simplemobiletools.contacts.models.*
|
import com.simplemobiletools.contacts.models.*
|
||||||
import com.simplemobiletools.contacts.overloads.times
|
import com.simplemobiletools.contacts.overloads.times
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
class ContactsHelper(val activity: Activity) {
|
class ContactsHelper(val activity: Activity) {
|
||||||
private val BATCH_SIZE = 100
|
private val BATCH_SIZE = 100
|
||||||
@ -1326,7 +1328,6 @@ class ContactsHelper(val activity: Activity) {
|
|||||||
CallLog.Calls._ID,
|
CallLog.Calls._ID,
|
||||||
CallLog.Calls.NUMBER,
|
CallLog.Calls.NUMBER,
|
||||||
CallLog.Calls.DATE,
|
CallLog.Calls.DATE,
|
||||||
CallLog.Calls.DURATION,
|
|
||||||
CallLog.Calls.CACHED_NAME,
|
CallLog.Calls.CACHED_NAME,
|
||||||
CallLog.Calls.TYPE
|
CallLog.Calls.TYPE
|
||||||
)
|
)
|
||||||
@ -1341,10 +1342,11 @@ class ContactsHelper(val activity: Activity) {
|
|||||||
val id = cursor.getIntValue(CallLog.Calls._ID)
|
val id = cursor.getIntValue(CallLog.Calls._ID)
|
||||||
val number = cursor.getStringValue(CallLog.Calls.NUMBER)
|
val number = cursor.getStringValue(CallLog.Calls.NUMBER)
|
||||||
val date = cursor.getLongValue(CallLog.Calls.DATE)
|
val date = cursor.getLongValue(CallLog.Calls.DATE)
|
||||||
val duration = cursor.getIntValue(CallLog.Calls.DURATION)
|
|
||||||
val name = cursor.getStringValue(CallLog.Calls.CACHED_NAME)
|
val name = cursor.getStringValue(CallLog.Calls.CACHED_NAME)
|
||||||
val type = cursor.getIntValue(CallLog.Calls.TYPE)
|
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)
|
calls.add(recentCall)
|
||||||
} while (cursor.moveToNext())
|
} while (cursor.moveToNext())
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
package com.simplemobiletools.contacts.models
|
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
|
<RelativeLayout
|
||||||
android:id="@+id/recent_call_holder"
|
android:id="@+id/recent_call_holder"
|
||||||
android:layout_width="match_parent"
|
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">
|
android:paddingRight="@dimen/activity_margin">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/recent_call_name"
|
android:id="@+id/recent_call_name"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/contact_item_height"
|
android:layout_height="wrap_content"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:paddingLeft="@dimen/activity_margin"
|
|
||||||
android:textSize="@dimen/big_text_size"
|
android:textSize="@dimen/big_text_size"
|
||||||
tools:text="John Doe"/>
|
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>
|
</RelativeLayout>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
Reference in New Issue
Block a user