Skip to content

Commit

Permalink
v.5.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Goodwy committed Sep 18, 2024
1 parent 9cc1430 commit 8d6e0b1
Show file tree
Hide file tree
Showing 21 changed files with 336 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,18 @@ class DialpadActivity : SimpleActivity() {
}

DIALPAD_GRID -> {
binding.dialpadRoundWrapper.root.beGone()
binding.dialpadRectWrapper.root.beGone()
binding.dialpadClearWrapper.apply {
dialpadGridHolder.beVisible()
dialpadGridHolder.setBackgroundColor(getProperBackgroundColor())
arrayOf(
dividerHorizontalZero, dividerHorizontalOne, dividerHorizontalTwo, dividerHorizontalThree,
dividerHorizontalFour, dividerVerticalOne, dividerVerticalTwo, dividerVerticalStart, dividerVerticalEnd
).forEach {
it.beVisible()
}
dialpadGridHolder.beVisible()
}
binding.dialpadRoundWrapper.root.beGone()
binding.dialpadRectWrapper.root.beGone()
initLetters()
}

Expand Down Expand Up @@ -503,6 +504,7 @@ class DialpadActivity : SimpleActivity() {
//setupCharClick(dialpadPlusHolder, '+', longClickable = false)
setupCharClick(dialpadAsteriskHolder, '*')
setupCharClick(dialpadHashtagHolder, '#')
dialpadGridHolder.setOnClickListener { } //Do not press between the buttons
}
binding.dialpadAddNumber.setOnClickListener { addNumberToContact() }

Expand Down Expand Up @@ -763,6 +765,7 @@ class DialpadActivity : SimpleActivity() {
//setupCharClick(dialpadPlusHolder, '+', longClickable = false)
setupCharClick(dialpadAsteriskHolder, '*')
setupCharClick(dialpadHashtagHolder, '#')
dialpadGridHolder.setOnClickListener { } //Do not press between the buttons
}
binding.dialpadAddNumber.setOnClickListener { addNumberToContact() }

Expand Down Expand Up @@ -1080,9 +1083,9 @@ class DialpadActivity : SimpleActivity() {
}
}

Handler().postDelayed({
binding.dialpadInput.setText("")
}, 1000)
// Handler().postDelayed({
// binding.dialpadInput.setText("")
// }, 1000)
} else {
RecentsHelper(this).getRecentCalls(queryLimit = 1) {
val mostRecentNumber = it.firstOrNull()?.phoneNumber
Expand Down Expand Up @@ -1234,7 +1237,7 @@ class DialpadActivity : SimpleActivity() {
private fun refreshCallLog(loadAll: Boolean = false, callback: (() -> Unit)? = null) {
getRecentCalls(loadAll) {
allRecentCalls = it
config.recentCallsCache = Gson().toJson(it.take(200))
config.recentCallsCache = Gson().toJson(it.take(400))
runOnUiThread { gotRecents(it) }

callback?.invoke()
Expand Down
29 changes: 19 additions & 10 deletions app/src/main/kotlin/com/goodwy/dialer/activities/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ class MainActivity : SimpleActivity() {
override fun onPageSelected(position: Int) {
if (config.bottomNavigationBar) {
binding.mainTabsHolder.getTabAt(position)?.select()
scrollChange()
if (config.changeColourTopBar) scrollChange()
} else binding.mainTopTabsHolder.getTabAt(position)?.select()

getAllFragments().forEach {
Expand Down Expand Up @@ -616,7 +616,7 @@ class MainActivity : SimpleActivity() {

binding.viewPager.onGlobalLayout {
refreshMenuItems()
if (config.bottomNavigationBar) scrollChange()
if (config.bottomNavigationBar && config.changeColourTopBar) scrollChange()
}

if (config.openDialPadAtLaunch && !launchedDialer) {
Expand Down Expand Up @@ -701,14 +701,21 @@ class MainActivity : SimpleActivity() {
it.icon?.applyColorFilter(properTextColor)
it.icon?.alpha = 220 // max 255
getFavoritesFragment()?.refreshItems() //to save sorting
closeSearch()
},
tabSelectedAction = {
if (config.closeSearch) {
closeSearch()
} else {
//On tab switch, the search string is not deleted
//It should not start on the first startup
if (isSearchOpen) getCurrentFragment()?.onSearchQueryChanged(searchQuery)
}

binding.viewPager.currentItem = it.position
it.icon?.applyColorFilter(properPrimaryColor)
it.icon?.alpha = 220 // max 255

val lastPosition = binding.mainTopTabsHolder.tabCount - 1
// val lastPosition = binding.mainTopTabsHolder.tabCount - 1
// if (it.position == lastPosition && config.showTabs and TAB_CALL_HISTORY > 0) {
// clearMissedCalls()
// }
Expand Down Expand Up @@ -751,16 +758,18 @@ class MainActivity : SimpleActivity() {
updateBottomTabItemColors(it.customView, false, getDeselectedTabDrawableIds()[it.position])
},
tabSelectedAction = {
// binding.mainMenu.closeSearch()

//On tab switch, the search string is not deleted
//It should not start on the first startup
if (binding.mainMenu.isSearchOpen) getCurrentFragment()?.onSearchQueryChanged(binding.mainMenu.getCurrentQuery())
if (config.closeSearch) {
binding.mainMenu.closeSearch()
} else {
//On tab switch, the search string is not deleted
//It should not start on the first startup
if (binding.mainMenu.isSearchOpen) getCurrentFragment()?.onSearchQueryChanged(binding.mainMenu.getCurrentQuery())
}

binding.viewPager.currentItem = it.position
updateBottomTabItemColors(it.customView, true, getSelectedTabDrawableIds()[it.position])

val lastPosition = binding.mainTabsHolder.tabCount - 1
// val lastPosition = binding.mainTabsHolder.tabCount - 1
// if (it.position == lastPosition && config.showTabs and TAB_CALL_HISTORY > 0) {
// clearMissedCalls()
// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class SettingsActivity : SimpleActivity() {
setupUseIconTabs()
setupScreenSlideAnimation()
setupOpenSearch()
setupEndSearch()

setupUseSwipeToAction()
setupSwipeVibration()
Expand All @@ -209,6 +210,7 @@ class SettingsActivity : SimpleActivity() {
setupGroupSubsequentCalls()
setupQueryLimitRecent()
setupShowCallConfirmation()
setupSimDialogStyle()
setupHideDialpadLetters()
setupDialpadNumbers()
setupDisableProximitySensor()
Expand All @@ -225,6 +227,7 @@ class SettingsActivity : SimpleActivity() {
setupFormatPhoneNumbers()
setupStartNameWithSurname()
setupUseRelativeDate()
setupChangeColourTopBar()

setupCallsExport()
setupCallsImport()
Expand Down Expand Up @@ -461,6 +464,7 @@ class SettingsActivity : SimpleActivity() {
config.bottomNavigationBar = it == 1
config.tabsChanged = true
binding.settingsNavigationBarStyle.text = getNavigationBarStyleText()
binding.settingsChangeColourTopBarHolder.beVisibleIf(config.bottomNavigationBar)
}
}
}
Expand Down Expand Up @@ -1079,6 +1083,28 @@ class SettingsActivity : SimpleActivity() {
}
}

private fun setupSimDialogStyle() {
binding.settingsSimDialogStyleHolder.beGoneIf(!areMultipleSIMsAvailable())
binding.settingsSimDialogStyle.text = getSimDialogStyleText()
binding.settingsSimDialogStyleHolder.setOnClickListener {
val items = arrayListOf(
RadioItem(SIM_DIALOG_STYLE_LIST, getString(R.string.list)),
RadioItem(SIM_DIALOG_STYLE_BUTTON, getString(R.string.buttons)))

RadioGroupDialog(this@SettingsActivity, items, config.simDialogStyle, R.string.sim_card_selection_dialog_style) {
config.simDialogStyle = it as Int
binding.settingsSimDialogStyle.text = getSimDialogStyleText()
}
}
}

private fun getSimDialogStyleText() = getString(
when (config.simDialogStyle) {
SIM_DIALOG_STYLE_LIST -> R.string.list
else -> R.string.buttons
}
)

private fun setupMaterialDesign3() {
binding.apply {
settingsMaterialDesign3.isChecked = config.materialDesign3
Expand Down Expand Up @@ -1241,6 +1267,16 @@ class SettingsActivity : SimpleActivity() {
}
}

private fun setupEndSearch() {
binding.apply {
settingsEndSearch.isChecked = config.closeSearch
settingsEndSearchHolder.setOnClickListener {
settingsEndSearch.toggle()
config.closeSearch = settingsEndSearch.isChecked
}
}
}

private fun setupUseSwipeToAction() {
updateSwipeToActionVisible()
binding.apply {
Expand Down Expand Up @@ -1449,8 +1485,20 @@ class SettingsActivity : SimpleActivity() {
}
}

private fun setupChangeColourTopBar() {
binding.apply {
settingsChangeColourTopBarHolder.beVisibleIf(config.bottomNavigationBar)
settingsChangeColourTopBar.isChecked = config.changeColourTopBar
settingsChangeColourTopBarHolder.setOnClickListener {
settingsChangeColourTopBar.toggle()
config.changeColourTopBar = settingsChangeColourTopBar.isChecked
config.tabsChanged = true
}
}
}

private fun setupOptionsMenu() {
val id = 529 //TODO changelog
val id = 530 //TODO changelog
binding.settingsToolbar.menu.apply {
findItem(R.id.whats_new).isVisible = BuildConfig.VERSION_CODE == id
}
Expand All @@ -1467,7 +1515,7 @@ class SettingsActivity : SimpleActivity() {

private fun showWhatsNewDialog(id: Int) {
arrayListOf<Release>().apply {
add(Release(id, R.string.release_529)) //TODO changelog
add(Release(id, R.string.release_530)) //TODO changelog
WhatsNewDialog(this@SettingsActivity, this)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,12 +515,14 @@ class ContactsAdapter(
override fun onSwipedLeft(swipeActionView: SwipeActionView): Boolean {
val swipeLeftOrRightAction = if (activity.isRTLLayout) activity.config.swipeRightAction else activity.config.swipeLeftAction
swipeAction(swipeLeftOrRightAction, contact)
slideLeftReturn(swipeLeftIcon!!, swipeLeftIconHolder!!)
return true
}

override fun onSwipedRight(swipeActionView: SwipeActionView): Boolean {
val swipeRightOrLeftAction = if (activity.isRTLLayout) activity.config.swipeLeftAction else activity.config.swipeRightAction
swipeAction(swipeRightOrLeftAction, contact)
slideRightReturn(swipeRightIcon!!, swipeRightIconHolder!!)
return true
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.goodwy.dialer.dialogs

import android.telecom.PhoneAccountHandle
import androidx.appcompat.app.AlertDialog
import com.goodwy.commons.activities.BaseSimpleActivity
import com.goodwy.commons.extensions.*
import com.goodwy.dialer.R
import com.goodwy.dialer.databinding.DialogSelectSimButtonBinding
import com.goodwy.dialer.extensions.config
import com.goodwy.dialer.extensions.getAvailableSIMCardLabels

class SelectSimButtonDialog(
val activity: BaseSimpleActivity,
val phoneNumber: String,
onDismiss: () -> Unit = {},
val callback: (handle: PhoneAccountHandle?, label: String?) -> Unit
) {
private var dialog: AlertDialog? = null
private val binding by activity.viewBinding(DialogSelectSimButtonBinding::inflate)

init {

val textColor = activity.baseConfig.simIconsColors[1].getContrastColor()

activity.getAvailableSIMCardLabels().forEachIndexed { index, SIMAccount ->
val indexText = index + 1
if (indexText == 1) {
binding.sim1Button.apply {
val drawable = resources.getColoredDrawableWithColor(activity, R.drawable.button_gray_bg, activity.baseConfig.simIconsColors[1])
background = drawable
setPadding(2, 2, 2, 2)
setTextColor(textColor)
setOnClickListener { selectedSIM(SIMAccount.handle, SIMAccount.label) }
}
} else if (indexText == 2) {
binding.sim2Button.apply {
val drawable = resources.getColoredDrawableWithColor(activity, R.drawable.button_gray_bg, activity.baseConfig.simIconsColors[2])
background = drawable
setPadding(2,2,2,2)
setTextColor(textColor)
setOnClickListener { selectedSIM(SIMAccount.handle, SIMAccount.label) }
}
}
}

activity.getAlertDialogBuilder()
.apply {
val title = activity.getString(R.string.select_sim)
activity.setupDialogStuff(binding.root, this, titleText = title) { alertDialog ->
dialog = alertDialog
}
}

dialog?.setOnDismissListener {
onDismiss()
}

binding.cancelButton.apply {
val drawable = resources.getColoredDrawableWithColor(activity, R.drawable.button_gray_bg, 0xFFEB5545.toInt())
background = drawable
setPadding(2,2,2,2)
setTextColor(textColor)
setOnClickListener {
dialog?.dismiss()
}
}

binding.selectSimRememberHolder.setOnClickListener {
binding.selectSimRemember.toggle()
}
}

private fun selectedSIM(handle: PhoneAccountHandle, label: String) {
if (binding.selectSimRemember.isChecked) {
activity.config.saveCustomSIM(phoneNumber, handle)
}

callback(handle, label)
dialog?.dismiss()
}
}
22 changes: 17 additions & 5 deletions app/src/main/kotlin/com/goodwy/dialer/extensions/Activity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import com.goodwy.dialer.activities.DialerActivity
import com.goodwy.dialer.R
import com.goodwy.dialer.activities.SimpleActivity
import com.goodwy.dialer.dialogs.SelectSIMDialog
import com.goodwy.dialer.dialogs.SelectSimButtonDialog
import com.goodwy.dialer.helpers.SIM_DIALOG_STYLE_LIST
import com.google.android.material.snackbar.Snackbar

fun SimpleActivity.startCallIntent(recipient: String) {
Expand Down Expand Up @@ -114,12 +116,22 @@ fun SimpleActivity.getHandleToUse(intent: Intent?, phoneNumber: String, callback
config.getCustomSIM(phoneNumber) != null && areMultipleSIMsAvailable() -> callback(config.getCustomSIM(phoneNumber))
defaultHandle != null -> callback(defaultHandle)
else -> {
SelectSIMDialog(this, phoneNumber, onDismiss = {
if (this is DialerActivity) {
finish()
if (config.simDialogStyle == SIM_DIALOG_STYLE_LIST) {
SelectSIMDialog(this, phoneNumber, onDismiss = {
if (this is DialerActivity) {
finish()
}
}) { handle, _ ->
callback(handle)
}
} else {
SelectSimButtonDialog(this, phoneNumber, onDismiss = {
if (this is DialerActivity) {
finish()
}
}) { handle, _ ->
callback(handle)
}
}) { handle, _ ->
callback(handle)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class RecentsFragment(
private fun refreshCallLog(loadAll: Boolean = false, callback: (() -> Unit)? = null) {
getRecentCalls(loadAll) {
allRecentCalls = it
context.config.recentCallsCache = Gson().toJson(it.filterIsInstance<RecentCall>().take(100))
context.config.recentCallsCache = Gson().toJson(it.filterIsInstance<RecentCall>().take(400))
if (searchQuery.isNullOrEmpty()) {
activity?.runOnUiThread { gotRecents(it) }
} else {
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/kotlin/com/goodwy/dialer/helpers/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getBoolean(SHOW_VOICEMAIL_ICON, false)
set(showVoicemailIcon) = prefs.edit().putBoolean(SHOW_VOICEMAIL_ICON, showVoicemailIcon).apply()

var simDialogStyle: Int
get() = prefs.getInt(SIM_DIALOG_STYLE, SIM_DIALOG_STYLE_LIST)
set(simDialogStyle) = prefs.edit().putInt(SIM_DIALOG_STYLE, simDialogStyle).apply()

//Timer
var timerSeconds: Int
get() = prefs.getInt(TIMER_SECONDS, 300)
Expand Down
Loading

0 comments on commit 8d6e0b1

Please sign in to comment.