Skip to content

Commit

Permalink
Fixed voicemail not working, fixes #358
Browse files Browse the repository at this point in the history
  • Loading branch information
roeiedri committed Mar 12, 2022
1 parent 18d64c9 commit 256940f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,39 @@ package com.chooloo.www.chooloolib.interactor.call
import android.Manifest
import android.content.Context
import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.net.Uri
import android.os.Bundle
import android.provider.VoicemailContract
import android.telecom.PhoneAccount
import android.telecom.TelecomManager
import androidx.annotation.RequiresPermission
import com.chooloo.www.chooloolib.R
import com.chooloo.www.chooloolib.interactor.base.BaseInteractorImpl
import com.chooloo.www.chooloolib.interactor.dialog.DialogsInteractor
import com.chooloo.www.chooloolib.interactor.permission.PermissionsInteractor
import com.chooloo.www.chooloolib.interactor.preferences.PreferencesInteractor
import com.chooloo.www.chooloolib.interactor.sim.SimsInteractor
import com.chooloo.www.chooloolib.model.SimAccount
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.android.scopes.ActivityScoped
import javax.inject.Inject

@ActivityScoped
class CallNavigationsInteractorImpl @Inject constructor(
private val sims: SimsInteractor,
private val dialogs: DialogsInteractor,
private val telecomManager: TelecomManager,
private val permissions: PermissionsInteractor,
private val preferences: PreferencesInteractor,
@ApplicationContext private val context: Context
) : BaseInteractorImpl<CallNavigationsInteractor.Listener>(), CallNavigationsInteractor {
override fun callVoicemail() {
permissions.runWithDefaultDialer(R.string.error_not_default_dialer_call) {
val intent = Intent(Intent.ACTION_CALL)
intent.data = Uri.fromParts("voicemail", "", null)
.setData(Uri.fromParts(PhoneAccount.SCHEME_VOICEMAIL, "", null))
.setFlags(FLAG_ACTIVITY_NEW_TASK)
context.startActivity(intent)
}
}

@RequiresPermission(allOf = [Manifest.permission.READ_PHONE_STATE, Manifest.permission.CALL_PHONE])
override fun call(number: String) {
telecomManager.placeCall(Uri.parse("tel:${Uri.encode(number)}"), Bundle())
telecomManager.placeCall(Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null), Bundle())
}

@RequiresPermission(Manifest.permission.CALL_PHONE)
Expand All @@ -47,6 +44,6 @@ class CallNavigationsInteractorImpl @Inject constructor(
simAccount?.phoneAccountHandle?.let {
extras.putParcelable(VoicemailContract.EXTRA_PHONE_ACCOUNT_HANDLE, it)
}
telecomManager.placeCall(Uri.parse("tel:${Uri.encode(number)}"), extras)
telecomManager.placeCall(Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null), extras)
}
}
1 change: 0 additions & 1 deletion chooloolib/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
<!--region bottom dialog -->
<style name="Chooloo.BottomSheet" parent="Theme.MaterialComponents.DayNight.BottomSheetDialog">
<item name="android:backgroundDimAmount">0.05</item>
<item name="android:navigationBarColor">?colorPrimarySurface</item>
<item name="bottomSheetStyle">@style/Chooloo.BottomDialog.BottomSheetStyle</item>
</style>

Expand Down
1 change: 0 additions & 1 deletion chooloolib/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

<item name="android:windowLightStatusBar">false</item>
<item name="android:fontFamily">@font/google_sans_regular</item>
<item name="android:navigationBarColor">?colorPrimarySurface</item>

<item name="alertDialogTheme">@style/Chooloo.AlertDialog</item>
<item name="bottomSheetDialogTheme">@style/Chooloo.BottomSheet</item>
Expand Down

0 comments on commit 256940f

Please sign in to comment.