Skip to content
Open
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
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,5 @@ dependencies {
androidTestImplementation(libs.coil.video)
debugImplementation(libs.androidx.compose.ui.test.manifest)
debugImplementation(libs.androidx.compose.ui.tooling)
debugImplementation(project(":core:harmony-ui"))
}
4 changes: 4 additions & 0 deletions app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
android:name=".UiStateTestActivity"
android:windowSoftInputMode="adjustResize"
android:exported="false" />
<activity
android:name=".HarmonyGalleryActivity"
android:exported="true"
android:theme="@style/Theme.Monogram" />
<activity
android:name=".PipTestActivity"
android:exported="false"
Expand Down
16 changes: 16 additions & 0 deletions app/src/debug/java/org/monogram/HarmonyGalleryActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.monogram

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import org.monogram.core.harmony.HarmonyGallery

/** Debug-only host for the HarmonyOS 7 visual prototype; no Telegram account is needed. */
class HarmonyGalleryActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent { HarmonyGallery() }
}
}
37 changes: 37 additions & 0 deletions core/harmony-ui/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.compose)
}

android {
namespace = "org.monogram.core.harmony"
compileSdk {
version = release(37)
}

defaultConfig {
minSdk = 24
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

buildFeatures {
compose = true
}
}

dependencies {
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.graphics)
implementation(libs.androidx.compose.animation)
implementation(libs.androidx.compose.ui.tooling.preview)
api(libs.androidx.compose.material3)
api(libs.androidx.compose.material.icons)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.core.ktx)
debugImplementation(libs.androidx.compose.ui.tooling)
}
2 changes: 2 additions & 0 deletions core/harmony-ui/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest />
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package org.monogram.core.harmony

import android.os.Build
import androidx.compose.foundation.background
import androidx.compose.foundation.border
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.Modifier
import androidx.compose.ui.draw.blur
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.unit.dp

/**
* HarmonyOS 7 only renders Immersive Light in navigation, dialogs and controls.
* [Content] deliberately falls back to an opaque surface.
*/
enum class HarmonyGlassScope {
Navigation,
Dialog,
Control,
Content,
}

@Composable
fun ImmersiveGlass(
scope: HarmonyGlassScope,
modifier: Modifier = Modifier,
shape: Shape = RoundedCornerShape(HarmonyTokens.Radius.panel),
strength: Float = 1f,
content: @Composable () -> Unit,
) {
val dark = HarmonyTheme.isDark
val palette = HarmonyTheme.palette
val immersive = scope != HarmonyGlassScope.Content && strength > 0f
val alpha = strength.coerceIn(0f, 1f)

val surface = if (immersive) {
Color.White.copy(alpha = (if (dark) 0.08f else 0.62f) * alpha)
} else {
if (dark) palette.surfaceDark else palette.surfaceLight
}
val highlight = if (immersive) {
Color.White.copy(alpha = (if (dark) 0.10f else 0.45f) * alpha)
} else {
surface
}
val border = if (immersive) {
Color.White.copy(alpha = (if (dark) 0.16f else 0.80f) * alpha)
} else {
MaterialTheme.colorScheme.outline.copy(alpha = 0.25f)
}
val elevation = if (immersive) HarmonyTokens.Elevation.medium else HarmonyTokens.Elevation.low

Box(
modifier
.shadow(elevation, shape, clip = false)
.background(brush = Brush.verticalGradient(listOf(highlight, surface)), shape = shape)
.border(1.dp, border, shape)
.clip(shape),
) {
content()
}
}

/**
* Compose has no backdrop-filter, so the frosted look comes from blurring this
* decorative layer rather than blurring arbitrary content above it.
*/
@Composable
fun GlassBackdrop(modifier: Modifier = Modifier) {
val dark = HarmonyTheme.isDark
val palette = HarmonyTheme.palette
val glow = HarmonyTheme.glow
val backdropBlur = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) Modifier.blur(40.dp) else Modifier

Box(
modifier
.clipToBounds()
.background(if (dark) palette.backgroundDark else palette.backgroundLight)
) {
Box(
Modifier
.fillMaxSize()
.then(backdropBlur)
.background(
Brush.radialGradient(
colors = listOf(glow.copy(alpha = 0.50f), Color.Transparent),
center = Offset(0.2f, 0.12f),
radius = 900f,
)
)
)
Box(
Modifier
.fillMaxSize()
.then(backdropBlur)
.background(
Brush.radialGradient(
colors = listOf(palette.secondary.copy(alpha = 0.32f), Color.Transparent),
center = Offset(0.9f, 0.55f),
radius = 760f,
)
)
)
}
}
Loading