-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: make Wi-Fi calling carrier name configurable (#265)
- Loading branch information
1 parent
160a735
commit a944bd1
Showing
18 changed files
with
1,084 additions
and
774 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
745 changes: 0 additions & 745 deletions
745
app/src/main/java/dev/bluehouse/enablevolte/Components.kt
This file was deleted.
Oops, something went wrong.
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
67 changes: 67 additions & 0 deletions
67
app/src/main/java/dev/bluehouse/enablevolte/components/BooleanPropertyView.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,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 } | ||
} |
59 changes: 59 additions & 0 deletions
59
app/src/main/java/dev/bluehouse/enablevolte/components/ClickablePropertyView.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,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
47
app/src/main/java/dev/bluehouse/enablevolte/components/Common.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,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") | ||
} |
Oops, something went wrong.