forked from ismartcoding/plain-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
254cdb6
commit 139ec4a
Showing
20 changed files
with
401 additions
and
50 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
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
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
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/ismartcoding/plain/helpers/SoundMeterHelper.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,14 @@ | ||
package com.ismartcoding.plain.helpers | ||
|
||
import kotlin.math.log10 | ||
|
||
object SoundMeterHelper { | ||
fun getMaxAmplitude(buffer: ShortArray, readSize: Int): Double { | ||
return buffer.maxOrNull()?.toDouble() ?: 0.0 | ||
} | ||
|
||
fun amplitudeToDecibel(amplitude: Double): Float { | ||
return (20 * log10(amplitude)).toFloat() | ||
} | ||
|
||
} |
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
32 changes: 32 additions & 0 deletions
32
app/src/main/java/com/ismartcoding/plain/ui/base/PAlertDialog.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,32 @@ | ||
package com.ismartcoding.plain.ui.base | ||
|
||
import androidx.compose.material3.AlertDialog | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.window.DialogProperties | ||
|
||
@Composable | ||
fun PAlertDialog( | ||
modifier: Modifier = Modifier, | ||
visible: Boolean, | ||
properties: DialogProperties = DialogProperties(), | ||
onDismissRequest: () -> Unit = {}, | ||
icon: @Composable (() -> Unit)? = null, | ||
title: @Composable (() -> Unit)? = null, | ||
text: @Composable (() -> Unit)? = null, | ||
confirmButton: @Composable () -> Unit, | ||
dismissButton: @Composable (() -> Unit)? = null, | ||
) { | ||
if (visible) { | ||
AlertDialog( | ||
properties = properties, | ||
modifier = modifier, | ||
onDismissRequest = onDismissRequest, | ||
icon = icon, | ||
title = title, | ||
text = text, | ||
confirmButton = confirmButton, | ||
dismissButton = dismissButton, | ||
) | ||
} | ||
} |
47 changes: 27 additions & 20 deletions
47
app/src/main/java/com/ismartcoding/plain/ui/base/PDialog.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 |
---|---|---|
@@ -1,32 +1,39 @@ | ||
package com.ismartcoding.plain.ui.base | ||
|
||
import androidx.compose.material3.AlertDialog | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.window.Dialog | ||
import androidx.compose.ui.window.DialogProperties | ||
import com.ismartcoding.plain.ui.theme.palette.onLight | ||
|
||
@Composable | ||
fun PDialog( | ||
modifier: Modifier = Modifier, | ||
visible: Boolean, | ||
properties: DialogProperties = DialogProperties(), | ||
onDismissRequest: () -> Unit = {}, | ||
icon: @Composable (() -> Unit)? = null, | ||
title: @Composable (() -> Unit)? = null, | ||
text: @Composable (() -> Unit)? = null, | ||
confirmButton: @Composable () -> Unit, | ||
dismissButton: @Composable (() -> Unit)? = null, | ||
onClose: () -> Unit, | ||
content: @Composable () -> Unit | ||
) { | ||
if (visible) { | ||
AlertDialog( | ||
properties = properties, | ||
modifier = modifier, | ||
onDismissRequest = onDismissRequest, | ||
icon = icon, | ||
title = title, | ||
text = text, | ||
confirmButton = confirmButton, | ||
dismissButton = dismissButton, | ||
Dialog( | ||
onDismissRequest = onClose, | ||
properties = DialogProperties( | ||
dismissOnBackPress = true, | ||
dismissOnClickOutside = true | ||
) | ||
) { | ||
Box( | ||
modifier = Modifier | ||
.clip(RoundedCornerShape(32.dp)) | ||
.background(MaterialTheme.colorScheme.surface onLight MaterialTheme.colorScheme.inverseOnSurface) | ||
.fillMaxSize(), | ||
contentAlignment = Alignment.Center | ||
) { | ||
content() | ||
} | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,5 @@ enum class RouteName { | |
SESSIONS, | ||
WEB_DEV, | ||
EXCHANGE_RATE, | ||
SOUND_METER, | ||
} |
Oops, something went wrong.