Skip to content

Commit

Permalink
Sound meter
Browse files Browse the repository at this point in the history
  • Loading branch information
ismartcoding committed Jul 7, 2023
1 parent 254cdb6 commit 139ec4a
Show file tree
Hide file tree
Showing 20 changed files with 401 additions and 50 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ PlainApp is an open-source application that allows you to manage your phone thro
- SMS, Calls: Read your SMS and calls on webpage.(Apk only)
- Apps: View your apps and download apk from phone.(web only)
- Screen mirror: Mirror your phone on webpage.
- Tools: Exchange rate, Sound meter.
- And more features are planned for the future.

PlainApp's minimalist design is intentional, so you can focus on what matters most: your valuable data.
Expand All @@ -44,12 +45,12 @@ Discord: https://discord.gg/RQWcS6DEEe

## Screenshots

| ![home](screenshots/1.jpeg) | ![files](screenshots/2.jpeg) | ![web](screenshots/3.jpeg) | ![notes](screenshots/4.jpeg) |
|----------------------------------------|-----------------------------------------|-----------------------------------------------|-------------------------------------------|
| ![audios](screenshots/5.jpeg) | ![images](screenshots/6.jpeg) | ![videos](screenshots/7.jpeg) | ![rss](screenshots/8.jpeg) |
| ![home](screenshots/web-home.png) | ![images](screenshots/web-images.png) | ![videos](screenshots/web-videos.png) | ![notes](screenshots/web-notes.png) |
| ![files](screenshots/web-files.png) | ![chatgpt](screenshots/web-chatgpt.png) | ![messages](screenshots/web-messages.png) | ![contacts](screenshots/web-contacts.png) |
| ![audios](screenshots/web-audios.png) | ![rss](screenshots/web-rss.png) | ![encryption](screenshots/web-encryption.png) | |
| ![sound meter](screenshots/1.jpeg) | ![files](screenshots/2.jpeg) | ![web](screenshots/3.jpeg) | ![notes](screenshots/4.jpeg) |
|---------------------------------------|-----------------------------------------|-----------------------------------------------|-------------------------------------------|
| ![audios](screenshots/5.jpeg) | ![images](screenshots/6.jpeg) | ![videos](screenshots/7.jpeg) | ![rss](screenshots/8.jpeg) |
| ![home](screenshots/web-home.png) | ![images](screenshots/web-images.png) | ![videos](screenshots/web-videos.png) | ![notes](screenshots/web-notes.png) |
| ![files](screenshots/web-files.png) | ![chatgpt](screenshots/web-chatgpt.png) | ![messages](screenshots/web-messages.png) | ![contacts](screenshots/web-contacts.png) |
| ![audios](screenshots/web-audios.png) | ![rss](screenshots/web-rss.png) | ![encryption](screenshots/web-encryption.png) | |

## Compatibility

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ android {
else -> 0
}

val vCode = 73
val vCode = 76
versionCode = vCode - singleAbiNum
versionName = "1.1.3"
versionName = "1.1.4"

ndk {
if (abiFilterList.isNotEmpty()) {
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />

<uses-feature android:name="android.hardware.microphone" android:required="false" />

<uses-feature
android:name="android.hardware.camera"
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/java/com/ismartcoding/plain/features/Permissions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ enum class Permission {
WRITE_SETTINGS,
CAMERA,
SYSTEM_ALERT_WINDOW,
RECORD_AUDIO,
NONE;

fun getText(): String {
Expand All @@ -56,7 +57,7 @@ enum class Permission {
return apiPermissions.contains(this.toString())
}

private fun toSysPermission(): String {
fun toSysPermission(): String {
return "android.permission.${this.name}"
}

Expand All @@ -65,19 +66,23 @@ enum class Permission {
this == WRITE_EXTERNAL_STORAGE -> {
FileHelper.hasStoragePermission(context)
}

this == WRITE_SETTINGS -> {
Settings.System.canWrite(context)
}

this == POST_NOTIFICATIONS -> {
if (isTIRAMISUPlus()) {
context.hasPermission(this.toSysPermission())
} else {
NotificationManagerCompat.from(context).areNotificationsEnabled()
}
}

this == SYSTEM_ALERT_WINDOW -> {
Settings.canDrawOverlays(context)
}

else -> context.hasPermission(this.toSysPermission())
}
}
Expand Down Expand Up @@ -133,15 +138,19 @@ enum class Permission {
this == READ_SMS -> {
getString(R.string.need_sms_permission)
}

this == READ_CALL_LOG -> {
getString(R.string.need_call_permission)
}

this == READ_CONTACTS -> {
getString(R.string.need_contact_permission)
}

this == WRITE_EXTERNAL_STORAGE -> {
getString(R.string.need_storage_permission)
}

else -> ""
}
}
Expand Down
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()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fun BlockOutlineButton(
) {
Text(
text = text,
style = MaterialTheme.typography.bodyMedium.copy(fontSize = 16.sp),
style = MaterialTheme.typography.bodyMedium.copy(fontSize = 20.sp),
)
}
}
32 changes: 32 additions & 0 deletions app/src/main/java/com/ismartcoding/plain/ui/base/PAlertDialog.kt
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 app/src/main/java/com/ismartcoding/plain/ui/base/PDialog.kt
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()
}
}
}
17 changes: 3 additions & 14 deletions app/src/main/java/com/ismartcoding/plain/ui/base/PScaffold.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,21 @@ import com.ismartcoding.plain.ui.theme.palette.onLight
fun PScaffold(
navController: NavHostController,
containerColor: Color = MaterialTheme.colorScheme.surface onLight MaterialTheme.colorScheme.inverseOnSurface,
topBarTonalElevation: Dp = 0.dp,
containerTonalElevation: Dp = 0.dp,
navigationIcon: (@Composable () -> Unit)? = {
NavigationBackIcon(navController)
},
topBarTitle: String = "",
actions: (@Composable RowScope.() -> Unit)? = null,
bottomBar: (@Composable () -> Unit)? = null,
floatingActionButton: (@Composable () -> Unit)? = null,
content: @Composable () -> Unit = {},
) {
Scaffold(
modifier = Modifier
.background(
MaterialTheme.colorScheme.surfaceColorAtElevation(
topBarTonalElevation,
color = containerColor
)
),
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(
containerTonalElevation,
color = containerColor
) onDark MaterialTheme.colorScheme.surface,
containerColor = containerColor,
topBar = {
if (navigationIcon != null || actions != null) {
TopAppBar(
title = {},
title = { Text(topBarTitle) },
navigationIcon = { navigationIcon?.invoke() },
actions = { actions?.invoke(this) },
colors = TopAppBarDefaults.topAppBarColors(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fun RadioDialog(
options: List<RadioDialogOption> = emptyList(),
onDismissRequest: () -> Unit = {},
) {
PDialog(
PAlertDialog(
modifier = modifier,
visible = visible,
onDismissRequest = onDismissRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.stringResource
Expand Down Expand Up @@ -42,7 +41,7 @@ fun TextFieldDialog(
) {
val focusManager = LocalFocusManager.current

PDialog(
PAlertDialog(
modifier = modifier,
visible = visible,
onDismissRequest = onDismissRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.CurrencyExchange
import androidx.compose.material.icons.outlined.GraphicEq
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
Expand Down Expand Up @@ -42,8 +43,16 @@ fun HomeItemTools(
) {
navController.navigate(RouteName.EXCHANGE_RATE)
}
Spacer(modifier = Modifier.width(16.dp))
Spacer(modifier = Modifier.weight(3f))
Spacer(modifier = Modifier.width(8.dp))
GridItem(
icon = Icons.Outlined.GraphicEq,
stringResource(id = R.string.sound_meter),
modifier = Modifier.weight(1f)
) {
navController.navigate(RouteName.SOUND_METER)
}
Spacer(modifier = Modifier.width(8.dp))
Spacer(modifier = Modifier.weight(2f))
}
}
}
2 changes: 2 additions & 0 deletions app/src/main/java/com/ismartcoding/plain/ui/page/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.ismartcoding.plain.ui.page.settings.DarkThemePage
import com.ismartcoding.plain.ui.page.settings.LanguagePage
import com.ismartcoding.plain.ui.page.settings.LogsPage
import com.ismartcoding.plain.ui.page.settings.SettingsPage
import com.ismartcoding.plain.ui.page.tools.SoundMeterPage
import com.ismartcoding.plain.ui.page.tools.ExchangeRatePage
import com.ismartcoding.plain.ui.page.web.PasswordPage
import com.ismartcoding.plain.ui.page.web.SessionsPage
Expand Down Expand Up @@ -63,6 +64,7 @@ fun Main(
RouteName.SESSIONS to { SessionsPage(navController) },
RouteName.WEB_DEV to { WebDevPage(navController) },
RouteName.EXCHANGE_RATE to { ExchangeRatePage(navController) },
RouteName.SOUND_METER to { SoundMeterPage(navController) },
).forEach { (routeName, content) ->
composable(routeName.name) {
content()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ enum class RouteName {
SESSIONS,
WEB_DEV,
EXCHANGE_RATE,
SOUND_METER,
}
Loading

0 comments on commit 139ec4a

Please sign in to comment.