Commit d56c6455 authored by Dhiman Paul's avatar Dhiman Paul
Browse files

Initial commit

parents
Pipeline #445 canceled with stages
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>
<entry key="..\:/DialerSDK/dialerservicewrapper/app/dialerextract/src/main/res/layout/activity_main.xml" value="0.11927083333333334" />
<entry key="..\:/DialerSDK/dialerservicewrapper/app/src/main/res/layout/activity_call_window.xml" value="0.264" />
<entry key="..\:/DialerSDK/dialerservicewrapper/app/src/main/res/layout/activity_main.xml" value="0.264" />
<entry key="..\:/DialerSDK/dialerservicewrapper/app/src/main/res/layout/log_row.xml" value="0.36666666666666664" />
</map>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
# dialerServiceWrapper
Wrapper Class Design Project for the Dialer service of Base Dialer. Created for the purpose of creating an SDK for Dialer Service
\ No newline at end of file
/build
\ No newline at end of file
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-android-extensions'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.example.dialerwrapper"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildFeatures{
viewBinding true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation 'com.revesoft.sdk:revecallsdk:1.0.1'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.google.android.material:material:1.4.0'
// Room components
implementation "androidx.room:room-runtime:2.3.0"
kapt "androidx.room:room-compiler:2.3.0"
implementation "androidx.room:room-ktx:2.3.0"
androidTestImplementation "androidx.room:room-testing:2.3.0"
// Lifecycle components
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation "androidx.lifecycle:lifecycle-common-java8:2.4.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0"
// Kotlin components
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.31"
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0"
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0"
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
\ No newline at end of file
package com.example.dialerwrapper
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.example.dialerwrapper", appContext.packageName)
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dialerwrapper">
<application
android:name=".SDK_APP"
android:allowBackup="false"
android:icon="@drawable/ic_call_reject"
android:label="@string/app_name"
android:roundIcon="@drawable/ic_call_reject"
android:supportsRtl="true"
android:theme="@style/Theme.DialerWrapper">
<activity
android:name=".CallWindowActivity"
android:exported="true"
android:launchMode="singleTop"
android:multiprocess="false"
android:parentActivityName=".MainActivity"
android:screenOrientation="portrait"/>
<activity
android:name=".MainActivity"
android:exported="true"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".receiver.IncomingCallReceiver" />
<service android:name=".receiver.IncomingCallListenerService" />
</application>
</manifest>
\ No newline at end of file
package com.example.dialerwrapper
import android.content.Context
import android.media.AudioManager
import androidx.lifecycle.LiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.dialerwrapper.database.CallLogString
import com.example.dialerwrapper.database.room.CallLogDao
import com.example.dialerwrapper.database.room.CallLogEntity
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import timber.log.Timber
class CallViewModel : ViewModel() {
lateinit var callLogDao: CallLogDao
var databaseInit = false
var hold =false
var mute =false
var speaker =false
var callLog = CallLogString()
val audioManager : AudioManager? = null
fun logDAOinit(logDao: CallLogDao){
callLogDao = logDao
databaseInit = true
}
fun insertLogInfo(logdata : String){
GlobalScope.launch(Dispatchers.IO){
callLogDao.insertCallLog(CallLogEntity(0,callLog.timestamp.toString(),callLog.callId,callLog.callerId,callLog.callType,callLog.duration))
}
}
}
\ No newline at end of file
package com.example.dialerwrapper
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.NotificationManagerCompat
import androidx.lifecycle.ViewModelProvider
import com.example.dialerwrapper.database.SubscriberDatabase
import com.example.dialerwrapper.database.room.LogDatabase
import com.example.dialerwrapper.databinding.ActivityCallWindowBinding
import com.revesoft.itelmobiledialer.callwrapper.ReveSdkCallHandler
import com.revesoft.itelmobiledialer.common.CallingResults
import com.revesoft.itelmobiledialer.common.CommonConfig
import com.revesoft.itelmobiledialer.listeners.ListenersProvider
import com.revesoft.itelmobiledialer.listeners.SDKSIPListener
import com.revesoft.itelmobiledialer.signalling.call.CallParameters
import com.revesoft.itelmobiledialer.signalling.data.CallState
import com.revesoft.itelmobiledialer.signalling.data.DisplayStatus
import timber.log.Timber
class CallWindowActivity : AppCompatActivity() {
private lateinit var binding: ActivityCallWindowBinding
private lateinit var reveSdkCallHandler: ReveSdkCallHandler
private var incomingCall = false
private var phoneNumber = " "
private var currentDuration = ""
private lateinit var model: CallViewModel
var disconnectedByUser = false
/*override fun onBackPressed() {
if (SIPProvider.callState != CallState._200_OK
||SIPProvider.callState != CallState._183_PROGRESS
){
super.onBackPressed()
}
}*/
override fun onCreate(savedInstanceState: Bundle?) {
val logDatabase = LogDatabase.getDatabase(applicationContext)!!
Timber.tag("DATABASE").d("CALL Database ${logDatabase.getLogDao()}")
binding = ActivityCallWindowBinding.inflate(layoutInflater)
super.onCreate(savedInstanceState)
setContentView(binding.root)
reveSdkCallHandler = ReveSdkCallHandler()
model = ViewModelProvider(this).get(CallViewModel::class.java)
logDatabase?.let {
// Timber.d("Database Init")
model.logDAOinit(logDatabase.getLogDao())
}
NotificationManagerCompat.from(applicationContext).cancelAll()
val ListenersProviderThread = Thread {
ListenersProvider.sdksipListener = object : SDKSIPListener {
override fun updateCallState(callState: String) {
runOnUiThread {
binding.callStateText.text = callState
}
}
override fun updateDuration(duration: String) {
if (duration != null) {
currentDuration = duration
}
runOnUiThread {
binding.durationText.text = duration
}
}
override fun updateCallState(callState: CallState) {
runOnUiThread {
callStateTextUpdate(callState)
}
}
override fun callStartOrStop(start: Boolean, duration: String) {
if (!start) {
Timber.d(
"Call Ending ${!start} $duration ${ReveSdkCallHandler.incomingCallID}l"
)
model.callLog.duration = binding.durationText.text.toString()
if (model.callLog.duration.equals("Calling")) {
model.callLog.duration = "00:00"
}
if (ReveSdkCallHandler.incomingCallID != "ENDED_CALL") {
ReveSdkCallHandler.incomingCallID = "ENDED_CALL"
// model.callLog.duration = duration
model.insertLogInfo(model.callLog.toString())
if (!disconnectedByUser && model.callLog.duration == "00:00") {
model.callLog.callType = "MISSED"
}
}
finish()
}
}
override fun incomingCallIdDeclaration(callid: String) {
ReveSdkCallHandler.incomingCallID = callid
}
override fun updateDisplayStatus(displayStatus: DisplayStatus) {
}
override fun onMissedCall(s: String, b: Boolean) {
model.callLog.callType = "MISSED"
Timber.d("Missed in Call")
}
override fun updateCallInfo(callParameters: CallParameters) {
}
override fun updateBalance(balance: String) {
}
override fun disconnectedErrorCode(i: Int) {
}
override fun invalidLogIn() {
}
}
}
ListenersProviderThread.start()
ListenersProviderThread.join()
try {
phoneNumber = intent.extras?.getString(CommonConfig.phoneNumberTag)!!
incomingCall = intent.extras?.getBoolean(CommonConfig.incomingCallTag)!!
model.callLog.callerId = phoneNumber
incomingCall.let {
if (it) {
model.callLog.callType = "INCOMING"
}
}
Timber.d("$phoneNumber $incomingCall")
} catch (e: Exception) {
Timber.d("Error: $e")
setResult(CallingResults.FAILED)
Toast.makeText(applicationContext, "Here 1", Toast.LENGTH_LONG).show()
}
if (!incomingCall) {
binding.acceptButton.visibility = View.GONE
}
binding.endButton.setOnClickListener {
disconnectedByUser = true
try {
ReveSdkCallHandler.endCall()
// finish()
} catch (e: Exception) {
}
}
if (!incomingCall) {
binding.numberText.text = phoneNumber
Toast.makeText(applicationContext,
"Calling $phoneNumber paid? ${!SubscriberDatabase.isSubscriber(phoneNumber)}",
Toast.LENGTH_SHORT).show()
ReveSdkCallHandler.makeCall(phoneNumber)
} else {
try {
runOnUiThread {
binding.numberText.text =
intent.extras?.getString(CommonConfig.incomingCallerIDTag)!!
}
ReveSdkCallHandler.incomingCallID =
intent.extras?.getString(CommonConfig.incomingCallIDTag)!!
Toast.makeText(applicationContext, "$phoneNumber $incomingCall", Toast.LENGTH_LONG)
.show()
} catch (e: Exception) {
Timber.d("$e")
setResult(CallingResults.FAILED)
Toast.makeText(applicationContext, "UI!!", Toast.LENGTH_LONG).show()
finish()
}
}
binding.acceptButton.setOnClickListener {
binding.acceptButton.visibility = View.GONE
try {
ReveSdkCallHandler.acceptCall(ReveSdkCallHandler.incomingCallID)
} catch (e: Exception) {
setResult(CallingResults.FAILED)
Toast.makeText(applicationContext, "Accept!!", Toast.LENGTH_LONG).show()
finish()
}
}
binding.speakerButton.setOnClickListener{
ReveSdkCallHandler.setSpeakerOn(!model.speaker)
if (!model.speaker){
binding.speakerButton.setBackgroundResource(R.drawable.ic_speaker_on)
}else{
binding.speakerButton.setBackgroundResource(R.drawable.ic_speaker_off)
}
model.speaker = !model.speaker
}
binding.muteButton.setOnClickListener{
ReveSdkCallHandler.setCallMute(!model.mute)
if (!model.mute){
binding.muteButton.setBackgroundResource(R.drawable.ic_mute)
}else{
binding.muteButton.setBackgroundResource(R.drawable.ic_mute_off)
}
model.mute = !model.mute
}
binding.holdButton.setOnClickListener{
ReveSdkCallHandler.holdCall(!model.hold)
if (!model.hold){
binding.holdButton.setBackgroundResource(R.drawable.ic_hold_on)
}else{
binding.holdButton.setBackgroundResource(R.drawable.ic_hold_off)
}
model.hold = !model.hold
}
}
private fun callStateTextUpdate(callState: CallState) {
binding.callStateText.text = callState.name
val callProgressingList = listOf<String>(
CallState._181_CALL_BEING_FORWARDED.name,
CallState._183_PROGRESS.name,
CallState._180_RING.name,
)
when {
callProgressingList.contains(callState.name) -> {
binding.callStateText.text = getString(R.string.call_progressing)
}
callState == CallState._200_OK -> {
binding.callStateText.text = getString(R.string.connected)
}
callState == CallState.INVITE -> {
binding.callStateText.text = getString(R.string.connecting2)
}
callState == CallState.INCOMING -> {
binding.callStateText.text = getString(R.string.incoming)
}
}
}
override fun onDestroy() {
// model.insertLogInfo(model.callLog.toString())
Timber.d("onDestroy ${ReveSdkCallHandler.incomingCallID}")
super.onDestroy()
}
}
\ No newline at end of file
package com.example.dialerwrapper
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import android.widget.Toast
import androidx.recyclerview.widget.RecyclerView
import com.example.dialerwrapper.database.room.CallLogEntity
import timber.log.Timber
class LogAdapter(private val dataSet: List<CallLogEntity>) :
RecyclerView.Adapter<LogAdapter.ViewHolder>() {
/**
* A reference to the type of views that are being used
* (custom ViewHolder).
*/
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val textView: TextView
val duration: TextView
val time_date : TextView
val time_clock: TextView
val log_image : ImageView
init {
Timber.d("init")
textView = view.findViewById(R.id.call_details)
duration = view.findViewById(R.id.duration_main)
time_date = view.findViewById(R.id.time_stamp)
time_clock = view.findViewById(R.id.time_clock)
log_image = view.findViewById(R.id.log_image)
}
}
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(viewGroup.context)
.inflate(R.layout.log_row, viewGroup,