adding some animating dots like Calling... on the caller screen
This commit is contained in:
parent
4bd42fb861
commit
f96f2bca22
|
@ -25,6 +25,7 @@ import com.simplemobiletools.contacts.pro.R
|
|||
import com.simplemobiletools.contacts.pro.helpers.*
|
||||
import com.simplemobiletools.contacts.pro.models.Contact
|
||||
import com.simplemobiletools.contacts.pro.objects.CallManager
|
||||
import com.simplemobiletools.contacts.pro.overloads.times
|
||||
import com.simplemobiletools.contacts.pro.services.DialerCallService
|
||||
import kotlinx.android.synthetic.main.activity_dialer.*
|
||||
|
||||
|
@ -33,16 +34,19 @@ import kotlinx.android.synthetic.main.activity_dialer.*
|
|||
class DialerActivity : SimpleActivity(), SensorEventListener {
|
||||
private val SENSOR_SENSITIVITY = 4
|
||||
private val DISCONNECT_DELAY = 3000L
|
||||
private val CALLING_DOT_ANIMATION_DELAY = 500L
|
||||
|
||||
private var callNumber = ""
|
||||
private var callStatus = Call.STATE_NEW
|
||||
private var isIncomingCall = false
|
||||
private var isCallActive = false
|
||||
private var callDuration = 0
|
||||
private var callingDotsCnt = 0
|
||||
private var sensorManager: SensorManager? = null
|
||||
private var proximity: Sensor? = null
|
||||
private var proximityWakeLock: PowerManager.WakeLock? = null
|
||||
private var timerHandler = Handler()
|
||||
private var callingDotsHandler = Handler()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -59,27 +63,27 @@ class DialerActivity : SimpleActivity(), SensorEventListener {
|
|||
val extras = intent.extras
|
||||
if (extras?.getBoolean(ANSWER_CALL, false) == true) {
|
||||
callNumber = intent.getStringExtra(CALL_NUMBER)
|
||||
initViews()
|
||||
CallManager.answerCall()
|
||||
tryFillingOtherEndsName()
|
||||
tryFillingOtherParticipantsName()
|
||||
initViews()
|
||||
} else if (action == Intent.ACTION_CALL && intent.data != null && intent.dataString?.contains("tel:") == true) {
|
||||
callNumber = Uri.decode(intent.dataString).substringAfter("tel:")
|
||||
initViews()
|
||||
tryFillingOtherEndsName()
|
||||
tryFillingOtherParticipantsName()
|
||||
initOutgoingCall()
|
||||
initViews()
|
||||
} else if (action == INCOMING_CALL && extras?.containsKey(CALL_NUMBER) == true && extras.containsKey(CALL_STATUS)) {
|
||||
isIncomingCall = true
|
||||
callNumber = intent.getStringExtra(CALL_NUMBER)
|
||||
initViews()
|
||||
updateUI(intent.getIntExtra(CALL_STATUS, Call.STATE_NEW))
|
||||
tryFillingOtherEndsName()
|
||||
tryFillingOtherParticipantsName()
|
||||
} else if (action == RESUME_DIALER && extras?.containsKey(CALL_NUMBER) == true && extras.containsKey(CALL_STATUS) && extras.containsKey(IS_INCOMING_CALL)) {
|
||||
callNumber = intent.getStringExtra(CALL_NUMBER)
|
||||
callStatus = intent.getIntExtra(CALL_STATUS, Call.STATE_NEW)
|
||||
isIncomingCall = intent.getBooleanExtra(IS_INCOMING_CALL, false)
|
||||
initViews()
|
||||
updateUI(callStatus)
|
||||
tryFillingOtherEndsName()
|
||||
tryFillingOtherParticipantsName()
|
||||
initViews()
|
||||
} else {
|
||||
toast(R.string.unknown_error_occurred)
|
||||
finish()
|
||||
|
@ -103,6 +107,7 @@ class DialerActivity : SimpleActivity(), SensorEventListener {
|
|||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
timerHandler.removeCallbacksAndMessages(null)
|
||||
callingDotsHandler.removeCallbacksAndMessages(null)
|
||||
}
|
||||
|
||||
private val messageReceiver = object : BroadcastReceiver() {
|
||||
|
@ -120,6 +125,17 @@ class DialerActivity : SimpleActivity(), SensorEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
// animate the dots after Calling... from 0 to 3
|
||||
private fun handleDotsAnimation() {
|
||||
callingDotsHandler.postDelayed({
|
||||
if (callStatus == Call.STATE_DIALING) {
|
||||
callingDotsCnt = ++callingDotsCnt % 4
|
||||
dialer_label_dots.text = ".".times(callingDotsCnt)
|
||||
handleDotsAnimation()
|
||||
}
|
||||
}, CALLING_DOT_ANIMATION_DELAY)
|
||||
}
|
||||
|
||||
private fun initProximityWakeLock() {
|
||||
sensorManager = getSystemService(Context.SENSOR_SERVICE) as SensorManager
|
||||
proximity = sensorManager!!.getDefaultSensor(Sensor.TYPE_PROXIMITY)
|
||||
|
@ -141,6 +157,9 @@ class DialerActivity : SimpleActivity(), SensorEventListener {
|
|||
dialer_incoming_accept.beVisibleIf(isIncomingCall)
|
||||
|
||||
dialer_label.setText(if (isIncomingCall) R.string.incoming_call_from else R.string.calling)
|
||||
if (!isIncomingCall) {
|
||||
handleDotsAnimation()
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
|
@ -183,7 +202,7 @@ class DialerActivity : SimpleActivity(), SensorEventListener {
|
|||
finish()
|
||||
}
|
||||
|
||||
private fun tryFillingOtherEndsName() {
|
||||
private fun tryFillingOtherParticipantsName() {
|
||||
ContactsHelper(this).getContactWithNumber(callNumber) {
|
||||
runOnUiThread {
|
||||
updateOtherParticipant(it)
|
||||
|
@ -200,6 +219,8 @@ class DialerActivity : SimpleActivity(), SensorEventListener {
|
|||
}
|
||||
|
||||
private fun statusActive() {
|
||||
callingDotsHandler.removeCallbacksAndMessages(null)
|
||||
dialer_label_dots.beGone()
|
||||
startNotificationService()
|
||||
isCallActive = true
|
||||
dialer_call_duration.beVisible()
|
||||
|
@ -222,8 +243,10 @@ class DialerActivity : SimpleActivity(), SensorEventListener {
|
|||
}
|
||||
|
||||
private fun statusDisconnected() {
|
||||
stopNotificationService()
|
||||
callingDotsHandler.removeCallbacksAndMessages(null)
|
||||
timerHandler.removeCallbacksAndMessages(null)
|
||||
dialer_label_dots.beGone()
|
||||
stopNotificationService()
|
||||
dialer_hangup_button.beGone()
|
||||
dialer_label.setText(R.string.disconnected)
|
||||
if (isCallActive) {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialer_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dialer_top_margin"
|
||||
android:gravity="center_horizontal"
|
||||
|
@ -19,6 +19,17 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialer_label_dots"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:textSize="@dimen/big_text_size"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/dialer_label"
|
||||
app:layout_constraintStart_toEndOf="@+id/dialer_label"
|
||||
app:layout_constraintTop_toTopOf="@+id/dialer_label"
|
||||
tools:text="..."/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialer_big_name_number"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
|
||||
<!-- Dialer -->
|
||||
<string name="dialer">Dialer</string>
|
||||
<string name="calling">Calling…</string>
|
||||
<string name="calling">Calling</string>
|
||||
<string name="incoming_call">Incoming call</string>
|
||||
<string name="incoming_call_from">Incoming call from…</string>
|
||||
<string name="ongoing_call">Ongoing call</string>
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
|
||||
<!-- Dialer -->
|
||||
<string name="dialer">Dialer</string>
|
||||
<string name="calling">Calling…</string>
|
||||
<string name="calling">Calling</string>
|
||||
<string name="incoming_call">Incoming call</string>
|
||||
<string name="incoming_call_from">Incoming call from…</string>
|
||||
<string name="ongoing_call">Ongoing call</string>
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
|
||||
<!-- Dialer -->
|
||||
<string name="dialer">Dialer</string>
|
||||
<string name="calling">Calling…</string>
|
||||
<string name="calling">Calling</string>
|
||||
<string name="incoming_call">Incoming call</string>
|
||||
<string name="incoming_call_from">Incoming call from…</string>
|
||||
<string name="ongoing_call">Ongoing call</string>
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
|
||||
<!-- Dialer -->
|
||||
<string name="dialer">Dialer</string>
|
||||
<string name="calling">Calling…</string>
|
||||
<string name="calling">Calling</string>
|
||||
<string name="incoming_call">Incoming call</string>
|
||||
<string name="incoming_call_from">Incoming call from…</string>
|
||||
<string name="ongoing_call">Ongoing call</string>
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
|
||||
<!-- Dialer -->
|
||||
<string name="dialer">Numéroteur</string>
|
||||
<string name="calling">Appel en cours…</string>
|
||||
<string name="calling">Appel en cours</string>
|
||||
<string name="incoming_call">Appel entrant</string>
|
||||
<string name="incoming_call_from">Appel entrant de…</string>
|
||||
<string name="ongoing_call">Appel en cours</string>
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
|
||||
<!-- Dialer -->
|
||||
<string name="dialer">Dialer</string>
|
||||
<string name="calling">Calling…</string>
|
||||
<string name="calling">Calling</string>
|
||||
<string name="incoming_call">Incoming call</string>
|
||||
<string name="incoming_call_from">Incoming call from…</string>
|
||||
<string name="ongoing_call">Ongoing call</string>
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
|
||||
<!-- Dialer -->
|
||||
<string name="dialer">Compositore</string>
|
||||
<string name="calling">Chiamata in corso…</string>
|
||||
<string name="calling">Chiamata in corso</string>
|
||||
<string name="incoming_call">Chiamata in arrivo</string>
|
||||
<string name="incoming_call_from">Chiamata in arrivo da…</string>
|
||||
<string name="ongoing_call">Chiamata in corso</string>
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
|
||||
<!-- Dialer -->
|
||||
<string name="dialer">電話</string>
|
||||
<string name="calling">発信中…</string>
|
||||
<string name="calling">発信中</string>
|
||||
<string name="incoming_call">Incoming call</string>
|
||||
<string name="incoming_call_from">着信中…</string>
|
||||
<string name="ongoing_call">通話中</string>
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
|
||||
<!-- Dialer -->
|
||||
<string name="dialer">Dialer</string>
|
||||
<string name="calling">Calling…</string>
|
||||
<string name="calling">Calling</string>
|
||||
<string name="incoming_call">Incoming call</string>
|
||||
<string name="incoming_call_from">Incoming call from…</string>
|
||||
<string name="ongoing_call">Ongoing call</string>
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
|
||||
<!-- Dialer -->
|
||||
<string name="dialer">Dialer</string>
|
||||
<string name="calling">Calling…</string>
|
||||
<string name="calling">Calling</string>
|
||||
<string name="incoming_call">Incoming call</string>
|
||||
<string name="incoming_call_from">Incoming call from…</string>
|
||||
<string name="ongoing_call">Ongoing call</string>
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
|
||||
<!-- Dialer -->
|
||||
<string name="dialer">Marcador</string>
|
||||
<string name="calling">A chamar…</string>
|
||||
<string name="calling">A chamar</string>
|
||||
<string name="incoming_call">Chamada recebida</string>
|
||||
<string name="incoming_call_from">Chamada recebida de…</string>
|
||||
<string name="ongoing_call">Chamada efetuada</string>
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
|
||||
<!-- Dialer -->
|
||||
<string name="dialer">Dialer</string>
|
||||
<string name="calling">Calling…</string>
|
||||
<string name="calling">Calling</string>
|
||||
<string name="incoming_call">Incoming call</string>
|
||||
<string name="incoming_call_from">Incoming call from…</string>
|
||||
<string name="ongoing_call">Ongoing call</string>
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
|
||||
<!-- Dialer -->
|
||||
<string name="dialer">Telefón</string>
|
||||
<string name="calling">Vytáča sa…</string>
|
||||
<string name="calling">Vytáča sa</string>
|
||||
<string name="incoming_call">Prichádzajúci hovor</string>
|
||||
<string name="incoming_call_from">Prichádzajúci hovor od…</string>
|
||||
<string name="ongoing_call">Prebiehajúci hovor</string>
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
|
||||
<!-- Dialer -->
|
||||
<string name="dialer">Dialer</string>
|
||||
<string name="calling">Calling…</string>
|
||||
<string name="calling">Calling</string>
|
||||
<string name="incoming_call">Incoming call</string>
|
||||
<string name="incoming_call_from">Incoming call from…</string>
|
||||
<string name="ongoing_call">Ongoing call</string>
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
|
||||
<!-- Dialer -->
|
||||
<string name="dialer">Dialer</string>
|
||||
<string name="calling">Calling…</string>
|
||||
<string name="calling">Calling</string>
|
||||
<string name="incoming_call">Incoming call</string>
|
||||
<string name="incoming_call_from">Incoming call from…</string>
|
||||
<string name="ongoing_call">Ongoing call</string>
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
|
||||
<!-- Dialer -->
|
||||
<string name="dialer">撥號器</string>
|
||||
<string name="calling">撥號中…</string>
|
||||
<string name="calling">撥號中</string>
|
||||
<string name="incoming_call">來電</string>
|
||||
<string name="incoming_call_from">通話來自於…</string>
|
||||
<string name="ongoing_call">持續通話</string>
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
|
||||
<!-- Dialer -->
|
||||
<string name="dialer">Dialer</string>
|
||||
<string name="calling">Calling…</string>
|
||||
<string name="calling">Calling</string>
|
||||
<string name="incoming_call">Incoming call</string>
|
||||
<string name="incoming_call_from">Incoming call from…</string>
|
||||
<string name="ongoing_call">Ongoing call</string>
|
||||
|
|
Loading…
Reference in New Issue