Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging #415

Merged
merged 27 commits into from
Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
73af5fd
Group recent calls
vbh Apr 9, 2022
ba43715
Fixed PRs code
roeiedri Apr 6, 2022
86912a3
Fix numbers custom label showing as 'custom', Fixes #397
roeiedri Apr 6, 2022
0c1c524
fix: settings text color not visible in dark theme mode
vbh Apr 8, 2022
84f3e68
Changed recent type image to be the contact's image, and moved the ty…
roeiedri Apr 8, 2022
05608b2
Removed numbers background from dialpad
roeiedri Apr 8, 2022
88ae99d
Fixed search bar icon position
roeiedri Apr 8, 2022
129c40e
Fixed dialpad reverse on rtl, fixes #392
roeiedri Apr 8, 2022
06813c9
update Persian translation
mojienjoyment Mar 30, 2022
1318483
Update Persian translation
mojienjoyment Mar 30, 2022
6790b8c
Increased app version
roeiedri Apr 8, 2022
336d470
removed unnecesarry window flags and implemented a working one
Esarve Apr 13, 2022
4379aaf
Merge branch 'staging' of github.com:Chooloo/koler into staging
roeiedri Apr 13, 2022
bde05cc
Merge pull request #411 from Esarve/fix/fixed_light_mode_statusbar_co…
roeiedri Apr 13, 2022
078642a
Merge branch 'staging' of github.com:Chooloo/koler into staging
roeiedri Apr 13, 2022
4d343ea
Fixed and improved status bar color pr
roeiedri Apr 13, 2022
680bd07
Merge pull request #409 from vbh/group-recents
roeiedri Apr 13, 2022
880ba76
ptbr update
Apr 14, 2022
410e7f5
few fixes
Apr 14, 2022
9355c03
Merge pull request #412 from inkh0rn/master
roeiedri Apr 15, 2022
a25c251
Added group recents preference and improved groups ux
roeiedri Apr 15, 2022
0338693
Fixed some recents image renders as a black image
roeiedri Apr 15, 2022
8c9421f
Merge pull request #413 from Chooloo/feature/groups
roeiedri Apr 15, 2022
afea99e
Merge pull request #414 from Chooloo/fix/blackimages
roeiedri Apr 15, 2022
2777904
Fixed call type icon position
roeiedri Apr 15, 2022
6aaf68d
Fixed permissions related crashes, fixes #408
roeiedri Apr 15, 2022
c3ff2f0
Increased app version
roeiedri Apr 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import android.graphics.Color
import android.net.Uri
import android.provider.ContactsContract.CommonDataKinds.Phone
import com.chooloo.www.chooloolib.interactor.animation.AnimationsInteractor
import com.chooloo.www.chooloolib.interactor.permission.PermissionsInteractor
import com.chooloo.www.chooloolib.interactor.phoneaccounts.PhonesInteractor
import com.chooloo.www.chooloolib.interactor.preferences.PreferencesInteractor
import com.chooloo.www.chooloolib.interactor.recents.RecentsInteractor
import com.chooloo.www.chooloolib.interactor.string.StringsInteractor
import com.chooloo.www.chooloolib.model.ListData
import com.chooloo.www.chooloolib.model.RecentAccount
import com.chooloo.www.chooloolib.ui.widgets.listitem.ListItem
Expand All @@ -18,29 +18,42 @@ import javax.inject.Inject
class RecentsAdapter @Inject constructor(
animations: AnimationsInteractor,
private val phones: PhonesInteractor,
private val strings: StringsInteractor,
private val recents: RecentsInteractor,
private val preferences: PreferencesInteractor
private val preferences: PreferencesInteractor,
private val permissions: PermissionsInteractor
) : ListAdapter<RecentAccount>(animations) {

private var _groupSimilar: Boolean = false

var groupSimilar: Boolean
get() = _groupSimilar
set(value) {
_groupSimilar = value
}


override fun onBindListItem(listItem: ListItem, item: RecentAccount) {
listItem.apply {
val date = context.getHoursString(item.date)

isCompact = preferences.isCompact
captionText = if (item.date != null) context.getHoursString(item.date) else null
captionText = if (item.groupCount > 1) "(${item.groupCount}) $date" else date

phones.lookupAccount(item.number) {
titleText = it?.name ?: item.number
it?.let {
captionText =
"$captionText · ${Phone.getTypeLabel(resources, it.type, it.label)} ·"
setImageInitials(it.name?.initials())
setImageUri(if (it.photoUri != null) Uri.parse(it.photoUri) else null)
}
setImageUri(if (it?.photoUri != null) Uri.parse(it.photoUri) else null)
}

setImageBackgroundColor(Color.TRANSPARENT)
setCaptionImageRes(recents.getCallTypeImage(item.type))
}
}

override fun convertDataToListData(data: List<RecentAccount>) = ListData.fromRecents(data)
override fun convertDataToListData(data: List<RecentAccount>) =
ListData.fromRecents(data, groupSimilar)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.chooloo.www.chooloolib.ui.phones.PhonesFragment
import com.chooloo.www.chooloolib.ui.prompt.PromptFragment
import com.chooloo.www.chooloolib.ui.recent.RecentFragment
import com.chooloo.www.chooloolib.ui.recents.RecentsFragment
import com.chooloo.www.chooloolib.ui.recents.RecentsHistoryFragment
import com.chooloo.www.chooloolib.ui.recentshistory.RecentsHistoryFragment
import com.chooloo.www.chooloolib.ui.settings.SettingsFragment

interface FragmentFactory {
Expand All @@ -23,11 +23,11 @@ interface FragmentFactory {
fun getRecentFragment(recentId: Long): RecentFragment
fun getDialerFragment(text: String? = null): DialerFragment
fun getPhonesFragment(contactId: Long? = null): PhonesFragment
fun getRecentsFragment(filter: String? = null): RecentsFragment
fun getContactsSuggestionsFragment(): ContactsSuggestionsFragment
fun getBriefContactFragment(contactId: Long): BriefContactFragment
fun getPromptFragment(title: String, subtitle: String): PromptFragment
fun getRecentsHistoryFragment(filter: String? = null): RecentsHistoryFragment
fun getRecentsFragment(filter: String? = null, isGrouped: Boolean? = null): RecentsFragment
fun getChoicesFragment(
@StringRes titleRes: Int,
@StringRes subtitleRes: Int?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.chooloo.www.chooloolib.ui.phones.PhonesFragment
import com.chooloo.www.chooloolib.ui.prompt.PromptFragment
import com.chooloo.www.chooloolib.ui.recent.RecentFragment
import com.chooloo.www.chooloolib.ui.recents.RecentsFragment
import com.chooloo.www.chooloolib.ui.recents.RecentsHistoryFragment
import com.chooloo.www.chooloolib.ui.recentshistory.RecentsHistoryFragment
import com.chooloo.www.chooloolib.ui.settings.SettingsFragment
import javax.inject.Inject
import javax.inject.Singleton
Expand All @@ -25,8 +25,8 @@ class FragmentFactoryImpl @Inject constructor() : FragmentFactory {
override fun getContactsSuggestionsFragment() = ContactsSuggestionsFragment()
override fun getDialerFragment(text: String?) = DialerFragment.newInstance(text)
override fun getRecentFragment(recentId: Long) = RecentFragment.newInstance(recentId)
override fun getRecentsFragment(filter: String?) = RecentsFragment.newInstance(filter)
override fun getPhonesFragment(contactId: Long?) = PhonesFragment.newInstance(contactId)

override fun getBriefContactFragment(contactId: Long) =
BriefContactFragment.newInstance(contactId)

Expand All @@ -36,6 +36,9 @@ class FragmentFactoryImpl @Inject constructor() : FragmentFactory {
override fun getRecentsHistoryFragment(filter: String?) =
RecentsHistoryFragment.newInstance(filter)

override fun getRecentsFragment(filter: String?, isGrouped: Boolean?): RecentsFragment =
RecentsFragment.newInstance(filter, isGrouped)

override fun getChoicesFragment(
titleRes: Int,
subtitleRes: Int?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import com.chooloo.www.chooloolib.interactor.base.BaseInteractor
interface ColorsInteractor : BaseInteractor<ColorsInteractor.Listener> {
interface Listener

val windowColor: Int

fun getColor(@ColorRes colorRes: Int): Int
fun getAttrColor(@AttrRes colorRes: Int): Int
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ class ColorsInteractorImpl @Inject constructor(
return context.createConfigurationContext(configuration)
}

override val windowColor: Int
get() {
val typedValue = TypedValue()
context.theme.resolveAttribute(
android.R.attr.windowBackground,
typedValue,
true
)
return if (typedValue.type in TypedValue.TYPE_FIRST_COLOR_INT..TypedValue.TYPE_LAST_COLOR_INT) {
typedValue.data;
} else -1
}

override fun getColor(colorRes: Int) = ContextCompat.getColor(getThemedContext(), colorRes)

override fun getAttrColor(colorRes: Int) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface PreferencesInteractor : BaseInteractor<PreferencesInteractor.Listener>
var isCompact: Boolean
var isAnimations: Boolean
var isShowBlocked: Boolean
var isGroupRecents: Boolean
var isDialpadTones: Boolean
var isDialpadVibrate: Boolean

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ class PreferencesInteractorImpl @Inject constructor(
preferencesManager.putBoolean(R.string.pref_key_show_blocked, value)
}

override var isGroupRecents: Boolean
get() = preferencesManager.getBoolean(
R.string.pref_key_group_recents,
R.bool.pref_default_value_group_recents
)
set(value) {
preferencesManager.putBoolean(R.string.pref_key_group_recents, value)
}

override var isDialpadTones: Boolean
get() = preferencesManager.getBoolean(
R.string.pref_key_dialpad_tones,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,41 @@ data class ListData<DataType>(
return ListData(contacts, headersToCounts)
}

fun fromRecents(recents: List<RecentAccount>) = ListData(
recents,
recents.groupingBy { getRelativeDateString(it.date) }.eachCount()
)
fun fromRecents(recents: List<RecentAccount>, isGrouped: Boolean) =
if (isGrouped && recents.size > 1) {
getGroupedRecents(recents)
} else {
ListData(
recents,
recents.groupingBy { getRelativeDateString(it.date) }.eachCount()
)
}

private fun getGroupedRecents(recents: List<RecentAccount>): ListData<RecentAccount> {
var prevItem: RecentAccount = recents[0]
val currentGroup = mutableListOf(prevItem)
var prevDate = getRelativeDateString(prevItem.date)
val groupedRecents = mutableListOf<RecentAccount>()

recents.drop(1).forEach { curItem ->
val curDate = getRelativeDateString(curItem.date)
if (prevItem.number == curItem.number && prevDate == curDate) {
currentGroup.add(curItem)
} else {
groupedRecents.add(prevItem.copy(groupAccounts = currentGroup.map { it.copy() }))
currentGroup.clear()
currentGroup.add(curItem)
prevItem = curItem
}
prevDate = curDate
}
groupedRecents.add(prevItem.copy(groupAccounts = currentGroup))

return ListData(
groupedRecents,
groupedRecents.groupingBy { getRelativeDateString(it.date) }.eachCount()
)
}

fun fromPhones(phones: List<PhoneAccount>): ListData<PhoneAccount> {
val phones = phones.toList().distinctBy { it.normalizedNumber }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import java.io.Serializable
import java.util.*

data class RecentAccount(
val date: Date,
val id: Long = 0,
val number: String,
@CallType val type: Int,
val id: Long = 0,
val duration: Long = 0,
val date: Date? = null,
val cachedName: String? = null,
val groupAccounts: List<RecentAccount> = listOf()
) : Serializable {

@kotlin.annotation.Retention(AnnotationRetention.SOURCE)
Expand All @@ -27,8 +28,9 @@ data class RecentAccount(
)
annotation class CallType

val relativeTime: String?
get() = date?.time?.let { getTimeAgo(it) }
val groupCount get() = groupAccounts.size

val relativeTime by lazy { getTimeAgo(date.time) }

companion object {
const val TYPE_UNKNOWN = 7
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
package com.chooloo.www.chooloolib.ui.base

import android.graphics.Color
import android.os.Bundle
import android.view.View
import android.view.WindowManager
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import com.chooloo.www.chooloolib.interactor.color.ColorsInteractor
import com.chooloo.www.chooloolib.interactor.preferences.PreferencesInteractor
import com.chooloo.www.chooloolib.interactor.string.StringsInteractor
import io.reactivex.disposables.CompositeDisposable
import javax.inject.Inject

abstract class BaseActivity<VM : BaseViewState> : AppCompatActivity(), BaseView<VM> {
@Inject lateinit var colors: ColorsInteractor
@Inject lateinit var strings: StringsInteractor
@Inject lateinit var disposables: CompositeDisposable
@Inject lateinit var preferences: PreferencesInteractor


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
window.apply {
clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
statusBarColor = Color.TRANSPARENT
}

applicationContext.setTheme(preferences.accentTheme.theme)
setTheme(preferences.accentTheme.theme)
window.statusBarColor = colors.windowColor
AppCompatDelegate.setDefaultNightMode(preferences.themeMode.mode)

contentView?.let { setContentView(it) }

onSetup()

viewState.apply {
attach()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ class CallViewState @Inject constructor(
callAudios.audioRoute?.let(this@CallViewState::onAudioRouteChanged)
}


isManageEnabled.value = false
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.chooloo.www.chooloolib.ui.contacts

import android.Manifest.permission.READ_CONTACTS
import androidx.lifecycle.LiveData
import com.chooloo.www.chooloolib.R
import com.chooloo.www.chooloolib.interactor.permission.PermissionsInteractor
Expand Down Expand Up @@ -29,7 +30,10 @@ open class ContactsViewState @Inject constructor(

override fun onFilterChanged(filter: String?) {
super.onFilterChanged(filter)
contactsLiveData.filter = filter
if (permissions.hasSelfPermission(READ_CONTACTS)) {
onPermissionsChanged(true)
contactsLiveData.filter = filter
}
}

override fun onItemClick(item: ContactAccount) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.chooloo.www.chooloolib.databinding.ItemsBinding
import com.chooloo.www.chooloolib.ui.base.BaseFragment

abstract class ListFragment<ItemType, VS : ListViewState<ItemType>> : BaseFragment<VS>() {

override val contentView by lazy { binding.root }
protected val binding by lazy { ItemsBinding.inflate(layoutInflater) }

Expand All @@ -33,7 +32,9 @@ abstract class ListFragment<ItemType, VS : ListViewState<ItemType>> : BaseFragme
ev.ifNew?.let { adapter.items = it }
}

getItemsObservable { it.observe(this@ListFragment, viewState::onItemsChanged) }
if (args.getBoolean(ARG_OBSERVE, true)) {
getItemsObservable { it.observe(this@ListFragment, viewState::onItemsChanged) }
}
}

adapter.apply {
Expand Down Expand Up @@ -61,5 +62,6 @@ abstract class ListFragment<ItemType, VS : ListViewState<ItemType>> : BaseFragme

companion object {
const val ARG_FILTER = "filter"
const val ARG_OBSERVE = "is_observe"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ abstract class ListViewState<ItemType> : BaseViewState() {
val itemLongClickedEvent = DataLiveEvent<ItemType>()
val itemsChangedEvent = DataLiveEvent<List<ItemType>>()

protected open val noResultsIconRes: Int? = null
protected open val noResultsTextRes: Int? = null
protected open val noPermissionsTextRes: Int? = null


override fun attach() {
emptyIcon.value = noResultsIconRes
Expand All @@ -43,12 +47,11 @@ abstract class ListViewState<ItemType> : BaseViewState() {

fun onPermissionsChanged(hasPermissions: Boolean) {
emptyMessage.value = if (hasPermissions) noResultsTextRes else noPermissionsTextRes
isEmpty.value = !hasPermissions
}

open fun onItemLeftClick(item: ItemType) {}
open fun onItemRightClick(item: ItemType) {}

protected open val noResultsIconRes: Int? = null
protected open val noResultsTextRes: Int? = null
protected open val noPermissionsTextRes: Int? = null
abstract fun getItemsObservable(callback: (LiveData<List<ItemType>>) -> Unit)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.chooloo.www.chooloolib.interactor.call.CallNavigationsInteractor
import com.chooloo.www.chooloolib.interactor.dialog.DialogsInteractor
import com.chooloo.www.chooloolib.interactor.prompt.PromptsInteractor
import com.chooloo.www.chooloolib.ui.base.BaseFragment
import com.chooloo.www.chooloolib.ui.recents.RecentsHistoryViewState
import com.chooloo.www.chooloolib.ui.recents.RecentsViewState
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

Expand All @@ -19,7 +19,7 @@ class RecentFragment @Inject constructor() : BaseFragment<RecentViewState>() {
override val contentView by lazy { binding.root }
override val viewState: RecentViewState by viewModels()

private val historyViewState: RecentsHistoryViewState by viewModels()
private val historyViewState: RecentsViewState by viewModels()
private val binding by lazy { RecentBinding.inflate(layoutInflater) }

@Inject lateinit var prompts: PromptsInteractor
Expand Down Expand Up @@ -112,7 +112,7 @@ class RecentFragment @Inject constructor() : BaseFragment<RecentViewState>() {

showHistoryEvent.observe(this@RecentFragment) { ev ->
ev.ifNew?.let {
prompts.showFragment(fragmentFactory.getRecentsHistoryFragment(it))
prompts.showFragment(fragmentFactory.getRecentsFragment(it))
}
}

Expand Down
Loading