-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: inbuilt dialer including call history
- Loading branch information
Showing
18 changed files
with
740 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.bnyro.contacts.ext | ||
|
||
fun String.removeLastChar(): String { | ||
return if (isEmpty()) this | ||
else substring(0, length - 1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.bnyro.contacts.obj | ||
|
||
data class CallLogEntry( | ||
val phoneNumber: String, | ||
val type: Int, | ||
val time: Long, | ||
val duration: Long | ||
) |
30 changes: 30 additions & 0 deletions
30
app/src/main/java/com/bnyro/contacts/services/CallService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.bnyro.contacts.services | ||
|
||
import android.content.Intent | ||
import android.telecom.Call | ||
import android.telecom.InCallService | ||
import com.bnyro.contacts.ui.activities.CallActivity | ||
import com.bnyro.contacts.util.CallManager | ||
|
||
class CallService : InCallService() { | ||
private val callCallback: Call.Callback = object : Call.Callback() { | ||
override fun onStateChanged(call: Call, state: Int) { | ||
CallManager.updateCallState(state) | ||
} | ||
} | ||
|
||
override fun onCallAdded(call: Call) { | ||
super.onCallAdded(call) | ||
call.registerCallback(callCallback) | ||
val intent = Intent(applicationContext, CallActivity::class.java) | ||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK | ||
startActivity(intent) | ||
CallManager.setCall(call) | ||
} | ||
|
||
override fun onCallRemoved(call: Call) { | ||
super.onCallRemoved(call) | ||
call.unregisterCallback(callCallback) | ||
CallManager.setCall(null) | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
app/src/main/java/com/bnyro/contacts/ui/activities/CallActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.bnyro.contacts.ui.activities | ||
|
||
import android.os.Bundle | ||
import androidx.activity.compose.setContent | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.ui.Modifier | ||
import androidx.lifecycle.ViewModelProvider | ||
import androidx.lifecycle.get | ||
import com.bnyro.contacts.ui.models.DialerModel | ||
import com.bnyro.contacts.ui.screens.DialerScreen | ||
import com.bnyro.contacts.ui.theme.ConnectYouTheme | ||
|
||
class CallActivity: BaseActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
val dialerModel: DialerModel = ViewModelProvider(this).get() | ||
|
||
setContent { | ||
ConnectYouTheme { | ||
Scaffold { pV -> | ||
Box( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.padding(pV) | ||
) { | ||
DialerScreen(contactsModel = contactsModel, dialerModel = dialerModel) { | ||
finish() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
app/src/main/java/com/bnyro/contacts/ui/components/ContactIconPlaceholder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.bnyro.contacts.ui.components | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.unit.dp | ||
import com.bnyro.contacts.ext.contentColor | ||
import com.bnyro.contacts.ui.models.ThemeModel | ||
import com.bnyro.contacts.util.ColorUtils | ||
|
||
@Composable | ||
fun ContactIconPlaceholder( | ||
themeModel: ThemeModel, | ||
firstChar: Char? | ||
) { | ||
val backgroundColor = if (themeModel.colorfulIcons) { | ||
remember { Color(ColorUtils.getRandomColor()) } | ||
} else { | ||
MaterialTheme.colorScheme.primary | ||
} | ||
val contentColor = when { | ||
!themeModel.colorfulIcons -> MaterialTheme.colorScheme.onPrimary | ||
else -> backgroundColor.contentColor() | ||
} | ||
|
||
Box( | ||
modifier = Modifier | ||
.size(42.dp) | ||
.background( | ||
shape = CircleShape, | ||
color = backgroundColor | ||
) | ||
) { | ||
Text( | ||
modifier = Modifier.align(Alignment.Center), | ||
text = firstChar?.toString() ?: "?", | ||
color = contentColor, | ||
fontWeight = FontWeight.Bold | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.