Skip to content

Commit 2879fc7

Browse files
committed
v.5.2.4
1 parent 06db118 commit 2879fc7

11 files changed

Lines changed: 59 additions & 109 deletions

File tree

app/src/main/kotlin/com/goodwy/contacts/activities/ContactActivity.kt

Lines changed: 3 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.goodwy.contacts.activities
22

33
import android.app.Activity
4+
import android.content.Context
45
import android.content.Intent
56
import android.graphics.Bitmap
67
import android.graphics.Canvas
@@ -178,95 +179,7 @@ abstract class ContactActivity : SimpleActivity() {
178179
}
179180
}
180181

181-
fun getEmailTypeText(type: Int, label: String): String {
182-
return if (type == BaseTypes.TYPE_CUSTOM) {
183-
label
184-
} else {
185-
getString(
186-
when (type) {
187-
Email.TYPE_HOME -> com.goodwy.commons.R.string.home
188-
Email.TYPE_WORK -> com.goodwy.commons.R.string.work
189-
Email.TYPE_MOBILE -> com.goodwy.commons.R.string.mobile
190-
else -> com.goodwy.commons.R.string.other
191-
}
192-
)
193-
}
194-
}
195-
196-
fun getRelationTypeText(type: Int, label: String): String {
197-
return if (type == BaseTypes.TYPE_CUSTOM) {
198-
label
199-
} else {
200-
getString(
201-
when (type) {
202-
// Relation.TYPE_CUSTOM -> com.goodwy.strings.R.string.custom
203-
Relation.TYPE_ASSISTANT -> com.goodwy.strings.R.string.relation_assistant_g
204-
Relation.TYPE_BROTHER -> com.goodwy.strings.R.string.relation_brother_g
205-
Relation.TYPE_CHILD -> com.goodwy.strings.R.string.relation_child_g
206-
Relation.TYPE_DOMESTIC_PARTNER -> com.goodwy.strings.R.string.relation_domestic_partner_g
207-
Relation.TYPE_FATHER -> com.goodwy.strings.R.string.relation_father_g
208-
Relation.TYPE_FRIEND -> com.goodwy.strings.R.string.relation_friend_g
209-
Relation.TYPE_MANAGER -> com.goodwy.strings.R.string.relation_manager_g
210-
Relation.TYPE_MOTHER -> com.goodwy.strings.R.string.relation_mother_g
211-
Relation.TYPE_PARENT -> com.goodwy.strings.R.string.relation_parent_g
212-
Relation.TYPE_PARTNER -> com.goodwy.strings.R.string.relation_partner_g
213-
Relation.TYPE_REFERRED_BY -> com.goodwy.strings.R.string.relation_referred_by_g
214-
Relation.TYPE_RELATIVE -> com.goodwy.strings.R.string.relation_relative_g
215-
Relation.TYPE_SISTER -> com.goodwy.strings.R.string.relation_sister_g
216-
Relation.TYPE_SPOUSE -> com.goodwy.strings.R.string.relation_spouse_g
217-
218-
// Relation types defined in vCard 4.0
219-
ContactRelation.TYPE_CONTACT -> com.goodwy.strings.R.string.relation_contact_g
220-
ContactRelation.TYPE_ACQUAINTANCE -> com.goodwy.strings.R.string.relation_acquaintance_g
221-
// ContactRelation.TYPE_FRIEND -> com.goodwy.strings.R.string.relation_friend
222-
ContactRelation.TYPE_MET -> com.goodwy.strings.R.string.relation_met_g
223-
ContactRelation.TYPE_CO_WORKER -> com.goodwy.strings.R.string.relation_co_worker_g
224-
ContactRelation.TYPE_COLLEAGUE -> com.goodwy.strings.R.string.relation_colleague_g
225-
ContactRelation.TYPE_CO_RESIDENT -> com.goodwy.strings.R.string.relation_co_resident_g
226-
ContactRelation.TYPE_NEIGHBOR -> com.goodwy.strings.R.string.relation_neighbor_g
227-
// ContactRelation.TYPE_CHILD -> com.goodwy.strings.R.string.relation_child
228-
// ContactRelation.TYPE_PARENT -> com.goodwy.strings.R.string.relation_parent
229-
ContactRelation.TYPE_SIBLING -> com.goodwy.strings.R.string.relation_sibling_g
230-
// ContactRelation.TYPE_SPOUSE -> com.goodwy.strings.R.string.relation_spouse
231-
ContactRelation.TYPE_KIN -> com.goodwy.strings.R.string.relation_kin_g
232-
ContactRelation.TYPE_MUSE -> com.goodwy.strings.R.string.relation_muse_g
233-
ContactRelation.TYPE_CRUSH -> com.goodwy.strings.R.string.relation_crush_g
234-
ContactRelation.TYPE_DATE -> com.goodwy.strings.R.string.relation_date_g
235-
ContactRelation.TYPE_SWEETHEART -> com.goodwy.strings.R.string.relation_sweetheart_g
236-
ContactRelation.TYPE_ME -> com.goodwy.strings.R.string.relation_me_g
237-
ContactRelation.TYPE_AGENT -> com.goodwy.strings.R.string.relation_agent_g
238-
ContactRelation.TYPE_EMERGENCY -> com.goodwy.strings.R.string.relation_emergency_g
239-
240-
ContactRelation.TYPE_SUPERIOR -> com.goodwy.strings.R.string.relation_superior_g
241-
ContactRelation.TYPE_SUBORDINATE -> com.goodwy.strings.R.string.relation_subordinate_g
242-
ContactRelation.TYPE_HUSBAND -> com.goodwy.strings.R.string.relation_husband_g
243-
ContactRelation.TYPE_WIFE -> com.goodwy.strings.R.string.relation_wife_g
244-
ContactRelation.TYPE_SON -> com.goodwy.strings.R.string.relation_son_g
245-
ContactRelation.TYPE_DAUGHTER -> com.goodwy.strings.R.string.relation_daughter_g
246-
ContactRelation.TYPE_GRANDPARENT -> com.goodwy.strings.R.string.relation_grandparent_g
247-
ContactRelation.TYPE_GRANDFATHER -> com.goodwy.strings.R.string.relation_grandfather_g
248-
ContactRelation.TYPE_GRANDMOTHER -> com.goodwy.strings.R.string.relation_grandmother_g
249-
ContactRelation.TYPE_GRANDCHILD -> com.goodwy.strings.R.string.relation_grandchild_g
250-
ContactRelation.TYPE_GRANDSON -> com.goodwy.strings.R.string.relation_grandson_g
251-
ContactRelation.TYPE_GRANDDAUGHTER -> com.goodwy.strings.R.string.relation_granddaughter_g
252-
ContactRelation.TYPE_UNCLE -> com.goodwy.strings.R.string.relation_uncle_g
253-
ContactRelation.TYPE_AUNT -> com.goodwy.strings.R.string.relation_aunt_g
254-
ContactRelation.TYPE_NEPHEW -> com.goodwy.strings.R.string.relation_nephew_g
255-
ContactRelation.TYPE_NIECE -> com.goodwy.strings.R.string.relation_niece_g
256-
ContactRelation.TYPE_FATHER_IN_LAW -> com.goodwy.strings.R.string.relation_father_in_law_g
257-
ContactRelation.TYPE_MOTHER_IN_LAW -> com.goodwy.strings.R.string.relation_mother_in_law_g
258-
ContactRelation.TYPE_SON_IN_LAW -> com.goodwy.strings.R.string.relation_son_in_law_g
259-
ContactRelation.TYPE_DAUGHTER_IN_LAW -> com.goodwy.strings.R.string.relation_daughter_in_law_g
260-
ContactRelation.TYPE_BROTHER_IN_LAW -> com.goodwy.strings.R.string.relation_brother_in_law_g
261-
ContactRelation.TYPE_SISTER_IN_LAW -> com.goodwy.strings.R.string.relation_sister_in_law_g
262-
263-
else -> com.goodwy.commons.R.string.other
264-
}
265-
)
266-
}
267-
}
268-
269-
fun getAddressTypeText(type: Int, label: String): String {
182+
fun Context.getAddressTypeText(type: Int, label: String): String {
270183
return if (type == BaseTypes.TYPE_CUSTOM) {
271184
label
272185
} else {
@@ -280,7 +193,7 @@ abstract class ContactActivity : SimpleActivity() {
280193
}
281194
}
282195

283-
fun getIMTypeText(type: Int, label: String): String {
196+
fun Context.getIMTypeText(type: Int, label: String): String {
284197
return if (type == Im.PROTOCOL_CUSTOM) {
285198
label
286199
} else {
@@ -299,12 +212,6 @@ abstract class ContactActivity : SimpleActivity() {
299212
}
300213
}
301214

302-
fun getEventTextId(type: Int) = when (type) {
303-
Event.TYPE_ANNIVERSARY -> com.goodwy.commons.R.string.anniversary
304-
Event.TYPE_BIRTHDAY -> com.goodwy.commons.R.string.birthday
305-
else -> com.goodwy.commons.R.string.other
306-
}
307-
308215
protected fun getDefaultRingtoneUri() = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE)
309216

310217
protected fun getRingtonePickerIntent(): Intent {

app/src/main/kotlin/com/goodwy/contacts/activities/EditContactActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ class EditContactActivity : ContactActivity() {
353353
updateMenuItemColors(this)
354354
findItem(R.id.favorite).setOnMenuItemClickListener {
355355
toggleFavorite()
356-
val newIsStarred = if (contact!!.starred == 1) 0 else 1
356+
val newIsStarred = if ((contact?.starred ?: 0) == 1) 0 else 1
357357
// ensureBackgroundThread {
358358
// val contacts = arrayListOf(contact!!)
359359
// if (newIsStarred == 1) {
@@ -2209,7 +2209,7 @@ class EditContactActivity : ContactActivity() {
22092209
override fun systemRingtoneSelected(uri: Uri?) {
22102210
contact!!.ringtone = uri?.toString() ?: ""
22112211
val contactRingtone = RingtoneManager.getRingtone(this, uri)
2212-
binding.contactRingtone.text = contactRingtone.getTitle(this)
2212+
binding.contactRingtone.text = contactRingtone.getTitle(this) ?: "?"
22132213
}
22142214

22152215
private fun getPhoneNumberTypeId(value: String) = when (value) {

app/src/main/kotlin/com/goodwy/contacts/activities/MainActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
817817
add(Release(521, R.string.release_521))
818818
add(Release(522, R.string.release_522))
819819
add(Release(523, R.string.release_523))
820+
add(Release(524, R.string.release_524))
820821
checkWhatsNew(this, BuildConfig.VERSION_CODE)
821822
}
822823
}

app/src/main/kotlin/com/goodwy/contacts/activities/SettingsActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,14 @@ class SettingsActivity : SimpleActivity() {
377377
settingsShowContactThumbnailsHolder.setOnClickListener {
378378
settingsShowContactThumbnails.toggle()
379379
config.showContactThumbnails = settingsShowContactThumbnails.isChecked
380+
settingsContactThumbnailsSizeHolder.beVisibleIf(config.showContactThumbnails)
380381
}
381382
}
382383
}
383384

384385
private fun setupContactThumbnailsSize() = binding.apply {
385386
val pro = isPro()
387+
settingsContactThumbnailsSizeHolder.beVisibleIf(config.showContactThumbnails)
386388
settingsContactThumbnailsSizeHolder.alpha = if (pro) 1f else 0.4f
387389
settingsContactThumbnailsSizeLabel.text = addLockedLabelIfNeeded(com.goodwy.strings.R.string.contact_thumbnails_size, pro)
388390
settingsContactThumbnailsSize.text = getContactThumbnailsSizeText()

app/src/main/kotlin/com/goodwy/contacts/activities/ViewContactActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class ViewContactActivity : ContactActivity() {
174174
binding.contactToolbar.menu.apply {
175175
updateMenuItemColors(this)
176176
findItem(R.id.favorite).setOnMenuItemClickListener {
177-
val newIsStarred = if (contact!!.starred == 1) 0 else 1
177+
val newIsStarred = if ((contact?.starred ?: 0) == 1) 0 else 1
178178
ensureBackgroundThread {
179179
val contacts = arrayListOf(contact!!)
180180
if (newIsStarred == 1) {

app/src/main/kotlin/com/goodwy/contacts/adapters/ContactsAdapter.kt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,14 +560,30 @@ class ContactsAdapter(
560560
override fun onSwipedLeft(swipeActionView: SwipeActionView): Boolean {
561561
val swipeLeftOrRightAction = if (activity.isRTLLayout) activity.config.swipeRightAction else activity.config.swipeLeftAction
562562
swipeAction(swipeLeftOrRightAction, contact)
563+
slideLeftReturn(findViewById<ImageView>(R.id.swipeLeftIcon), findViewById<RelativeLayout>(R.id.swipeLeftIconHolder))
563564
return true
564565
}
565566

566567
override fun onSwipedRight(swipeActionView: SwipeActionView): Boolean {
567568
val swipeRightOrLeftAction = if (activity.isRTLLayout) activity.config.swipeLeftAction else activity.config.swipeRightAction
568569
swipeAction(swipeRightOrLeftAction, contact)
570+
slideRightReturn(findViewById<ImageView>(R.id.swipeRightIcon), findViewById<RelativeLayout>(R.id.swipeRightIconHolder))
569571
return true
570572
}
573+
574+
override fun onSwipedActivated(swipedRight: Boolean) {
575+
if (viewType != VIEW_TYPE_GRID) {
576+
if (swipedRight) slideRight(findViewById<ImageView>(R.id.swipeRightIcon), findViewById<RelativeLayout>(R.id.swipeRightIconHolder))
577+
else slideLeft(findViewById<ImageView>(R.id.swipeLeftIcon))
578+
}
579+
}
580+
581+
override fun onSwipedDeactivated(swipedRight: Boolean) {
582+
if (viewType != VIEW_TYPE_GRID) {
583+
if (swipedRight) slideRightReturn(findViewById<ImageView>(R.id.swipeRightIcon), findViewById<RelativeLayout>(R.id.swipeRightIconHolder))
584+
else slideLeftReturn(findViewById<ImageView>(R.id.swipeLeftIcon), findViewById<RelativeLayout>(R.id.swipeLeftIconHolder))
585+
}
586+
}
571587
}
572588
}
573589

@@ -582,6 +598,26 @@ class ContactsAdapter(
582598
}
583599
}
584600

601+
private fun slideRight(view: View, parent: View) {
602+
view.animate()
603+
.x(parent.right - activity.resources.getDimension(com.goodwy.commons.R.dimen.big_margin) - view.width)
604+
}
605+
606+
private fun slideLeft(view: View) {
607+
view.animate()
608+
.x(activity.resources.getDimension(com.goodwy.commons.R.dimen.big_margin))
609+
}
610+
611+
private fun slideRightReturn(view: View, parent: View) {
612+
view.animate()
613+
.x(parent.left + activity.resources.getDimension(com.goodwy.commons.R.dimen.big_margin))
614+
}
615+
616+
private fun slideLeftReturn(view: View, parent: View) {
617+
view.animate()
618+
.x(parent.width - activity.resources.getDimension(com.goodwy.commons.R.dimen.big_margin) - view.width)
619+
}
620+
585621
override fun onChange(position: Int) = contactItems.getOrNull(position)?.getBubbleText() ?: ""
586622

587623
override fun onRowMoved(fromPosition: Int, toPosition: Int) {

app/src/main/res/layout/top_view.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
<ImageView
1212
android:id="@+id/contactPhoto"
13-
android:layout_width="@dimen/contact_photo_big_size"
14-
android:layout_height="@dimen/contact_photo_big_size"
13+
android:layout_width="@dimen/contact_photo_size"
14+
android:layout_height="@dimen/contact_photo_size"
1515
android:layout_marginTop="36dp"
1616
app:layout_constraintEnd_toEndOf="parent"
1717
app:layout_constraintStart_toStartOf="parent"

app/src/main/res/values-sw600dp/dimens.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<dimen name="contact_padding_left">72dp</dimen>
4-
54
<dimen name="contact_edit_type_width">198dp</dimen>
65

76
<!--collapsing toolbar-->

app/src/main/res/values/dimens.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
<!--collapsing toolbar-->
1717
<dimen name="toolbar_height">102dp</dimen>
1818
<dimen name="image_top_margin">24dp</dimen>
19-
<dimen name="image_right_margin">32dp</dimen>
20-
<dimen name="name_top_margin">42dp</dimen>
21-
<dimen name="company_top_margin">56dp</dimen>
19+
<dimen name="image_right_margin">23dp</dimen>
20+
<dimen name="name_top_margin">12dp</dimen>
21+
<dimen name="company_top_margin">32dp</dimen>
2222
<dimen name="name_right_margin">38dp</dimen>
2323
<dimen name="zero">0dp</dimen>
2424

app/src/main/res/values/donottranslate.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
<string name="viber" translatable="false">Viber</string>
1717

1818
<!-- Release notes -->
19+
<string name="release_524">
20+
Changed swipe behaviour and added animation\n
21+
Reduced the contact icon when viewing call details\n
22+
Fixed bugs
23+
</string>
1924
<string name="release_523">
2025
Fixed bugs
2126
</string>

0 commit comments

Comments
 (0)