Skip to content

Commit

Permalink
feature: make Wi-Fi calling carrier name configurable (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyujin-cho authored Feb 18, 2024
1 parent 160a735 commit a944bd1
Show file tree
Hide file tree
Showing 18 changed files with 1,084 additions and 774 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/build-apk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ jobs:
KEY_ALIAS: ${{ secrets.key-alias }}
KEY_PASSWORD: ${{ secrets.key-password }}
BUILD_TYPE: ${{ inputs.build-type }}
if: ${{ secrets.key-password != '' }}
if: ${{ env.KEY_PASSWORD != '' }}
- name: Rename APK
run: mv app-unsigned-aligned.apk dev.bluehouse.enablevolte.apk
env:
KEY_PASSWORD: ${{ secrets.key-password }}
if: ${{ env.KEY_PASSWORD == '' }}
- name: Upload APK
uses: actions/upload-artifact@v3
with:
Expand Down
745 changes: 0 additions & 745 deletions app/src/main/java/dev/bluehouse/enablevolte/Components.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import androidx.navigation.compose.NavHost
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.navigation
import androidx.navigation.compose.rememberNavController
import dev.bluehouse.enablevolte.components.OnLifecycleEvent
import dev.bluehouse.enablevolte.pages.Config
import dev.bluehouse.enablevolte.pages.DumpedConfig
import dev.bluehouse.enablevolte.pages.Editor
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/dev/bluehouse/enablevolte/Moder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,12 @@ class SubscriptionModer(val subscriptionId: Int) : Moder() {
@RequiresApi(VERSION_CODES.R)
get() = this.getBooleanValue(CarrierConfigManager.KEY_EDITABLE_WFC_ROAMING_MODE_BOOL)

val showVoWifiInNetworkName: Int
val wfcSpnFormatIndex: Int
get() = this.getIntValue(CarrierConfigManager.KEY_WFC_SPN_FORMAT_IDX_INT)

val carrierName: String
get() = this.loadCachedInterface { telephony }.getSubscriptionCarrierName(this.subscriptionId)

val showVoWifiIcon: Boolean
get() = this.getBooleanValue(CarrierConfigManager.KEY_SHOW_WIFI_CALLING_ICON_IN_STATUS_BAR_BOOL)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package dev.bluehouse.enablevolte.components

import android.os.Build
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import dev.bluehouse.enablevolte.R

@Composable
fun BooleanPropertyView(
label: String,
toggled: Boolean?,
enabled: Boolean = true,
trueLabel: String = stringResource(R.string.yes),
falseLabel: String = stringResource(R.string.no),
minSdk: Int = Build.VERSION.SDK_INT,
onClick: ((Boolean) -> Unit)? = null,
) {
val localEnabled = enabled && Build.VERSION.SDK_INT >= minSdk

if (toggled == null) {
Column(modifier = Modifier.padding(top = 12.dp, bottom = 12.dp)) {
Text(text = label, fontSize = 18.sp, modifier = Modifier.padding(bottom = 4.dp))
Text(text = stringResource(R.string.unknown), fontSize = 14.sp, color = MaterialTheme.colorScheme.outline)
}
return
}
if (onClick != null) {
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(top = 12.dp, bottom = 12.dp)) {
Text(text = label, modifier = Modifier.weight(1F), fontSize = 18.sp)
Switch(checked = toggled, enabled = localEnabled, onCheckedChange = onClick)
}
} else {
Column(modifier = Modifier.padding(top = 12.dp, bottom = 12.dp)) {
Text(text = label, fontSize = 18.sp, modifier = Modifier.padding(bottom = 4.dp))
Text(text = if (toggled) { trueLabel } else { falseLabel }, fontSize = 14.sp, color = MaterialTheme.colorScheme.outline)
}
}
}

@Preview
@Composable
fun BooleanPropertyViewPreview() {
var toggled by remember { mutableStateOf(false) }
BooleanPropertyView(label = "Lorem Ipsum", toggled = toggled) { toggled = !toggled }
}

@Preview
@Composable
fun LowSDKBooleanPropertyViewPreview() {
var toggled by remember { mutableStateOf(false) }
BooleanPropertyView(label = "Lorem Ipsum", toggled = toggled, minSdk = 999) { toggled = !toggled }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package dev.bluehouse.enablevolte.components

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import dev.bluehouse.enablevolte.R

@Composable
fun ClickablePropertyView(
label: String,
value: String?,
labelFontSize: TextUnit = 18.sp,
valueFontSize: TextUnit = 14.sp,
labelFontFamily: FontFamily? = null,
valueFontFamily: FontFamily? = null,
onClick: (() -> Unit)? = null,
) {
if (value == null) {
Column(modifier = Modifier.padding(top = 12.dp, bottom = 12.dp)) {
Text(text = label, fontSize = labelFontSize, modifier = Modifier.padding(bottom = 4.dp))
Text(text = stringResource(R.string.unknown), color = MaterialTheme.colorScheme.outline, fontSize = valueFontSize)
}
return
}
if (onClick != null) {
Surface(onClick = onClick, modifier = Modifier.fillMaxWidth()) {
Column(modifier = Modifier.padding(top = 12.dp, bottom = 12.dp)) {
Text(text = label, modifier = Modifier.padding(bottom = 4.dp), fontSize = labelFontSize, fontFamily = labelFontFamily)
Text(text = value, color = MaterialTheme.colorScheme.outline, fontSize = valueFontSize, fontFamily = valueFontFamily)
}
}
} else {
Column(modifier = Modifier.padding(top = 12.dp, bottom = 12.dp)) {
Text(text = label, modifier = Modifier.padding(bottom = 4.dp), fontSize = labelFontSize, fontFamily = labelFontFamily)
Text(text = value, color = MaterialTheme.colorScheme.outline, fontSize = valueFontSize, fontFamily = valueFontFamily)
}
}
}

@Preview
@Composable
fun ClickablePropertyViewPreview() {
val value by remember { mutableStateOf("dolor sit amet") }
ClickablePropertyView("Lorem Ipsum", value) {}
}
47 changes: 47 additions & 0 deletions app/src/main/java/dev/bluehouse/enablevolte/components/Common.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package dev.bluehouse.enablevolte.components

import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.LifecycleOwner

@Composable
fun OnLifecycleEvent(onEvent: (owner: LifecycleOwner, event: Lifecycle.Event) -> Unit) {
val eventHandler = rememberUpdatedState(onEvent)
val lifecycleOwner = rememberUpdatedState(LocalLifecycleOwner.current)

DisposableEffect(lifecycleOwner.value) {
val lifecycle = lifecycleOwner.value.lifecycle
val observer = LifecycleEventObserver { owner, event ->
eventHandler.value(owner, event)
}

lifecycle.addObserver(observer)
onDispose {
lifecycle.removeObserver(observer)
}
}
}

@Composable
fun HeaderText(text: String) {
Row(modifier = Modifier.padding(top = 20.dp, bottom = 12.dp)) {
Text(text = text, style = MaterialTheme.typography.labelMedium, color = MaterialTheme.colorScheme.onSurfaceVariant)
}
}

@Preview
@Composable
fun HeaderTextPreview() {
HeaderText("Lorem Ipsum")
}
Loading

0 comments on commit a944bd1

Please sign in to comment.