Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] Admin Consent #51

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/runConfigurations/Run.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/Run_Standalone.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,28 @@ import androidx.compose.ui.unit.sp

class Typography {

/**
* fontSize = 32.sp,
* lineHeight = 0.sp,
* fontWeight = W400,
*/
val titleXXL: TextStyle
@Composable get() = defaultTextStyle.copy(
fontSize = 32.sp,
lineHeight = 0.sp,
fontFamily = fontFamilyNormal,
)

/**
* fontSize = 16.sp,
* lineHeight = 0.sp,
* fontWeight = W500,
* fontWeight = W400,
*/
val titleM: TextStyle
@Composable get() = defaultTextStyle.copy(
fontSize = 16.sp,
lineHeight = 0.sp,
fontFamily = fontFamilyMedium,
fontFamily = fontFamilyNormal,
)

/**
Expand Down
2 changes: 1 addition & 1 deletion target/desktop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ compose.desktop {
}
}

mainClass = "app.cleanmeter.target.desktop.ServerMainKt"
mainClass = "app.cleanmeter.target.desktop.DesktopMainKt"

buildTypes.release.proguard {
version.set("7.5.0")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package app.cleanmeter.target.desktop

import app.cleanmeter.core.common.process.singleInstance
import app.cleanmeter.core.common.reporting.ApplicationParams
import app.cleanmeter.core.os.ProcessManager
import app.cleanmeter.core.os.util.isDev
import app.cleanmeter.core.os.win32.WindowsService
import app.cleanmeter.target.desktop.data.PREFERENCE_PERMISSION_CONSENT
import app.cleanmeter.target.desktop.data.PreferencesRepository

fun main(vararg args: String) = singleInstance(args) {
if (PreferencesRepository.getPreferenceBoolean(PREFERENCE_PERMISSION_CONSENT, false)) {
WindowsService.tryElevateProcess(ApplicationParams.isAutostart)

if (isDev()) {
Runtime.getRuntime().addShutdownHook(Thread {
ProcessManager.stop()
})
} else {
KeyboardManager.registerKeyboardHook()
}

if (!ApplicationParams.isAutostart) {
ProcessManager.start()
}
}

composeApp()
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import java.util.prefs.Preferences

const val OVERLAY_SETTINGS_PREFERENCE_KEY = "OVERLAY_SETTINGS_PREFERENCE_KEY"
const val PREFERENCE_START_MINIMIZED = "PREFERENCE_START_MINIMIZED"
const val PREFERENCE_PERMISSION_CONSENT = "PREFERENCE_PERMISSION_CONSENT"

object PreferencesRepository {

Expand All @@ -24,6 +25,7 @@ object PreferencesRepository {

fun setPreference(key: String, value: String) = prefs.put(key, value)
fun setPreferenceBoolean(key: String, value: Boolean) = prefs.putBoolean(key, value)
fun clear() = prefs.clear()
}

fun PreferencesRepository.loadOverlaySettings(): OverlaySettings {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Text
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.dp
import app.cleanmeter.core.designsystem.LocalColorScheme
import app.cleanmeter.core.designsystem.LocalTypography

@Composable
internal fun ClearButton(
label: String,
textColor: Color = LocalColorScheme.current.text.inverse,
onClick: () -> Unit
) {
Button(
onClick = onClick,
colors = ButtonDefaults.textButtonColors(
containerColor = Color.Transparent,
),
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 0.dp),
) {
Text(
text = label,
style = LocalTypography.current.labelLMedium,
color = textColor,
modifier = Modifier.wrapContentHeight(),
)
}
}

@Composable
internal fun FilledButton(
label: String,
containerColor: Color = LocalColorScheme.current.background.surfaceRaised,
textColor: Color = LocalColorScheme.current.text.heading,
textStyle: TextStyle = LocalTypography.current.labelLMedium,
contentPadding: PaddingValues = PaddingValues(horizontal = 8.dp, vertical = 0.dp),
onClick: () -> Unit
) {
Button(
onClick = onClick,
colors = ButtonDefaults.textButtonColors(
containerColor = containerColor,
),
contentPadding = contentPadding,
shape = RoundedCornerShape(100),
) {
Text(
text = label,
color = textColor,
style = textStyle,
modifier = Modifier.wrapContentHeight(),
)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package app.cleanmeter.target.desktop.ui.components

import ClearButton
import FilledButton
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateContentSize
import androidx.compose.animation.slideInVertically
Expand Down Expand Up @@ -128,42 +130,7 @@ private fun RowScope.BodyText(state: UpdateState) {
}
}

@Composable
private fun ClearButton(onClick: () -> Unit, label: String) {
Button(
onClick = onClick,
colors = ButtonDefaults.textButtonColors(
containerColor = Color.Transparent,
),
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 0.dp),
) {
Text(
text = label,
style = LocalTypography.current.labelLMedium,
color = LocalColorScheme.current.text.inverse,
modifier = Modifier.wrapContentHeight(),
)
}
}

@Composable
private fun FilledButton(onClick: () -> Unit, label: String) {
Button(
onClick = onClick,
colors = ButtonDefaults.textButtonColors(
containerColor = LocalColorScheme.current.background.surfaceRaised,
),
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 0.dp),
shape = RoundedCornerShape(100),
) {
Text(
text = label,
color = LocalColorScheme.current.text.heading,
style = LocalTypography.current.labelLMedium,
modifier = Modifier.wrapContentHeight(),
)
}
}

@Composable
private fun RowScope.CallToAction(
Expand Down
Loading
Loading