show the contacts ringtone at the View screen

This commit is contained in:
tibbi 2021-02-14 16:03:54 +01:00
parent 5b6fce0535
commit 8c488ba5ca
4 changed files with 97 additions and 45 deletions

View File

@ -2,6 +2,8 @@ package com.simplemobiletools.contacts.pro.activities
import android.content.ContentUris
import android.content.Intent
import android.media.RingtoneManager
import android.net.Uri
import android.os.Bundle
import android.provider.ContactsContract
import android.view.View
@ -170,7 +172,7 @@ class ViewContactActivity : ContactActivity() {
val textColor = config.textColor
arrayOf(contact_name_image, contact_numbers_image, contact_emails_image, contact_addresses_image, contact_events_image, contact_source_image,
contact_notes_image, contact_organization_image, contact_websites_image, contact_groups_image).forEach {
contact_notes_image, contact_ringtone_image, contact_organization_image, contact_websites_image, contact_groups_image).forEach {
it.applyColorFilter(textColor)
}
@ -212,6 +214,7 @@ class ViewContactActivity : ContactActivity() {
setupGroups()
setupContactSources()
setupNotes()
setupRingtone()
setupOrganization()
updateTextColors(contact_scrollview)
}
@ -566,6 +569,20 @@ class ViewContactActivity : ContactActivity() {
}
}
private fun setupRingtone() {
val ringtone = contact!!.ringtone
if (ringtone != null && ringtone.isNotEmpty() && showFields and SHOW_RINGTONE != 0) {
val contactRingtone = RingtoneManager.getRingtone(this, Uri.parse(ringtone))
contact_ringtone.text = contactRingtone.getTitle(this)
contact_ringtone_image.beVisible()
contact_ringtone.beVisible()
contact_ringtone.setOnClickListener { }
} else {
contact_ringtone_image.beGone()
contact_ringtone.beGone()
}
}
private fun setupOrganization() {
val organization = contact!!.organization
if (organization.isNotEmpty() && showFields and SHOW_ORGANIZATION_FIELD != 0) {

View File

@ -30,6 +30,7 @@ class ManageVisibleFieldsDialog(val activity: BaseSimpleActivity) {
put(SHOW_WEBSITES_FIELD, R.id.manage_visible_fields_websites)
put(SHOW_GROUPS_FIELD, R.id.manage_visible_fields_groups)
put(SHOW_CONTACT_SOURCE_FIELD, R.id.manage_visible_fields_contact_source)
put(SHOW_RINGTONE, R.id.manage_ringtone)
}
val showContactFields = activity.config.showContactFields
@ -38,11 +39,11 @@ class ManageVisibleFieldsDialog(val activity: BaseSimpleActivity) {
}
AlertDialog.Builder(activity)
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
.setNegativeButton(R.string.cancel, null)
.create().apply {
activity.setupDialogStuff(view, this)
}
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
.setNegativeButton(R.string.cancel, null)
.create().apply {
activity.setupDialogStuff(view, this)
}
}
private fun dialogConfirmed() {

View File

@ -117,9 +117,9 @@
android:paddingTop="@dimen/normal_margin"
android:paddingEnd="@dimen/normal_margin"
android:paddingBottom="@dimen/normal_margin"
android:tooltipText="John Doe"
android:singleLine="true"
android:textSize="@dimen/bigger_text_size" />
android:textSize="@dimen/bigger_text_size"
android:tooltipText="John Doe" />
<ImageView
android:id="@+id/contact_numbers_image"
@ -193,6 +193,18 @@
android:src="@drawable/ic_label_vector"
android:visibility="gone" />
<ImageView
android:id="@+id/contact_ringtone_image"
android:layout_width="@dimen/contact_icons_size"
android:layout_height="@dimen/contact_icons_size"
android:layout_alignTop="@+id/contact_ringtone"
android:layout_marginStart="@dimen/normal_margin"
android:paddingTop="@dimen/medium_margin"
android:paddingEnd="@dimen/small_margin"
android:paddingBottom="@dimen/small_margin"
android:src="@drawable/ic_bell_vector"
android:visibility="gone" />
<ImageView
android:id="@+id/contact_organization_image"
android:layout_width="@dimen/contact_icons_size"
@ -329,11 +341,26 @@
android:visibility="gone" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/contact_organization_company"
android:id="@+id/contact_ringtone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/contact_notes"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/contact_ringtone_image"
android:background="?attr/selectableItemBackground"
android:lineSpacingExtra="@dimen/medium_margin"
android:paddingStart="@dimen/small_margin"
android:paddingTop="@dimen/normal_margin"
android:paddingBottom="@dimen/normal_margin"
android:textSize="@dimen/bigger_text_size"
android:visibility="gone" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/contact_organization_company"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/contact_ringtone"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/contact_organization_image"
android:background="?attr/selectableItemBackground"
android:lineSpacingExtra="@dimen/medium_margin"

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/manage_visible_fields_scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -11,136 +10,144 @@
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin">
android:paddingTop="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/manage_visible_fields_prefix"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/prefix"/>
android:paddingBottom="@dimen/activity_margin"
android:text="@string/prefix" />
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/manage_visible_fields_first_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/first_name"/>
android:paddingBottom="@dimen/activity_margin"
android:text="@string/first_name" />
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/manage_visible_fields_middle_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/middle_name"/>
android:paddingBottom="@dimen/activity_margin"
android:text="@string/middle_name" />
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/manage_visible_fields_surname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/surname"/>
android:paddingBottom="@dimen/activity_margin"
android:text="@string/surname" />
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/manage_visible_fields_suffix"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/suffix"/>
android:paddingBottom="@dimen/activity_margin"
android:text="@string/suffix" />
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/manage_visible_fields_nickname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/nickname"/>
android:paddingBottom="@dimen/activity_margin"
android:text="@string/nickname" />
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/manage_visible_fields_phone_numbers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/phone_numbers"/>
android:paddingBottom="@dimen/activity_margin"
android:text="@string/phone_numbers" />
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/manage_visible_fields_emails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/emails"/>
android:paddingBottom="@dimen/activity_margin"
android:text="@string/emails" />
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/manage_visible_fields_addresses"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/addresses"/>
android:paddingBottom="@dimen/activity_margin"
android:text="@string/addresses" />
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/manage_visible_fields_ims"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/instant_messaging"/>
android:paddingBottom="@dimen/activity_margin"
android:text="@string/instant_messaging" />
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/manage_visible_fields_events"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/events"/>
android:paddingBottom="@dimen/activity_margin"
android:text="@string/events" />
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/manage_visible_fields_notes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/notes"/>
android:paddingBottom="@dimen/activity_margin"
android:text="@string/notes" />
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/manage_ringtone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin"
android:text="@string/ringtone" />
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/manage_visible_fields_organization"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/organization"/>
android:paddingBottom="@dimen/activity_margin"
android:text="@string/organization" />
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/manage_visible_fields_websites"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/websites"/>
android:paddingBottom="@dimen/activity_margin"
android:text="@string/websites" />
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/manage_visible_fields_groups"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/groups"/>
android:paddingBottom="@dimen/activity_margin"
android:text="@string/groups" />
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/manage_visible_fields_contact_source"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/contact_source"/>
android:paddingBottom="@dimen/activity_margin"
android:text="@string/contact_source" />
</LinearLayout>
</ScrollView>