Request restart of Telecom Framework setting is changed
This commit is contained in:
@@ -207,8 +207,8 @@ private fun AudioContent(contentPadding: PaddingValues) {
|
|||||||
verticalArrangement = Arrangement.spacedBy(12.dp),
|
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||||
) {
|
) {
|
||||||
Telecom()
|
Telecom()
|
||||||
ToneCountry()
|
|
||||||
Ringtone()
|
Ringtone()
|
||||||
|
ToneCountry()
|
||||||
SpeakerPhone()
|
SpeakerPhone()
|
||||||
CallVolume()
|
CallVolume()
|
||||||
MicGain()
|
MicGain()
|
||||||
@@ -250,6 +250,65 @@ private fun Telecom() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun Ringtone() {
|
||||||
|
val ringToneTitle = stringResource(R.string.ringtone)
|
||||||
|
val selectRingToneMessage = stringResource(R.string.select_ringtone)
|
||||||
|
val ctx = LocalContext.current
|
||||||
|
var ringtoneUri by remember {
|
||||||
|
mutableStateOf(if (Preferences(ctx).ringtoneUri == "")
|
||||||
|
RingtoneManager.getActualDefaultRingtoneUri(ctx, RingtoneManager.TYPE_RINGTONE).toString()
|
||||||
|
else
|
||||||
|
Preferences(ctx).ringtoneUri!!)
|
||||||
|
}
|
||||||
|
newRingtoneUri = ringtoneUri
|
||||||
|
val launcher = rememberLauncherForActivityResult(
|
||||||
|
ActivityResultContracts.StartActivityForResult()
|
||||||
|
) { result: ActivityResult ->
|
||||||
|
if (result.resultCode == android.app.Activity.RESULT_OK) {
|
||||||
|
val uri: Uri? = if (VERSION.SDK_INT >= 33)
|
||||||
|
result.data?.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI, Uri::class.java)
|
||||||
|
else
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
result.data?.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI)
|
||||||
|
if (uri != null) {
|
||||||
|
ringtoneUri = uri.toString()
|
||||||
|
newRingtoneUri = ringtoneUri
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Row(
|
||||||
|
Modifier.fillMaxWidth(),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.Start
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = ringToneTitle,
|
||||||
|
modifier = Modifier
|
||||||
|
.weight(1f)
|
||||||
|
.clickable {
|
||||||
|
val intent = Intent(RingtoneManager.ACTION_RINGTONE_PICKER)
|
||||||
|
intent.putExtra(
|
||||||
|
RingtoneManager.EXTRA_RINGTONE_TYPE,
|
||||||
|
RingtoneManager.TYPE_RINGTONE
|
||||||
|
)
|
||||||
|
intent.putExtra(
|
||||||
|
RingtoneManager.EXTRA_RINGTONE_TITLE,
|
||||||
|
selectRingToneMessage
|
||||||
|
)
|
||||||
|
intent.putExtra(
|
||||||
|
RingtoneManager.EXTRA_RINGTONE_EXISTING_URI,
|
||||||
|
ringtoneUri.toUri()
|
||||||
|
)
|
||||||
|
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false)
|
||||||
|
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true)
|
||||||
|
launcher.launch(intent)
|
||||||
|
},
|
||||||
|
fontSize = 18.sp,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ToneCountry() {
|
private fun ToneCountry() {
|
||||||
Row(
|
Row(
|
||||||
@@ -312,65 +371,6 @@ private fun ToneCountry() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun Ringtone() {
|
|
||||||
val ringToneTitle = stringResource(R.string.ringtone)
|
|
||||||
val selectRingToneMessage = stringResource(R.string.select_ringtone)
|
|
||||||
val ctx = LocalContext.current
|
|
||||||
var ringtoneUri by remember {
|
|
||||||
mutableStateOf(if (Preferences(ctx).ringtoneUri == "")
|
|
||||||
RingtoneManager.getActualDefaultRingtoneUri(ctx, RingtoneManager.TYPE_RINGTONE).toString()
|
|
||||||
else
|
|
||||||
Preferences(ctx).ringtoneUri!!)
|
|
||||||
}
|
|
||||||
newRingtoneUri = ringtoneUri
|
|
||||||
val launcher = rememberLauncherForActivityResult(
|
|
||||||
ActivityResultContracts.StartActivityForResult()
|
|
||||||
) { result: ActivityResult ->
|
|
||||||
if (result.resultCode == android.app.Activity.RESULT_OK) {
|
|
||||||
val uri: Uri? = if (VERSION.SDK_INT >= 33)
|
|
||||||
result.data?.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI, Uri::class.java)
|
|
||||||
else
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
result.data?.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI)
|
|
||||||
if (uri != null) {
|
|
||||||
ringtoneUri = uri.toString()
|
|
||||||
newRingtoneUri = ringtoneUri
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Row(
|
|
||||||
Modifier.fillMaxWidth(),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.Start
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = ringToneTitle,
|
|
||||||
modifier = Modifier
|
|
||||||
.weight(1f)
|
|
||||||
.clickable {
|
|
||||||
val intent = Intent(RingtoneManager.ACTION_RINGTONE_PICKER)
|
|
||||||
intent.putExtra(
|
|
||||||
RingtoneManager.EXTRA_RINGTONE_TYPE,
|
|
||||||
RingtoneManager.TYPE_RINGTONE
|
|
||||||
)
|
|
||||||
intent.putExtra(
|
|
||||||
RingtoneManager.EXTRA_RINGTONE_TITLE,
|
|
||||||
selectRingToneMessage
|
|
||||||
)
|
|
||||||
intent.putExtra(
|
|
||||||
RingtoneManager.EXTRA_RINGTONE_EXISTING_URI,
|
|
||||||
ringtoneUri.toUri()
|
|
||||||
)
|
|
||||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false)
|
|
||||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true)
|
|
||||||
launcher.launch(intent)
|
|
||||||
},
|
|
||||||
fontSize = 18.sp,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun SpeakerPhone() {
|
private fun SpeakerPhone() {
|
||||||
Row(
|
Row(
|
||||||
@@ -629,11 +629,25 @@ private fun checkOnClick(ctx: Context): Result {
|
|||||||
|
|
||||||
var restart = false
|
var restart = false
|
||||||
|
|
||||||
|
if (newTelecom != oldTelecom) {
|
||||||
|
Config.replaceVariable("telecom", if (newTelecom) "yes" else "no")
|
||||||
|
BaresipService.telecom = newTelecom
|
||||||
|
restart = true
|
||||||
|
save = true
|
||||||
|
}
|
||||||
|
|
||||||
if (Preferences(ctx).ringtoneUri != newRingtoneUri) {
|
if (Preferences(ctx).ringtoneUri != newRingtoneUri) {
|
||||||
Preferences(ctx).ringtoneUri = newRingtoneUri
|
Preferences(ctx).ringtoneUri = newRingtoneUri
|
||||||
BaresipService.rt = RingtoneManager.getRingtone(ctx, newRingtoneUri.toUri())
|
BaresipService.rt = RingtoneManager.getRingtone(ctx, newRingtoneUri.toUri())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (BaresipService.toneCountry != newToneCountry) {
|
||||||
|
BaresipService.toneCountry = newToneCountry
|
||||||
|
Config.replaceVariable("tone_country", newToneCountry)
|
||||||
|
save = true
|
||||||
|
}
|
||||||
|
|
||||||
if (BaresipService.callVolume != newCallVolume) {
|
if (BaresipService.callVolume != newCallVolume) {
|
||||||
BaresipService.callVolume = newCallVolume
|
BaresipService.callVolume = newCallVolume
|
||||||
Config.replaceVariable("call_volume", newCallVolume.toString())
|
Config.replaceVariable("call_volume", newCallVolume.toString())
|
||||||
@@ -739,18 +753,6 @@ private fun checkOnClick(ctx: Context): Result {
|
|||||||
save = true
|
save = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BaresipService.toneCountry != newToneCountry) {
|
|
||||||
BaresipService.toneCountry = newToneCountry
|
|
||||||
Config.replaceVariable("tone_country", newToneCountry)
|
|
||||||
save = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newTelecom != oldTelecom) {
|
|
||||||
Config.replaceVariable("telecom", if (newTelecom) "yes" else "no")
|
|
||||||
BaresipService.telecom = newTelecom
|
|
||||||
save = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (save) Config.save()
|
if (save) Config.save()
|
||||||
|
|
||||||
return if (restart) Result.RESTART else Result.OK
|
return if (restart) Result.RESTART else Result.OK
|
||||||
|
|||||||
Reference in New Issue
Block a user