From 40777553fef32cabb294f505bff6c937b73f4e85 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 4 Aug 2018 23:11:19 +0200 Subject: [PATCH] add a placeholder button for requesting permissions for displaying Recent Calls --- .../contacts/fragments/MyViewPagerFragment.kt | 5 ++++- .../contacts/fragments/RecentsFragment.kt | 12 +++++++++++- app/src/main/res/values-az/strings.xml | 1 + app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values-el/strings.xml | 1 + app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values-hr/strings.xml | 1 + app/src/main/res/values-ja/strings.xml | 1 + app/src/main/res/values-ko-rKR/strings.xml | 1 + app/src/main/res/values-lt/strings.xml | 1 + app/src/main/res/values-pt/strings.xml | 1 + app/src/main/res/values-ru/strings.xml | 1 + app/src/main/res/values-sk/strings.xml | 1 + app/src/main/res/values-sv/strings.xml | 1 + app/src/main/res/values-tr/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 17 files changed, 30 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/fragments/MyViewPagerFragment.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/fragments/MyViewPagerFragment.kt index 7e0c03fe..09e9b6e4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/fragments/MyViewPagerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/fragments/MyViewPagerFragment.kt @@ -58,7 +58,10 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) fragment_placeholder.text = activity.getString(R.string.no_group_created) fragment_placeholder_2.text = activity.getString(R.string.create_group) } - this is RecentsFragment -> fragment_fab.beGone() + this is RecentsFragment -> { + fragment_fab.beGone() + fragment_placeholder_2.text = activity.getString(R.string.request_the_required_permissions) + } } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/fragments/RecentsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/fragments/RecentsFragment.kt index d8ac307c..30b16f79 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/fragments/RecentsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/fragments/RecentsFragment.kt @@ -4,12 +4,15 @@ import android.content.Context import android.content.Intent import android.util.AttributeSet import com.simplemobiletools.commons.extensions.beVisibleIf +import com.simplemobiletools.commons.extensions.hasPermission import com.simplemobiletools.commons.extensions.isActivityDestroyed +import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_CALL_LOG import com.simplemobiletools.contacts.activities.EditContactActivity import com.simplemobiletools.contacts.adapters.RecentCallsAdapter import com.simplemobiletools.contacts.extensions.contactClicked import com.simplemobiletools.contacts.helpers.KEY_PHONE import com.simplemobiletools.contacts.helpers.PHONE_NUMBER_PATTERN +import com.simplemobiletools.contacts.helpers.RECENTS_TAB_MASK import com.simplemobiletools.contacts.models.Contact import com.simplemobiletools.contacts.models.RecentCall import kotlinx.android.synthetic.main.fragment_layout.view.* @@ -17,7 +20,13 @@ import kotlinx.android.synthetic.main.fragment_layout.view.* class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) { override fun fabClicked() {} - override fun placeholderClicked() {} + override fun placeholderClicked() { + activity!!.handlePermission(PERMISSION_WRITE_CALL_LOG) { + if (it) { + activity?.refreshContacts(RECENTS_TAB_MASK) + } + } + } fun updateRecentCalls(recentCalls: ArrayList) { if (activity == null || activity!!.isActivityDestroyed()) { @@ -25,6 +34,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage } fragment_placeholder.beVisibleIf(recentCalls.isEmpty()) + fragment_placeholder_2.beVisibleIf(recentCalls.isEmpty() && !activity!!.hasPermission(PERMISSION_WRITE_CALL_LOG)) fragment_list.beVisibleIf(recentCalls.isNotEmpty()) val currAdapter = fragment_list.adapter diff --git a/app/src/main/res/values-az/strings.xml b/app/src/main/res/values-az/strings.xml index 3e362b2d..46f4c74a 100644 --- a/app/src/main/res/values-az/strings.xml +++ b/app/src/main/res/values-az/strings.xml @@ -14,6 +14,7 @@ Grupa SMS göndər Grupa e-poçt göndər Call %s + Request the required permissions Yeni kontakt Redaktə et diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index a1527c07..0ebec726 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -14,6 +14,7 @@ Sende SMS an Gruppe Sende E-Mail an Gruppe Call %s + Request the required permissions Neuer Kontakt Kontakt bearbeiten diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 7af6ada3..3e7c89a8 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -14,6 +14,7 @@ Send SMS to group Send email to group Call %s + Request the required permissions Νέα επαφή Επεξεργασία επαφής diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 3dec8f48..78acf3e7 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -14,6 +14,7 @@ Envoyer un SMS au groupe Envoyer un e-mail au groupe Call %s + Request the required permissions Nouveau contact Modifier contact diff --git a/app/src/main/res/values-hr/strings.xml b/app/src/main/res/values-hr/strings.xml index 4bc2b827..5e46bb0a 100644 --- a/app/src/main/res/values-hr/strings.xml +++ b/app/src/main/res/values-hr/strings.xml @@ -14,6 +14,7 @@ Send SMS to group Send email to group Call %s + Request the required permissions Novi kontakt Uredi kontakt diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 703b96d8..31ec9b66 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -14,6 +14,7 @@ グループにSMSを送信 グループにメールを送信 Call %s + Request the required permissions 新しい連絡先 連絡先を編集 diff --git a/app/src/main/res/values-ko-rKR/strings.xml b/app/src/main/res/values-ko-rKR/strings.xml index 7b62c688..ed854ef9 100644 --- a/app/src/main/res/values-ko-rKR/strings.xml +++ b/app/src/main/res/values-ko-rKR/strings.xml @@ -14,6 +14,7 @@ Send SMS to group Send email to group Call %s + Request the required permissions 새로운 연락처 연락처 수정 diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index be456240..09805977 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -14,6 +14,7 @@ Send SMS to group Send email to group Call %s + Request the required permissions Naujas kontaktas Redaguoti kontaktą diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index db97baf4..23fab7d4 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -14,6 +14,7 @@ Enviar SMS para o grupo Enviar e-mail para o grupo Call %s + Request the required permissions Novo contacto Editar contacto diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 3505d21b..a80fc3a0 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -14,6 +14,7 @@ Отправить SMS группе Отправить письмо группе Call %s + Request the required permissions Новый контакт Редактировать контакт diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index e99c2230..b8e165cf 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -14,6 +14,7 @@ Poslať skupine SMS Poslať skupine email Zavolať %s + Vyžiadať potrebné oprávnenia Nový kontakt Upraviť kontakt diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 4b3ba2cd..2b0d0352 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -14,6 +14,7 @@ Skicka sms till grupp Skicka e-post till grupp Call %s + Request the required permissions Ny kontakt Redigera kontakt diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index aeb4f28a..48847d70 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -14,6 +14,7 @@ Gruba SMS gönder Gruba e-posta gönder Call %s + Request the required permissions Yeni kişi Kişiyi düzenle diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index f41009c8..19e7a0ec 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -14,6 +14,7 @@ 發送簡訊給群組 發送電子郵件給群組 Call %s + Request the required permissions 新聯絡人 編輯聯絡人 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4d456010..b6bb08ca 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -14,6 +14,7 @@ Send SMS to group Send email to group Call %s + Request the required permissions New contact Edit contact