migrate activities to viewbinding
This commit is contained in:
parent
071a78e00a
commit
f962765108
|
@ -26,13 +26,12 @@ import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.SimpleListItem
|
import com.simplemobiletools.commons.models.SimpleListItem
|
||||||
import com.simplemobiletools.dialer.R
|
import com.simplemobiletools.dialer.R
|
||||||
|
import com.simplemobiletools.dialer.databinding.ActivityCallBinding
|
||||||
import com.simplemobiletools.dialer.dialogs.DynamicBottomSheetChooserDialog
|
import com.simplemobiletools.dialer.dialogs.DynamicBottomSheetChooserDialog
|
||||||
import com.simplemobiletools.dialer.extensions.*
|
import com.simplemobiletools.dialer.extensions.*
|
||||||
import com.simplemobiletools.dialer.helpers.*
|
import com.simplemobiletools.dialer.helpers.*
|
||||||
import com.simplemobiletools.dialer.models.AudioRoute
|
import com.simplemobiletools.dialer.models.AudioRoute
|
||||||
import com.simplemobiletools.dialer.models.CallContact
|
import com.simplemobiletools.dialer.models.CallContact
|
||||||
import kotlinx.android.synthetic.main.activity_call.*
|
|
||||||
import kotlinx.android.synthetic.main.dialpad.*
|
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
|
@ -45,6 +44,8 @@ class CallActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val binding by viewBinding(ActivityCallBinding::inflate)
|
||||||
|
|
||||||
private var isSpeakerOn = false
|
private var isSpeakerOn = false
|
||||||
private var isMicrophoneOff = false
|
private var isMicrophoneOff = false
|
||||||
private var isCallEnded = false
|
private var isCallEnded = false
|
||||||
|
@ -63,14 +64,14 @@ class CallActivity : SimpleActivity() {
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_call)
|
setContentView(binding.root)
|
||||||
|
|
||||||
if (CallManager.getPhoneState() == NoCall) {
|
if (CallManager.getPhoneState() == NoCall) {
|
||||||
finish()
|
finish()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTextColors(call_holder)
|
updateTextColors(binding.callHolder)
|
||||||
initButtons()
|
initButtons()
|
||||||
audioManager.mode = AudioManager.MODE_IN_CALL
|
audioManager.mode = AudioManager.MODE_IN_CALL
|
||||||
addLockScreenFlags()
|
addLockScreenFlags()
|
||||||
|
@ -104,7 +105,7 @@ class CallActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
if (dialpad_wrapper.isVisible()) {
|
if (binding.dialpadWrapper.isVisible()) {
|
||||||
hideDialpad()
|
hideDialpad()
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
|
@ -117,119 +118,121 @@ class CallActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initButtons() {
|
private fun initButtons() = binding.apply {
|
||||||
if (config.disableSwipeToAnswer) {
|
if (config.disableSwipeToAnswer) {
|
||||||
call_draggable.beGone()
|
callDraggable.beGone()
|
||||||
call_draggable_background.beGone()
|
callDraggableBackground.beGone()
|
||||||
call_left_arrow.beGone()
|
callLeftArrow.beGone()
|
||||||
call_right_arrow.beGone()
|
callRightArrow.beGone()
|
||||||
|
|
||||||
call_decline.setOnClickListener {
|
callDecline.setOnClickListener {
|
||||||
endCall()
|
endCall()
|
||||||
}
|
}
|
||||||
|
|
||||||
call_accept.setOnClickListener {
|
callAccept.setOnClickListener {
|
||||||
acceptCall()
|
acceptCall()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
handleSwipe()
|
handleSwipe()
|
||||||
}
|
}
|
||||||
|
|
||||||
call_toggle_microphone.setOnClickListener {
|
callToggleMicrophone.setOnClickListener {
|
||||||
toggleMicrophone()
|
toggleMicrophone()
|
||||||
}
|
}
|
||||||
|
|
||||||
call_toggle_speaker.setOnClickListener {
|
callToggleSpeaker.setOnClickListener {
|
||||||
changeCallAudioRoute()
|
changeCallAudioRoute()
|
||||||
}
|
}
|
||||||
|
|
||||||
call_dialpad.setOnClickListener {
|
callDialpad.setOnClickListener {
|
||||||
toggleDialpadVisibility()
|
toggleDialpadVisibility()
|
||||||
}
|
}
|
||||||
|
|
||||||
dialpad_close.setOnClickListener {
|
dialpadClose.setOnClickListener {
|
||||||
hideDialpad()
|
hideDialpad()
|
||||||
}
|
}
|
||||||
|
|
||||||
call_toggle_hold.setOnClickListener {
|
callToggleHold.setOnClickListener {
|
||||||
toggleHold()
|
toggleHold()
|
||||||
}
|
}
|
||||||
|
|
||||||
call_add.setOnClickListener {
|
callAdd.setOnClickListener {
|
||||||
Intent(applicationContext, DialpadActivity::class.java).apply {
|
Intent(applicationContext, DialpadActivity::class.java).apply {
|
||||||
addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
|
addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
|
||||||
startActivity(this)
|
startActivity(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
call_swap.setOnClickListener {
|
callSwap.setOnClickListener {
|
||||||
CallManager.swap()
|
CallManager.swap()
|
||||||
}
|
}
|
||||||
|
|
||||||
call_merge.setOnClickListener {
|
callMerge.setOnClickListener {
|
||||||
CallManager.merge()
|
CallManager.merge()
|
||||||
}
|
}
|
||||||
|
|
||||||
call_manage.setOnClickListener {
|
callManage.setOnClickListener {
|
||||||
startActivity(Intent(this, ConferenceActivity::class.java))
|
startActivity(Intent(this@CallActivity, ConferenceActivity::class.java))
|
||||||
}
|
}
|
||||||
|
|
||||||
call_end.setOnClickListener {
|
callEnd.setOnClickListener {
|
||||||
endCall()
|
endCall()
|
||||||
}
|
}
|
||||||
|
|
||||||
dialpad_0_holder.setOnClickListener { dialpadPressed('0') }
|
dialpadInclude.apply {
|
||||||
dialpad_1_holder.setOnClickListener { dialpadPressed('1') }
|
dialpad0Holder.setOnClickListener { dialpadPressed('0') }
|
||||||
dialpad_2_holder.setOnClickListener { dialpadPressed('2') }
|
dialpad1Holder.setOnClickListener { dialpadPressed('1') }
|
||||||
dialpad_3_holder.setOnClickListener { dialpadPressed('3') }
|
dialpad2Holder.setOnClickListener { dialpadPressed('2') }
|
||||||
dialpad_4_holder.setOnClickListener { dialpadPressed('4') }
|
dialpad3Holder.setOnClickListener { dialpadPressed('3') }
|
||||||
dialpad_5_holder.setOnClickListener { dialpadPressed('5') }
|
dialpad4Holder.setOnClickListener { dialpadPressed('4') }
|
||||||
dialpad_6_holder.setOnClickListener { dialpadPressed('6') }
|
dialpad5Holder.setOnClickListener { dialpadPressed('5') }
|
||||||
dialpad_7_holder.setOnClickListener { dialpadPressed('7') }
|
dialpad6Holder.setOnClickListener { dialpadPressed('6') }
|
||||||
dialpad_8_holder.setOnClickListener { dialpadPressed('8') }
|
dialpad7Holder.setOnClickListener { dialpadPressed('7') }
|
||||||
dialpad_9_holder.setOnClickListener { dialpadPressed('9') }
|
dialpad8Holder.setOnClickListener { dialpadPressed('8') }
|
||||||
|
dialpad9Holder.setOnClickListener { dialpadPressed('9') }
|
||||||
|
|
||||||
arrayOf(
|
arrayOf(
|
||||||
dialpad_0_holder,
|
dialpad0Holder,
|
||||||
dialpad_1_holder,
|
dialpad1Holder,
|
||||||
dialpad_2_holder,
|
dialpad2Holder,
|
||||||
dialpad_3_holder,
|
dialpad3Holder,
|
||||||
dialpad_4_holder,
|
dialpad4Holder,
|
||||||
dialpad_5_holder,
|
dialpad5Holder,
|
||||||
dialpad_6_holder,
|
dialpad6Holder,
|
||||||
dialpad_7_holder,
|
dialpad7Holder,
|
||||||
dialpad_8_holder,
|
dialpad8Holder,
|
||||||
dialpad_9_holder,
|
dialpad9Holder,
|
||||||
dialpad_plus_holder,
|
dialpadPlusHolder,
|
||||||
dialpad_asterisk_holder,
|
dialpadAsteriskHolder,
|
||||||
dialpad_hashtag_holder
|
dialpadHashtagHolder
|
||||||
).forEach {
|
).forEach {
|
||||||
it.background = ResourcesCompat.getDrawable(resources, R.drawable.pill_background, theme)
|
it.background = ResourcesCompat.getDrawable(resources, R.drawable.pill_background, theme)
|
||||||
it.background?.alpha = LOWER_ALPHA_INT
|
it.background?.alpha = LOWER_ALPHA_INT
|
||||||
|
}
|
||||||
|
|
||||||
|
dialpad0Holder.setOnLongClickListener { dialpadPressed('+'); true }
|
||||||
|
dialpadAsteriskHolder.setOnClickListener { dialpadPressed('*') }
|
||||||
|
dialpadHashtagHolder.setOnClickListener { dialpadPressed('#') }
|
||||||
}
|
}
|
||||||
|
|
||||||
dialpad_0_holder.setOnLongClickListener { dialpadPressed('+'); true }
|
dialpadWrapper.setBackgroundColor(getProperBackgroundColor())
|
||||||
dialpad_asterisk_holder.setOnClickListener { dialpadPressed('*') }
|
arrayOf(dialpadClose, callSimImage).forEach {
|
||||||
dialpad_hashtag_holder.setOnClickListener { dialpadPressed('#') }
|
|
||||||
|
|
||||||
dialpad_wrapper.setBackgroundColor(getProperBackgroundColor())
|
|
||||||
arrayOf(dialpad_close, call_sim_image).forEach {
|
|
||||||
it.applyColorFilter(getProperTextColor())
|
it.applyColorFilter(getProperTextColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
val bgColor = getProperBackgroundColor()
|
val bgColor = getProperBackgroundColor()
|
||||||
val inactiveColor = getInactiveButtonColor()
|
val inactiveColor = getInactiveButtonColor()
|
||||||
arrayOf(
|
arrayOf(
|
||||||
call_toggle_microphone, call_toggle_speaker, call_dialpad,
|
callToggleMicrophone, callToggleSpeaker, callDialpad,
|
||||||
call_toggle_hold, call_add, call_swap, call_merge, call_manage
|
callToggleHold, callAdd, callSwap, callMerge, callManage
|
||||||
).forEach {
|
).forEach {
|
||||||
it.applyColorFilter(bgColor.getContrastColor())
|
it.applyColorFilter(bgColor.getContrastColor())
|
||||||
it.background.applyColorFilter(inactiveColor)
|
it.background.applyColorFilter(inactiveColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
arrayOf(
|
arrayOf(
|
||||||
call_toggle_microphone, call_toggle_speaker, call_dialpad,
|
callToggleMicrophone, callToggleSpeaker, callDialpad,
|
||||||
call_toggle_hold, call_add, call_swap, call_merge, call_manage
|
callToggleHold, callAdd, callSwap, callMerge, callManage
|
||||||
).forEach { imageView ->
|
).forEach { imageView ->
|
||||||
imageView.setOnLongClickListener {
|
imageView.setOnLongClickListener {
|
||||||
if (!imageView.contentDescription.isNullOrEmpty()) {
|
if (!imageView.contentDescription.isNullOrEmpty()) {
|
||||||
|
@ -239,16 +242,16 @@ class CallActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
call_sim_id.setTextColor(getProperTextColor().getContrastColor())
|
callSimId.setTextColor(getProperTextColor().getContrastColor())
|
||||||
dialpad_input.disableKeyboard()
|
dialpadInput.disableKeyboard()
|
||||||
|
|
||||||
dialpad_wrapper.onGlobalLayout {
|
dialpadWrapper.onGlobalLayout {
|
||||||
dialpadHeight = dialpad_wrapper.height.toFloat()
|
dialpadHeight = dialpadWrapper.height.toFloat()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private fun handleSwipe() {
|
private fun handleSwipe() = binding.apply {
|
||||||
var minDragX = 0f
|
var minDragX = 0f
|
||||||
var maxDragX = 0f
|
var maxDragX = 0f
|
||||||
var initialDraggableX = 0f
|
var initialDraggableX = 0f
|
||||||
|
@ -262,84 +265,85 @@ class CallActivity : SimpleActivity() {
|
||||||
var rightArrowTranslation = 0f
|
var rightArrowTranslation = 0f
|
||||||
|
|
||||||
val isRtl = isRTLLayout
|
val isRtl = isRTLLayout
|
||||||
call_accept.onGlobalLayout {
|
callAccept.onGlobalLayout {
|
||||||
minDragX = if (isRtl) {
|
minDragX = if (isRtl) {
|
||||||
call_accept.left.toFloat()
|
callAccept.left.toFloat()
|
||||||
} else {
|
} else {
|
||||||
call_decline.left.toFloat()
|
callDecline.left.toFloat()
|
||||||
}
|
}
|
||||||
|
|
||||||
maxDragX = if (isRtl) {
|
maxDragX = if (isRtl) {
|
||||||
call_decline.left.toFloat()
|
callDecline.left.toFloat()
|
||||||
} else {
|
} else {
|
||||||
call_accept.left.toFloat()
|
callAccept.left.toFloat()
|
||||||
}
|
}
|
||||||
|
|
||||||
initialDraggableX = call_draggable.left.toFloat()
|
initialDraggableX = callDraggable.left.toFloat()
|
||||||
initialLeftArrowX = call_left_arrow.x
|
initialLeftArrowX = callLeftArrow.x
|
||||||
initialRightArrowX = call_right_arrow.x
|
initialRightArrowX = callRightArrow.x
|
||||||
initialLeftArrowScaleX = call_left_arrow.scaleX
|
initialLeftArrowScaleX = callLeftArrow.scaleX
|
||||||
initialLeftArrowScaleY = call_left_arrow.scaleY
|
initialLeftArrowScaleY = callLeftArrow.scaleY
|
||||||
initialRightArrowScaleX = call_right_arrow.scaleX
|
initialRightArrowScaleX = callRightArrow.scaleX
|
||||||
initialRightArrowScaleY = call_right_arrow.scaleY
|
initialRightArrowScaleY = callRightArrow.scaleY
|
||||||
leftArrowTranslation = if (isRtl) {
|
leftArrowTranslation = if (isRtl) {
|
||||||
call_accept.x
|
callAccept.x
|
||||||
} else {
|
} else {
|
||||||
-call_decline.x
|
-callDecline.x
|
||||||
}
|
}
|
||||||
|
|
||||||
rightArrowTranslation = if (isRtl) {
|
rightArrowTranslation = if (isRtl) {
|
||||||
-call_accept.x
|
-callAccept.x
|
||||||
} else {
|
} else {
|
||||||
call_decline.x
|
callDecline.x
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRtl) {
|
if (isRtl) {
|
||||||
call_left_arrow.setImageResource(R.drawable.ic_chevron_right_vector)
|
callLeftArrow.setImageResource(R.drawable.ic_chevron_right_vector)
|
||||||
call_right_arrow.setImageResource(R.drawable.ic_chevron_left_vector)
|
callRightArrow.setImageResource(R.drawable.ic_chevron_left_vector)
|
||||||
}
|
}
|
||||||
|
|
||||||
call_left_arrow.applyColorFilter(getColor(R.color.md_red_400))
|
callLeftArrow.applyColorFilter(getColor(R.color.md_red_400))
|
||||||
call_right_arrow.applyColorFilter(getColor(R.color.md_green_400))
|
callRightArrow.applyColorFilter(getColor(R.color.md_green_400))
|
||||||
|
|
||||||
startArrowAnimation(call_left_arrow, initialLeftArrowX, initialLeftArrowScaleX, initialLeftArrowScaleY, leftArrowTranslation)
|
startArrowAnimation(callLeftArrow, initialLeftArrowX, initialLeftArrowScaleX, initialLeftArrowScaleY, leftArrowTranslation)
|
||||||
startArrowAnimation(call_right_arrow, initialRightArrowX, initialRightArrowScaleX, initialRightArrowScaleY, rightArrowTranslation)
|
startArrowAnimation(callRightArrow, initialRightArrowX, initialRightArrowScaleX, initialRightArrowScaleY, rightArrowTranslation)
|
||||||
}
|
}
|
||||||
|
|
||||||
call_draggable.drawable.mutate().setTint(getProperTextColor())
|
callDraggable.drawable.mutate().setTint(getProperTextColor())
|
||||||
call_draggable_background.drawable.mutate().setTint(getProperTextColor())
|
callDraggableBackground.drawable.mutate().setTint(getProperTextColor())
|
||||||
|
|
||||||
var lock = false
|
var lock = false
|
||||||
call_draggable.setOnTouchListener { _, event ->
|
callDraggable.setOnTouchListener { _, event ->
|
||||||
when (event.action) {
|
when (event.action) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
dragDownX = event.x
|
dragDownX = event.x
|
||||||
call_draggable_background.animate().alpha(0f)
|
callDraggableBackground.animate().alpha(0f)
|
||||||
stopAnimation = true
|
stopAnimation = true
|
||||||
call_left_arrow.animate().alpha(0f)
|
callLeftArrow.animate().alpha(0f)
|
||||||
call_right_arrow.animate().alpha(0f)
|
callRightArrow.animate().alpha(0f)
|
||||||
lock = false
|
lock = false
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
||||||
dragDownX = 0f
|
dragDownX = 0f
|
||||||
call_draggable.animate().x(initialDraggableX).withEndAction {
|
callDraggable.animate().x(initialDraggableX).withEndAction {
|
||||||
call_draggable_background.animate().alpha(0.2f)
|
callDraggableBackground.animate().alpha(0.2f)
|
||||||
}
|
}
|
||||||
call_draggable.setImageDrawable(getDrawable(R.drawable.ic_phone_down_vector))
|
callDraggable.setImageDrawable(getDrawable(R.drawable.ic_phone_down_vector))
|
||||||
call_draggable.drawable.mutate().setTint(getProperTextColor())
|
callDraggable.drawable.mutate().setTint(getProperTextColor())
|
||||||
call_left_arrow.animate().alpha(1f)
|
callLeftArrow.animate().alpha(1f)
|
||||||
call_right_arrow.animate().alpha(1f)
|
callRightArrow.animate().alpha(1f)
|
||||||
stopAnimation = false
|
stopAnimation = false
|
||||||
startArrowAnimation(call_left_arrow, initialLeftArrowX, initialLeftArrowScaleX, initialLeftArrowScaleY, leftArrowTranslation)
|
startArrowAnimation(callLeftArrow, initialLeftArrowX, initialLeftArrowScaleX, initialLeftArrowScaleY, leftArrowTranslation)
|
||||||
startArrowAnimation(call_right_arrow, initialRightArrowX, initialRightArrowScaleX, initialRightArrowScaleY, rightArrowTranslation)
|
startArrowAnimation(callRightArrow, initialRightArrowX, initialRightArrowScaleX, initialRightArrowScaleY, rightArrowTranslation)
|
||||||
}
|
}
|
||||||
MotionEvent.ACTION_MOVE -> {
|
MotionEvent.ACTION_MOVE -> {
|
||||||
call_draggable.x = min(maxDragX, max(minDragX, event.rawX - dragDownX))
|
callDraggable.x = min(maxDragX, max(minDragX, event.rawX - dragDownX))
|
||||||
when {
|
when {
|
||||||
call_draggable.x >= maxDragX - 50f -> {
|
callDraggable.x >= maxDragX - 50f -> {
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
lock = true
|
lock = true
|
||||||
call_draggable.performHapticFeedback()
|
callDraggable.performHapticFeedback()
|
||||||
if (isRtl) {
|
if (isRtl) {
|
||||||
endCall()
|
endCall()
|
||||||
} else {
|
} else {
|
||||||
|
@ -347,10 +351,11 @@ class CallActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
call_draggable.x <= minDragX + 50f -> {
|
|
||||||
|
callDraggable.x <= minDragX + 50f -> {
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
lock = true
|
lock = true
|
||||||
call_draggable.performHapticFeedback()
|
callDraggable.performHapticFeedback()
|
||||||
if (isRtl) {
|
if (isRtl) {
|
||||||
acceptCall()
|
acceptCall()
|
||||||
} else {
|
} else {
|
||||||
|
@ -358,23 +363,25 @@ class CallActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
call_draggable.x > initialDraggableX -> {
|
|
||||||
|
callDraggable.x > initialDraggableX -> {
|
||||||
lock = false
|
lock = false
|
||||||
val drawableRes = if (isRtl) {
|
val drawableRes = if (isRtl) {
|
||||||
R.drawable.ic_phone_down_red_vector
|
R.drawable.ic_phone_down_red_vector
|
||||||
} else {
|
} else {
|
||||||
R.drawable.ic_phone_green_vector
|
R.drawable.ic_phone_green_vector
|
||||||
}
|
}
|
||||||
call_draggable.setImageDrawable(getDrawable(drawableRes))
|
callDraggable.setImageDrawable(getDrawable(drawableRes))
|
||||||
}
|
}
|
||||||
call_draggable.x <= initialDraggableX -> {
|
|
||||||
|
callDraggable.x <= initialDraggableX -> {
|
||||||
lock = false
|
lock = false
|
||||||
val drawableRes = if (isRtl) {
|
val drawableRes = if (isRtl) {
|
||||||
R.drawable.ic_phone_green_vector
|
R.drawable.ic_phone_green_vector
|
||||||
} else {
|
} else {
|
||||||
R.drawable.ic_phone_down_red_vector
|
R.drawable.ic_phone_down_red_vector
|
||||||
}
|
}
|
||||||
call_draggable.setImageDrawable(getDrawable(drawableRes))
|
callDraggable.setImageDrawable(getDrawable(drawableRes))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -405,7 +412,7 @@ class CallActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun dialpadPressed(char: Char) {
|
private fun dialpadPressed(char: Char) {
|
||||||
CallManager.keypad(char)
|
CallManager.keypad(char)
|
||||||
dialpad_input.addCharacter(char)
|
binding.dialpadInput.addCharacter(char)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun changeCallAudioRoute() {
|
private fun changeCallAudioRoute() {
|
||||||
|
@ -449,7 +456,7 @@ class CallActivity : SimpleActivity() {
|
||||||
|
|
||||||
isSpeakerOn = route == AudioRoute.SPEAKER
|
isSpeakerOn = route == AudioRoute.SPEAKER
|
||||||
val supportedAudioRoutes = CallManager.getSupportedAudioRoutes()
|
val supportedAudioRoutes = CallManager.getSupportedAudioRoutes()
|
||||||
call_toggle_speaker.apply {
|
binding.callToggleSpeaker.apply {
|
||||||
val bluetoothConnected = supportedAudioRoutes.contains(AudioRoute.BLUETOOTH)
|
val bluetoothConnected = supportedAudioRoutes.contains(AudioRoute.BLUETOOTH)
|
||||||
contentDescription = if (bluetoothConnected) {
|
contentDescription = if (bluetoothConnected) {
|
||||||
getString(R.string.choose_audio_route)
|
getString(R.string.choose_audio_route)
|
||||||
|
@ -463,7 +470,7 @@ class CallActivity : SimpleActivity() {
|
||||||
setImageResource(route.iconRes)
|
setImageResource(route.iconRes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toggleButtonColor(call_toggle_speaker, enabled = route != AudioRoute.EARPIECE && route != AudioRoute.WIRED_HEADSET)
|
toggleButtonColor(binding.callToggleSpeaker, enabled = route != AudioRoute.EARPIECE && route != AudioRoute.WIRED_HEADSET)
|
||||||
createOrUpdateAudioRouteChooser(supportedAudioRoutes, create = false)
|
createOrUpdateAudioRouteChooser(supportedAudioRoutes, create = false)
|
||||||
|
|
||||||
if (isSpeakerOn) {
|
if (isSpeakerOn) {
|
||||||
|
@ -482,20 +489,20 @@ class CallActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateMicrophoneButton() {
|
private fun updateMicrophoneButton() {
|
||||||
toggleButtonColor(call_toggle_microphone, isMicrophoneOff)
|
toggleButtonColor(binding.callToggleMicrophone, isMicrophoneOff)
|
||||||
call_toggle_microphone.contentDescription = getString(if (isMicrophoneOff) R.string.turn_microphone_on else R.string.turn_microphone_off)
|
binding.callToggleMicrophone.contentDescription = getString(if (isMicrophoneOff) R.string.turn_microphone_on else R.string.turn_microphone_off)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleDialpadVisibility() {
|
private fun toggleDialpadVisibility() {
|
||||||
if (dialpad_wrapper.isVisible()) hideDialpad() else showDialpad()
|
if (binding.dialpadWrapper.isVisible()) hideDialpad() else showDialpad()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findVisibleViewsUnderDialpad(): Sequence<Pair<View, Float>> {
|
private fun findVisibleViewsUnderDialpad(): Sequence<Pair<View, Float>> {
|
||||||
return ongoing_call_holder.children.filter { it.isVisible() }.map { view -> Pair(view, view.alpha) }
|
return binding.ongoingCallHolder.children.filter { it.isVisible() }.map { view -> Pair(view, view.alpha) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showDialpad() {
|
private fun showDialpad() {
|
||||||
dialpad_wrapper.apply {
|
binding.dialpadWrapper.apply {
|
||||||
translationY = dialpadHeight
|
translationY = dialpadHeight
|
||||||
alpha = 0f
|
alpha = 0f
|
||||||
animate()
|
animate()
|
||||||
|
@ -518,8 +525,8 @@ class CallActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hideDialpad() {
|
private fun hideDialpad() {
|
||||||
dialpad_wrapper.animate()
|
binding.dialpadWrapper.animate()
|
||||||
.withEndAction { dialpad_wrapper.beGone() }
|
.withEndAction { binding.dialpadWrapper.beGone() }
|
||||||
.setInterpolator(AccelerateDecelerateInterpolator())
|
.setInterpolator(AccelerateDecelerateInterpolator())
|
||||||
.setDuration(200L)
|
.setDuration(200L)
|
||||||
.alpha(0f)
|
.alpha(0f)
|
||||||
|
@ -536,9 +543,9 @@ class CallActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun toggleHold() {
|
private fun toggleHold() {
|
||||||
val isOnHold = CallManager.toggleHold()
|
val isOnHold = CallManager.toggleHold()
|
||||||
toggleButtonColor(call_toggle_hold, isOnHold)
|
toggleButtonColor(binding.callToggleHold, isOnHold)
|
||||||
call_toggle_hold.contentDescription = getString(if (isOnHold) R.string.resume_call else R.string.hold_call)
|
binding.callToggleHold.contentDescription = getString(if (isOnHold) R.string.resume_call else R.string.hold_call)
|
||||||
hold_status_label.beVisibleIf(isOnHold)
|
binding.holdStatusLabel.beVisibleIf(isOnHold)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateOtherPersonsInfo(avatar: Bitmap?) {
|
private fun updateOtherPersonsInfo(avatar: Bitmap?) {
|
||||||
|
@ -546,21 +553,23 @@ class CallActivity : SimpleActivity() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
caller_name_label.text = if (callContact!!.name.isNotEmpty()) callContact!!.name else getString(R.string.unknown_caller)
|
binding.apply {
|
||||||
if (callContact!!.number.isNotEmpty() && callContact!!.number != callContact!!.name) {
|
callerNameLabel.text = if (callContact!!.name.isNotEmpty()) callContact!!.name else getString(R.string.unknown_caller)
|
||||||
caller_number.text = callContact!!.number
|
if (callContact!!.number.isNotEmpty() && callContact!!.number != callContact!!.name) {
|
||||||
|
callerNumber.text = callContact!!.number
|
||||||
|
|
||||||
if (callContact!!.numberLabel.isNotEmpty()) {
|
if (callContact!!.numberLabel.isNotEmpty()) {
|
||||||
caller_number.text = "${callContact!!.number} - ${callContact!!.numberLabel}"
|
callerNumber.text = "${callContact!!.number} - ${callContact!!.numberLabel}"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
callerNumber.beGone()
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
caller_number.beGone()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (avatar != null) {
|
if (avatar != null) {
|
||||||
caller_avatar.setImageBitmap(avatar)
|
callerAvatar.setImageBitmap(avatar)
|
||||||
} else {
|
} else {
|
||||||
caller_avatar.setImageDrawable(null)
|
callerAvatar.setImageDrawable(null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,9 +588,11 @@ class CallActivity : SimpleActivity() {
|
||||||
if (accounts.size > 1) {
|
if (accounts.size > 1) {
|
||||||
accounts.forEachIndexed { index, account ->
|
accounts.forEachIndexed { index, account ->
|
||||||
if (account == CallManager.getPrimaryCall()?.details?.accountHandle) {
|
if (account == CallManager.getPrimaryCall()?.details?.accountHandle) {
|
||||||
call_sim_id.text = "${index + 1}"
|
binding.apply {
|
||||||
call_sim_id.beVisible()
|
callSimId.text = "${index + 1}"
|
||||||
call_sim_image.beVisible()
|
callSimId.beVisible()
|
||||||
|
callSimImage.beVisible()
|
||||||
|
}
|
||||||
|
|
||||||
val acceptDrawableId = when (index) {
|
val acceptDrawableId = when (index) {
|
||||||
0 -> R.drawable.ic_phone_one_vector
|
0 -> R.drawable.ic_phone_one_vector
|
||||||
|
@ -592,7 +603,7 @@ class CallActivity : SimpleActivity() {
|
||||||
val rippleBg = resources.getDrawable(R.drawable.ic_call_accept, theme) as RippleDrawable
|
val rippleBg = resources.getDrawable(R.drawable.ic_call_accept, theme) as RippleDrawable
|
||||||
val layerDrawable = rippleBg.findDrawableByLayerId(R.id.accept_call_background_holder) as LayerDrawable
|
val layerDrawable = rippleBg.findDrawableByLayerId(R.id.accept_call_background_holder) as LayerDrawable
|
||||||
layerDrawable.setDrawableByLayerId(R.id.accept_call_icon, getDrawable(acceptDrawableId))
|
layerDrawable.setDrawableByLayerId(R.id.accept_call_icon, getDrawable(acceptDrawableId))
|
||||||
call_accept.setImageDrawable(rippleBg)
|
binding.callAccept.setImageDrawable(rippleBg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -616,13 +627,15 @@ class CallActivity : SimpleActivity() {
|
||||||
else -> 0
|
else -> 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if (statusTextId != 0) {
|
binding.apply {
|
||||||
call_status_label.text = getString(statusTextId)
|
if (statusTextId != 0) {
|
||||||
}
|
callStatusLabel.text = getString(statusTextId)
|
||||||
|
}
|
||||||
|
|
||||||
call_manage.beVisibleIf(call.hasCapability(Call.Details.CAPABILITY_MANAGE_CONFERENCE))
|
callManage.beVisibleIf(call.hasCapability(Call.Details.CAPABILITY_MANAGE_CONFERENCE))
|
||||||
setActionButtonEnabled(call_swap, state == Call.STATE_ACTIVE)
|
setActionButtonEnabled(callSwap, state == Call.STATE_ACTIVE)
|
||||||
setActionButtonEnabled(call_merge, state == Call.STATE_ACTIVE)
|
setActionButtonEnabled(callMerge, state == Call.STATE_ACTIVE)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateState() {
|
private fun updateState() {
|
||||||
|
@ -633,8 +646,8 @@ class CallActivity : SimpleActivity() {
|
||||||
val state = phoneState.call.getStateCompat()
|
val state = phoneState.call.getStateCompat()
|
||||||
val isSingleCallActionsEnabled = (state == Call.STATE_ACTIVE || state == Call.STATE_DISCONNECTED
|
val isSingleCallActionsEnabled = (state == Call.STATE_ACTIVE || state == Call.STATE_DISCONNECTED
|
||||||
|| state == Call.STATE_DISCONNECTING || state == Call.STATE_HOLDING)
|
|| state == Call.STATE_DISCONNECTING || state == Call.STATE_HOLDING)
|
||||||
setActionButtonEnabled(call_toggle_hold, isSingleCallActionsEnabled)
|
setActionButtonEnabled(binding.callToggleHold, isSingleCallActionsEnabled)
|
||||||
setActionButtonEnabled(call_add, isSingleCallActionsEnabled)
|
setActionButtonEnabled(binding.callAdd, isSingleCallActionsEnabled)
|
||||||
} else if (phoneState is TwoCalls) {
|
} else if (phoneState is TwoCalls) {
|
||||||
updateCallState(phoneState.active)
|
updateCallState(phoneState.active)
|
||||||
updateCallOnHoldState(phoneState.onHold)
|
updateCallOnHoldState(phoneState.onHold)
|
||||||
|
@ -648,13 +661,15 @@ class CallActivity : SimpleActivity() {
|
||||||
if (hasCallOnHold) {
|
if (hasCallOnHold) {
|
||||||
getCallContact(applicationContext, call) { contact ->
|
getCallContact(applicationContext, call) { contact ->
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
on_hold_caller_name.text = getContactNameOrNumber(contact)
|
binding.onHoldCallerName.text = getContactNameOrNumber(contact)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
on_hold_status_holder.beVisibleIf(hasCallOnHold)
|
binding.apply {
|
||||||
controls_single_call.beVisibleIf(!hasCallOnHold)
|
onHoldStatusHolder.beVisibleIf(hasCallOnHold)
|
||||||
controls_two_calls.beVisibleIf(hasCallOnHold)
|
controlsSingleCall.beVisibleIf(!hasCallOnHold)
|
||||||
|
controlsTwoCalls.beVisibleIf(hasCallOnHold)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateCallContactInfo(call: Call?) {
|
private fun updateCallContactInfo(call: Call?) {
|
||||||
|
@ -677,18 +692,18 @@ class CallActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun initOutgoingCallUI() {
|
private fun initOutgoingCallUI() {
|
||||||
enableProximitySensor()
|
enableProximitySensor()
|
||||||
incoming_call_holder.beGone()
|
binding.incomingCallHolder.beGone()
|
||||||
ongoing_call_holder.beVisible()
|
binding.ongoingCallHolder.beVisible()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun callRinging() {
|
private fun callRinging() {
|
||||||
incoming_call_holder.beVisible()
|
binding.incomingCallHolder.beVisible()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun callStarted() {
|
private fun callStarted() {
|
||||||
enableProximitySensor()
|
enableProximitySensor()
|
||||||
incoming_call_holder.beGone()
|
binding.incomingCallHolder.beGone()
|
||||||
ongoing_call_holder.beVisible()
|
binding.ongoingCallHolder.beVisible()
|
||||||
callDurationHandler.removeCallbacks(updateCallDurationTask)
|
callDurationHandler.removeCallbacks(updateCallDurationTask)
|
||||||
callDurationHandler.post(updateCallDurationTask)
|
callDurationHandler.post(updateCallDurationTask)
|
||||||
}
|
}
|
||||||
|
@ -719,13 +734,13 @@ class CallActivity : SimpleActivity() {
|
||||||
isCallEnded = true
|
isCallEnded = true
|
||||||
if (callDuration > 0) {
|
if (callDuration > 0) {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
call_status_label.text = "${callDuration.getFormattedDuration()} (${getString(R.string.call_ended)})"
|
binding.callStatusLabel.text = "${callDuration.getFormattedDuration()} (${getString(R.string.call_ended)})"
|
||||||
Handler().postDelayed({
|
Handler().postDelayed({
|
||||||
finishAndRemoveTask()
|
finishAndRemoveTask()
|
||||||
}, 3000)
|
}, 3000)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
call_status_label.text = getString(R.string.call_ended)
|
binding.callStatusLabel.text = getString(R.string.call_ended)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -750,7 +765,7 @@ class CallActivity : SimpleActivity() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
callDuration = CallManager.getPrimaryCall().getCallDuration()
|
callDuration = CallManager.getPrimaryCall().getCallDuration()
|
||||||
if (!isCallEnded) {
|
if (!isCallEnded) {
|
||||||
call_status_label.text = callDuration.getFormattedDuration()
|
binding.callStatusLabel.text = callDuration.getFormattedDuration()
|
||||||
callDurationHandler.postDelayed(this, 1000)
|
callDurationHandler.postDelayed(this, 1000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,28 @@
|
||||||
package com.simplemobiletools.dialer.activities
|
package com.simplemobiletools.dialer.activities
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import com.simplemobiletools.commons.extensions.viewBinding
|
||||||
import com.simplemobiletools.commons.helpers.NavigationIcon
|
import com.simplemobiletools.commons.helpers.NavigationIcon
|
||||||
import com.simplemobiletools.dialer.R
|
|
||||||
import com.simplemobiletools.dialer.adapters.ConferenceCallsAdapter
|
import com.simplemobiletools.dialer.adapters.ConferenceCallsAdapter
|
||||||
|
import com.simplemobiletools.dialer.databinding.ActivityConferenceBinding
|
||||||
import com.simplemobiletools.dialer.helpers.CallManager
|
import com.simplemobiletools.dialer.helpers.CallManager
|
||||||
import kotlinx.android.synthetic.main.activity_conference.*
|
|
||||||
|
|
||||||
class ConferenceActivity : SimpleActivity() {
|
class ConferenceActivity : SimpleActivity() {
|
||||||
|
private val binding by viewBinding(ActivityConferenceBinding::inflate)
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_conference)
|
setContentView(binding.root)
|
||||||
updateMaterialActivityViews(conference_coordinator, conference_list, useTransparentNavigation = true, useTopSearchMenu = false)
|
binding.apply {
|
||||||
setupMaterialScrollListener(conference_list, conference_toolbar)
|
updateMaterialActivityViews(conferenceCoordinator, conferenceList, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||||
conference_list.adapter = ConferenceCallsAdapter(this, conference_list, ArrayList(CallManager.getConferenceCalls())) {}
|
setupMaterialScrollListener(conferenceList, conferenceToolbar)
|
||||||
|
conferenceList.adapter = ConferenceCallsAdapter(this@ConferenceActivity, conferenceList, ArrayList(CallManager.getConferenceCalls())) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setupToolbar(conference_toolbar, NavigationIcon.Arrow)
|
setupToolbar(binding.conferenceToolbar, NavigationIcon.Arrow)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,17 +26,17 @@ import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.contacts.Contact
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.dialer.R
|
import com.simplemobiletools.dialer.R
|
||||||
import com.simplemobiletools.dialer.adapters.ContactsAdapter
|
import com.simplemobiletools.dialer.adapters.ContactsAdapter
|
||||||
|
import com.simplemobiletools.dialer.databinding.ActivityDialpadBinding
|
||||||
import com.simplemobiletools.dialer.extensions.*
|
import com.simplemobiletools.dialer.extensions.*
|
||||||
import com.simplemobiletools.dialer.helpers.DIALPAD_TONE_LENGTH_MS
|
import com.simplemobiletools.dialer.helpers.DIALPAD_TONE_LENGTH_MS
|
||||||
import com.simplemobiletools.dialer.helpers.ToneGeneratorHelper
|
import com.simplemobiletools.dialer.helpers.ToneGeneratorHelper
|
||||||
import com.simplemobiletools.dialer.models.SpeedDial
|
import com.simplemobiletools.dialer.models.SpeedDial
|
||||||
import kotlinx.android.synthetic.main.activity_dialpad.*
|
|
||||||
import kotlinx.android.synthetic.main.activity_dialpad.dialpad_holder
|
|
||||||
import kotlinx.android.synthetic.main.dialpad.*
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
class DialpadActivity : SimpleActivity() {
|
class DialpadActivity : SimpleActivity() {
|
||||||
|
private val binding by viewBinding(ActivityDialpadBinding::inflate)
|
||||||
|
|
||||||
private var allContacts = ArrayList<Contact>()
|
private var allContacts = ArrayList<Contact>()
|
||||||
private var speedDialValues = ArrayList<SpeedDial>()
|
private var speedDialValues = ArrayList<SpeedDial>()
|
||||||
private val russianCharsMap = HashMap<Char, Int>()
|
private val russianCharsMap = HashMap<Char, Int>()
|
||||||
|
@ -49,48 +49,53 @@ class DialpadActivity : SimpleActivity() {
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_dialpad)
|
setContentView(binding.root)
|
||||||
hasRussianLocale = Locale.getDefault().language == "ru"
|
hasRussianLocale = Locale.getDefault().language == "ru"
|
||||||
|
|
||||||
updateMaterialActivityViews(dialpad_coordinator, dialpad_holder, useTransparentNavigation = true, useTopSearchMenu = false)
|
binding.apply {
|
||||||
setupMaterialScrollListener(dialpad_list, dialpad_toolbar)
|
updateMaterialActivityViews(dialpadCoordinator, dialpadHolder, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||||
|
setupMaterialScrollListener(dialpadList, dialpadToolbar)
|
||||||
|
}
|
||||||
|
|
||||||
updateNavigationBarColor(getProperBackgroundColor())
|
updateNavigationBarColor(getProperBackgroundColor())
|
||||||
|
|
||||||
if (checkAppSideloading()) {
|
if (checkAppSideloading()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.hideDialpadNumbers) {
|
binding.dialpadWrapper.apply {
|
||||||
dialpad_1_holder.isVisible = false
|
if (config.hideDialpadNumbers) {
|
||||||
dialpad_2_holder.isVisible = false
|
dialpad1Holder.isVisible = false
|
||||||
dialpad_3_holder.isVisible = false
|
dialpad2Holder.isVisible = false
|
||||||
dialpad_4_holder.isVisible = false
|
dialpad3Holder.isVisible = false
|
||||||
dialpad_5_holder.isVisible = false
|
dialpad4Holder.isVisible = false
|
||||||
dialpad_6_holder.isVisible = false
|
dialpad5Holder.isVisible = false
|
||||||
dialpad_7_holder.isVisible = false
|
dialpad6Holder.isVisible = false
|
||||||
dialpad_8_holder.isVisible = false
|
dialpad7Holder.isVisible = false
|
||||||
dialpad_9_holder.isVisible = false
|
dialpad8Holder.isVisible = false
|
||||||
dialpad_plus_holder.isVisible = true
|
dialpad9Holder.isVisible = false
|
||||||
dialpad_0_holder.visibility = View.INVISIBLE
|
dialpadPlusHolder.isVisible = true
|
||||||
}
|
dialpad0Holder.visibility = View.INVISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
arrayOf(
|
arrayOf(
|
||||||
dialpad_0_holder,
|
dialpad0Holder,
|
||||||
dialpad_1_holder,
|
dialpad1Holder,
|
||||||
dialpad_2_holder,
|
dialpad2Holder,
|
||||||
dialpad_3_holder,
|
dialpad3Holder,
|
||||||
dialpad_4_holder,
|
dialpad4Holder,
|
||||||
dialpad_5_holder,
|
dialpad5Holder,
|
||||||
dialpad_6_holder,
|
dialpad6Holder,
|
||||||
dialpad_7_holder,
|
dialpad7Holder,
|
||||||
dialpad_8_holder,
|
dialpad8Holder,
|
||||||
dialpad_9_holder,
|
dialpad9Holder,
|
||||||
dialpad_plus_holder,
|
dialpadPlusHolder,
|
||||||
dialpad_asterisk_holder,
|
dialpadAsteriskHolder,
|
||||||
dialpad_hashtag_holder
|
dialpadHashtagHolder
|
||||||
).forEach {
|
).forEach {
|
||||||
it.background = ResourcesCompat.getDrawable(resources, R.drawable.pill_background, theme)
|
it.background = ResourcesCompat.getDrawable(resources, R.drawable.pill_background, theme)
|
||||||
it.background?.alpha = LOWER_ALPHA_INT
|
it.background?.alpha = LOWER_ALPHA_INT
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
|
@ -99,46 +104,50 @@ class DialpadActivity : SimpleActivity() {
|
||||||
|
|
||||||
toneGeneratorHelper = ToneGeneratorHelper(this, DIALPAD_TONE_LENGTH_MS)
|
toneGeneratorHelper = ToneGeneratorHelper(this, DIALPAD_TONE_LENGTH_MS)
|
||||||
|
|
||||||
if (hasRussianLocale) {
|
binding.dialpadWrapper.apply {
|
||||||
initRussianChars()
|
if (hasRussianLocale) {
|
||||||
dialpad_2_letters.append("\nАБВГ")
|
initRussianChars()
|
||||||
dialpad_3_letters.append("\nДЕЁЖЗ")
|
dialpad2Letters.append("\nАБВГ")
|
||||||
dialpad_4_letters.append("\nИЙКЛ")
|
dialpad3Letters.append("\nДЕЁЖЗ")
|
||||||
dialpad_5_letters.append("\nМНОП")
|
dialpad4Letters.append("\nИЙКЛ")
|
||||||
dialpad_6_letters.append("\nРСТУ")
|
dialpad5Letters.append("\nМНОП")
|
||||||
dialpad_7_letters.append("\nФХЦЧ")
|
dialpad6Letters.append("\nРСТУ")
|
||||||
dialpad_8_letters.append("\nШЩЪЫ")
|
dialpad7Letters.append("\nФХЦЧ")
|
||||||
dialpad_9_letters.append("\nЬЭЮЯ")
|
dialpad8Letters.append("\nШЩЪЫ")
|
||||||
|
dialpad9Letters.append("\nЬЭЮЯ")
|
||||||
|
|
||||||
val fontSize = resources.getDimension(R.dimen.small_text_size)
|
val fontSize = resources.getDimension(R.dimen.small_text_size)
|
||||||
arrayOf(
|
arrayOf(
|
||||||
dialpad_2_letters, dialpad_3_letters, dialpad_4_letters, dialpad_5_letters, dialpad_6_letters, dialpad_7_letters, dialpad_8_letters,
|
dialpad2Letters, dialpad3Letters, dialpad4Letters, dialpad5Letters, dialpad6Letters, dialpad7Letters, dialpad8Letters,
|
||||||
dialpad_9_letters
|
dialpad9Letters
|
||||||
).forEach {
|
).forEach {
|
||||||
it.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
it.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setupCharClick(dialpad1Holder, '1')
|
||||||
|
setupCharClick(dialpad2Holder, '2')
|
||||||
|
setupCharClick(dialpad3Holder, '3')
|
||||||
|
setupCharClick(dialpad4Holder, '4')
|
||||||
|
setupCharClick(dialpad5Holder, '5')
|
||||||
|
setupCharClick(dialpad6Holder, '6')
|
||||||
|
setupCharClick(dialpad7Holder, '7')
|
||||||
|
setupCharClick(dialpad8Holder, '8')
|
||||||
|
setupCharClick(dialpad9Holder, '9')
|
||||||
|
setupCharClick(dialpad0Holder, '0')
|
||||||
|
setupCharClick(dialpadPlusHolder, '+', longClickable = false)
|
||||||
|
setupCharClick(dialpadAsteriskHolder, '*', longClickable = false)
|
||||||
|
setupCharClick(dialpadHashtagHolder, '#', longClickable = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setupCharClick(dialpad_1_holder, '1')
|
binding.apply {
|
||||||
setupCharClick(dialpad_2_holder, '2')
|
dialpadClearChar.setOnClickListener { clearChar(it) }
|
||||||
setupCharClick(dialpad_3_holder, '3')
|
dialpadClearChar.setOnLongClickListener { clearInput(); true }
|
||||||
setupCharClick(dialpad_4_holder, '4')
|
dialpadCallButton.setOnClickListener { initCall(dialpadInput.value, 0) }
|
||||||
setupCharClick(dialpad_5_holder, '5')
|
dialpadInput.onTextChangeListener { dialpadValueChanged(it) }
|
||||||
setupCharClick(dialpad_6_holder, '6')
|
dialpadInput.requestFocus()
|
||||||
setupCharClick(dialpad_7_holder, '7')
|
dialpadInput.disableKeyboard()
|
||||||
setupCharClick(dialpad_8_holder, '8')
|
}
|
||||||
setupCharClick(dialpad_9_holder, '9')
|
|
||||||
setupCharClick(dialpad_0_holder, '0')
|
|
||||||
setupCharClick(dialpad_plus_holder, '+', longClickable = false)
|
|
||||||
setupCharClick(dialpad_asterisk_holder, '*', longClickable = false)
|
|
||||||
setupCharClick(dialpad_hashtag_holder, '#', longClickable = false)
|
|
||||||
|
|
||||||
dialpad_clear_char.setOnClickListener { clearChar(it) }
|
|
||||||
dialpad_clear_char.setOnLongClickListener { clearInput(); true }
|
|
||||||
dialpad_call_button.setOnClickListener { initCall(dialpad_input.value, 0) }
|
|
||||||
dialpad_input.onTextChangeListener { dialpadValueChanged(it) }
|
|
||||||
dialpad_input.requestFocus()
|
|
||||||
dialpad_input.disableKeyboard()
|
|
||||||
|
|
||||||
ContactsHelper(this).getContacts(showOnlyContactsWithNumbers = true) { allContacts ->
|
ContactsHelper(this).getContacts(showOnlyContactsWithNumbers = true) { allContacts ->
|
||||||
gotContacts(allContacts)
|
gotContacts(allContacts)
|
||||||
|
@ -147,11 +156,13 @@ class DialpadActivity : SimpleActivity() {
|
||||||
val properPrimaryColor = getProperPrimaryColor()
|
val properPrimaryColor = getProperPrimaryColor()
|
||||||
val callIconId = if (areMultipleSIMsAvailable()) {
|
val callIconId = if (areMultipleSIMsAvailable()) {
|
||||||
val callIcon = resources.getColoredDrawableWithColor(R.drawable.ic_phone_two_vector, properPrimaryColor.getContrastColor())
|
val callIcon = resources.getColoredDrawableWithColor(R.drawable.ic_phone_two_vector, properPrimaryColor.getContrastColor())
|
||||||
dialpad_call_two_button.setImageDrawable(callIcon)
|
binding.apply {
|
||||||
dialpad_call_two_button.background.applyColorFilter(properPrimaryColor)
|
dialpadCallTwoButton.setImageDrawable(callIcon)
|
||||||
dialpad_call_two_button.beVisible()
|
dialpadCallTwoButton.background.applyColorFilter(properPrimaryColor)
|
||||||
dialpad_call_two_button.setOnClickListener {
|
dialpadCallTwoButton.beVisible()
|
||||||
initCall(dialpad_input.value, 1)
|
dialpadCallTwoButton.setOnClickListener {
|
||||||
|
initCall(dialpadInput.value, 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
R.drawable.ic_phone_one_vector
|
R.drawable.ic_phone_one_vector
|
||||||
|
@ -159,27 +170,29 @@ class DialpadActivity : SimpleActivity() {
|
||||||
R.drawable.ic_phone_vector
|
R.drawable.ic_phone_vector
|
||||||
}
|
}
|
||||||
|
|
||||||
val callIcon = resources.getColoredDrawableWithColor(callIconId, properPrimaryColor.getContrastColor())
|
binding.apply {
|
||||||
dialpad_call_button.setImageDrawable(callIcon)
|
val callIcon = resources.getColoredDrawableWithColor(callIconId, properPrimaryColor.getContrastColor())
|
||||||
dialpad_call_button.background.applyColorFilter(properPrimaryColor)
|
dialpadCallButton.setImageDrawable(callIcon)
|
||||||
|
dialpadCallButton.background.applyColorFilter(properPrimaryColor)
|
||||||
|
|
||||||
letter_fastscroller.textColor = getProperTextColor().getColorStateList()
|
letterFastscroller.textColor = getProperTextColor().getColorStateList()
|
||||||
letter_fastscroller.pressedTextColor = properPrimaryColor
|
letterFastscroller.pressedTextColor = properPrimaryColor
|
||||||
letter_fastscroller_thumb.setupWithFastScroller(letter_fastscroller)
|
letterFastscrollerThumb.setupWithFastScroller(letterFastscroller)
|
||||||
letter_fastscroller_thumb.textColor = properPrimaryColor.getContrastColor()
|
letterFastscrollerThumb.textColor = properPrimaryColor.getContrastColor()
|
||||||
letter_fastscroller_thumb.thumbColor = properPrimaryColor.getColorStateList()
|
letterFastscrollerThumb.thumbColor = properPrimaryColor.getColorStateList()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
updateTextColors(dialpad_holder)
|
updateTextColors(binding.dialpadHolder)
|
||||||
dialpad_clear_char.applyColorFilter(getProperTextColor())
|
binding.dialpadClearChar.applyColorFilter(getProperTextColor())
|
||||||
updateNavigationBarColor(getProperBackgroundColor())
|
updateNavigationBarColor(getProperBackgroundColor())
|
||||||
setupToolbar(dialpad_toolbar, NavigationIcon.Arrow)
|
setupToolbar(binding.dialpadToolbar, NavigationIcon.Arrow)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
dialpad_toolbar.setOnMenuItemClickListener { menuItem ->
|
binding.dialpadToolbar.setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.add_number_to_contact -> addNumberToContact()
|
R.id.add_number_to_contact -> addNumberToContact()
|
||||||
else -> return@setOnMenuItemClickListener false
|
else -> return@setOnMenuItemClickListener false
|
||||||
|
@ -191,8 +204,8 @@ class DialpadActivity : SimpleActivity() {
|
||||||
private fun checkDialIntent(): Boolean {
|
private fun checkDialIntent(): Boolean {
|
||||||
return if ((intent.action == Intent.ACTION_DIAL || intent.action == Intent.ACTION_VIEW) && intent.data != null && intent.dataString?.contains("tel:") == true) {
|
return if ((intent.action == Intent.ACTION_DIAL || intent.action == Intent.ACTION_VIEW) && intent.data != null && intent.dataString?.contains("tel:") == true) {
|
||||||
val number = Uri.decode(intent.dataString).substringAfter("tel:")
|
val number = Uri.decode(intent.dataString).substringAfter("tel:")
|
||||||
dialpad_input.setText(number)
|
binding.dialpadInput.setText(number)
|
||||||
dialpad_input.setSelection(number.length)
|
binding.dialpadInput.setSelection(number.length)
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
@ -203,23 +216,23 @@ class DialpadActivity : SimpleActivity() {
|
||||||
Intent().apply {
|
Intent().apply {
|
||||||
action = Intent.ACTION_INSERT_OR_EDIT
|
action = Intent.ACTION_INSERT_OR_EDIT
|
||||||
type = "vnd.android.cursor.item/contact"
|
type = "vnd.android.cursor.item/contact"
|
||||||
putExtra(KEY_PHONE, dialpad_input.value)
|
putExtra(KEY_PHONE, binding.dialpadInput.value)
|
||||||
launchActivityIntent(this)
|
launchActivityIntent(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dialpadPressed(char: Char, view: View?) {
|
private fun dialpadPressed(char: Char, view: View?) {
|
||||||
dialpad_input.addCharacter(char)
|
binding.dialpadInput.addCharacter(char)
|
||||||
maybePerformDialpadHapticFeedback(view)
|
maybePerformDialpadHapticFeedback(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun clearChar(view: View) {
|
private fun clearChar(view: View) {
|
||||||
dialpad_input.dispatchKeyEvent(dialpad_input.getKeyEvent(KeyEvent.KEYCODE_DEL))
|
binding.dialpadInput.dispatchKeyEvent(binding.dialpadInput.getKeyEvent(KeyEvent.KEYCODE_DEL))
|
||||||
maybePerformDialpadHapticFeedback(view)
|
maybePerformDialpadHapticFeedback(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun clearInput() {
|
private fun clearInput() {
|
||||||
dialpad_input.setText("")
|
binding.dialpadInput.setText("")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun gotContacts(newContacts: ArrayList<Contact>) {
|
private fun gotContacts(newContacts: ArrayList<Contact>) {
|
||||||
|
@ -232,7 +245,7 @@ class DialpadActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
if (!checkDialIntent() && dialpad_input.value.isEmpty()) {
|
if (!checkDialIntent() && binding.dialpadInput.value.isEmpty()) {
|
||||||
dialpadValueChanged("")
|
dialpadValueChanged("")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,7 +269,7 @@ class DialpadActivity : SimpleActivity() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
(dialpad_list.adapter as? ContactsAdapter)?.finishActMode()
|
(binding.dialpadList.adapter as? ContactsAdapter)?.finishActMode()
|
||||||
|
|
||||||
val filtered = allContacts.filter {
|
val filtered = allContacts.filter {
|
||||||
var convertedName = PhoneNumberUtils.convertKeypadLettersToDigits(it.name.normalizeString())
|
var convertedName = PhoneNumberUtils.convertKeypadLettersToDigits(it.name.normalizeString())
|
||||||
|
@ -275,7 +288,7 @@ class DialpadActivity : SimpleActivity() {
|
||||||
!it.doesContainPhoneNumber(text)
|
!it.doesContainPhoneNumber(text)
|
||||||
}).toMutableList() as ArrayList<Contact>
|
}).toMutableList() as ArrayList<Contact>
|
||||||
|
|
||||||
letter_fastscroller.setupWithRecyclerView(dialpad_list, { position ->
|
binding.letterFastscroller.setupWithRecyclerView(binding.dialpadList, { position ->
|
||||||
try {
|
try {
|
||||||
val name = filtered[position].getNameToDisplay()
|
val name = filtered[position].getNameToDisplay()
|
||||||
val character = if (name.isNotEmpty()) name.substring(0, 1) else ""
|
val character = if (name.isNotEmpty()) name.substring(0, 1) else ""
|
||||||
|
@ -288,7 +301,7 @@ class DialpadActivity : SimpleActivity() {
|
||||||
ContactsAdapter(
|
ContactsAdapter(
|
||||||
activity = this,
|
activity = this,
|
||||||
contacts = filtered,
|
contacts = filtered,
|
||||||
recyclerView = dialpad_list,
|
recyclerView = binding.dialpadList,
|
||||||
highlightText = text
|
highlightText = text
|
||||||
) {
|
) {
|
||||||
val contact = it as Contact
|
val contact = it as Contact
|
||||||
|
@ -300,21 +313,21 @@ class DialpadActivity : SimpleActivity() {
|
||||||
startCallIntent(contact.getPrimaryNumber() ?: return@ContactsAdapter)
|
startCallIntent(contact.getPrimaryNumber() ?: return@ContactsAdapter)
|
||||||
}
|
}
|
||||||
}.apply {
|
}.apply {
|
||||||
dialpad_list.adapter = this
|
binding.dialpadList.adapter = this
|
||||||
}
|
}
|
||||||
|
|
||||||
dialpad_placeholder.beVisibleIf(filtered.isEmpty())
|
binding.dialpadPlaceholder.beVisibleIf(filtered.isEmpty())
|
||||||
dialpad_list.beVisibleIf(filtered.isNotEmpty())
|
binding.dialpadList.beVisibleIf(filtered.isNotEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
||||||
super.onActivityResult(requestCode, resultCode, resultData)
|
super.onActivityResult(requestCode, resultCode, resultData)
|
||||||
if (requestCode == REQUEST_CODE_SET_DEFAULT_DIALER && isDefaultDialer()) {
|
if (requestCode == REQUEST_CODE_SET_DEFAULT_DIALER && isDefaultDialer()) {
|
||||||
dialpadValueChanged(dialpad_input.value)
|
dialpadValueChanged(binding.dialpadInput.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initCall(number: String = dialpad_input.value, handleIndex: Int) {
|
private fun initCall(number: String = binding.dialpadInput.value, handleIndex: Int) {
|
||||||
if (number.isNotEmpty()) {
|
if (number.isNotEmpty()) {
|
||||||
if (handleIndex != -1 && areMultipleSIMsAvailable()) {
|
if (handleIndex != -1 && areMultipleSIMsAvailable()) {
|
||||||
if (config.showCallConfirmation) {
|
if (config.showCallConfirmation) {
|
||||||
|
@ -337,7 +350,7 @@ class DialpadActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun speedDial(id: Int): Boolean {
|
private fun speedDial(id: Int): Boolean {
|
||||||
if (dialpad_input.value.length == 1) {
|
if (binding.dialpadInput.value.length == 1) {
|
||||||
val speedDial = speedDialValues.firstOrNull { it.id == id }
|
val speedDial = speedDialValues.firstOrNull { it.id == id }
|
||||||
if (speedDial?.isValid() == true) {
|
if (speedDial?.isValid() == true) {
|
||||||
initCall(speedDial.number, -1)
|
initCall(speedDial.number, -1)
|
||||||
|
|
|
@ -28,20 +28,21 @@ import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.dialer.BuildConfig
|
import com.simplemobiletools.dialer.BuildConfig
|
||||||
import com.simplemobiletools.dialer.R
|
import com.simplemobiletools.dialer.R
|
||||||
import com.simplemobiletools.dialer.adapters.ViewPagerAdapter
|
import com.simplemobiletools.dialer.adapters.ViewPagerAdapter
|
||||||
|
import com.simplemobiletools.dialer.databinding.ActivityMainBinding
|
||||||
import com.simplemobiletools.dialer.dialogs.ChangeSortingDialog
|
import com.simplemobiletools.dialer.dialogs.ChangeSortingDialog
|
||||||
import com.simplemobiletools.dialer.dialogs.FilterContactSourcesDialog
|
import com.simplemobiletools.dialer.dialogs.FilterContactSourcesDialog
|
||||||
import com.simplemobiletools.dialer.extensions.config
|
import com.simplemobiletools.dialer.extensions.config
|
||||||
import com.simplemobiletools.dialer.extensions.launchCreateNewContactIntent
|
import com.simplemobiletools.dialer.extensions.launchCreateNewContactIntent
|
||||||
|
import com.simplemobiletools.dialer.fragments.ContactsFragment
|
||||||
import com.simplemobiletools.dialer.fragments.FavoritesFragment
|
import com.simplemobiletools.dialer.fragments.FavoritesFragment
|
||||||
import com.simplemobiletools.dialer.fragments.MyViewPagerFragment
|
import com.simplemobiletools.dialer.fragments.MyViewPagerFragment
|
||||||
|
import com.simplemobiletools.dialer.fragments.RecentsFragment
|
||||||
import com.simplemobiletools.dialer.helpers.*
|
import com.simplemobiletools.dialer.helpers.*
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
|
||||||
import kotlinx.android.synthetic.main.fragment_contacts.*
|
|
||||||
import kotlinx.android.synthetic.main.fragment_favorites.*
|
|
||||||
import kotlinx.android.synthetic.main.fragment_recents.*
|
|
||||||
import me.grantland.widget.AutofitHelper
|
import me.grantland.widget.AutofitHelper
|
||||||
|
|
||||||
class MainActivity : SimpleActivity() {
|
class MainActivity : SimpleActivity() {
|
||||||
|
private val binding by viewBinding(ActivityMainBinding::inflate)
|
||||||
|
|
||||||
private var launchedDialer = false
|
private var launchedDialer = false
|
||||||
private var storedShowTabs = 0
|
private var storedShowTabs = 0
|
||||||
private var storedFontSize = 0
|
private var storedFontSize = 0
|
||||||
|
@ -51,11 +52,11 @@ class MainActivity : SimpleActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(binding.root)
|
||||||
appLaunched(BuildConfig.APPLICATION_ID)
|
appLaunched(BuildConfig.APPLICATION_ID)
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
updateMaterialActivityViews(main_coordinator, main_holder, useTransparentNavigation = false, useTopSearchMenu = true)
|
updateMaterialActivityViews(binding.mainCoordinator, binding.mainHolder, useTransparentNavigation = false, useTopSearchMenu = true)
|
||||||
|
|
||||||
launchedDialer = savedInstanceState?.getBoolean(OPEN_DIAL_PAD_AT_LAUNCH) ?: false
|
launchedDialer = savedInstanceState?.getBoolean(OPEN_DIAL_PAD_AT_LAUNCH) ?: false
|
||||||
|
|
||||||
|
@ -63,7 +64,7 @@ class MainActivity : SimpleActivity() {
|
||||||
checkContactPermissions()
|
checkContactPermissions()
|
||||||
|
|
||||||
if (!config.wasOverlaySnackbarConfirmed && !Settings.canDrawOverlays(this)) {
|
if (!config.wasOverlaySnackbarConfirmed && !Settings.canDrawOverlays(this)) {
|
||||||
val snackbar = Snackbar.make(main_holder, R.string.allow_displaying_over_other_apps, Snackbar.LENGTH_INDEFINITE).setAction(R.string.ok) {
|
val snackbar = Snackbar.make(binding.mainHolder, R.string.allow_displaying_over_other_apps, Snackbar.LENGTH_INDEFINITE).setAction(R.string.ok) {
|
||||||
config.wasOverlaySnackbarConfirmed = true
|
config.wasOverlaySnackbarConfirmed = true
|
||||||
startActivity(Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION))
|
startActivity(Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION))
|
||||||
}
|
}
|
||||||
|
@ -102,9 +103,9 @@ class MainActivity : SimpleActivity() {
|
||||||
updateMenuColors()
|
updateMenuColors()
|
||||||
val properPrimaryColor = getProperPrimaryColor()
|
val properPrimaryColor = getProperPrimaryColor()
|
||||||
val dialpadIcon = resources.getColoredDrawableWithColor(R.drawable.ic_dialpad_vector, properPrimaryColor.getContrastColor())
|
val dialpadIcon = resources.getColoredDrawableWithColor(R.drawable.ic_dialpad_vector, properPrimaryColor.getContrastColor())
|
||||||
main_dialpad_button.setImageDrawable(dialpadIcon)
|
binding.mainDialpadButton.setImageDrawable(dialpadIcon)
|
||||||
|
|
||||||
updateTextColors(main_holder)
|
updateTextColors(binding.mainHolder)
|
||||||
setupTabColors()
|
setupTabColors()
|
||||||
|
|
||||||
getAllFragments().forEach {
|
getAllFragments().forEach {
|
||||||
|
@ -113,12 +114,12 @@ class MainActivity : SimpleActivity() {
|
||||||
|
|
||||||
val configStartNameWithSurname = config.startNameWithSurname
|
val configStartNameWithSurname = config.startNameWithSurname
|
||||||
if (storedStartNameWithSurname != configStartNameWithSurname) {
|
if (storedStartNameWithSurname != configStartNameWithSurname) {
|
||||||
contacts_fragment?.startNameWithSurnameChanged(configStartNameWithSurname)
|
getContactsFragment()?.startNameWithSurnameChanged(configStartNameWithSurname)
|
||||||
favorites_fragment?.startNameWithSurnameChanged(configStartNameWithSurname)
|
getFavoritesFragment()?.startNameWithSurnameChanged(configStartNameWithSurname)
|
||||||
storedStartNameWithSurname = config.startNameWithSurname
|
storedStartNameWithSurname = config.startNameWithSurname
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!main_menu.isSearchOpen) {
|
if (!binding.mainMenu.isSearchOpen) {
|
||||||
refreshItems(true)
|
refreshItems(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +132,7 @@ class MainActivity : SimpleActivity() {
|
||||||
|
|
||||||
checkShortcuts()
|
checkShortcuts()
|
||||||
Handler().postDelayed({
|
Handler().postDelayed({
|
||||||
recents_fragment?.refreshItems()
|
getRecentsFragment()?.refreshItems()
|
||||||
}, 2000)
|
}, 2000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +140,7 @@ class MainActivity : SimpleActivity() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
storedShowTabs = config.showTabs
|
storedShowTabs = config.showTabs
|
||||||
storedStartNameWithSurname = config.startNameWithSurname
|
storedStartNameWithSurname = config.startNameWithSurname
|
||||||
config.lastUsedViewPagerPage = view_pager.currentItem
|
config.lastUsedViewPagerPage = binding.viewPager.currentItem
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
||||||
|
@ -165,8 +166,8 @@ class MainActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
if (main_menu.isSearchOpen) {
|
if (binding.mainMenu.isSearchOpen) {
|
||||||
main_menu.closeSearch()
|
binding.mainMenu.closeSearch()
|
||||||
} else {
|
} else {
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
}
|
}
|
||||||
|
@ -174,45 +175,47 @@ class MainActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun refreshMenuItems() {
|
private fun refreshMenuItems() {
|
||||||
val currentFragment = getCurrentFragment()
|
val currentFragment = getCurrentFragment()
|
||||||
main_menu.getToolbar().menu.apply {
|
binding.mainMenu.getToolbar().menu.apply {
|
||||||
findItem(R.id.clear_call_history).isVisible = currentFragment == recents_fragment
|
findItem(R.id.clear_call_history).isVisible = currentFragment == getRecentsFragment()
|
||||||
findItem(R.id.sort).isVisible = currentFragment != recents_fragment
|
findItem(R.id.sort).isVisible = currentFragment != getRecentsFragment()
|
||||||
findItem(R.id.create_new_contact).isVisible = currentFragment == contacts_fragment
|
findItem(R.id.create_new_contact).isVisible = currentFragment == getContactsFragment()
|
||||||
findItem(R.id.change_view_type).isVisible = currentFragment == favorites_fragment
|
findItem(R.id.change_view_type).isVisible = currentFragment == getFavoritesFragment()
|
||||||
findItem(R.id.column_count).isVisible = currentFragment == favorites_fragment && config.viewType == VIEW_TYPE_GRID
|
findItem(R.id.column_count).isVisible = currentFragment == getFavoritesFragment() && config.viewType == VIEW_TYPE_GRID
|
||||||
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(R.bool.hide_google_relations)
|
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(R.bool.hide_google_relations)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
main_menu.getToolbar().inflateMenu(R.menu.menu)
|
binding.mainMenu.apply {
|
||||||
main_menu.toggleHideOnScroll(false)
|
getToolbar().inflateMenu(R.menu.menu)
|
||||||
main_menu.setupMenu()
|
toggleHideOnScroll(false)
|
||||||
|
setupMenu()
|
||||||
|
|
||||||
main_menu.onSearchClosedListener = {
|
onSearchClosedListener = {
|
||||||
getAllFragments().forEach {
|
getAllFragments().forEach {
|
||||||
it?.onSearchQueryChanged("")
|
it?.onSearchQueryChanged("")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
main_menu.onSearchTextChangedListener = { text ->
|
onSearchTextChangedListener = { text ->
|
||||||
getCurrentFragment()?.onSearchQueryChanged(text)
|
getCurrentFragment()?.onSearchQueryChanged(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
main_menu.getToolbar().setOnMenuItemClickListener { menuItem ->
|
getToolbar().setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.clear_call_history -> clearCallHistory()
|
R.id.clear_call_history -> clearCallHistory()
|
||||||
R.id.create_new_contact -> launchCreateNewContactIntent()
|
R.id.create_new_contact -> launchCreateNewContactIntent()
|
||||||
R.id.sort -> showSortingDialog(showCustomSorting = getCurrentFragment() is FavoritesFragment)
|
R.id.sort -> showSortingDialog(showCustomSorting = getCurrentFragment() is FavoritesFragment)
|
||||||
R.id.filter -> showFilterDialog()
|
R.id.filter -> showFilterDialog()
|
||||||
R.id.more_apps_from_us -> launchMoreAppsFromUsIntent()
|
R.id.more_apps_from_us -> launchMoreAppsFromUsIntent()
|
||||||
R.id.settings -> launchSettings()
|
R.id.settings -> launchSettings()
|
||||||
R.id.change_view_type -> changeViewType()
|
R.id.change_view_type -> changeViewType()
|
||||||
R.id.column_count -> changeColumnCount()
|
R.id.column_count -> changeColumnCount()
|
||||||
R.id.about -> launchAbout()
|
R.id.about -> launchAbout()
|
||||||
else -> return@setOnMenuItemClickListener false
|
else -> return@setOnMenuItemClickListener false
|
||||||
|
}
|
||||||
|
return@setOnMenuItemClickListener true
|
||||||
}
|
}
|
||||||
return@setOnMenuItemClickListener true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +230,7 @@ class MainActivity : SimpleActivity() {
|
||||||
val newColumnCount = it as Int
|
val newColumnCount = it as Int
|
||||||
if (currentColumnCount != newColumnCount) {
|
if (currentColumnCount != newColumnCount) {
|
||||||
config.contactsGridColumnCount = newColumnCount
|
config.contactsGridColumnCount = newColumnCount
|
||||||
favorites_fragment?.columnCountChanged()
|
getFavoritesFragment()?.columnCountChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,13 +238,13 @@ class MainActivity : SimpleActivity() {
|
||||||
private fun changeViewType() {
|
private fun changeViewType() {
|
||||||
ChangeViewTypeDialog(this) {
|
ChangeViewTypeDialog(this) {
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
favorites_fragment?.refreshItems()
|
getFavoritesFragment()?.refreshItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateMenuColors() {
|
private fun updateMenuColors() {
|
||||||
updateStatusbarColor(getProperBackgroundColor())
|
updateStatusbarColor(getProperBackgroundColor())
|
||||||
main_menu.updateColors()
|
binding.mainMenu.updateColors()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkContactPermissions() {
|
private fun checkContactPermissions() {
|
||||||
|
@ -255,7 +258,7 @@ class MainActivity : SimpleActivity() {
|
||||||
ConfirmationDialog(this, confirmationText) {
|
ConfirmationDialog(this, confirmationText) {
|
||||||
RecentsHelper(this).removeAllRecentCalls(this) {
|
RecentsHelper(this).removeAllRecentCalls(this) {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
recents_fragment?.refreshItems()
|
getRecentsFragment()?.refreshItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,20 +296,20 @@ class MainActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupTabColors() {
|
private fun setupTabColors() {
|
||||||
val activeView = main_tabs_holder.getTabAt(view_pager.currentItem)?.customView
|
val activeView = binding.mainTabsHolder.getTabAt(binding.viewPager.currentItem)?.customView
|
||||||
updateBottomTabItemColors(activeView, true, getSelectedTabDrawableIds()[view_pager.currentItem])
|
updateBottomTabItemColors(activeView, true, getSelectedTabDrawableIds()[binding.viewPager.currentItem])
|
||||||
|
|
||||||
getInactiveTabIndexes(view_pager.currentItem).forEach { index ->
|
getInactiveTabIndexes(binding.viewPager.currentItem).forEach { index ->
|
||||||
val inactiveView = main_tabs_holder.getTabAt(index)?.customView
|
val inactiveView = binding.mainTabsHolder.getTabAt(index)?.customView
|
||||||
updateBottomTabItemColors(inactiveView, false, getDeselectedTabDrawableIds()[index])
|
updateBottomTabItemColors(inactiveView, false, getDeselectedTabDrawableIds()[index])
|
||||||
}
|
}
|
||||||
|
|
||||||
val bottomBarColor = getBottomNavigationBackgroundColor()
|
val bottomBarColor = getBottomNavigationBackgroundColor()
|
||||||
main_tabs_holder.setBackgroundColor(bottomBarColor)
|
binding.mainTabsHolder.setBackgroundColor(bottomBarColor)
|
||||||
updateNavigationBarColor(bottomBarColor)
|
updateNavigationBarColor(bottomBarColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getInactiveTabIndexes(activeIndex: Int) = (0 until main_tabs_holder.tabCount).filter { it != activeIndex }
|
private fun getInactiveTabIndexes(activeIndex: Int) = (0 until binding.mainTabsHolder.tabCount).filter { it != activeIndex }
|
||||||
|
|
||||||
private fun getSelectedTabDrawableIds(): List<Int> {
|
private fun getSelectedTabDrawableIds(): List<Int> {
|
||||||
val showTabs = config.showTabs
|
val showTabs = config.showTabs
|
||||||
|
@ -347,14 +350,14 @@ class MainActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initFragments() {
|
private fun initFragments() {
|
||||||
view_pager.offscreenPageLimit = 2
|
binding.viewPager.offscreenPageLimit = 2
|
||||||
view_pager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
|
binding.viewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
|
||||||
override fun onPageScrollStateChanged(state: Int) {}
|
override fun onPageScrollStateChanged(state: Int) {}
|
||||||
|
|
||||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {}
|
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {}
|
||||||
|
|
||||||
override fun onPageSelected(position: Int) {
|
override fun onPageSelected(position: Int) {
|
||||||
main_tabs_holder.getTabAt(position)?.select()
|
binding.mainTabsHolder.getTabAt(position)?.select()
|
||||||
getAllFragments().forEach {
|
getAllFragments().forEach {
|
||||||
it?.finishActMode()
|
it?.finishActMode()
|
||||||
}
|
}
|
||||||
|
@ -363,29 +366,29 @@ class MainActivity : SimpleActivity() {
|
||||||
})
|
})
|
||||||
|
|
||||||
// selecting the proper tab sometimes glitches, add an extra selector to make sure we have it right
|
// selecting the proper tab sometimes glitches, add an extra selector to make sure we have it right
|
||||||
main_tabs_holder.onGlobalLayout {
|
binding.mainTabsHolder.onGlobalLayout {
|
||||||
Handler().postDelayed({
|
Handler().postDelayed({
|
||||||
var wantedTab = getDefaultTab()
|
var wantedTab = getDefaultTab()
|
||||||
|
|
||||||
// open the Recents tab if we got here by clicking a missed call notification
|
// open the Recents tab if we got here by clicking a missed call notification
|
||||||
if (intent.action == Intent.ACTION_VIEW && config.showTabs and TAB_CALL_HISTORY > 0) {
|
if (intent.action == Intent.ACTION_VIEW && config.showTabs and TAB_CALL_HISTORY > 0) {
|
||||||
wantedTab = main_tabs_holder.tabCount - 1
|
wantedTab = binding.mainTabsHolder.tabCount - 1
|
||||||
|
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
clearMissedCalls()
|
clearMissedCalls()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main_tabs_holder.getTabAt(wantedTab)?.select()
|
binding.mainTabsHolder.getTabAt(wantedTab)?.select()
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
}, 100L)
|
}, 100L)
|
||||||
}
|
}
|
||||||
|
|
||||||
main_dialpad_button.setOnClickListener {
|
binding.mainDialpadButton.setOnClickListener {
|
||||||
launchDialpad()
|
launchDialpad()
|
||||||
}
|
}
|
||||||
|
|
||||||
view_pager.onGlobalLayout {
|
binding.viewPager.onGlobalLayout {
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,31 +399,31 @@ class MainActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupTabs() {
|
private fun setupTabs() {
|
||||||
view_pager.adapter = null
|
binding.viewPager.adapter = null
|
||||||
main_tabs_holder.removeAllTabs()
|
binding.mainTabsHolder.removeAllTabs()
|
||||||
tabsList.forEachIndexed { index, value ->
|
tabsList.forEachIndexed { index, value ->
|
||||||
if (config.showTabs and value != 0) {
|
if (config.showTabs and value != 0) {
|
||||||
main_tabs_holder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply {
|
binding.mainTabsHolder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply {
|
||||||
customView?.findViewById<ImageView>(R.id.tab_item_icon)?.setImageDrawable(getTabIcon(index))
|
customView?.findViewById<ImageView>(R.id.tab_item_icon)?.setImageDrawable(getTabIcon(index))
|
||||||
customView?.findViewById<TextView>(R.id.tab_item_label)?.text = getTabLabel(index)
|
customView?.findViewById<TextView>(R.id.tab_item_label)?.text = getTabLabel(index)
|
||||||
AutofitHelper.create(customView?.findViewById(R.id.tab_item_label))
|
AutofitHelper.create(customView?.findViewById(R.id.tab_item_label))
|
||||||
main_tabs_holder.addTab(this)
|
binding.mainTabsHolder.addTab(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main_tabs_holder.onTabSelectionChanged(
|
binding.mainTabsHolder.onTabSelectionChanged(
|
||||||
tabUnselectedAction = {
|
tabUnselectedAction = {
|
||||||
updateBottomTabItemColors(it.customView, false, getDeselectedTabDrawableIds()[it.position])
|
updateBottomTabItemColors(it.customView, false, getDeselectedTabDrawableIds()[it.position])
|
||||||
},
|
},
|
||||||
tabSelectedAction = {
|
tabSelectedAction = {
|
||||||
main_menu.closeSearch()
|
binding.mainMenu.closeSearch()
|
||||||
view_pager.currentItem = it.position
|
binding.viewPager.currentItem = it.position
|
||||||
updateBottomTabItemColors(it.customView, true, getSelectedTabDrawableIds()[it.position])
|
updateBottomTabItemColors(it.customView, true, getSelectedTabDrawableIds()[it.position])
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
main_tabs_holder.beGoneIf(main_tabs_holder.tabCount == 1)
|
binding.mainTabsHolder.beGoneIf(binding.mainTabsHolder.tabCount == 1)
|
||||||
storedShowTabs = config.showTabs
|
storedShowTabs = config.showTabs
|
||||||
storedStartNameWithSurname = config.startNameWithSurname
|
storedStartNameWithSurname = config.startNameWithSurname
|
||||||
}
|
}
|
||||||
|
@ -450,14 +453,16 @@ class MainActivity : SimpleActivity() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view_pager.adapter == null) {
|
binding.apply {
|
||||||
view_pager.adapter = ViewPagerAdapter(this)
|
if (viewPager.adapter == null) {
|
||||||
view_pager.currentItem = if (openLastTab) config.lastUsedViewPagerPage else getDefaultTab()
|
viewPager.adapter = ViewPagerAdapter(this@MainActivity)
|
||||||
view_pager.onGlobalLayout {
|
viewPager.currentItem = if (openLastTab) config.lastUsedViewPagerPage else getDefaultTab()
|
||||||
|
viewPager.onGlobalLayout {
|
||||||
|
refreshFragments()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
refreshFragments()
|
refreshFragments()
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
refreshFragments()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,36 +473,42 @@ class MainActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun refreshFragments() {
|
fun refreshFragments() {
|
||||||
contacts_fragment?.refreshItems()
|
getContactsFragment()?.refreshItems()
|
||||||
favorites_fragment?.refreshItems()
|
getFavoritesFragment()?.refreshItems()
|
||||||
recents_fragment?.refreshItems()
|
getRecentsFragment()?.refreshItems()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAllFragments(): ArrayList<MyViewPagerFragment?> {
|
private fun getAllFragments(): ArrayList<MyViewPagerFragment<*>?> {
|
||||||
val showTabs = config.showTabs
|
val showTabs = config.showTabs
|
||||||
val fragments = arrayListOf<MyViewPagerFragment?>()
|
val fragments = arrayListOf<MyViewPagerFragment<*>?>()
|
||||||
|
|
||||||
if (showTabs and TAB_CONTACTS > 0) {
|
if (showTabs and TAB_CONTACTS > 0) {
|
||||||
fragments.add(contacts_fragment)
|
fragments.add(getContactsFragment())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showTabs and TAB_FAVORITES > 0) {
|
if (showTabs and TAB_FAVORITES > 0) {
|
||||||
fragments.add(favorites_fragment)
|
fragments.add(getFavoritesFragment())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showTabs and TAB_CALL_HISTORY > 0) {
|
if (showTabs and TAB_CALL_HISTORY > 0) {
|
||||||
fragments.add(recents_fragment)
|
fragments.add(getRecentsFragment())
|
||||||
}
|
}
|
||||||
|
|
||||||
return fragments
|
return fragments
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCurrentFragment(): MyViewPagerFragment? = getAllFragments().getOrNull(view_pager.currentItem)
|
private fun getCurrentFragment(): MyViewPagerFragment<*>? = getAllFragments().getOrNull(binding.viewPager.currentItem)
|
||||||
|
|
||||||
|
private fun getContactsFragment(): ContactsFragment? = findViewById(R.id.contacts_fragment)
|
||||||
|
|
||||||
|
private fun getFavoritesFragment(): FavoritesFragment? = findViewById(R.id.favorites_fragment)
|
||||||
|
|
||||||
|
private fun getRecentsFragment(): RecentsFragment? = findViewById(R.id.recents_fragment)
|
||||||
|
|
||||||
private fun getDefaultTab(): Int {
|
private fun getDefaultTab(): Int {
|
||||||
val showTabsMask = config.showTabs
|
val showTabsMask = config.showTabs
|
||||||
return when (config.defaultTab) {
|
return when (config.defaultTab) {
|
||||||
TAB_LAST_USED -> if (config.lastUsedViewPagerPage < main_tabs_holder.tabCount) config.lastUsedViewPagerPage else 0
|
TAB_LAST_USED -> if (config.lastUsedViewPagerPage < binding.mainTabsHolder.tabCount) config.lastUsedViewPagerPage else 0
|
||||||
TAB_CONTACTS -> 0
|
TAB_CONTACTS -> 0
|
||||||
TAB_FAVORITES -> if (showTabsMask and TAB_CONTACTS > 0) 1 else 0
|
TAB_FAVORITES -> if (showTabsMask and TAB_CONTACTS > 0) 1 else 0
|
||||||
else -> {
|
else -> {
|
||||||
|
@ -556,15 +567,15 @@ class MainActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun showSortingDialog(showCustomSorting: Boolean) {
|
private fun showSortingDialog(showCustomSorting: Boolean) {
|
||||||
ChangeSortingDialog(this, showCustomSorting) {
|
ChangeSortingDialog(this, showCustomSorting) {
|
||||||
favorites_fragment?.refreshItems {
|
getFavoritesFragment()?.refreshItems {
|
||||||
if (main_menu.isSearchOpen) {
|
if (binding.mainMenu.isSearchOpen) {
|
||||||
getCurrentFragment()?.onSearchQueryChanged(main_menu.getCurrentQuery())
|
getCurrentFragment()?.onSearchQueryChanged(binding.mainMenu.getCurrentQuery())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contacts_fragment?.refreshItems {
|
getContactsFragment()?.refreshItems {
|
||||||
if (main_menu.isSearchOpen) {
|
if (binding.mainMenu.isSearchOpen) {
|
||||||
getCurrentFragment()?.onSearchQueryChanged(main_menu.getCurrentQuery())
|
getCurrentFragment()?.onSearchQueryChanged(binding.mainMenu.getCurrentQuery())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -572,21 +583,21 @@ class MainActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun showFilterDialog() {
|
private fun showFilterDialog() {
|
||||||
FilterContactSourcesDialog(this) {
|
FilterContactSourcesDialog(this) {
|
||||||
favorites_fragment?.refreshItems {
|
getFavoritesFragment()?.refreshItems {
|
||||||
if (main_menu.isSearchOpen) {
|
if (binding.mainMenu.isSearchOpen) {
|
||||||
getCurrentFragment()?.onSearchQueryChanged(main_menu.getCurrentQuery())
|
getCurrentFragment()?.onSearchQueryChanged(binding.mainMenu.getCurrentQuery())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contacts_fragment?.refreshItems {
|
getContactsFragment()?.refreshItems {
|
||||||
if (main_menu.isSearchOpen) {
|
if (binding.mainMenu.isSearchOpen) {
|
||||||
getCurrentFragment()?.onSearchQueryChanged(main_menu.getCurrentQuery())
|
getCurrentFragment()?.onSearchQueryChanged(binding.mainMenu.getCurrentQuery())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
recents_fragment?.refreshItems {
|
getRecentsFragment()?.refreshItems {
|
||||||
if (main_menu.isSearchOpen) {
|
if (binding.mainMenu.isSearchOpen) {
|
||||||
getCurrentFragment()?.onSearchQueryChanged(main_menu.getCurrentQuery())
|
getCurrentFragment()?.onSearchQueryChanged(binding.mainMenu.getCurrentQuery())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,31 +5,36 @@ import com.google.gson.Gson
|
||||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||||
import com.simplemobiletools.commons.extensions.getMyContactsCursor
|
import com.simplemobiletools.commons.extensions.getMyContactsCursor
|
||||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||||
|
import com.simplemobiletools.commons.extensions.viewBinding
|
||||||
import com.simplemobiletools.commons.helpers.ContactsHelper
|
import com.simplemobiletools.commons.helpers.ContactsHelper
|
||||||
import com.simplemobiletools.commons.helpers.MyContactsContentProvider
|
import com.simplemobiletools.commons.helpers.MyContactsContentProvider
|
||||||
import com.simplemobiletools.commons.helpers.NavigationIcon
|
import com.simplemobiletools.commons.helpers.NavigationIcon
|
||||||
import com.simplemobiletools.commons.models.PhoneNumber
|
import com.simplemobiletools.commons.models.PhoneNumber
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.commons.models.contacts.Contact
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.dialer.R
|
|
||||||
import com.simplemobiletools.dialer.adapters.SpeedDialAdapter
|
import com.simplemobiletools.dialer.adapters.SpeedDialAdapter
|
||||||
|
import com.simplemobiletools.dialer.databinding.ActivityManageSpeedDialBinding
|
||||||
import com.simplemobiletools.dialer.dialogs.SelectContactDialog
|
import com.simplemobiletools.dialer.dialogs.SelectContactDialog
|
||||||
import com.simplemobiletools.dialer.extensions.config
|
import com.simplemobiletools.dialer.extensions.config
|
||||||
import com.simplemobiletools.dialer.interfaces.RemoveSpeedDialListener
|
import com.simplemobiletools.dialer.interfaces.RemoveSpeedDialListener
|
||||||
import com.simplemobiletools.dialer.models.SpeedDial
|
import com.simplemobiletools.dialer.models.SpeedDial
|
||||||
import kotlinx.android.synthetic.main.activity_manage_speed_dial.*
|
|
||||||
|
|
||||||
class ManageSpeedDialActivity : SimpleActivity(), RemoveSpeedDialListener {
|
class ManageSpeedDialActivity : SimpleActivity(), RemoveSpeedDialListener {
|
||||||
|
private val binding by viewBinding(ActivityManageSpeedDialBinding::inflate)
|
||||||
|
|
||||||
private var allContacts = mutableListOf<Contact>()
|
private var allContacts = mutableListOf<Contact>()
|
||||||
private var speedDialValues = mutableListOf<SpeedDial>()
|
private var speedDialValues = mutableListOf<SpeedDial>()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_manage_speed_dial)
|
setContentView(binding.root)
|
||||||
|
|
||||||
updateMaterialActivityViews(manage_speed_dial_coordinator, manage_speed_dial_holder, useTransparentNavigation = true, useTopSearchMenu = false)
|
binding.apply {
|
||||||
setupMaterialScrollListener(manage_speed_dial_scrollview, manage_speed_dial_toolbar)
|
updateMaterialActivityViews(manageSpeedDialCoordinator, manageSpeedDialHolder, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||||
|
setupMaterialScrollListener(manageSpeedDialScrollview, manageSpeedDialToolbar)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
speedDialValues = config.getSpeedDialValues()
|
speedDialValues = config.getSpeedDialValues()
|
||||||
updateAdapter()
|
updateAdapter()
|
||||||
|
@ -43,12 +48,12 @@ class ManageSpeedDialActivity : SimpleActivity(), RemoveSpeedDialListener {
|
||||||
allContacts.sort()
|
allContacts.sort()
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTextColors(manage_speed_dial_scrollview)
|
updateTextColors(binding.manageSpeedDialScrollview)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setupToolbar(manage_speed_dial_toolbar, NavigationIcon.Arrow)
|
setupToolbar(binding.manageSpeedDialToolbar, NavigationIcon.Arrow)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
|
@ -57,7 +62,7 @@ class ManageSpeedDialActivity : SimpleActivity(), RemoveSpeedDialListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateAdapter() {
|
private fun updateAdapter() {
|
||||||
SpeedDialAdapter(this, speedDialValues, this, speed_dial_list) {
|
SpeedDialAdapter(this, speedDialValues, this, binding.speedDialList) {
|
||||||
val clickedContact = it as SpeedDial
|
val clickedContact = it as SpeedDial
|
||||||
if (allContacts.isEmpty()) {
|
if (allContacts.isEmpty()) {
|
||||||
return@SpeedDialAdapter
|
return@SpeedDialAdapter
|
||||||
|
@ -88,7 +93,7 @@ class ManageSpeedDialActivity : SimpleActivity(), RemoveSpeedDialListener {
|
||||||
|
|
||||||
}
|
}
|
||||||
}.apply {
|
}.apply {
|
||||||
speed_dial_list.adapter = this
|
binding.speedDialList.adapter = this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,23 +15,24 @@ import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.dialer.R
|
import com.simplemobiletools.dialer.R
|
||||||
|
import com.simplemobiletools.dialer.databinding.ActivitySettingsBinding
|
||||||
import com.simplemobiletools.dialer.dialogs.ExportCallHistoryDialog
|
import com.simplemobiletools.dialer.dialogs.ExportCallHistoryDialog
|
||||||
import com.simplemobiletools.dialer.dialogs.ManageVisibleTabsDialog
|
import com.simplemobiletools.dialer.dialogs.ManageVisibleTabsDialog
|
||||||
import com.simplemobiletools.dialer.extensions.config
|
import com.simplemobiletools.dialer.extensions.config
|
||||||
import com.simplemobiletools.dialer.helpers.RecentsHelper
|
import com.simplemobiletools.dialer.helpers.RecentsHelper
|
||||||
import com.simplemobiletools.dialer.models.RecentCall
|
import com.simplemobiletools.dialer.models.RecentCall
|
||||||
import kotlinx.android.synthetic.main.activity_settings.*
|
|
||||||
import kotlinx.serialization.SerializationException
|
import kotlinx.serialization.SerializationException
|
||||||
import kotlinx.serialization.decodeFromString
|
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
class SettingsActivity : SimpleActivity() {
|
class SettingsActivity : SimpleActivity() {
|
||||||
|
companion object {
|
||||||
|
private const val CALL_HISTORY_FILE_TYPE = "application/json"
|
||||||
|
}
|
||||||
|
|
||||||
private val callHistoryFileType = "application/json"
|
private val binding by viewBinding(ActivitySettingsBinding::inflate)
|
||||||
|
|
||||||
private val getContent = registerForActivityResult(ActivityResultContracts.GetContent()) { uri ->
|
private val getContent = registerForActivityResult(ActivityResultContracts.GetContent()) { uri ->
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
toast(R.string.importing)
|
toast(R.string.importing)
|
||||||
|
@ -39,7 +40,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val saveDocument = registerForActivityResult(ActivityResultContracts.CreateDocument(callHistoryFileType)) { uri ->
|
private val saveDocument = registerForActivityResult(ActivityResultContracts.CreateDocument(CALL_HISTORY_FILE_TYPE)) { uri ->
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
toast(R.string.exporting)
|
toast(R.string.exporting)
|
||||||
RecentsHelper(this).getRecentCalls(false, Int.MAX_VALUE) { recents ->
|
RecentsHelper(this).getRecentCalls(false, Int.MAX_VALUE) { recents ->
|
||||||
|
@ -51,15 +52,17 @@ class SettingsActivity : SimpleActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_settings)
|
setContentView(binding.root)
|
||||||
|
|
||||||
updateMaterialActivityViews(settings_coordinator, settings_holder, useTransparentNavigation = true, useTopSearchMenu = false)
|
binding.apply {
|
||||||
setupMaterialScrollListener(settings_nested_scrollview, settings_toolbar)
|
updateMaterialActivityViews(settingsCoordinator, settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||||
|
setupMaterialScrollListener(settingsNestedScrollview, settingsToolbar)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setupToolbar(settings_toolbar, NavigationIcon.Arrow)
|
setupToolbar(binding.settingsToolbar, NavigationIcon.Arrow)
|
||||||
|
|
||||||
setupPurchaseThankYou()
|
setupPurchaseThankYou()
|
||||||
setupCustomizeColors()
|
setupCustomizeColors()
|
||||||
|
@ -83,16 +86,18 @@ class SettingsActivity : SimpleActivity() {
|
||||||
setupAlwaysShowFullscreen()
|
setupAlwaysShowFullscreen()
|
||||||
setupCallsExport()
|
setupCallsExport()
|
||||||
setupCallsImport()
|
setupCallsImport()
|
||||||
updateTextColors(settings_holder)
|
updateTextColors(binding.settingsHolder)
|
||||||
|
|
||||||
arrayOf(
|
binding.apply {
|
||||||
settings_color_customization_section_label,
|
arrayOf(
|
||||||
settings_general_settings_label,
|
settingsColorCustomizationSectionLabel,
|
||||||
settings_startup_label,
|
settingsGeneralSettingsLabel,
|
||||||
settings_calls_label,
|
settingsStartupLabel,
|
||||||
settings_migration_section_label
|
settingsCallsLabel,
|
||||||
).forEach {
|
settingsMigrationSectionLabel
|
||||||
it.setTextColor(getProperPrimaryColor())
|
).forEach {
|
||||||
|
it.setTextColor(getProperPrimaryColor())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,55 +107,61 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupPurchaseThankYou() {
|
private fun setupPurchaseThankYou() {
|
||||||
settings_purchase_thank_you_holder.beGoneIf(isOrWasThankYouInstalled())
|
binding.settingsPurchaseThankYouHolder.beGoneIf(isOrWasThankYouInstalled())
|
||||||
settings_purchase_thank_you_holder.setOnClickListener {
|
binding.settingsPurchaseThankYouHolder.setOnClickListener {
|
||||||
launchPurchaseThankYouIntent()
|
launchPurchaseThankYouIntent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupCustomizeColors() {
|
private fun setupCustomizeColors() {
|
||||||
settings_color_customization_label.text = getCustomizeColorsString()
|
binding.settingsColorCustomizationLabel.text = getCustomizeColorsString()
|
||||||
settings_color_customization_holder.setOnClickListener {
|
binding.settingsColorCustomizationHolder.setOnClickListener {
|
||||||
handleCustomizeColorsClick()
|
handleCustomizeColorsClick()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupUseEnglish() {
|
private fun setupUseEnglish() {
|
||||||
settings_use_english_holder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
binding.apply {
|
||||||
settings_use_english.isChecked = config.useEnglish
|
settingsUseEnglishHolder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
||||||
settings_use_english_holder.setOnClickListener {
|
settingsUseEnglish.isChecked = config.useEnglish
|
||||||
settings_use_english.toggle()
|
settingsUseEnglishHolder.setOnClickListener {
|
||||||
config.useEnglish = settings_use_english.isChecked
|
settingsUseEnglish.toggle()
|
||||||
exitProcess(0)
|
config.useEnglish = settingsUseEnglish.isChecked
|
||||||
|
exitProcess(0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupLanguage() {
|
private fun setupLanguage() {
|
||||||
settings_language.text = Locale.getDefault().displayLanguage
|
binding.apply {
|
||||||
settings_language_holder.beVisibleIf(isTiramisuPlus())
|
settingsLanguage.text = Locale.getDefault().displayLanguage
|
||||||
settings_language_holder.setOnClickListener {
|
settingsLanguageHolder.beVisibleIf(isTiramisuPlus())
|
||||||
launchChangeAppLanguageIntent()
|
settingsLanguageHolder.setOnClickListener {
|
||||||
|
launchChangeAppLanguageIntent()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// support for device-wise blocking came on Android 7, rely only on that
|
// support for device-wise blocking came on Android 7, rely only on that
|
||||||
@TargetApi(Build.VERSION_CODES.N)
|
@TargetApi(Build.VERSION_CODES.N)
|
||||||
private fun setupManageBlockedNumbers() {
|
private fun setupManageBlockedNumbers() {
|
||||||
settings_manage_blocked_numbers_label.text = addLockedLabelIfNeeded(R.string.manage_blocked_numbers)
|
binding.apply {
|
||||||
settings_manage_blocked_numbers_holder.beVisibleIf(isNougatPlus())
|
settingsManageBlockedNumbersLabel.text = addLockedLabelIfNeeded(R.string.manage_blocked_numbers)
|
||||||
settings_manage_blocked_numbers_holder.setOnClickListener {
|
settingsManageBlockedNumbersHolder.beVisibleIf(isNougatPlus())
|
||||||
if (isOrWasThankYouInstalled()) {
|
settingsManageBlockedNumbersHolder.setOnClickListener {
|
||||||
Intent(this, ManageBlockedNumbersActivity::class.java).apply {
|
if (isOrWasThankYouInstalled()) {
|
||||||
startActivity(this)
|
Intent(this@SettingsActivity, ManageBlockedNumbersActivity::class.java).apply {
|
||||||
|
startActivity(this)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
FeatureLockedDialog(this@SettingsActivity) { }
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
FeatureLockedDialog(this) { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupManageSpeedDial() {
|
private fun setupManageSpeedDial() {
|
||||||
settings_manage_speed_dial_holder.setOnClickListener {
|
binding.settingsManageSpeedDialHolder.setOnClickListener {
|
||||||
Intent(this, ManageSpeedDialActivity::class.java).apply {
|
Intent(this, ManageSpeedDialActivity::class.java).apply {
|
||||||
startActivity(this)
|
startActivity(this)
|
||||||
}
|
}
|
||||||
|
@ -158,14 +169,14 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupChangeDateTimeFormat() {
|
private fun setupChangeDateTimeFormat() {
|
||||||
settings_change_date_time_format_holder.setOnClickListener {
|
binding.settingsChangeDateTimeFormatHolder.setOnClickListener {
|
||||||
ChangeDateTimeFormatDialog(this) {}
|
ChangeDateTimeFormatDialog(this) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupFontSize() {
|
private fun setupFontSize() {
|
||||||
settings_font_size.text = getFontSizeText()
|
binding.settingsFontSize.text = getFontSizeText()
|
||||||
settings_font_size_holder.setOnClickListener {
|
binding.settingsFontSizeHolder.setOnClickListener {
|
||||||
val items = arrayListOf(
|
val items = arrayListOf(
|
||||||
RadioItem(FONT_SIZE_SMALL, getString(R.string.small)),
|
RadioItem(FONT_SIZE_SMALL, getString(R.string.small)),
|
||||||
RadioItem(FONT_SIZE_MEDIUM, getString(R.string.medium)),
|
RadioItem(FONT_SIZE_MEDIUM, getString(R.string.medium)),
|
||||||
|
@ -175,20 +186,20 @@ class SettingsActivity : SimpleActivity() {
|
||||||
|
|
||||||
RadioGroupDialog(this@SettingsActivity, items, config.fontSize) {
|
RadioGroupDialog(this@SettingsActivity, items, config.fontSize) {
|
||||||
config.fontSize = it as Int
|
config.fontSize = it as Int
|
||||||
settings_font_size.text = getFontSizeText()
|
binding.settingsFontSize.text = getFontSizeText()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupManageShownTabs() {
|
private fun setupManageShownTabs() {
|
||||||
settings_manage_tabs_holder.setOnClickListener {
|
binding.settingsManageTabsHolder.setOnClickListener {
|
||||||
ManageVisibleTabsDialog(this)
|
ManageVisibleTabsDialog(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupDefaultTab() {
|
private fun setupDefaultTab() {
|
||||||
settings_default_tab.text = getDefaultTabText()
|
binding.settingsDefaultTab.text = getDefaultTabText()
|
||||||
settings_default_tab_holder.setOnClickListener {
|
binding.settingsDefaultTabHolder.setOnClickListener {
|
||||||
val items = arrayListOf(
|
val items = arrayListOf(
|
||||||
RadioItem(TAB_CONTACTS, getString(R.string.contacts_tab)),
|
RadioItem(TAB_CONTACTS, getString(R.string.contacts_tab)),
|
||||||
RadioItem(TAB_FAVORITES, getString(R.string.favorites_tab)),
|
RadioItem(TAB_FAVORITES, getString(R.string.favorites_tab)),
|
||||||
|
@ -198,7 +209,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
|
|
||||||
RadioGroupDialog(this@SettingsActivity, items, config.defaultTab) {
|
RadioGroupDialog(this@SettingsActivity, items, config.defaultTab) {
|
||||||
config.defaultTab = it as Int
|
config.defaultTab = it as Int
|
||||||
settings_default_tab.text = getDefaultTabText()
|
binding.settingsDefaultTab.text = getDefaultTabText()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,87 +224,107 @@ class SettingsActivity : SimpleActivity() {
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun setupDialPadOpen() {
|
private fun setupDialPadOpen() {
|
||||||
settings_open_dialpad_at_launch.isChecked = config.openDialPadAtLaunch
|
binding.apply {
|
||||||
settings_open_dialpad_at_launch_holder.setOnClickListener {
|
settingsOpenDialpadAtLaunch.isChecked = config.openDialPadAtLaunch
|
||||||
settings_open_dialpad_at_launch.toggle()
|
settingsOpenDialpadAtLaunchHolder.setOnClickListener {
|
||||||
config.openDialPadAtLaunch = settings_open_dialpad_at_launch.isChecked
|
settingsOpenDialpadAtLaunch.toggle()
|
||||||
|
config.openDialPadAtLaunch = settingsOpenDialpadAtLaunch.isChecked
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupGroupSubsequentCalls() {
|
private fun setupGroupSubsequentCalls() {
|
||||||
settings_group_subsequent_calls.isChecked = config.groupSubsequentCalls
|
binding.apply {
|
||||||
settings_group_subsequent_calls_holder.setOnClickListener {
|
settingsGroupSubsequentCalls.isChecked = config.groupSubsequentCalls
|
||||||
settings_group_subsequent_calls.toggle()
|
settingsGroupSubsequentCallsHolder.setOnClickListener {
|
||||||
config.groupSubsequentCalls = settings_group_subsequent_calls.isChecked
|
settingsGroupSubsequentCalls.toggle()
|
||||||
|
config.groupSubsequentCalls = settingsGroupSubsequentCalls.isChecked
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupStartNameWithSurname() {
|
private fun setupStartNameWithSurname() {
|
||||||
settings_start_name_with_surname.isChecked = config.startNameWithSurname
|
binding.apply {
|
||||||
settings_start_name_with_surname_holder.setOnClickListener {
|
settingsStartNameWithSurname.isChecked = config.startNameWithSurname
|
||||||
settings_start_name_with_surname.toggle()
|
settingsStartNameWithSurnameHolder.setOnClickListener {
|
||||||
config.startNameWithSurname = settings_start_name_with_surname.isChecked
|
settingsStartNameWithSurname.toggle()
|
||||||
|
config.startNameWithSurname = settingsStartNameWithSurname.isChecked
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupDialpadVibrations() {
|
private fun setupDialpadVibrations() {
|
||||||
settings_dialpad_vibration.isChecked = config.dialpadVibration
|
binding.apply {
|
||||||
settings_dialpad_vibration_holder.setOnClickListener {
|
settingsDialpadVibration.isChecked = config.dialpadVibration
|
||||||
settings_dialpad_vibration.toggle()
|
settingsDialpadVibrationHolder.setOnClickListener {
|
||||||
config.dialpadVibration = settings_dialpad_vibration.isChecked
|
settingsDialpadVibration.toggle()
|
||||||
|
config.dialpadVibration = settingsDialpadVibration.isChecked
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupDialpadNumbers() {
|
private fun setupDialpadNumbers() {
|
||||||
settings_hide_dialpad_numbers.isChecked = config.hideDialpadNumbers
|
binding.apply {
|
||||||
settings_hide_dialpad_numbers_holder.setOnClickListener {
|
settingsHideDialpadNumbers.isChecked = config.hideDialpadNumbers
|
||||||
settings_hide_dialpad_numbers.toggle()
|
settingsHideDialpadNumbersHolder.setOnClickListener {
|
||||||
config.hideDialpadNumbers = settings_hide_dialpad_numbers.isChecked
|
settingsHideDialpadNumbers.toggle()
|
||||||
|
config.hideDialpadNumbers = settingsHideDialpadNumbers.isChecked
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupDialpadBeeps() {
|
private fun setupDialpadBeeps() {
|
||||||
settings_dialpad_beeps.isChecked = config.dialpadBeeps
|
binding.apply {
|
||||||
settings_dialpad_beeps_holder.setOnClickListener {
|
settingsDialpadBeeps.isChecked = config.dialpadBeeps
|
||||||
settings_dialpad_beeps.toggle()
|
settingsDialpadBeepsHolder.setOnClickListener {
|
||||||
config.dialpadBeeps = settings_dialpad_beeps.isChecked
|
settingsDialpadBeeps.toggle()
|
||||||
|
config.dialpadBeeps = settingsDialpadBeeps.isChecked
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupShowCallConfirmation() {
|
private fun setupShowCallConfirmation() {
|
||||||
settings_show_call_confirmation.isChecked = config.showCallConfirmation
|
binding.apply {
|
||||||
settings_show_call_confirmation_holder.setOnClickListener {
|
settingsShowCallConfirmation.isChecked = config.showCallConfirmation
|
||||||
settings_show_call_confirmation.toggle()
|
settingsShowCallConfirmationHolder.setOnClickListener {
|
||||||
config.showCallConfirmation = settings_show_call_confirmation.isChecked
|
settingsShowCallConfirmation.toggle()
|
||||||
|
config.showCallConfirmation = settingsShowCallConfirmation.isChecked
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupDisableProximitySensor() {
|
private fun setupDisableProximitySensor() {
|
||||||
settings_disable_proximity_sensor.isChecked = config.disableProximitySensor
|
binding.apply {
|
||||||
settings_disable_proximity_sensor_holder.setOnClickListener {
|
settingsDisableProximitySensor.isChecked = config.disableProximitySensor
|
||||||
settings_disable_proximity_sensor.toggle()
|
settingsDisableProximitySensorHolder.setOnClickListener {
|
||||||
config.disableProximitySensor = settings_disable_proximity_sensor.isChecked
|
settingsDisableProximitySensor.toggle()
|
||||||
|
config.disableProximitySensor = settingsDisableProximitySensor.isChecked
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupDisableSwipeToAnswer() {
|
private fun setupDisableSwipeToAnswer() {
|
||||||
settings_disable_swipe_to_answer.isChecked = config.disableSwipeToAnswer
|
binding.apply {
|
||||||
settings_disable_swipe_to_answer_holder.setOnClickListener {
|
settingsDisableSwipeToAnswer.isChecked = config.disableSwipeToAnswer
|
||||||
settings_disable_swipe_to_answer.toggle()
|
settingsDisableSwipeToAnswerHolder.setOnClickListener {
|
||||||
config.disableSwipeToAnswer = settings_disable_swipe_to_answer.isChecked
|
settingsDisableSwipeToAnswer.toggle()
|
||||||
|
config.disableSwipeToAnswer = settingsDisableSwipeToAnswer.isChecked
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAlwaysShowFullscreen() {
|
private fun setupAlwaysShowFullscreen() {
|
||||||
settings_always_show_fullscreen.isChecked = config.alwaysShowFullscreen
|
binding.apply {
|
||||||
settings_always_show_fullscreen_holder.setOnClickListener {
|
settingsAlwaysShowFullscreen.isChecked = config.alwaysShowFullscreen
|
||||||
settings_always_show_fullscreen.toggle()
|
settingsAlwaysShowFullscreenHolder.setOnClickListener {
|
||||||
config.alwaysShowFullscreen = settings_always_show_fullscreen.isChecked
|
settingsAlwaysShowFullscreen.toggle()
|
||||||
|
config.alwaysShowFullscreen = settingsAlwaysShowFullscreen.isChecked
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupCallsExport() {
|
private fun setupCallsExport() {
|
||||||
settings_export_calls_holder.setOnClickListener {
|
binding.settingsExportCallsHolder.setOnClickListener {
|
||||||
ExportCallHistoryDialog(this) { filename ->
|
ExportCallHistoryDialog(this) { filename ->
|
||||||
saveDocument.launch(filename)
|
saveDocument.launch(filename)
|
||||||
}
|
}
|
||||||
|
@ -301,8 +332,8 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupCallsImport() {
|
private fun setupCallsImport() {
|
||||||
settings_import_calls_holder.setOnClickListener {
|
binding.settingsImportCallsHolder.setOnClickListener {
|
||||||
getContent.launch(callHistoryFileType)
|
getContent.launch(CALL_HISTORY_FILE_TYPE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue