diff --git a/app/build.gradle b/app/build.gradle index e4943059f..e38d1e205 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -61,9 +61,9 @@ dependencies { //100ms.live prebuilt lib implementation "live.100ms:room-kit:$HMS_ROOM_KIT_VERSION" + implementation "live.100ms:virtual-background:$HMS_SDK_VERSION" //100ms noise cancellation dep - def hmsVersion = "2.9.62" - implementation "live.100ms:hms-noise-cancellation-android:$hmsVersion" + implementation "live.100ms:hms-noise-cancellation-android:$HMS_SDK_VERSION" // Navigation implementation "androidx.navigation:navigation-fragment-ktx:2.4.0" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e80d69d66..608965a60 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -23,7 +23,7 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="false" - android:theme="@style/Theme.App2"> + android:theme="@style/Theme.HmsHomeApp"> @@ -31,8 +31,8 @@ android:name=".ui.home.HomeActivity" android:exported="true" android:label="@string/app_name" + android:theme="@style/Theme.HmsHomeApp.NoActionBar" android:screenOrientation="portrait" - android:theme="@style/Theme.App2.NoActionBar" android:windowSoftInputMode="stateAlwaysHidden|adjustResize"> diff --git a/app/src/main/res/drawable/stroked_drawable.xml b/app/src/main/res/drawable/stroked_drawable.xml deleted file mode 100644 index f9c0af3d1..000000000 --- a/app/src/main/res/drawable/stroked_drawable.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/stroked_round_drawable.xml b/app/src/main/res/drawable/stroked_round_drawable.xml deleted file mode 100644 index 6fd5b72b9..000000000 --- a/app/src/main/res/drawable/stroked_round_drawable.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/thick_stroked_drawable.xml b/app/src/main/res/drawable/thick_stroked_drawable.xml deleted file mode 100644 index 63b8a9fd0..000000000 --- a/app/src/main/res/drawable/thick_stroked_drawable.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index daefcf282..78b24ae6f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -41,7 +41,6 @@ Share Link More Options Meeting Options - Meeting Open Chat Share Screen Stop Share Screen diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index cc8eed5d2..2a710f3fb 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,113 +1,3 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 9b580a907..88d4a107b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,5 +20,13 @@ kotlin.code.style=official 100MS_APP_VERSION_CODE=376 100MS_APP_VERSION_NAME=5.0.10 hmsRoomKitGroup=live.100ms -HMS_ROOM_KIT_VERSION=1.2.16 +HMS_ROOM_KIT_VERSION=1.2.17 android.suppressUnsupportedCompileSdk=33 +HMS_SDK_VERSION=2.9.64 +# Common publishing info +publishing_licence_name="MIT License" +publishing_licence_url="http://www.opensource.org/licenses/mit-license.php" +publishing_project_url="live.100ms" +publishing_developer_id="1" +publishing_developer_name = "100ms" +publishing_developer_email = "support@100ms.live" diff --git a/prebuilt-themes/.gitignore b/prebuilt-themes/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/prebuilt-themes/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/prebuilt-themes/build.gradle.kts b/prebuilt-themes/build.gradle.kts new file mode 100644 index 000000000..90b41cb56 --- /dev/null +++ b/prebuilt-themes/build.gradle.kts @@ -0,0 +1,101 @@ +plugins { + id("com.android.library") + id("org.jetbrains.kotlin.android") + id("maven-publish") + id("signing") + id("org.jetbrains.dokka") version "1.5.0" +} + +android { + namespace = "live.hms.prebuilt_themes" + compileSdk = 34 + + defaultConfig { + minSdk = 21 + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } +} + +dependencies { + val HMS_SDK_VERSION: String by project + implementation("live.100ms:android-sdk:$HMS_SDK_VERSION") + implementation("com.google.code.gson:gson:2.9.0") + implementation("androidx.core:core-ktx:1.12.0") + implementation("androidx.appcompat:appcompat:1.6.1") + implementation("com.google.android.material:material:1.10.0") + implementation(platform("androidx.compose:compose-bom:2024.06.00")) + implementation("androidx.compose.ui:ui-android:1.6.8") + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.2.1") + androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1") +} + +val HMS_ROOM_KIT_VERSION : String by project +val publishing_licence_url : String by project +val publishing_licence_name : String by project +val publishing_project_url : String by project +val publishing_developer_id : String by project +val publishing_developer_name : String by project +val publishing_developer_email : String by project +publishing { + publications { + register("release") { + groupId = "live.100ms.room-kit" + artifactId = "prebuilt-themes" + version = HMS_ROOM_KIT_VERSION + + afterEvaluate { + from(components["release"]) + } + + pom { + // Avoid trying to sign local builds + if(rootProject.properties["ossrhUsername"] != "") { + signing { + sign(publishing.publications["release"]) + } + } + name.set("100ms.live Android Room Kit themes") + description.set("Base themes for prebuilt/room-kit.") + url.set(publishing_project_url) + licenses { + license { + name.set(publishing_licence_name) + url.set(publishing_licence_url) + } + } + developers { + developer { + id.set(publishing_developer_id) + name.set(publishing_developer_name) + email.set(publishing_developer_email) + } + } + scm { + connection.set("SCM is private") + developerConnection.set("SCM is private") + url.set("https://github.com/100mslive/100ms-android") + } + } + } + } +} \ No newline at end of file diff --git a/prebuilt-themes/consumer-rules.pro b/prebuilt-themes/consumer-rules.pro new file mode 100644 index 000000000..e69de29bb diff --git a/prebuilt-themes/proguard-rules.pro b/prebuilt-themes/proguard-rules.pro new file mode 100644 index 000000000..481bb4348 --- /dev/null +++ b/prebuilt-themes/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/prebuilt-themes/src/androidTest/java/live/hms/prebuilt_themes/ExampleInstrumentedTest.kt b/prebuilt-themes/src/androidTest/java/live/hms/prebuilt_themes/ExampleInstrumentedTest.kt new file mode 100644 index 000000000..d7ef3ca04 --- /dev/null +++ b/prebuilt-themes/src/androidTest/java/live/hms/prebuilt_themes/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package live.hms.prebuilt_themes + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("live.hms.prebuilt_themes.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/prebuilt-themes/src/main/AndroidManifest.xml b/prebuilt-themes/src/main/AndroidManifest.xml new file mode 100644 index 000000000..a5918e68a --- /dev/null +++ b/prebuilt-themes/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/theme/DefaultDarkThemeColours.kt b/prebuilt-themes/src/main/java/live/hms/prebuilt_themes/DefaultDarkThemeColours.kt similarity index 98% rename from room-kit/src/main/java/live/hms/roomkit/ui/theme/DefaultDarkThemeColours.kt rename to prebuilt-themes/src/main/java/live/hms/prebuilt_themes/DefaultDarkThemeColours.kt index 2fb9a5647..a0f8cdfab 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/theme/DefaultDarkThemeColours.kt +++ b/prebuilt-themes/src/main/java/live/hms/prebuilt_themes/DefaultDarkThemeColours.kt @@ -1,4 +1,4 @@ -package live.hms.roomkit.ui.theme +package live.hms.prebuilt_themes import com.google.gson.annotations.SerializedName diff --git a/prebuilt-themes/src/main/java/live/hms/prebuilt_themes/ThemeExt.kt b/prebuilt-themes/src/main/java/live/hms/prebuilt_themes/ThemeExt.kt new file mode 100644 index 000000000..67af3f852 --- /dev/null +++ b/prebuilt-themes/src/main/java/live/hms/prebuilt_themes/ThemeExt.kt @@ -0,0 +1,752 @@ +package live.hms.prebuilt_themes + + +import android.content.res.ColorStateList +import android.content.res.Resources +import android.graphics.* +import android.graphics.drawable.* +import android.graphics.drawable.shapes.RectShape +import android.graphics.drawable.shapes.RoundRectShape +import android.view.View +import android.widget.Button +import android.widget.EditText +import android.widget.ImageView +import android.widget.TextView +import androidx.annotation.ColorInt +import androidx.annotation.DimenRes +import androidx.annotation.DrawableRes +import androidx.appcompat.widget.AppCompatImageButton +import androidx.appcompat.widget.LinearLayoutCompat +import androidx.cardview.widget.CardView +import androidx.core.content.res.ResourcesCompat +import androidx.core.graphics.BlendModeColorFilterCompat +import androidx.core.graphics.BlendModeCompat +import androidx.core.graphics.drawable.DrawableCompat +import com.google.android.material.card.MaterialCardView +import com.google.android.material.imageview.ShapeableImageView +import com.google.android.material.progressindicator.LinearProgressIndicator +import com.google.android.material.shape.CornerFamily +import com.google.android.material.switchmaterial.SwitchMaterial +import com.google.android.material.textfield.TextInputEditText +import com.google.android.material.textfield.TextInputLayout +import com.google.android.material.textview.MaterialTextView +import live.hms.video.signal.init.HMSRoomLayout +import live.hms.video.utils.GsonUtils.gson + +//get theme detail from theme utils parse it accordingly + +object HMSPrebuiltTheme { + var theme: HMSRoomLayout.HMSRoomLayoutData.HMSRoomTheme.HMSColorPalette? = null + fun getColours() = theme + + fun getDefaults() = DefaultDarkThemeColours() + + //temp + fun getDefaultHmsColorPalette(): HMSRoomLayout.HMSRoomLayoutData.HMSRoomTheme.HMSColorPalette { + val jsonStr = + "{\"alert_error_bright\":\"#FFB2B6\",\"alert_error_brighter\":\"#FFEDEC\",\"alert_error_default\":\"#C74E5B\",\"alert_error_dim\":\"#270005\",\"alert_success\":\"#36B37E\",\"alert_warning\":\"#FFAB00\",\"background_default\":\"#0B0E15\",\"background_dim\":\"#000000\",\"border_bright\":\"#272A31\",\"border_default\":\"#1D1F27\",\"on_primary_high\":\"#ffffff\",\"on_primary_low\":\"#7faaff\",\"on_primary_medium\":\"#cbdaff\",\"on_secondary_high\":\"#FFFFFF\",\"on_secondary_low\":\"#A4ABC0\",\"on_secondary_medium\":\"#D3D9F0\",\"on_surface_high\":\"#EFF0FA\",\"on_surface_low\":\"#8F9099\",\"on_surface_medium\":\"#C5C6D0\",\"primary_bright\":\"#3da6ff\",\"primary_default\":\"#2F80FF\",\"primary_dim\":\"#2059b2\",\"primary_disabled\":\"#338cff\",\"secondary_bright\":\"#70778B\",\"secondary_default\":\"#444954\",\"secondary_dim\":\"#293042\",\"secondary_disabled\":\"#404759\",\"surface_bright\":\"#272A31\",\"surface_brighter\":\"#2E3038\",\"surface_default\":\"#191B23\",\"surface_dim\":\"#11131A\"}" + + return gson.fromJson( + jsonStr, HMSRoomLayout.HMSRoomLayoutData.HMSRoomTheme.HMSColorPalette::class.java + ) + } +} + +fun HMSRoomLayout.getPreviewLayout(roleName: String?): HMSRoomLayout.HMSRoomLayoutData.Screens.Preview? { + return if (roleName.isNullOrEmpty()) this.data?.getOrNull(0)?.screens?.preview + else this.data?.find { it?.role == roleName }?.screens?.preview +} + +fun HMSRoomLayout.getCurrentRoleData(roleName: String?): HMSRoomLayout.HMSRoomLayoutData? { + return if (roleName.isNullOrEmpty()) this.data?.getOrNull(0) + else this.data?.find { it?.role == roleName } +} + + +fun CardView.setBackgroundColor( + backgroundColorStr: String?, + defaultBackgroundColor: String, +) { + this.setCardBackgroundColor(getColorOrDefault(backgroundColorStr, defaultBackgroundColor)) +} + +fun View.setBackgroundAndColor( + backgroundColorStr: String?, + defaultBackgroundColor: String, +) { + setBackgroundColor(getColorOrDefault(backgroundColorStr, defaultBackgroundColor)) +} + + +//AppCompatImageView tint +fun androidx.appcompat.widget.AppCompatImageView.setIconTintColor( + iconTintColorStr: String?, + defaultIconTintColor: String, +) { + this.imageTintList = + ColorStateList.valueOf(getColorOrDefault(iconTintColorStr, defaultIconTintColor)) +} + +fun View.setBackgroundAndColor( + backgroundColorStr: String?, + defaultBackgroundColor: String, + @DrawableRes backGroundDrawableRes: Int? +) { + this.backgroundTintList = + ColorStateList.valueOf(getColorOrDefault(backgroundColorStr, defaultBackgroundColor)) + val normalDrawable: Drawable = if (backGroundDrawableRes != null) ResourcesCompat.getDrawable( + this.context.resources, + backGroundDrawableRes, + null + )!! + else getShape() + val wrapDrawable: Drawable = DrawableCompat.wrap(normalDrawable) + DrawableCompat.setTint( + wrapDrawable, getColorOrDefault(backgroundColorStr, defaultBackgroundColor) + ) + background = wrapDrawable +} + +fun getColorOrDefault(colorStr: String?, defaultColor: String): Int { + return try { + colorStr!!.toColorInt() + } catch (e: Exception) { + try { + defaultColor.toColorInt() + } catch (e: Exception) { + Color.parseColor("#FFFFFF") + } + } +} + +fun View.backgroundGradientDrawable(@ColorInt startColor: Int, @ColorInt endColor: Int): Unit { + val h = this.height.toFloat() + val shapeDrawable = ShapeDrawable(RectShape()) + shapeDrawable.paint.shader = + LinearGradient(0f, 0f, 0f, h, startColor, endColor, Shader.TileMode.REPEAT) + this.background = shapeDrawable +} + + +fun ShapeableImageView.setIconEnabled( + @DrawableRes enabledIconDrawableRes: Int +) { + val radius = resources.getDimension(R.dimen.eight_dp).toInt() + + this.setBackgroundColor(resources.getColor(android.R.color.transparent)) + + shapeAppearanceModel = + shapeAppearanceModel.toBuilder().setAllCorners(CornerFamily.ROUNDED, radius.toFloat()) + .build() + + this.strokeColor = ColorStateList.valueOf( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.borderBright, + HMSPrebuiltTheme.getDefaults().border_bright + ) + ) + + this.strokeWidth = resources.getDimension(R.dimen.one_dp) + + this.setImageResource(enabledIconDrawableRes) + + drawable.setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) + ) + + (drawable as? Animatable)?.start() +} + + +fun ImageView.setIconDisabled( + @DrawableRes disabledIconDrawableRes: Int, + @DrawableRes backgroundRes: Int = R.drawable.gray_round_solid_drawable +) { + + this.setImageResource(disabledIconDrawableRes) + this.setBackgroundResource(backgroundRes) + background.setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.secondaryDim, + HMSPrebuiltTheme.getDefaults().secondary_dim + ) + ) + + drawable.setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) + ) + + (drawable as? Animatable)?.start() + +} + +fun ShapeableImageView.setIconDisabled( + @DrawableRes disabledIconDrawableRes: Int, + @DimenRes radiusREs: Int = R.dimen.eight_dp, +) { + + val radius = resources.getDimension(radiusREs).toInt() + + this.strokeWidth = 0f + + shapeAppearanceModel = + shapeAppearanceModel.toBuilder().setAllCornerSizes(radius.toFloat()).build() + + this.setBackgroundColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.secondaryDim, + HMSPrebuiltTheme.getDefaults().secondary_dim + ) + ) + this.setImageResource(disabledIconDrawableRes) + + + drawable.setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onPrimaryHigh, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) + ) + + (drawable as? Animatable)?.start() + +} + +fun TextView.alertButtonEnabled() { + this.isEnabled = true + + this.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onPrimaryHigh, + HMSPrebuiltTheme.getDefaults().onprimary_high_emp + ) + ) + + this.setBackgroundAndColor( + HMSPrebuiltTheme.getColours()?.alertErrorDefault, + HMSPrebuiltTheme.getDefaults().error_default, + null + ) + + this.drawableStart?.setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onPrimaryHigh, + HMSPrebuiltTheme.getDefaults().onprimary_high_emp + ) + ) +} + +fun TextView.buttonStrokeEnabled() { + this.isEnabled = true + this.setBackgroundAndColor( + HMSPrebuiltTheme.getColours()?.alertErrorDefault, + HMSPrebuiltTheme.getDefaults().error_default, + R.drawable.gray_round_stroked_drawable + ) + + this.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onPrimaryHigh, + HMSPrebuiltTheme.getDefaults().onprimary_high_emp + ) + ) + +} + +fun TextView.buttonEnabled() { + this.isEnabled = true + + this.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onPrimaryHigh, + HMSPrebuiltTheme.getDefaults().onprimary_high_emp + ) + ) + + this.setBackgroundAndColor( + HMSPrebuiltTheme.getColours()?.primaryDefault, + HMSPrebuiltTheme.getDefaults().primary_default, + null + ) + + this.drawableStart?.setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onPrimaryHigh, + HMSPrebuiltTheme.getDefaults().onprimary_high_emp + ) + ) +} + +private fun getBackgroundForColor(color: Int) = getShape().apply { setTint(color) } + +fun TextView.buttonDisabled() { + this.isEnabled = false + + + this.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onPrimaryLow, + HMSPrebuiltTheme.getDefaults().onprimary_low_emp + ) + ) + + this.setBackgroundAndColor( + HMSPrebuiltTheme.getColours()?.primaryDisabled, + HMSPrebuiltTheme.getDefaults().primary_disabled, + null + ) + + this.drawableStart?.setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onPrimaryLow, + HMSPrebuiltTheme.getDefaults().onprimary_low_emp + ) + ) + +} + + +//hex color to int color +private fun String.toColorInt(): Int = Color.parseColor(this) + +fun pinMessageTheme(pinCloseButton: ImageView) { + pinCloseButton.drawable?.setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) + ) + +} + +private fun chatPausedTheme( + chatPausedContainer: LinearLayoutCompat, chatPausedTitle: TextView, chatPausedBy: TextView +) { + chatPausedContainer.background = getChatBackgroundDrawable() + + chatPausedTitle.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) + ) + chatPausedBy.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) + ) +} + +private fun userBlockedTheme(userBlocked: TextView) { + userBlocked.background = getChatBackgroundDrawable() + userBlocked.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) + ) +} + +private fun closeButtonTheme(closeCombinedTabButton: AppCompatImageButton, res: Resources) { + closeCombinedTabButton.setBackgroundDrawable(ResourcesCompat.getDrawable( + res, R.drawable.ic_cross, null + )?.apply { + setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) + ) + }) +} + +fun getShape(radiusAt: ApplyRadiusatVertex = ApplyRadiusatVertex.ALL_CORNERS): ShapeDrawable { + val eightDp = 8.dp().toFloat() + + val lines = floatArrayOf( + if (radiusAt == ApplyRadiusatVertex.TOP || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, + if (radiusAt == ApplyRadiusatVertex.TOP || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, + if (radiusAt == ApplyRadiusatVertex.TOP || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, + if (radiusAt == ApplyRadiusatVertex.TOP || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, + if (radiusAt == ApplyRadiusatVertex.BOTTOM || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, + if (radiusAt == ApplyRadiusatVertex.BOTTOM || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, + if (radiusAt == ApplyRadiusatVertex.BOTTOM || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, + if (radiusAt == ApplyRadiusatVertex.BOTTOM || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f + ) + + return ShapeDrawable( + RoundRectShape( + lines, null, null + ) + ) +} + +fun getChatBackgroundDrawable(alpha: Double? = null): ShapeDrawable { + return getShape()//ResourcesCompat.getDrawable(this.root.resources,R.drawable.send_message_background, null)!! + .apply { + val initialColor = if (alpha == null) HMSPrebuiltTheme.getColours()?.surfaceDefault + else HMSPrebuiltTheme.getColours()?.surfaceDefault?.let { addAlpha(it, alpha) } + val defaultColor: String = + if (alpha == null) HMSPrebuiltTheme.getDefaults().surface_default + else addAlpha(HMSPrebuiltTheme.getDefaults().surface_default, alpha) + val color = getColorOrDefault( + initialColor, defaultColor + ) + colorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat( + color, + BlendModeCompat.SRC + ) + } +} + +private fun configureChatControlsTheme( + sendToBackground: MaterialCardView, + sendToChipText: MaterialTextView, + chatOptionsCard: MaterialCardView, + chatOptions: ImageView +) { + chatOptions.drawable.setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceLow, + HMSPrebuiltTheme.getDefaults().onsurface_low_emp + ) + ) + + chatOptionsCard.strokeColor = getColorOrDefault( + HMSPrebuiltTheme.getColours()?.borderBright, HMSPrebuiltTheme.getDefaults().border_bright + ) + chatOptionsCard.strokeWidth = 1.dp() + chatOptionsCard.setBackgroundColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.surfaceDefault, + HMSPrebuiltTheme.getDefaults().surface_default + ) + ) + + sendToBackground.background = getShape().apply { + val color = getColorOrDefault( + HMSPrebuiltTheme.getColours()?.primaryDefault, + HMSPrebuiltTheme.getDefaults().primary_default + ) + colorFilter = + BlendModeColorFilterCompat.createBlendModeColorFilterCompat(color, BlendModeCompat.SRC) + } + + sendToChipText.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onPrimaryHigh, + HMSPrebuiltTheme.getDefaults().onprimary_high_emp + ) + ) + sendToBackground.strokeWidth = 0 +// sendToBackground.strokeColor = getColorOrDefault( +// HMSPrebuiltTheme.getColours()?.borderBright, +// HMSPrebuiltTheme.getDefaults().border_bright +// ) + + sendToChipText.drawableEnd?.setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onPrimaryHigh, + HMSPrebuiltTheme.getDefaults().onprimary_high_emp + ) + ) +} + +private fun TextInputLayout.applyTheme() { + // text color + // hint color + // background color + + background = getChatBackgroundDrawable() + defaultHintTextColor = ColorStateList.valueOf( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceLow, + HMSPrebuiltTheme.getDefaults().onsurface_low_emp + ) + ) + startIconDrawable = + ResourcesCompat.getDrawable(resources, R.drawable.ic_search_24, null)?.apply { + colorFilter = PorterDuffColorFilter( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceLow, + HMSPrebuiltTheme.getDefaults().onsurface_low_emp + ), PorterDuff.Mode.SRC_IN + ) + } +// boxStrokeColor = getColorOrDefault( +// HMSPrebuiltTheme.getColours()?.borderBright, +// HMSPrebuiltTheme.getDefaults().border_bright +// ) + boxStrokeWidth = 0 + boxStrokeWidthFocused = 0 +} + +private fun TextInputEditText.applyTheme() { + setHintTextColor( + ColorStateList.valueOf( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceLow, + HMSPrebuiltTheme.getDefaults().onsurface_low_emp + ) + ) + ) + setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) + ) + background = getChatBackgroundDrawable() +} + +private fun backgroundShape( + inset: Boolean = false, + innerRadii: Float = 8.dp().toFloat() +): ShapeDrawable { + val lines = floatArrayOf( + innerRadii, + innerRadii, + innerRadii, + innerRadii, + innerRadii, + innerRadii, + innerRadii, + innerRadii, + innerRadii + ) + return if (inset) { + ShapeDrawable( + RoundRectShape( + lines, RectF(1f, 1f, 1f, 1f), lines + ) + ) + } else { + ShapeDrawable( + RoundRectShape( + lines, null, null + ) + ) + } +} + +fun trackTintList(): ColorStateList { + val checkedUncheckedState = arrayOf( + intArrayOf(android.R.attr.state_checked), intArrayOf(-android.R.attr.state_checked) + ) + + return ColorStateList( + checkedUncheckedState, intArrayOf( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.primaryDefault, + HMSPrebuiltTheme.getDefaults().primary_default + ), getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) + ) + ) +} + +private fun setSwitchThemes(switchCompat: SwitchMaterial) { + with(switchCompat) { + thumbTintList = thumbTintList() + trackTintList = trackTintList() + } + + switchCompat.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) + ) + +} + +private fun thumbTintList(): ColorStateList { + val checkedUncheckedState = arrayOf( + intArrayOf(android.R.attr.state_checked), intArrayOf(-android.R.attr.state_checked) + ) + + return ColorStateList( + checkedUncheckedState, intArrayOf( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onPrimaryHigh, + HMSPrebuiltTheme.getDefaults().onprimary_high_emp + ), getColorOrDefault( + HMSPrebuiltTheme.getColours()?.secondaryDefault, + HMSPrebuiltTheme.getDefaults().secondary_default + ) + ) + ) +} + +// Polls + +fun Button.voteButtons() { + + val buttonDisabledBackgroundColor = getColorOrDefault( + HMSPrebuiltTheme.getColours()?.primaryDisabled, + HMSPrebuiltTheme.getDefaults().primary_disabled + ) + val buttonDisabledTextColor = getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onPrimaryLow, + HMSPrebuiltTheme.getDefaults().onprimary_low_emp + ) + + + val buttonEnabledBackgroundColor = getColorOrDefault( + HMSPrebuiltTheme.getColours()?.primaryDefault, + HMSPrebuiltTheme.getDefaults().primary_default + ) + + val buttonEnabledTextColor = getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onPrimaryHigh, + HMSPrebuiltTheme.getDefaults().onprimary_high_emp + ) + + val states = arrayOf( + intArrayOf(android.R.attr.state_enabled), intArrayOf(-android.R.attr.state_enabled) + ) + val backgroundColors = intArrayOf(buttonEnabledBackgroundColor, buttonDisabledBackgroundColor) + val textColors = intArrayOf(buttonEnabledTextColor, buttonDisabledTextColor) + + backgroundTintList = ColorStateList( + states, backgroundColors + ) + + setTextColor( + ColorStateList( + states, textColors + ) + ) + +} + + +fun MaterialCardView.isSelectedStroke(isSelected: Boolean) { + if (isSelected.not()) this.strokeColor = getColorOrDefault( + HMSPrebuiltTheme.getColours()?.borderBright, HMSPrebuiltTheme.getDefaults().primary_default + ) + else this.strokeColor = getColorOrDefault( + HMSPrebuiltTheme.getColours()?.primaryDefault, + HMSPrebuiltTheme.getDefaults().primary_default + ) + +} + + +fun TextView.saveButtonEnabled() { + this.isEnabled = true + + this.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onprimary_high_emp + ) + ) + + this.setBackgroundAndColor( + HMSPrebuiltTheme.getColours()?.secondaryDefault, + HMSPrebuiltTheme.getDefaults().primary_default, + null + ) + +} + + +fun TextView.saveButtonDisabled() { + this.isEnabled = false + + + this.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSecondaryLow, + HMSPrebuiltTheme.getDefaults().onprimary_low_emp + ) + ) + + this.setBackgroundAndColor( + HMSPrebuiltTheme.getColours()?.secondaryDim, + HMSPrebuiltTheme.getDefaults().primary_disabled, + null + ) + + +} + +fun LinearProgressIndicator.applyProgressbarTheme() { + trackColor = getColorOrDefault( + HMSPrebuiltTheme.getColours()?.surfaceBright, HMSPrebuiltTheme.getDefaults().primary_default + ) + + setIndicatorColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.primaryDefault, + HMSPrebuiltTheme.getDefaults().surface_bright + ) + ) + +} + +fun MaterialCardView.highlightCorrectAnswer(isCorrect: Boolean) { + strokeColor = if (isCorrect) { + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.alertSuccess, + HMSPrebuiltTheme.getDefaults().error_default + ) + } else { + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.alertErrorDefault, + HMSPrebuiltTheme.getDefaults().error_default + ) + } + strokeWidth = 1.dp() +} + +private fun dialogBackground(resources: Resources): Drawable = + ResourcesCompat.getDrawable(resources, R.drawable.gray_shape_round_dialog, null)!!.apply { + val color = getColorOrDefault( + HMSPrebuiltTheme.getColours()?.backgroundDefault, + HMSPrebuiltTheme.getDefaults().background_default + ) + setColorFilter(color, PorterDuff.Mode.ADD) + } + +private fun searchViewTheme(containerSearch: MaterialCardView, textInputSearch: EditText) { + + textInputSearch.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) + ) + + textInputSearch.setHintTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) + ) + textInputSearch.setBackgroundColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.surfaceDim, HMSPrebuiltTheme.getDefaults().surface_dim + ) + ) + textInputSearch.drawableStart?.setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) + ) + containerSearch.strokeWidth = 1.dp() + containerSearch.strokeColor = getColorOrDefault( + HMSPrebuiltTheme.getColours()?.borderBright, HMSPrebuiltTheme.getDefaults().border_bright + ) +} \ No newline at end of file diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/compose/Variables.kt b/prebuilt-themes/src/main/java/live/hms/prebuilt_themes/Variables.kt similarity index 91% rename from room-kit/src/main/java/live/hms/roomkit/ui/meeting/compose/Variables.kt rename to prebuilt-themes/src/main/java/live/hms/prebuilt_themes/Variables.kt index 2d539fd26..9d3caabc0 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/compose/Variables.kt +++ b/prebuilt-themes/src/main/java/live/hms/prebuilt_themes/Variables.kt @@ -1,10 +1,7 @@ -package live.hms.roomkit.ui.meeting.compose - +package live.hms.prebuilt_themes import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme -import live.hms.roomkit.ui.theme.getColorOrDefault class Variables { companion object { @@ -63,5 +60,10 @@ class Variables { )).copy(alpha = 0.64f) // backrground dim is always 64% transparent. val SurfaceDim: Color = Color(0xFF11131A) + + val SurfaceBright : Color = Color(getColorOrDefault( + HMSPrebuiltTheme.getColours()?.surfaceBright, + HMSPrebuiltTheme.getDefaults().surface_bright + )) } } diff --git a/prebuilt-themes/src/main/java/live/hms/prebuilt_themes/ViewExt.kt b/prebuilt-themes/src/main/java/live/hms/prebuilt_themes/ViewExt.kt new file mode 100644 index 000000000..9c43e586a --- /dev/null +++ b/prebuilt-themes/src/main/java/live/hms/prebuilt_themes/ViewExt.kt @@ -0,0 +1,59 @@ +package live.hms.prebuilt_themes + +import android.content.res.Resources +import android.graphics.drawable.Drawable +import android.os.Build +import android.widget.TextView +import kotlin.math.roundToInt + +enum class ApplyRadiusatVertex { + TOP, + ALL_CORNERS, + BOTTOM, + NONE +} +private fun getDip(): Float = Resources.getSystem().displayMetrics.density +fun Float.dp() = this * getDip() +fun Int.dp() = (this * getDip()).roundToInt() +fun addAlpha(originalColor: String, alpha: Double): String { + + val alphaFixed = (alpha * 255) + var alphaHex = java.lang.Double.toHexString(alphaFixed) + if (alphaHex.length == 1) { + alphaHex = "0$alphaHex" + } + return originalColor.replace("#", "#$alphaHex") +} + +var TextView.drawableStart: Drawable? + get() = drawables[0] + set(value) = setDrawables(value, drawableTop, drawableEnd, drawableBottom) + +var TextView.drawableTop: Drawable? + get() = drawables[1] + set(value) = setDrawables(drawableStart, value, drawableEnd, drawableBottom) + +var TextView.drawableEnd: Drawable? + get() = drawables[2] + set(value) = setDrawables(drawableStart, drawableTop, value, drawableBottom) + +var TextView.drawableBottom: Drawable? + get() = drawables[3] + set(value) = setDrawables(drawableStart, drawableTop, drawableEnd, value) + +@Deprecated("Consider replace with drawableStart to better support right-to-left Layout", ReplaceWith("drawableStart")) +var TextView.drawableLeft: Drawable? + get() = compoundDrawables[0] + set(value) = setCompoundDrawablesWithIntrinsicBounds(value, drawableTop, drawableRight, drawableBottom) + +@Deprecated("Consider replace with drawableEnd to better support right-to-left Layout", ReplaceWith("drawableEnd")) +var TextView.drawableRight: Drawable? + get() = compoundDrawables[2] + set(value) = setCompoundDrawablesWithIntrinsicBounds(drawableLeft, drawableTop, value, drawableBottom) + +private val TextView.drawables: Array + get() = if (Build.VERSION.SDK_INT >= 17) compoundDrawablesRelative else compoundDrawables + +fun TextView.setDrawables(start: Drawable? = drawableStart, top: Drawable? = drawableTop, end: Drawable? = drawableEnd, bottom: Drawable? = drawableBottom) { + setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom) +} diff --git a/prebuilt-themes/src/main/res/drawable/gray_round_solid_drawable.xml b/prebuilt-themes/src/main/res/drawable/gray_round_solid_drawable.xml new file mode 100644 index 000000000..6d6db278d --- /dev/null +++ b/prebuilt-themes/src/main/res/drawable/gray_round_solid_drawable.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/prebuilt-themes/src/main/res/drawable/gray_round_stroked_drawable.xml b/prebuilt-themes/src/main/res/drawable/gray_round_stroked_drawable.xml new file mode 100644 index 000000000..ecefde79a --- /dev/null +++ b/prebuilt-themes/src/main/res/drawable/gray_round_stroked_drawable.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/prebuilt-themes/src/main/res/drawable/gray_shape_round_dialog.xml b/prebuilt-themes/src/main/res/drawable/gray_shape_round_dialog.xml new file mode 100644 index 000000000..c475dd223 --- /dev/null +++ b/prebuilt-themes/src/main/res/drawable/gray_shape_round_dialog.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/prebuilt-themes/src/main/res/drawable/ic_cross.xml b/prebuilt-themes/src/main/res/drawable/ic_cross.xml new file mode 100644 index 000000000..b2d56fa3f --- /dev/null +++ b/prebuilt-themes/src/main/res/drawable/ic_cross.xml @@ -0,0 +1,10 @@ + + + diff --git a/prebuilt-themes/src/main/res/drawable/ic_search_24.xml b/prebuilt-themes/src/main/res/drawable/ic_search_24.xml new file mode 100644 index 000000000..07b76d627 --- /dev/null +++ b/prebuilt-themes/src/main/res/drawable/ic_search_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/prebuilt-themes/src/main/res/drawable/outline_cross.xml b/prebuilt-themes/src/main/res/drawable/outline_cross.xml new file mode 100644 index 000000000..0dc4ae2bd --- /dev/null +++ b/prebuilt-themes/src/main/res/drawable/outline_cross.xml @@ -0,0 +1,10 @@ + + + diff --git a/room-kit/src/main/res/font/clan_pro_medium.ttf b/prebuilt-themes/src/main/res/font/clan_pro_medium.ttf similarity index 100% rename from room-kit/src/main/res/font/clan_pro_medium.ttf rename to prebuilt-themes/src/main/res/font/clan_pro_medium.ttf diff --git a/room-kit/src/main/res/font/clan_pro_news.TTF b/prebuilt-themes/src/main/res/font/clan_pro_news.TTF similarity index 100% rename from room-kit/src/main/res/font/clan_pro_news.TTF rename to prebuilt-themes/src/main/res/font/clan_pro_news.TTF diff --git a/room-kit/src/main/res/font/inter_bold.ttf b/prebuilt-themes/src/main/res/font/inter_bold.ttf similarity index 100% rename from room-kit/src/main/res/font/inter_bold.ttf rename to prebuilt-themes/src/main/res/font/inter_bold.ttf diff --git a/room-kit/src/main/res/font/inter_extrabold.ttf b/prebuilt-themes/src/main/res/font/inter_extrabold.ttf similarity index 100% rename from room-kit/src/main/res/font/inter_extrabold.ttf rename to prebuilt-themes/src/main/res/font/inter_extrabold.ttf diff --git a/room-kit/src/main/res/font/inter_medium.ttf b/prebuilt-themes/src/main/res/font/inter_medium.ttf similarity index 100% rename from room-kit/src/main/res/font/inter_medium.ttf rename to prebuilt-themes/src/main/res/font/inter_medium.ttf diff --git a/app/src/main/res/font/inter_regular.ttf b/prebuilt-themes/src/main/res/font/inter_regular.ttf similarity index 100% rename from app/src/main/res/font/inter_regular.ttf rename to prebuilt-themes/src/main/res/font/inter_regular.ttf diff --git a/room-kit/src/main/res/font/inter_semibold.ttf b/prebuilt-themes/src/main/res/font/inter_semibold.ttf similarity index 100% rename from room-kit/src/main/res/font/inter_semibold.ttf rename to prebuilt-themes/src/main/res/font/inter_semibold.ttf diff --git a/prebuilt-themes/src/main/res/values/dimens.xml b/prebuilt-themes/src/main/res/values/dimens.xml new file mode 100644 index 000000000..8e4935048 --- /dev/null +++ b/prebuilt-themes/src/main/res/values/dimens.xml @@ -0,0 +1,33 @@ + + 16dp + + 120dp + 120dp + 64dp + 104dp + 186dp + 16dp + 8dp + 1dp + 2dp + 170dp + 160dp + 225dp + 200dp + 4dp + 12dp + 32dp + 90% + 12dp + 4dp + 8dp + 16dp + 24dp + @dimen/spacing_d1 + @dimen/spacing_d3 + 32dp + 24dp + 4dp + 8dp + 0dp + \ No newline at end of file diff --git a/prebuilt-themes/src/test/java/live/hms/prebuilt_themes/ExampleUnitTest.kt b/prebuilt-themes/src/test/java/live/hms/prebuilt_themes/ExampleUnitTest.kt new file mode 100644 index 000000000..954071a81 --- /dev/null +++ b/prebuilt-themes/src/test/java/live/hms/prebuilt_themes/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package live.hms.prebuilt_themes + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} \ No newline at end of file diff --git a/room-kit/build.gradle b/room-kit/build.gradle index c59c0ea9e..bb5f37f32 100644 --- a/room-kit/build.gradle +++ b/room-kit/build.gradle @@ -72,13 +72,19 @@ dependencies { implementation 'com.google.android.material:material:1.10.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.percentlayout:percentlayout:1.0.0' - def hmsVersion = "2.9.61" + implementation "com.otaliastudios:zoomlayout:1.9.0" + implementation project(":prebuilt-themes") + implementation project(":vb-prebuilt") // To add dependencies of specific module - implementation "live.100ms:android-sdk:$hmsVersion" - implementation "live.100ms:video-view:$hmsVersion" - implementation "live.100ms:hls-player:$hmsVersion" - implementation "live.100ms:video-filters:$hmsVersion" + implementation "live.100ms:android-sdk:$HMS_SDK_VERSION" + implementation "live.100ms:video-view:$HMS_SDK_VERSION" + implementation "live.100ms:hls-player:$HMS_SDK_VERSION" + implementation "live.100ms:video-filters:$HMS_SDK_VERSION" + // allows the api to be present so the [HMsVirtualBackgroundInjector] can add the real + // class when it is included but also allows the fake one to be injected when + // the import is not added. This saves 26Mb from being added to every prebuilt user. + compileOnly "live.100ms:virtual-background:$HMS_SDK_VERSION" // Navigation implementation "androidx.navigation:navigation-fragment-ktx:2.7.4" @@ -169,7 +175,7 @@ afterEvaluate { scm { connection = 'SCM is private' developerConnection = 'SCM is private' - url = 'SCM is private' + url = 'https://github.com/100mslive/100ms-android' } } groupId = "live.100ms" diff --git a/room-kit/src/main/java/live/hms/roomkit/PluginExt.kt b/room-kit/src/main/java/live/hms/roomkit/PluginExt.kt new file mode 100644 index 000000000..b49a7cadd --- /dev/null +++ b/room-kit/src/main/java/live/hms/roomkit/PluginExt.kt @@ -0,0 +1,51 @@ +package live.hms.roomkit + +import android.util.Log +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.asCoroutineDispatcher +import kotlinx.coroutines.suspendCancellableCoroutine +import live.hms.video.error.HMSException +import live.hms.video.plugin.video.HMSVideoPlugin +import live.hms.video.sdk.HMSActionResultListener +import live.hms.video.sdk.HMSSDK +import java.util.concurrent.Executors +import kotlin.coroutines.CoroutineContext + +object HMSPluginScope : CoroutineScope { + private val executor = Executors.newSingleThreadScheduledExecutor() + private val dispatcher = executor.asCoroutineDispatcher() + override val coroutineContext: CoroutineContext + get() = dispatcher +} +internal suspend fun HMSSDK.addPlugin(plugin : HMSVideoPlugin): Unit { + return suspendCancellableCoroutine { continuation -> + if (getPlugins().orEmpty().isEmpty().not()){ + continuation.resume(Unit, {}) + return@suspendCancellableCoroutine + } + addPlugin(plugin, object : HMSActionResultListener { + override fun onError(error: HMSException) { + Log.d("HmsPluginError","$error") + continuation.resume(Unit, {}) + } + override fun onSuccess() { + continuation.resume(Unit, {}) + } + }) + } +} + +internal suspend fun HMSSDK.removePlugin(): Unit { + return suspendCancellableCoroutine { continuation -> + for (plugin in this.getPlugins().orEmpty()) { + removePlugin(plugin, object : HMSActionResultListener { + override fun onError(error: HMSException) { + continuation.resume(Unit, {}) + } + override fun onSuccess() { + continuation.resume(Unit, {}) + } + }) + } + } +} \ No newline at end of file diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/GridOptionItem.kt b/room-kit/src/main/java/live/hms/roomkit/ui/GridOptionItem.kt index acf316d9f..742da0519 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/GridOptionItem.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/GridOptionItem.kt @@ -4,13 +4,12 @@ import android.view.View import androidx.annotation.DrawableRes import com.google.android.material.shape.CornerFamily import com.xwray.groupie.viewbinding.BindableItem +import live.hms.prebuilt_themes.HMSPrebuiltTheme +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.roomkit.R import live.hms.roomkit.databinding.ItemGridOptionBinding -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.getColorOrDefault import live.hms.roomkit.ui.theme.getShape -import live.hms.roomkit.ui.theme.setBackgroundAndColor class GridOptionItem( private var title: String, diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/DiagnosticActivity.kt b/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/DiagnosticActivity.kt index c7e58fa8c..0f040a52a 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/DiagnosticActivity.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/DiagnosticActivity.kt @@ -7,9 +7,7 @@ import androidx.fragment.app.activityViewModels import androidx.navigation.fragment.NavHostFragment import androidx.navigation.fragment.findNavController import live.hms.roomkit.R -import live.hms.roomkit.ui.meeting.MeetingViewModel -import live.hms.roomkit.ui.meeting.MeetingViewModelFactory -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme +import live.hms.prebuilt_themes.HMSPrebuiltTheme class DiagnosticActivity : AppCompatActivity() { @@ -23,7 +21,7 @@ class DiagnosticActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_diagnostic) if (HMSPrebuiltTheme.getColours() == null) { - HMSPrebuiltTheme.setTheme(HMSPrebuiltTheme.getDefaultHmsColorPalette()) + HMSPrebuiltTheme.theme = HMSPrebuiltTheme.getDefaultHmsColorPalette() } viewModel.initSDK() setupNavGraph() diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/DiagnosticProvider.kt b/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/DiagnosticProvider.kt index 8011e7e95..2b3e52814 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/DiagnosticProvider.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/DiagnosticProvider.kt @@ -3,22 +3,22 @@ package live.hms.roomkit.ui.diagnostic import android.app.Application import android.content.Context import androidx.core.content.edit -import live.hms.video.diagnostics.HMSDiagnostic +import live.hms.video.diagnostics.HMSDiagnostics import live.hms.video.sdk.HMSSDK import java.util.UUID class DiagnosticProvider(private val application: Application) { - private var hms : Pair? = null + private var hms : Pair? = null private val consistentUserId = getConsistentUserIdOverSessions() fun disposeOfDiagnostic() { hms?.second?.stopConnectivityCheck() hms = null } fun getSdk() = hms?.first ?: createInstance(application).first - fun getDiagnosticSdk() : HMSDiagnostic = hms?.second ?: createInstance(application).second - private fun createInstance(application: Application) : Pair { + fun getDiagnosticSdk() : HMSDiagnostics = hms?.second ?: createInstance(application).second + private fun createInstance(application: Application) : Pair { val hmsSDK = HMSSDK.Builder(application).build() - val diag = hmsSDK.getDiagnosticSDK(consistentUserId) + val diag = hmsSDK.getDiagnosticsSDK(consistentUserId) return Pair(hmsSDK, diag).apply { hms = this } } diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/DiagnosticViewModel.kt b/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/DiagnosticViewModel.kt index 645fd54b3..9b078ea72 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/DiagnosticViewModel.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/DiagnosticViewModel.kt @@ -8,7 +8,7 @@ import androidx.lifecycle.MutableLiveData import live.hms.video.audio.HMSAudioManager import live.hms.video.diagnostics.HMSAudioDeviceCheckListener import live.hms.video.diagnostics.HMSCameraCheckListener -import live.hms.video.diagnostics.HMSDiagnostic +import live.hms.video.diagnostics.HMSDiagnostics import live.hms.video.diagnostics.models.ConnectivityCheckResult import live.hms.video.diagnostics.models.ConnectivityState import live.hms.video.error.HMSException @@ -23,7 +23,7 @@ class DiagnosticViewModel(application: Application) : AndroidViewModel(applicati // First create a new sdk instance private var regionCode = "in" private val diagnosticProvider = DiagnosticProvider(application) - private val diagnosticSDK : HMSDiagnostic + private val diagnosticSDK : HMSDiagnostics get() {return diagnosticProvider.getDiagnosticSdk()} private val hmsSDK : HMSSDK get() { return diagnosticProvider.getSdk()} diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/fragments/PreCallAudioSwitchDialog.kt b/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/fragments/PreCallAudioSwitchDialog.kt index e83467268..401d2e266 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/fragments/PreCallAudioSwitchDialog.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/fragments/PreCallAudioSwitchDialog.kt @@ -17,8 +17,8 @@ import live.hms.roomkit.drawableStart import live.hms.roomkit.ui.diagnostic.DiagnosticViewModel import live.hms.roomkit.ui.diagnostic.DiagnosticViewModelFactory import live.hms.roomkit.ui.meeting.AudioItem -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.HMSPrebuiltTheme +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.roomkit.util.viewLifecycle import live.hms.video.audio.HMSAudioManager diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/fragments/PreCallCameraFragment.kt b/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/fragments/PreCallCameraFragment.kt index e22d8abb3..ea29535c9 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/fragments/PreCallCameraFragment.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/fragments/PreCallCameraFragment.kt @@ -22,8 +22,8 @@ import live.hms.roomkit.show import live.hms.roomkit.ui.diagnostic.DiagnosticViewModel import live.hms.roomkit.ui.diagnostic.DiagnosticViewModelFactory import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.buttonEnabled -import live.hms.roomkit.ui.theme.buttonStrokeEnabled +import live.hms.prebuilt_themes.buttonEnabled +import live.hms.prebuilt_themes.buttonStrokeEnabled import live.hms.roomkit.util.switchCamera import live.hms.roomkit.util.viewLifecycle diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/fragments/PreCallConnectivityTestFragment.kt b/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/fragments/PreCallConnectivityTestFragment.kt index 5522a8729..e597f208c 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/fragments/PreCallConnectivityTestFragment.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/fragments/PreCallConnectivityTestFragment.kt @@ -26,7 +26,7 @@ import live.hms.roomkit.ui.diagnostic.item.DiagnosticDetail import live.hms.roomkit.ui.diagnostic.item.ExpandableHeader import live.hms.roomkit.ui.diagnostic.item.Padding import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.buttonEnabled +import live.hms.prebuilt_themes.buttonEnabled import live.hms.roomkit.util.viewLifecycle import live.hms.stats.Utils import live.hms.video.diagnostics.models.ConnectivityCheckResult diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/fragments/PreCallMicFragment.kt b/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/fragments/PreCallMicFragment.kt index ab5036737..855b4752a 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/fragments/PreCallMicFragment.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/fragments/PreCallMicFragment.kt @@ -26,10 +26,10 @@ import live.hms.roomkit.ui.meeting.AudioOutputSwitchBottomSheet import live.hms.roomkit.ui.meeting.MeetingFragment import live.hms.roomkit.ui.meeting.PreviewFragment import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.buttonEnabled +import live.hms.prebuilt_themes.buttonEnabled import live.hms.roomkit.ui.theme.saveButtonDisabled import live.hms.roomkit.ui.theme.saveButtonEnabled -import live.hms.roomkit.ui.theme.setIconEnabled +import live.hms.prebuilt_themes.setIconEnabled import live.hms.roomkit.util.setOnSingleClickListener import live.hms.roomkit.util.switchCamera import live.hms.roomkit.util.viewLifecycle diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/fragments/PreCallRegionSelectionFragment.kt b/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/fragments/PreCallRegionSelectionFragment.kt index 94b17ad52..f6a30ae06 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/fragments/PreCallRegionSelectionFragment.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/diagnostic/fragments/PreCallRegionSelectionFragment.kt @@ -19,10 +19,10 @@ import live.hms.roomkit.ui.diagnostic.DiagnosticViewModel import live.hms.roomkit.ui.diagnostic.DiagnosticViewModelFactory import live.hms.roomkit.ui.meeting.MeetingViewModel import live.hms.roomkit.ui.meeting.MeetingViewModelFactory -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme +import live.hms.prebuilt_themes.HMSPrebuiltTheme import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.buttonEnabled -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.buttonEnabled +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.roomkit.util.viewLifecycle // TODO: Rename parameter arguments, choose names that match diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/filters/FilterBottomSheet.kt b/room-kit/src/main/java/live/hms/roomkit/ui/filters/FilterBottomSheet.kt index b037f70d1..28d3d304e 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/filters/FilterBottomSheet.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/filters/FilterBottomSheet.kt @@ -27,9 +27,10 @@ import live.hms.roomkit.drawableEnd import live.hms.roomkit.drawableStart import live.hms.roomkit.ui.meeting.MeetingViewModel import live.hms.roomkit.ui.meeting.MeetingViewModelFactory -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.HMSPrebuiltTheme +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.roomkit.util.viewLifecycle +import live.hms.video.plugin.video.virtualbackground.VideoPluginMode class FilterBottomSheet( @@ -129,6 +130,9 @@ class FilterBottomSheet( binding.seekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) { when (currentSelectedFilter) { + is VideoFilter.Blur -> { + currentSelectedFilter = VideoFilter.Blur + } is VideoFilter.Brightness -> meetingViewModel.filterPlugin.setBrightness( progress / 100f ) @@ -159,35 +163,42 @@ class FilterBottomSheet( binding.tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { override fun onTabSelected(tab: TabLayout.Tab?) { when (tab?.tag) { - is VideoFilter.Brightness -> { - currentSelectedFilter = VideoFilter.Brightness - binding.seekBar.progress = - (meetingViewModel.filterPlugin.getBrightnessProgress() * 100f).toInt() - } - - is VideoFilter.Sharpness -> { - currentSelectedFilter = VideoFilter.Sharpness - binding.seekBar.progress = - (meetingViewModel.filterPlugin.getSharpnessProgress() * 100f).toInt() - } - - - is VideoFilter.Contrast -> { - currentSelectedFilter = VideoFilter.Contrast - binding.seekBar.progress = - ( meetingViewModel.filterPlugin.getContrastProgress() * 100f).toInt() - } - - is VideoFilter.Redness -> { - currentSelectedFilter = VideoFilter.Redness - binding.seekBar.progress = - (meetingViewModel.filterPlugin.getRednessProgress() * 100f).toInt() - } - - is VideoFilter.Smoothness -> { - currentSelectedFilter = VideoFilter.Smoothness - binding.seekBar.progress = - ( meetingViewModel.filterPlugin.getSmoothnessProgress() * 100f).toInt() +// is VideoFilter.Brightness -> { +// currentSelectedFilter = VideoFilter.Brightness +// binding.seekBar.progress = +// (meetingViewModel.virtualBackGroundPlugin.getCurrentBlurPercentage()) +// if (lastPluginMode != null) { +// meetingViewModel.isVbPlugin = lastPluginMode!! +// } +//// update() +// } +// +// is VideoFilter.Sharpness -> { +// currentSelectedFilter = VideoFilter.Sharpness +// binding.seekBar.progress = +// (meetingViewModel.filterPlugin.getSharpnessProgress() * 100f).toInt() +// } +// +// +// is VideoFilter.Contrast -> { +// currentSelectedFilter = VideoFilter.Contrast +// binding.seekBar.progress = +// ( meetingViewModel.filterPlugin.getContrastProgress() * 100f).toInt() +// } +// +// is VideoFilter.Redness -> { +// currentSelectedFilter = VideoFilter.Redness +// binding.seekBar.progress = +// (meetingViewModel.filterPlugin.getRednessProgress() * 100f).toInt() +// } +// +// is VideoFilter.Smoothness -> { +// currentSelectedFilter = VideoFilter.Smoothness +// binding.seekBar.progress = +// ( meetingViewModel.filterPlugin.getSmoothnessProgress() * 100f).toInt() +// } + is VideoFilter.Blur -> { + meetingViewModel.isVbPlugin = VideoPluginMode.BLUR_BACKGROUND } @@ -221,19 +232,11 @@ class FilterBottomSheet( ) addTab( - this.newTab().setText("Brightness").setTag(VideoFilter.Brightness), true - ) - addTab( - this.newTab().setText("Contrast").setTag(VideoFilter.Contrast) - ) - addTab( - this.newTab().setText("Sharpness").setTag(VideoFilter.Sharpness) - ) - addTab( - this.newTab().setText("Redness").setTag(VideoFilter.Redness) + this.newTab().setText(meetingViewModel.isVbPlugin.toString()) + .setTag(VideoFilter.Blur), true ) addTab( - this.newTab().setText("Smoothness").setTag(VideoFilter.Smoothness) + this.newTab().setText("Disable Effects").setTag(VideoFilter.Quality) ) setSelectedTabIndicatorColor(Color.TRANSPARENT) } diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/filters/VideoFilter.kt b/room-kit/src/main/java/live/hms/roomkit/ui/filters/VideoFilter.kt index e316ef48e..67c8a25e8 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/filters/VideoFilter.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/filters/VideoFilter.kt @@ -2,6 +2,8 @@ package live.hms.roomkit.ui.filters sealed class VideoFilter { object Brightness : VideoFilter() + object Blur : VideoFilter() + object Quality : VideoFilter() object Sharpness : VideoFilter() object Saturation : VideoFilter() object Redness : VideoFilter() diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/AudioItem.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/AudioItem.kt index 093272aa5..67ee1ee11 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/AudioItem.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/AudioItem.kt @@ -13,8 +13,8 @@ import live.hms.roomkit.drawableEnd import live.hms.roomkit.drawableStart import live.hms.roomkit.setDrawables import live.hms.roomkit.setOnSingleClickListener -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.HMSPrebuiltTheme +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.video.audio.HMSAudioManager import live.hms.video.audio.manager.AudioManagerUtil import kotlin.math.roundToInt diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/AudioOutputSwitchBottomSheet.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/AudioOutputSwitchBottomSheet.kt index 5e4b3da4b..e4397da62 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/AudioOutputSwitchBottomSheet.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/AudioOutputSwitchBottomSheet.kt @@ -16,8 +16,8 @@ import live.hms.roomkit.databinding.BottomSheetAudioSwitchBinding import live.hms.roomkit.drawableEnd import live.hms.roomkit.drawableStart import live.hms.roomkit.setDrawables -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.HMSPrebuiltTheme +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.roomkit.util.viewLifecycle import live.hms.video.audio.HMSAudioManager.AudioDevice diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/ClosedCaptionsForEveryone.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/ClosedCaptionsForEveryone.kt index b53470a8b..8b259078f 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/ClosedCaptionsForEveryone.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/ClosedCaptionsForEveryone.kt @@ -37,7 +37,7 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialogFragment import live.hms.roomkit.R -import live.hms.roomkit.ui.meeting.compose.Variables +import live.hms.prebuilt_themes.Variables import live.hms.video.sdk.models.TranscriptionState import live.hms.video.sdk.models.TranscriptionsMode diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/CustomPeerMetadata.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/CustomPeerMetadata.kt index c92e7dcbe..4372f40f3 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/CustomPeerMetadata.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/CustomPeerMetadata.kt @@ -5,12 +5,12 @@ import com.google.gson.JsonSyntaxException import com.google.gson.annotations.SerializedName data class CustomPeerMetadata( - @SerializedName("isHandRaised") - val isHandRaised: Boolean, @SerializedName("isBRBOn") val isBRBOn: Boolean, @SerializedName("name") val name: String? = null, + @SerializedName("handRaisedAt") + val handRaisedAt : Long? = null, @SerializedName("prevRole") val prevRole : String? = null ) { diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/FakeVirtualBackground.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/FakeVirtualBackground.kt new file mode 100644 index 000000000..87daa371c --- /dev/null +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/FakeVirtualBackground.kt @@ -0,0 +1,58 @@ +package live.hms.roomkit.ui.meeting + +import android.graphics.Bitmap +import android.util.Log +import live.hms.video.plugin.video.HMSVideoPluginType +import live.hms.video.plugin.video.virtualbackground.HmsVirtualBackgroundInterface +import live.hms.video.plugin.video.virtualbackground.VideoFrameInfoListener +import live.hms.video.sdk.HMSPluginResultListener +import org.webrtc.VideoFrame + +class FakeVirtualBackground : HmsVirtualBackgroundInterface { + private fun loggingIgnore(method : String) { + Log.d("HMSVirtualBackground", "Ignoring method") + } + override fun disableEffects() { + loggingIgnore("disableEffects") + } + + override fun enableBackground(bitmap: Bitmap) { + loggingIgnore("enableBackground") + } + + override fun enableBlur(blurPercentage: Int) { + loggingIgnore("") + } + + override fun getCurrentBlurPercentage(): Int { + loggingIgnore("") + return 0 + } + + override fun getName(): String = + "@100mslive/placeholder-hms-virtual-background" + + override fun getPluginType(): HMSVideoPluginType = HMSVideoPluginType.TRANSFORM + + override suspend fun init() { + loggingIgnore("init") + } + + override fun isSupported(): Boolean = false + + override fun processVideoFrame( + input: VideoFrame, + outputListener: HMSPluginResultListener?, + skipProcessing: Boolean? + ) { + loggingIgnore("processVideoFrame") + } + + override fun setVideoFrameInfoListener(listener: VideoFrameInfoListener) { + loggingIgnore("setVideoFrameInfoListener") + } + + override fun stop() { + loggingIgnore("stop") + } +} \ No newline at end of file diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/HlsVideoQualitySelectorBottomSheet.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/HlsVideoQualitySelectorBottomSheet.kt index 88cac1298..9399bdca6 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/HlsVideoQualitySelectorBottomSheet.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/HlsVideoQualitySelectorBottomSheet.kt @@ -19,8 +19,8 @@ import live.hms.roomkit.util.viewLifecycle import live.hms.hls_player.HmsHlsPlayer import live.hms.hls_player.HmsHlsLayer import live.hms.roomkit.ui.meeting.videogrid.VideoGridPageFragment -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.HMSPrebuiltTheme +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.roomkit.ui.theme.trackTintList diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/HmsVirtualBackgroundInjector.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/HmsVirtualBackgroundInjector.kt new file mode 100644 index 000000000..a059aec44 --- /dev/null +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/HmsVirtualBackgroundInjector.kt @@ -0,0 +1,28 @@ +package live.hms.roomkit.ui.meeting + +import live.hms.video.plugin.video.virtualbackground.HmsVirtualBackgroundInterface +import live.hms.video.sdk.HMSSDK +import live.hms.video.virtualbackground.HMSVirtualBackground + +class HmsVirtualBackgroundInjector(private val hmsSdk : HMSSDK) { + val vbPlugin : HmsVirtualBackgroundInterface + init { + // implementation "live.100ms:virtual-background:$hmsVersion" + // without the above import being added, this will return false. + val isVbImportAdded = try { + // the class is not local or an anonymous object so this can't be null + // and if it was turned into a local one the crash would happen every time and + // be noticeable + val qualifiedName = HMSVirtualBackground::class.qualifiedName!! + Class.forName(qualifiedName) + true + } catch (ex : ClassNotFoundException) { + false + } catch (ex : NoClassDefFoundError) { + false + } + + vbPlugin = if(isVbImportAdded) HMSVirtualBackground(hmsSdk) else FakeVirtualBackground() + + } +} \ No newline at end of file diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingFragment.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingFragment.kt index e24a2b1f8..a09dcf45a 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingFragment.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingFragment.kt @@ -61,6 +61,11 @@ import com.google.android.material.imageview.ShapeableImageView import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext +import live.hms.prebuilt_themes.HMSPrebuiltTheme +import live.hms.prebuilt_themes.getColorOrDefault +import live.hms.prebuilt_themes.getPreviewLayout +import live.hms.prebuilt_themes.setIconEnabled +import live.hms.prebuilt_themes.setIconDisabled import live.hms.roomkit.R import live.hms.roomkit.databinding.FragmentMeetingBinding import live.hms.roomkit.setGradient @@ -87,7 +92,7 @@ import live.hms.roomkit.ui.meeting.chat.combined.OPEN_TO_PARTICIPANTS import live.hms.roomkit.ui.meeting.chat.combined.PinnedMessageUiUseCase import live.hms.roomkit.ui.meeting.chat.rbac.RoleBasedChatBottomSheet import live.hms.roomkit.ui.meeting.commons.VideoGridBaseFragment -import live.hms.roomkit.ui.meeting.compose.Variables +import live.hms.prebuilt_themes.Variables import live.hms.roomkit.ui.meeting.participants.DIRECTLY_OPENED import live.hms.roomkit.ui.meeting.participants.ParticipantsFragment import live.hms.roomkit.ui.meeting.pinnedvideo.PinnedVideoFragment @@ -103,6 +108,7 @@ import live.hms.video.media.tracks.HMSLocalAudioTrack import live.hms.video.media.tracks.HMSLocalVideoTrack import live.hms.video.sdk.HMSActionResultListener import live.hms.video.sdk.models.HMSHlsRecordingConfig +import live.hms.video.sdk.models.HMSLocalPeer import live.hms.video.sdk.models.HMSRemovedFromRoom import live.hms.video.sdk.models.enums.HMSRecordingState import live.hms.video.sdk.models.enums.HMSStreamingState @@ -1232,10 +1238,12 @@ class MeetingFragment : Fragment() { } }, onRaiseHandClicked = { meetingViewModel.toggleRaiseHand()}, - onNameChange = { FilterBottomSheet().show( - childFragmentManager, - ChangeNameDialogFragment.TAG - ) + onNameChange = { + // Get the local peer but if it's null, return + VirtualBackgroundBottomSheet().show( + childFragmentManager, + VirtualBackgroundBottomSheet.TAG + ) }, disableHandRaiseDisplay = !meetingViewModel.handRaiseAvailable(), showPolls = { findNavController().navigate(MeetingFragmentDirections.actionMeetingFragmentToPollsCreationFragment()) }, diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingViewModel.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingViewModel.kt index b28774e15..6d74e77dc 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingViewModel.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingViewModel.kt @@ -3,6 +3,8 @@ package live.hms.roomkit.ui.meeting import android.Manifest import android.app.Application import android.content.Intent +import android.graphics.Bitmap +import android.graphics.Matrix import android.media.AudioManager import android.os.Build import android.util.Log @@ -14,8 +16,13 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.launch +import kotlinx.coroutines.sync.Mutex +import kotlinx.coroutines.sync.withLock import live.hms.hls_player.HmsHlsPlaybackState import live.hms.hls_player.HmsHlsPlayer +import live.hms.prebuilt_themes.HMSPrebuiltTheme +import live.hms.prebuilt_themes.getPreviewLayout +import live.hms.roomkit.HMSPluginScope import live.hms.roomkit.R import live.hms.roomkit.ui.HMSPrebuiltOptions import live.hms.roomkit.ui.meeting.activespeaker.ActiveSpeakerHandler @@ -30,20 +37,20 @@ import live.hms.roomkit.ui.polls.PollCreationInfo import live.hms.roomkit.ui.polls.QuestionUi import live.hms.roomkit.ui.settings.SettingsFragment.Companion.REAR_FACING_CAMERA import live.hms.roomkit.ui.settings.SettingsStore -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme -import live.hms.roomkit.ui.theme.getPreviewLayout import live.hms.roomkit.util.POLL_IDENTIFIER_FOR_HLS_CUE import live.hms.roomkit.util.SingleLiveEvent import live.hms.roomkit.util.debounce import live.hms.video.audio.HMSAudioManager import live.hms.video.connection.stats.* import live.hms.video.error.HMSException -import live.hms.video.interactivity.HmsInteractivityCenter -import live.hms.video.interactivity.HmsPollUpdateListener import live.hms.video.events.AgentType import live.hms.video.factories.noisecancellation.AvailabilityStatus +import live.hms.video.interactivity.HmsInteractivityCenter +import live.hms.video.interactivity.HmsPollUpdateListener import live.hms.video.media.settings.* import live.hms.video.media.tracks.* +import live.hms.video.plugin.video.virtualbackground.VideoFrameInfoListener +import live.hms.video.plugin.video.virtualbackground.VideoPluginMode import live.hms.video.polls.HMSPollBuilder import live.hms.video.polls.HMSPollQuestionBuilder import live.hms.video.polls.HMSPollResponseBuilder @@ -73,7 +80,7 @@ import live.hms.video.whiteboard.HMSWhiteboardUpdateListener import live.hms.video.whiteboard.State import live.hms.videofilters.HMSVideoFilter import java.util.* -import kotlin.collections.ArrayList +import kotlin.math.abs import kotlin.properties.Delegates @@ -179,6 +186,13 @@ class MeetingViewModel( val filterPlugin by lazy { HMSVideoFilter(hmsSDK) } + var isVbPlugin : VideoPluginMode = VideoPluginMode.NONE + var selectedVbBackgroundUrl : String? = null + val virtualBackGroundPlugin by lazy { HmsVirtualBackgroundInjector(hmsSDK).vbPlugin } + fun setBlurPercentage(percentage : Int) { + virtualBackGroundPlugin.enableBlur(percentage) + } + private var lastPollStartedTime : Long = 0 val localHmsInteractivityCenter : HmsInteractivityCenter = hmsSDK.getHmsInteractivityCenter() @@ -335,40 +349,60 @@ class MeetingViewModel( }) } - fun showVideoFilterIcon() = settings.enableVideoFilter - - fun setupFilterVideoPlugin() { - - if (hmsSDK.getPlugins().isNullOrEmpty() && hmsSDK.getLocalPeer()?.videoTrack != null ) { - hmsSDK.addPlugin(filterPlugin, object : HMSActionResultListener { - override fun onError(error: HMSException) { - + private val pluginMutex = Mutex() + fun setupFilterVideoPlugin(bitmap : Bitmap? = null) { + when(isVbPlugin) { + VideoPluginMode.REPLACE_BACKGROUND -> { + if(bitmap == null) { + Log.d( + TAG, + "Ignoring replace background call because no bitmap to replace with was provided" + ) + return } - override fun onSuccess() { - + if (isVbPlugin == VideoPluginMode.REPLACE_BACKGROUND) { + var isLandscapeSet = false + var isPotraitSet = false + virtualBackGroundPlugin.setVideoFrameInfoListener(object : + VideoFrameInfoListener { + override fun onFrame(rotatedWidth: Int, rotatedHeight: Int, rotation: Int) { + if (isVbPlugin == VideoPluginMode.REPLACE_BACKGROUND) { + if (abs(rotation) % 180 == 0 && isLandscapeSet.not()) { + isLandscapeSet = true + isPotraitSet = false + virtualBackGroundPlugin.enableBackground(getCenterCroppedBitmap(bitmap, rotatedWidth, rotatedHeight)) + } else if (abs(rotation) % 180 != 0 && isPotraitSet.not()) { + isLandscapeSet = false + isPotraitSet = true + virtualBackGroundPlugin.enableBackground(getCenterCroppedBitmap(bitmap, rotatedWidth, rotatedHeight)) + } + } + } + } + ) } - - }) + } + VideoPluginMode.BLUR_BACKGROUND -> virtualBackGroundPlugin.enableBlur() + VideoPluginMode.NONE -> virtualBackGroundPlugin.disableEffects() } } fun removeVideoFilterPlugIn() { + HMSPluginScope.launch { + pluginMutex.withLock { + hmsSDK.removePlugin(virtualBackGroundPlugin, object : HMSActionResultListener { + override fun onError(error: HMSException) { + triggerErrorNotification(error.message) + } - if (hmsSDK.getPlugins().isNullOrEmpty().not() ) { - filterPlugin.stop() - hmsSDK.removePlugin(filterPlugin, object : HMSActionResultListener { - override fun onError(error: HMSException) { - - } - - override fun onSuccess() { + override fun onSuccess() { - } + } - }) + }) + } } - } @@ -397,7 +431,22 @@ class MeetingViewModel( setHmsConfig(hmsPrebuiltOptions, token, initURL) kotlin.runCatching { setTheme(layoutConfig.data?.getOrNull(0)?.themes?.getOrNull(0)?.palette!!) } onHMSActionResultListener?.onSuccess() - roomLayoutLiveData.postValue(true) + if(vbEnabled()) { + viewModelScope.launch { + hmsSDK.addPlugin(virtualBackGroundPlugin, object : HMSActionResultListener { + override fun onError(error: HMSException) { + triggerErrorNotification(error.message) + } + + override fun onSuccess() { + } + + }) + roomLayoutLiveData.postValue(true) + } + } else { + roomLayoutLiveData.postValue(true) + } } }) @@ -405,7 +454,7 @@ class MeetingViewModel( } private fun setTheme(theme: HMSRoomLayout.HMSRoomLayoutData.HMSRoomTheme.HMSColorPalette) { - HMSPrebuiltTheme.setTheme(theme) + HMSPrebuiltTheme.theme = theme } fun updateNameInPreview(nameStr: String) { @@ -422,7 +471,6 @@ class MeetingViewModel( token, Gson().toJson( CustomPeerMetadata( - isHandRaised = false, name = hmsPrebuiltOptions?.userName.orEmpty(), isBRBOn = false ) @@ -2054,6 +2102,7 @@ class MeetingViewModel( } override fun onSuccess() { + setHandRaisedAtTime(true) Log.d(TAG, "Successfully raised hand") } }) @@ -2067,6 +2116,7 @@ class MeetingViewModel( override fun onSuccess() { Log.d(TAG, "Successfully lowered hand") + setHandRaisedAtTime(false) } }) } @@ -2091,6 +2141,23 @@ class MeetingViewModel( return currentMetadata?.isBRBOn?:false } + fun setHandRaisedAtTime(raised : Boolean) { + val raisedAt = if(raised) System.currentTimeMillis() else null + val localPeer = hmsSDK.getLocalPeer() + val currentMetadata = CustomPeerMetadata.fromJson(localPeer?.metadata) + val newMetadataJson = currentMetadata?.copy(handRaisedAt = raisedAt) ?: CustomPeerMetadata(false, handRaisedAt = raisedAt) + + hmsSDK.changeMetadata(newMetadataJson.toJson(), object : HMSActionResultListener { + override fun onError(error: HMSException) { + triggerErrorNotification(error.message) + } + + override fun onSuccess() { + + } + + }) + } fun toggleBRB() { val localPeer = hmsSDK.getLocalPeer()!! val currentMetadata = CustomPeerMetadata.fromJson(localPeer.metadata) @@ -2809,5 +2876,78 @@ class MeetingViewModel( fun ncPreviewNoiseCancellationInLayout() = prebuiltInfoContainer.ncInPreviewState() fun getAllWhitelistedRolesForChangeRole() = prebuiltInfoContainer.getAllWhitelistedRolesForChangeRole() + suspend fun searchPeerNameInLargeRoom(query: String, + offset : Long, + limit: Int = 10, + ): List { + val peers = CompletableDeferred>() + hmsSDK.searchPeerNameInLargeRoom(query,limit, offset, object : HmsTypedActionResultListener { + override fun onSuccess(result: PeerSearchResponse) { + peers.complete(result.peers) + } + + override fun onError(error: HMSException) { + // Send an error here + peers.complete(emptyList()) + triggerErrorNotification( + error.message + ) + } + + }) + return peers.await() + } + + fun vbEnabled() = prebuiltInfoContainer.vbEnabledState().vbEnabled + fun vbBackgrounds(): VbBackgrounds = + prebuiltInfoContainer.vbEnabledState().backgroundVbBackgrounds + + fun getLocalPeerMeetingTracks() : MeetingTrack? { + val localPeer = hmsSDK.getLocalPeer() ?: return null + return with(localPeer) { + MeetingTrack(this, + videoTrack, + audioTrack) + } + } + + fun getCenterCroppedBitmap( + src: Bitmap, + expectedWidth: Int, + expectedHeight: Int + ): Bitmap { + // Check if the image is big enough + val widthDelta = src.width - expectedWidth + val heightDelta = src.height - expectedHeight + val scaleFactor : Float = if(widthDelta < 0 || heightDelta < 0){ + // Find the biggest stretch that might be required. + val isHeightLess = heightDelta < widthDelta + if(isHeightLess) { + //scale factor depends on height + expectedHeight.toFloat()/src.height + } else { + expectedWidth.toFloat() / src.width + } + } else { + 1.0f + } + val matrix = Matrix() + if(scaleFactor != 1.0f) { + matrix.postScale(scaleFactor, scaleFactor) + } + + // We've got to crop the image to the expected size. + // We either scale up first or scale down first. + + val newW = ((src.width * scaleFactor - expectedWidth)/2).toInt() + val newH = ((src.height * scaleFactor - expectedHeight)/2).toInt() + return Bitmap.createBitmap( + Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true), + newW, + newH, + expectedWidth, + expectedHeight + ) + } } diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MessageOptionsBottomSheet.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MessageOptionsBottomSheet.kt index b55067181..630a20125 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MessageOptionsBottomSheet.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MessageOptionsBottomSheet.kt @@ -22,9 +22,9 @@ import live.hms.roomkit.setOnSingleClickListener import live.hms.roomkit.ui.GridOptionItem import live.hms.roomkit.ui.HMSPrebuiltOptions import live.hms.roomkit.ui.meeting.chat.ChatMessage -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme +import live.hms.prebuilt_themes.HMSPrebuiltTheme import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.roomkit.ui.theme.getShape import live.hms.roomkit.util.ROOM_PREBUILT import live.hms.roomkit.util.viewLifecycle diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/NoiseCancellationInPreviewUseCase.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/NoiseCancellationInPreviewUseCase.kt index b9526463f..3a3c53bcd 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/NoiseCancellationInPreviewUseCase.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/NoiseCancellationInPreviewUseCase.kt @@ -40,7 +40,7 @@ class NoiseCancellationInPreviewUseCase( fun setNcStateForPreview(value : Boolean?) { state = when(value) { true -> NcInPreview.ON - false -> NcInPreview.ON + false -> NcInPreview.OFF null -> NcInPreview.UNSET } diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/PrebuiltInfoContainer.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/PrebuiltInfoContainer.kt index 6c92c3c65..f6ef9c8d8 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/PrebuiltInfoContainer.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/PrebuiltInfoContainer.kt @@ -183,8 +183,50 @@ class PrebuiltInfoContainer(private val hmssdk: HMSSDK) { fun getAllWhitelistedRolesForChangeRole() = roleMap[localPeer.hmsRole.name]?.screens?.conferencing ?.default?.elements?.chat?.rolesWhiteList ?: emptyList() + /** + * Returns a pair of the default url and the list of backgrounds. + * Can both be null. + */ + fun vbEnabledState() : VbState { + val localPeer = hmssdk.getLocalPeer() + val isVbEnabled = if (localPeer == null) { + hmsRoomLayout?.data?.get(0)?.screens?.conferencing?.default?.elements + ?.virtualBackground != null + } else { + roleMap[localPeer.hmsRole.name]?.screens?.conferencing?.default?.elements + ?.virtualBackground != null + } + + val defaultVbUrl =if (localPeer == null) { + hmsRoomLayout?.data?.get(0)?.screens?.conferencing?.default?.elements + ?.virtualBackground?.backgroundMedia?.find { it.default == true }?.url + } else { + roleMap[localPeer.hmsRole.name]?.screens?.conferencing?.default?.elements + ?.virtualBackground?.backgroundMedia?.find { it.default == true }?.url + } + + val vbBackgroundImagesList = if (localPeer == null) { + hmsRoomLayout?.data?.get(0)?.screens?.conferencing?.default?.elements + ?.virtualBackground?.backgroundMedia?.mapNotNull { it.url } + } else { + roleMap[localPeer.hmsRole.name]?.screens?.conferencing?.default?.elements + ?.virtualBackground?.backgroundMedia?.mapNotNull { it.url } + } + + + return VbState(isVbEnabled, VbBackgrounds(defaultVbUrl, vbBackgroundImagesList ?: emptyList())) + } } +data class VbState( + val vbEnabled : Boolean, + val backgroundVbBackgrounds: VbBackgrounds +) +data class VbBackgrounds( + val default : String?, + val backgroundUrls : List +) + data class AllowedToMessageParticipants( val everyone : Boolean, val peers : Boolean, diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/PreviewFragment.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/PreviewFragment.kt index ebdce12c7..2c9b2f2ca 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/PreviewFragment.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/PreviewFragment.kt @@ -38,12 +38,12 @@ import live.hms.roomkit.ui.meeting.participants.ParticipantsAdapter import live.hms.roomkit.ui.meeting.participants.ParticipantsDialog import live.hms.roomkit.ui.settings.SettingsStore import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.buttonDisabled -import live.hms.roomkit.ui.theme.buttonEnabled -import live.hms.roomkit.ui.theme.getCurrentRoleData -import live.hms.roomkit.ui.theme.getPreviewLayout -import live.hms.roomkit.ui.theme.setIconDisabled -import live.hms.roomkit.ui.theme.setIconEnabled +import live.hms.prebuilt_themes.buttonDisabled +import live.hms.prebuilt_themes.buttonEnabled +import live.hms.prebuilt_themes.getCurrentRoleData +import live.hms.prebuilt_themes.getPreviewLayout +import live.hms.prebuilt_themes.setIconDisabled +import live.hms.prebuilt_themes.setIconEnabled import live.hms.roomkit.util.NameUtils import live.hms.roomkit.util.contextSafe import live.hms.roomkit.util.openShareIntent @@ -80,11 +80,10 @@ class PreviewFragment : Fragment() { requireActivity().application ) } + private var track : MeetingTrack? = null private var alertDialog: AlertDialog? = null - private var track: MeetingTrack? = null - private var isViewVisible = false private var participantsDialog: ParticipantsDialog? = null @@ -253,6 +252,7 @@ class PreviewFragment : Fragment() { buttonToggleAudio.initAnimState(littleLessTranslate = true) buttonToggleVideo.initAnimState(littleLessTranslate = true) buttonSwitchCamera.initAnimState(littleLessTranslate = true) + previewVirtualBackground.initAnimState(littleLessTranslate = true) buttonNetworkQuality.initAnimState(littleLessTranslate = true) iconOutputDevice.initAnimState(littleLessTranslate = true) editContainerName.initAnimState() @@ -406,6 +406,15 @@ class PreviewFragment : Fragment() { if (it.isEnabled) track?.video.switchCamera() } + binding.previewVirtualBackground.setOnSingleClickListener(200L) { + if (it.isEnabled) { + VirtualBackgroundBottomSheet().show( + childFragmentManager, + VirtualBackgroundBottomSheet.TAG + ) + } + } + binding.buttonToggleVideo.apply { setOnSingleClickListener(200L) { @@ -654,7 +663,7 @@ class PreviewFragment : Fragment() { isPreviewLoaded = true enableDisableJoinNowButton() - updateUiBasedOnPublishParams(room.localPeer?.hmsRole?.publishParams) + updateUiBasedOnPublishParams(room.localPeer?.hmsRole?.publishParams) track = MeetingTrack(room.localPeer!!, null, null) localTracks.forEach { when (it) { @@ -694,10 +703,15 @@ class PreviewFragment : Fragment() { if (it.isMute) { binding.buttonSwitchCamera.alpha = 0.5f binding.buttonSwitchCamera.isEnabled = false + binding.previewVirtualBackground.alpha = 0.5f + binding.previewVirtualBackground.isEnabled = false setIconDisabled(R.drawable.avd_video_on_to_off) } else { binding.buttonSwitchCamera.alpha = 1f binding.buttonSwitchCamera.isEnabled = true + binding.previewVirtualBackground.alpha = 1f + binding.previewVirtualBackground.isEnabled = true + setIconEnabled(R.drawable.avd_video_off_to_on) } } @@ -746,9 +760,11 @@ class PreviewFragment : Fragment() { if (publishParams.allowed.contains("video")) { binding.buttonToggleVideo.visibility = View.VISIBLE binding.buttonSwitchCamera.visibility = View.VISIBLE + binding.previewVirtualBackground.visibility = if(meetingViewModel.vbEnabled()) View.VISIBLE else View.GONE binding.buttonToggleVideo.startBounceAnimationUpwards() binding.buttonSwitchCamera.startBounceAnimationUpwards() + binding.previewVirtualBackground.startBounceAnimationUpwards() binding.videoCardContainer.visibility = View.VISIBLE } else { @@ -757,6 +773,7 @@ class PreviewFragment : Fragment() { binding.buttonSwitchCamera.visibility = View.GONE binding.videoCardContainer.visibility = View.GONE binding.iconNoiseCancellation.visibility = View.GONE + binding.previewVirtualBackground.visibility = View.GONE } } diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/SessionOptionBottomSheet.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/SessionOptionBottomSheet.kt index 45f287bb1..d8260f08a 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/SessionOptionBottomSheet.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/SessionOptionBottomSheet.kt @@ -20,9 +20,10 @@ import kotlinx.coroutines.launch import live.hms.roomkit.R import live.hms.roomkit.databinding.BottomSheetOptionBinding import live.hms.roomkit.ui.GridOptionItem -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.HMSPrebuiltTheme +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.roomkit.util.viewLifecycle +import live.hms.video.plugin.video.virtualbackground.VideoPluginMode import live.hms.video.sdk.models.TranscriptionState import live.hms.video.sdk.models.TranscriptionsMode import live.hms.video.sdk.models.enums.HMSRecordingState @@ -168,14 +169,14 @@ class SessionOptionBottomSheet( ) val videoFilter = GridOptionItem( - "Video Filter", R.drawable.emoji_icon, { + "Virtual Background", R.drawable.vb_session_option_icon, { + meetingViewModel.isVbPlugin = VideoPluginMode.REPLACE_BACKGROUND onNameChange.invoke() dismissAllowingStateLoss() }, isSelected = false ) - val whiteboard = GridOptionItem( resources.getString(R.string.start_white_board), R.drawable.whiteboard, { meetingViewModel.toggleWhiteBoard() @@ -218,7 +219,7 @@ class SessionOptionBottomSheet( ) ) } - if (meetingViewModel.isLocalVideoEnabled() == true && meetingViewModel.showVideoFilterIcon()) { + if (meetingViewModel.isLocalVideoEnabled() == true && meetingViewModel.vbEnabled()) { add(videoFilter) } } diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/SwitchRoleBottomSheet.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/SwitchRoleBottomSheet.kt index 7d6dfe80e..999b689ac 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/SwitchRoleBottomSheet.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/SwitchRoleBottomSheet.kt @@ -55,7 +55,7 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialogFragment import live.hms.roomkit.R -import live.hms.roomkit.ui.meeting.compose.Variables +import live.hms.prebuilt_themes.Variables import live.hms.video.sdk.models.HMSPeer import live.hms.video.sdk.models.role.HMSRole diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/VirtualBackgroundBottomSheet.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/VirtualBackgroundBottomSheet.kt new file mode 100644 index 000000000..a65840afe --- /dev/null +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/VirtualBackgroundBottomSheet.kt @@ -0,0 +1,90 @@ +package live.hms.roomkit.ui.meeting + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.ui.platform.ComposeView +import androidx.compose.ui.platform.ViewCompositionStrategy +import androidx.compose.ui.viewinterop.AndroidView +import androidx.fragment.app.activityViewModels +import com.google.android.material.bottomsheet.BottomSheetBehavior +import com.google.android.material.bottomsheet.BottomSheetDialog +import com.google.android.material.bottomsheet.BottomSheetDialogFragment +import live.hms.roomkit.R +import live.hms.vb_prebuilt.SelectedEffect +import live.hms.vb_prebuilt.VirtualBackgroundOptions +import live.hms.video.plugin.video.virtualbackground.VideoPluginMode +import live.hms.videoview.HMSVideoView + +class VirtualBackgroundBottomSheet : BottomSheetDialogFragment() { + private val meetingViewModel: MeetingViewModel by activityViewModels() + + companion object { + const val TAG = "VirtualBackgroundBottomSheet" + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + dialog?.let { + val sheet = it as BottomSheetDialog + //Don't let the sheet be draggable so that the items will be able to scroll + sheet.behavior.isDraggable = false + sheet.behavior.state = BottomSheetBehavior.STATE_EXPANDED + } + } + + override fun getTheme(): Int { + return R.style.AppBottomSheetDialogTheme + } + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + return ComposeView(requireContext()).apply { + // Dispose the Composition when viewLifecycleOwner is destroyed + setViewCompositionStrategy( + ViewCompositionStrategy.DisposeOnLifecycleDestroyed(viewLifecycleOwner) + ) + + setContent { + val allVbBackgrounds by remember { mutableStateOf(meetingViewModel.vbBackgrounds()) } + val localPeerMeetingTrack by remember { mutableStateOf(meetingViewModel.getLocalPeerMeetingTracks()) } + + VirtualBackgroundOptions( + videoView = { modifier -> AndroidView(modifier = modifier,factory ={ + HMSVideoView(it).apply { + localPeerMeetingTrack?.video?.let { track -> + addTrack(track) + } + }} ) }, + allBackgrounds = allVbBackgrounds.backgroundUrls, + defaultBackground = meetingViewModel.selectedVbBackgroundUrl, + currentlySelectedVbMode = when(meetingViewModel.isVbPlugin) { + VideoPluginMode.REPLACE_BACKGROUND -> SelectedEffect.BACKGROUND + VideoPluginMode.NONE -> SelectedEffect.NO_EFFECT + VideoPluginMode.BLUR_BACKGROUND -> SelectedEffect.BLUR + }, + close = { dismissAllowingStateLoss() }, + removeEffects = { + meetingViewModel.isVbPlugin = VideoPluginMode.NONE + meetingViewModel.setupFilterVideoPlugin()}, + blur = { blurPercentage -> + meetingViewModel.isVbPlugin = VideoPluginMode.BLUR_BACKGROUND + meetingViewModel.setupFilterVideoPlugin() + meetingViewModel.setBlurPercentage(blurPercentage.toInt()) + }, + backgroundSelected = { url, bitmap -> + meetingViewModel.selectedVbBackgroundUrl = url + meetingViewModel.isVbPlugin = VideoPluginMode.REPLACE_BACKGROUND + meetingViewModel.setupFilterVideoPlugin(bitmap) + }, + onBlurPercentageChanged = {meetingViewModel.setBlurPercentage(it.toInt())}, + initialBlurPercentage = 30f + ) + } + } + } +} diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/activespeaker/HlsFragment.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/activespeaker/HlsFragment.kt index 6f867c41d..15eb63992 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/activespeaker/HlsFragment.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/activespeaker/HlsFragment.kt @@ -131,12 +131,12 @@ import live.hms.roomkit.ui.meeting.chat.combined.ChatRbacRecipientHandling import live.hms.roomkit.ui.meeting.chat.combined.LaunchMessageOptionsDialog import live.hms.roomkit.ui.meeting.chat.combined.PinnedMessageUiUseCase import live.hms.roomkit.ui.meeting.chat.rbac.RoleBasedChatBottomSheet -import live.hms.roomkit.ui.meeting.compose.Variables -import live.hms.roomkit.ui.meeting.compose.Variables.Companion.OnSurfaceHigh -import live.hms.roomkit.ui.meeting.compose.Variables.Companion.PrimaryDefault -import live.hms.roomkit.ui.meeting.compose.Variables.Companion.Spacing0 -import live.hms.roomkit.ui.meeting.compose.Variables.Companion.Spacing1 -import live.hms.roomkit.ui.meeting.compose.Variables.Companion.Spacing2 +import live.hms.prebuilt_themes.Variables +import live.hms.prebuilt_themes.Variables.Companion.OnSurfaceHigh +import live.hms.prebuilt_themes.Variables.Companion.PrimaryDefault +import live.hms.prebuilt_themes.Variables.Companion.Spacing0 +import live.hms.prebuilt_themes.Variables.Companion.Spacing1 +import live.hms.prebuilt_themes.Variables.Companion.Spacing2 import live.hms.roomkit.ui.polls.leaderboard.millisToText import live.hms.roomkit.ui.theme.applyTheme import live.hms.roomkit.util.contextSafe diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/audiomode/AudioLevelView.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/audiomode/AudioLevelView.kt index e3cff2b8e..e99cc3a6d 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/audiomode/AudioLevelView.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/audiomode/AudioLevelView.kt @@ -7,11 +7,9 @@ import android.graphics.Color import android.graphics.Paint import android.graphics.RectF import android.util.AttributeSet -import android.util.Log -import android.view.animation.DecelerateInterpolator import android.widget.FrameLayout import androidx.interpolator.view.animation.FastOutLinearInInterpolator -import live.hms.roomkit.util.dp +import live.hms.prebuilt_themes.dp class AudioLevelView(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs) { diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/ChatUseCase.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/ChatUseCase.kt index 2d17283e0..6c4eae4f7 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/ChatUseCase.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/ChatUseCase.kt @@ -17,8 +17,8 @@ import live.hms.roomkit.R import live.hms.roomkit.ui.meeting.AllowedToMessageParticipants import live.hms.roomkit.ui.meeting.ChatPauseState import live.hms.roomkit.ui.meeting.MeetingViewModel -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.HMSPrebuiltTheme +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.video.sdk.models.HMSPeer diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/SingleSideFadeRecyclerview.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/SingleSideFadeRecyclerview.kt index 21767810c..bd06951c3 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/SingleSideFadeRecyclerview.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/SingleSideFadeRecyclerview.kt @@ -6,8 +6,9 @@ import androidx.core.content.res.ResourcesCompat import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import live.hms.prebuilt_themes.dp import live.hms.roomkit.R -import live.hms.roomkit.util.dp + class SingleSideFadeRecyclerview @JvmOverloads constructor( context: Context, diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/combined/ChatRbacRecipientHandling.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/combined/ChatRbacRecipientHandling.kt index b9ed74025..7abc07f12 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/combined/ChatRbacRecipientHandling.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/combined/ChatRbacRecipientHandling.kt @@ -5,8 +5,8 @@ import com.google.android.material.textview.MaterialTextView import live.hms.roomkit.R import live.hms.roomkit.drawableStart import live.hms.roomkit.ui.meeting.chat.Recipient -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.HMSPrebuiltTheme +import live.hms.prebuilt_themes.getColorOrDefault class ChatRbacRecipientHandling { fun updateChipRecipientUI( diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/combined/PinnedMessageUiUseCase.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/combined/PinnedMessageUiUseCase.kt index eda51edfd..62479d6ec 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/combined/PinnedMessageUiUseCase.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/combined/PinnedMessageUiUseCase.kt @@ -18,10 +18,10 @@ import live.hms.roomkit.R import live.hms.roomkit.setOnSingleClickListener import live.hms.roomkit.ui.meeting.SessionMetadataUseCase import live.hms.roomkit.ui.meeting.participants.PinnedMessageItem -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.HMSPrebuiltTheme +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.roomkit.ui.theme.getShape -import live.hms.roomkit.util.dp +import live.hms.prebuilt_themes.dp class PinnedMessageUiUseCase { private val pinnedMessagesAdapter = GroupieAdapter() diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/rbac/RecipientHeader.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/rbac/RecipientHeader.kt index c71f25463..bb1a99dce 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/rbac/RecipientHeader.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/rbac/RecipientHeader.kt @@ -9,9 +9,9 @@ import live.hms.roomkit.R import live.hms.roomkit.databinding.LayoutRoleBasedChatMessageBottomSheetItemHeaderBinding import live.hms.roomkit.setOnSingleClickListener import live.hms.roomkit.ui.meeting.chat.Recipient -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme +import live.hms.prebuilt_themes.HMSPrebuiltTheme import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.getColorOrDefault const val RECIPIENT_PEERS = "PARTICIPANTS" const val RECIPIENT_ROLES = "ROLES" class RecipientHeader(private val recipientHeaderName: String) : diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/rbac/RecipientItem.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/rbac/RecipientItem.kt index 2c3bb3247..9cbe41900 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/rbac/RecipientItem.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/rbac/RecipientItem.kt @@ -7,9 +7,9 @@ import live.hms.roomkit.R import live.hms.roomkit.databinding.LayoutRoleBasedChatMessageBottomSheetItemRecipientBinding import live.hms.roomkit.setOnSingleClickListener import live.hms.roomkit.ui.meeting.chat.Recipient -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme +import live.hms.prebuilt_themes.HMSPrebuiltTheme import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.getColorOrDefault class RecipientItem(private val recipient: Recipient, private val currentSelectedRecipient: Recipient?, diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/rbac/RoleBasedChatBottomSheet.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/rbac/RoleBasedChatBottomSheet.kt index fa7c14ad1..542a8cc21 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/rbac/RoleBasedChatBottomSheet.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/chat/rbac/RoleBasedChatBottomSheet.kt @@ -25,9 +25,9 @@ import live.hms.roomkit.ui.meeting.chat.ChatViewModel import live.hms.roomkit.ui.meeting.chat.Recipient import live.hms.roomkit.ui.meeting.participants.ChatRecipientSearchUseCase import live.hms.roomkit.ui.meeting.participants.MessageHeaderItemDecoration -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme +import live.hms.prebuilt_themes.HMSPrebuiltTheme import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.roomkit.util.viewLifecycle import live.hms.video.sdk.HMSSDK import live.hms.video.signal.init.HMSRoomLayout diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/commons/VideoGridBaseFragment.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/commons/VideoGridBaseFragment.kt index f92bb309f..b78fdff9d 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/commons/VideoGridBaseFragment.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/commons/VideoGridBaseFragment.kt @@ -24,10 +24,10 @@ import live.hms.roomkit.ui.meeting.MeetingTrack import live.hms.roomkit.ui.meeting.MeetingViewModel import live.hms.roomkit.ui.meeting.pinnedvideo.StatsInterpreter import live.hms.roomkit.ui.settings.SettingsStore -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme +import live.hms.prebuilt_themes.HMSPrebuiltTheme import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.getColorOrDefault -import live.hms.roomkit.ui.theme.setBackgroundAndColor +import live.hms.prebuilt_themes.getColorOrDefault +import live.hms.prebuilt_themes.setBackgroundAndColor import live.hms.roomkit.util.* import live.hms.video.media.tracks.HMSLocalVideoTrack import live.hms.video.media.tracks.HMSRemoteVideoTrack diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/MessageHeaderItemDecoration.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/MessageHeaderItemDecoration.kt index ae01b6360..3c64942c3 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/MessageHeaderItemDecoration.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/MessageHeaderItemDecoration.kt @@ -7,7 +7,7 @@ import android.view.View import androidx.annotation.ColorInt import androidx.annotation.LayoutRes import androidx.recyclerview.widget.RecyclerView -import live.hms.roomkit.util.dp +import live.hms.prebuilt_themes.dp class MessageHeaderItemDecoration( @ColorInt background: Int, diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/ParticipantHeaderItem.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/ParticipantHeaderItem.kt index c219156c3..c99251ab6 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/ParticipantHeaderItem.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/ParticipantHeaderItem.kt @@ -8,9 +8,9 @@ import com.xwray.groupie.viewbinding.BindableItem import live.hms.roomkit.R import live.hms.roomkit.databinding.ParticipantHeaderItemBinding import live.hms.roomkit.drawableEnd -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme +import live.hms.prebuilt_themes.HMSPrebuiltTheme import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.getColorOrDefault class ParticipantHeaderItem(private val roleName: String, private val numPeers: Int? = 0, val expanded : (String, Boolean) -> Unit) : BindableItem(roleName.hashCode().toLong()), ExpandableItem { diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/ParticipantItem.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/ParticipantItem.kt index 79e48eb66..8cc996de5 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/ParticipantItem.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/ParticipantItem.kt @@ -18,9 +18,9 @@ import live.hms.roomkit.setOnSingleClickListener import live.hms.roomkit.show import live.hms.roomkit.ui.meeting.MeetingTrack import live.hms.roomkit.ui.meeting.PrebuiltInfoContainer -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme +import live.hms.prebuilt_themes.HMSPrebuiltTheme import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.video.connection.stats.quality.HMSNetworkQuality import live.hms.video.error.HMSException import live.hms.video.media.tracks.HMSAudioTrack diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/ParticipantPreviousRoleChangeUseCase.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/ParticipantPreviousRoleChangeUseCase.kt index e472ff89f..103c18a3e 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/ParticipantPreviousRoleChangeUseCase.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/ParticipantPreviousRoleChangeUseCase.kt @@ -17,10 +17,8 @@ class ParticipantPreviousRoleChangeUseCase(private val changeMetadata: (String, // Set the role or create a new metadata object with it. val updatedMetadata = existingMetadata?.copy(prevRole = roleName, name = peer.name, - isHandRaised = false, isBRBOn = false) ?: CustomPeerMetadata( - isHandRaised = false, isBRBOn = false, name = peer.name, prevRole = roleName diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/ParticipantsFragment.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/ParticipantsFragment.kt index edced085e..37a877904 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/ParticipantsFragment.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/ParticipantsFragment.kt @@ -19,7 +19,7 @@ import live.hms.roomkit.ui.meeting.MeetingViewModel import live.hms.roomkit.ui.meeting.SwitchRoleBottomSheet import live.hms.roomkit.ui.theme.applyTheme import live.hms.roomkit.util.viewLifecycle -import live.hms.video.sdk.models.HMSPeer + const val DIRECTLY_OPENED: String= "PARTICIPANTS_DIRECTLY_OPENED" class ParticipantsFragment : Fragment() { @@ -36,9 +36,7 @@ class ParticipantsFragment : Fragment() { ) { binding.participantsBack.visibility = View.VISIBLE } } - private val paginatedPeerList = arrayListOf() private var isLargeRoom = false - private var iteratorsInitated = false override fun onDetach() { super.onDetach() @@ -93,15 +91,7 @@ class ParticipantsFragment : Fragment() { @SuppressLint("SetTextI18n") private fun initViewModels() { binding.recyclerView.adapter = participantsUseCase.adapter - // Initial updating of views - // Using HMSCoroutine scope here since we want the next call to get queued -// initPaginatedPeerlist() -// meetingViewModel.participantPeerUpdate.observe(viewLifecycleOwner) { -// lifecycleScope.launch { -// periodicallyUpdatePeerListForLargeRoom() // WARING: This clears the peerlist -// participantsUseCase.updateParticipantsAdapter(getPeerList(), true) -// } -// } + meetingViewModel.peerCount.observe(viewLifecycleOwner,::updateParticipantCount) meetingViewModel.state.observe(viewLifecycleOwner) { state -> @@ -114,10 +104,10 @@ class ParticipantsFragment : Fragment() { val builder = AlertDialog.Builder(requireContext()) .setMessage(message) - .setTitle(live.hms.roomkit.R.string.non_fatal_error_dialog_title) + .setTitle(R.string.non_fatal_error_dialog_title) .setCancelable(true) - builder.setPositiveButton(live.hms.roomkit.R.string.ok) { dialog, _ -> + builder.setPositiveButton(R.string.ok) { dialog, _ -> dialog.dismiss() alertDialog = null meetingViewModel.setStatetoOngoing() // hack, so that the liveData represents the correct state. Use SingleLiveEvent instead diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/ParticipantsUseCase.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/ParticipantsUseCase.kt index 099115cca..f6338722b 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/ParticipantsUseCase.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/participants/ParticipantsUseCase.kt @@ -19,8 +19,8 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.supervisorScope import live.hms.roomkit.R import live.hms.roomkit.ui.meeting.MeetingViewModel -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.HMSPrebuiltTheme +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.video.error.HMSException import live.hms.video.sdk.listeners.PeerListResultListener import live.hms.video.sdk.models.HMSLocalPeer @@ -115,7 +115,12 @@ class ParticipantsUseCase(val meetingViewModel: MeetingViewModel, addTextChangedListener { text -> scope.launch { filterText = text.toString() - updateParticipantsAdapter(getAllPeers()) + if(isLargeRoom) { + val peers = meetingViewModel.searchPeerNameInLargeRoom(text.toString(), 0) + updateParticipantsAdapter(peers) + } else { + updateParticipantsAdapter(getAllPeers()) + } } } } diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/pinnedvideo/PinnedVideoFragment.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/pinnedvideo/PinnedVideoFragment.kt index 163e7583f..cdff2ac5f 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/pinnedvideo/PinnedVideoFragment.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/pinnedvideo/PinnedVideoFragment.kt @@ -220,10 +220,7 @@ class PinnedVideoFragment : Fragment() { } private fun changePinnedRaiseHandState() { - val customData = CustomPeerMetadata.fromJson(pinnedTrack?.peer?.metadata) - if (customData != null) { - binding.pinVideo.raisedHand.alpha = visibilityOpacity(customData.isHandRaised) - } + binding.pinVideo.raisedHand.alpha = visibilityOpacity(pinnedTrack?.peer?.isHandRaised == true) } private fun changePinnedName() { diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/pinnedvideo/VideoListAdapter.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/pinnedvideo/VideoListAdapter.kt index d03f4d508..2305784ff 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/pinnedvideo/VideoListAdapter.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/pinnedvideo/VideoListAdapter.kt @@ -14,8 +14,8 @@ import live.hms.roomkit.databinding.ListItemVideoBinding import live.hms.roomkit.helpers.NetworkQualityHelper import live.hms.roomkit.ui.meeting.CustomPeerMetadata import live.hms.roomkit.ui.meeting.MeetingTrack -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.HMSPrebuiltTheme +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.roomkit.util.NameUtils import live.hms.roomkit.util.visibility import live.hms.video.sdk.models.HMSPeer @@ -188,7 +188,7 @@ class VideoListAdapter( when (payload) { is PeerUpdatePayloads.MetadataChanged -> { holder.binding.raisedHand.visibility = - visibility(payload.metadata?.isHandRaised == true) + visibility(payload.isHandRaised) } is PeerUpdatePayloads.NameChanged -> { holder.binding.nameInitials.text = NameUtils.getInitials(payload.name) @@ -230,7 +230,8 @@ class VideoListAdapter( HMSPeerUpdate.METADATA_CHANGED -> PeerUpdatePayloads.MetadataChanged( CustomPeerMetadata.fromJson( changedPeer.first.metadata - ) + ), + changedPeer.first.isHandRaised ) HMSPeerUpdate.NETWORK_QUALITY_UPDATED -> { // Don't send network quality updates for SIP peers. @@ -254,7 +255,7 @@ class VideoListAdapter( sealed class PeerUpdatePayloads { data class NameChanged(val name: String) : PeerUpdatePayloads() data class NetworkQualityChanged(val downlinkSpeed: Int?) : PeerUpdatePayloads() - data class MetadataChanged(val metadata: CustomPeerMetadata?) : PeerUpdatePayloads() + data class MetadataChanged(val metadata: CustomPeerMetadata?,val isHandRaised : Boolean) : PeerUpdatePayloads() data class SpeakerMuteUnmute(val isMute: Boolean) : PeerUpdatePayloads() } diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/LocalTileBottomSheet.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/LocalTileBottomSheet.kt index d7a61c60e..e79a32b79 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/LocalTileBottomSheet.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/LocalTileBottomSheet.kt @@ -17,9 +17,9 @@ import live.hms.roomkit.drawableStart import live.hms.roomkit.setOnSingleClickListener import live.hms.roomkit.ui.meeting.MeetingViewModel import live.hms.roomkit.ui.meeting.MeetingViewModelFactory -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme +import live.hms.prebuilt_themes.HMSPrebuiltTheme import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.roomkit.util.viewLifecycle class LocalTileBottomSheet(val onMinimizeClicked: () -> Unit, val onNameChange: () -> Unit) : BottomSheetDialogFragment() { diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/ScreenShareFragement.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/ScreenShareFragement.kt index b2ce36dd5..67bfdf46b 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/ScreenShareFragement.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/ScreenShareFragement.kt @@ -17,8 +17,8 @@ import live.hms.roomkit.databinding.BottomSheetScreenShareBinding import live.hms.roomkit.ui.meeting.MeetingViewModel import live.hms.roomkit.ui.meeting.MeetingViewModelFactory import live.hms.roomkit.ui.meeting.participants.LoadAfterJoin -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.HMSPrebuiltTheme +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.roomkit.util.contextSafe import live.hms.roomkit.util.viewLifecycle import live.hms.videoview.VideoViewStateChangeListener diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/VideoGridFragment.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/VideoGridFragment.kt index ae8550275..96a96a60a 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/VideoGridFragment.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/VideoGridFragment.kt @@ -33,7 +33,7 @@ import live.hms.roomkit.ui.meeting.MeetingTrack import live.hms.roomkit.ui.meeting.MeetingViewModel import live.hms.roomkit.ui.settings.SettingsStore import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.setIconDisabled +import live.hms.prebuilt_themes.setIconDisabled import live.hms.roomkit.util.NameUtils import live.hms.roomkit.util.applyConstraint import live.hms.roomkit.util.contextSafe diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/VideoGridPageFragment.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/VideoGridPageFragment.kt index c2447ae30..d28c7df73 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/VideoGridPageFragment.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/VideoGridPageFragment.kt @@ -9,8 +9,8 @@ import androidx.core.os.bundleOf import live.hms.roomkit.databinding.FragmentVideoGridPageBinding import live.hms.roomkit.ui.meeting.MeetingTrack import live.hms.roomkit.ui.meeting.commons.VideoGridBaseFragment -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme -import live.hms.roomkit.ui.theme.setBackgroundAndColor +import live.hms.prebuilt_themes.HMSPrebuiltTheme +import live.hms.prebuilt_themes.setBackgroundAndColor import live.hms.roomkit.util.viewLifecycle import kotlin.math.min diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/notification/HMSNotificationAdapter.kt b/room-kit/src/main/java/live/hms/roomkit/ui/notification/HMSNotificationAdapter.kt index 6a6ee0fa7..6733ff9fb 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/notification/HMSNotificationAdapter.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/notification/HMSNotificationAdapter.kt @@ -6,10 +6,10 @@ import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import live.hms.roomkit.R import live.hms.roomkit.databinding.NotificationCardBinding -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme +import live.hms.prebuilt_themes.HMSPrebuiltTheme import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.getColorOrDefault -import live.hms.roomkit.ui.theme.setBackgroundAndColor +import live.hms.prebuilt_themes.getColorOrDefault +import live.hms.prebuilt_themes.setBackgroundAndColor class HMSNotificationAdapter( private var notifications: List = emptyList(), diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/polls/PollQuestionViewHolder.kt b/room-kit/src/main/java/live/hms/roomkit/ui/polls/PollQuestionViewHolder.kt index f5af7ad67..b88609755 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/polls/PollQuestionViewHolder.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/polls/PollQuestionViewHolder.kt @@ -22,8 +22,8 @@ import live.hms.roomkit.databinding.LayoutPollQuestionCreationItemBinding import live.hms.roomkit.databinding.LayoutPollQuizOptionsItemMultiChoiceBinding import live.hms.roomkit.setOnSingleClickListener import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.buttonDisabled -import live.hms.roomkit.ui.theme.buttonEnabled +import live.hms.prebuilt_themes.buttonDisabled +import live.hms.prebuilt_themes.buttonEnabled import live.hms.roomkit.ui.theme.saveButtonDisabled import live.hms.roomkit.ui.theme.saveButtonEnabled diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/polls/display/PollDisplayQuestionHolder.kt b/room-kit/src/main/java/live/hms/roomkit/ui/polls/display/PollDisplayQuestionHolder.kt index 096eb960d..1aabbd741 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/polls/display/PollDisplayQuestionHolder.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/polls/display/PollDisplayQuestionHolder.kt @@ -12,10 +12,10 @@ import live.hms.roomkit.databinding.LayoutPollsDisplayChoicesQuesionBinding import live.hms.roomkit.databinding.LayoutQuizDisplayShortAnswerBinding import live.hms.roomkit.drawableStart import live.hms.roomkit.ui.polls.display.voting.VotingProgressAdapter -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme -import live.hms.roomkit.ui.theme.alertButtonEnabled -import live.hms.roomkit.ui.theme.buttonEnabled -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.HMSPrebuiltTheme +import live.hms.prebuilt_themes.alertButtonEnabled +import live.hms.prebuilt_themes.buttonEnabled +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.roomkit.ui.theme.highlightCorrectAnswer import live.hms.roomkit.ui.theme.voteButtons import live.hms.roomkit.util.setOnSingleClickListener diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/polls/display/voting/ProgressDisplayViewHolder.kt b/room-kit/src/main/java/live/hms/roomkit/ui/polls/display/voting/ProgressDisplayViewHolder.kt index 47433cd8d..a7c65b526 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/polls/display/voting/ProgressDisplayViewHolder.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/polls/display/voting/ProgressDisplayViewHolder.kt @@ -9,9 +9,9 @@ import live.hms.roomkit.R import live.hms.roomkit.databinding.LayoutPollsDisplayResultProgressBarsItemBinding import live.hms.roomkit.databinding.LayoutPollsDisplayResultQuizAnswerItemsBinding import live.hms.roomkit.drawableStart -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme +import live.hms.prebuilt_themes.HMSPrebuiltTheme import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.video.polls.models.HmsPollCategory import live.hms.video.polls.models.HmsPollState import live.hms.video.polls.models.question.HMSPollQuestionType diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/polls/leaderboard/LeaderBoardBottomSheetFragment.kt b/room-kit/src/main/java/live/hms/roomkit/ui/polls/leaderboard/LeaderBoardBottomSheetFragment.kt index 056453d4c..322b76759 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/polls/leaderboard/LeaderBoardBottomSheetFragment.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/polls/leaderboard/LeaderBoardBottomSheetFragment.kt @@ -15,19 +15,19 @@ import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialogFragment import com.xwray.groupie.GroupieAdapter import kotlinx.coroutines.launch +import live.hms.prebuilt_themes.ApplyRadiusatVertex import live.hms.roomkit.R import live.hms.roomkit.databinding.LayoutQuizLeaderboardBinding import live.hms.roomkit.ui.meeting.InsetItemDecoration import live.hms.roomkit.ui.meeting.MeetingViewModel import live.hms.roomkit.ui.polls.display.POLL_TO_DISPLAY import live.hms.roomkit.ui.polls.display.PollDisplayFragment -import live.hms.roomkit.ui.polls.leaderboard.item.ApplyRadiusatVertex import live.hms.roomkit.ui.polls.leaderboard.item.LeaderBoardHeader import live.hms.roomkit.ui.polls.leaderboard.item.LeaderBoardNameSection import live.hms.roomkit.ui.polls.leaderboard.item.LeaderBoardSubGrid -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme +import live.hms.prebuilt_themes.HMSPrebuiltTheme import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.roomkit.util.contextSafe import live.hms.roomkit.util.viewLifecycle import live.hms.video.error.HMSException diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/polls/leaderboard/item/LeaderBoardNameSection.kt b/room-kit/src/main/java/live/hms/roomkit/ui/polls/leaderboard/item/LeaderBoardNameSection.kt index 215c6d90d..9dafe904c 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/polls/leaderboard/item/LeaderBoardNameSection.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/polls/leaderboard/item/LeaderBoardNameSection.kt @@ -2,20 +2,15 @@ package live.hms.roomkit.ui.polls.leaderboard.item import android.view.View import com.xwray.groupie.viewbinding.BindableItem +import live.hms.prebuilt_themes.ApplyRadiusatVertex import live.hms.roomkit.R import live.hms.roomkit.databinding.ItemNameSectionBinding -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme +import live.hms.prebuilt_themes.HMSPrebuiltTheme import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.roomkit.ui.theme.getShape -import live.hms.roomkit.ui.theme.setBackgroundAndColor - -enum class ApplyRadiusatVertex { - TOP, - ALL_CORNERS, - BOTTOM, - NONE -} +import live.hms.prebuilt_themes.setBackgroundAndColor + class LeaderBoardNameSection( private val titleStr: String, private val subtitleStr: String, diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/polls/leaderboard/item/LeaderBoardSubGrid.kt b/room-kit/src/main/java/live/hms/roomkit/ui/polls/leaderboard/item/LeaderBoardSubGrid.kt index 1bcfacd63..4ab0530a2 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/polls/leaderboard/item/LeaderBoardSubGrid.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/polls/leaderboard/item/LeaderBoardSubGrid.kt @@ -6,9 +6,9 @@ import com.xwray.groupie.viewbinding.BindableItem import live.hms.roomkit.R import live.hms.roomkit.databinding.ItemGridOptionBinding import live.hms.roomkit.databinding.ItemGridSubTextBinding -import live.hms.roomkit.ui.theme.HMSPrebuiltTheme +import live.hms.prebuilt_themes.HMSPrebuiltTheme import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.getColorOrDefault +import live.hms.prebuilt_themes.getColorOrDefault import live.hms.roomkit.ui.theme.getShape class LeaderBoardSubGrid( diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/role/RolePreviewFragment.kt b/room-kit/src/main/java/live/hms/roomkit/ui/role/RolePreviewFragment.kt index 6307ad602..15e001763 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/role/RolePreviewFragment.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/role/RolePreviewFragment.kt @@ -14,8 +14,8 @@ import live.hms.roomkit.databinding.FragmentRolePreviewBinding import live.hms.roomkit.ui.meeting.MeetingViewModel import live.hms.roomkit.ui.meeting.MeetingViewModelFactory import live.hms.roomkit.ui.theme.applyTheme -import live.hms.roomkit.ui.theme.setIconDisabled -import live.hms.roomkit.ui.theme.setIconEnabled +import live.hms.prebuilt_themes.setIconDisabled +import live.hms.prebuilt_themes.setIconEnabled import live.hms.roomkit.util.NameUtils import live.hms.roomkit.util.contextSafe diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/theme/ThemeExt.kt b/room-kit/src/main/java/live/hms/roomkit/ui/theme/ThemeExt.kt index cb04e5199..1b7baf869 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/theme/ThemeExt.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/theme/ThemeExt.kt @@ -31,6 +31,10 @@ import com.google.android.material.switchmaterial.SwitchMaterial import com.google.android.material.textfield.TextInputEditText import com.google.android.material.textfield.TextInputLayout import com.google.android.material.textview.MaterialTextView +import live.hms.prebuilt_themes.ApplyRadiusatVertex +import live.hms.prebuilt_themes.DefaultDarkThemeColours +import live.hms.prebuilt_themes.HMSPrebuiltTheme +import live.hms.prebuilt_themes.addAlpha import live.hms.roomkit.R import live.hms.roomkit.databinding.* import live.hms.roomkit.drawableEnd @@ -38,311 +42,24 @@ import live.hms.roomkit.drawableLeft import live.hms.roomkit.drawableStart import live.hms.roomkit.setGradient import live.hms.roomkit.ui.meeting.participants.EnabledMenuOptions -import live.hms.roomkit.ui.polls.leaderboard.item.ApplyRadiusatVertex -import live.hms.roomkit.util.EmailUtils -import live.hms.roomkit.util.EmailUtils.addAlpha -import live.hms.roomkit.util.dp +import live.hms.prebuilt_themes.* import live.hms.video.polls.models.HmsPollState -import live.hms.video.signal.init.HMSRoomLayout -import live.hms.video.utils.GsonUtils.gson //get theme detail from theme utils parse it accordingly -object HMSPrebuiltTheme { - var theme: HMSRoomLayout.HMSRoomLayoutData.HMSRoomTheme.HMSColorPalette? = null - fun getColours() = theme - internal fun setTheme(theme: HMSRoomLayout.HMSRoomLayoutData.HMSRoomTheme.HMSColorPalette) { - this.theme = theme - } - - fun getDefaults() = DefaultDarkThemeColours() - - //temp - fun getDefaultHmsColorPalette(): HMSRoomLayout.HMSRoomLayoutData.HMSRoomTheme.HMSColorPalette { - val jsonStr = - "{\"alert_error_bright\":\"#FFB2B6\",\"alert_error_brighter\":\"#FFEDEC\",\"alert_error_default\":\"#C74E5B\",\"alert_error_dim\":\"#270005\",\"alert_success\":\"#36B37E\",\"alert_warning\":\"#FFAB00\",\"background_default\":\"#0B0E15\",\"background_dim\":\"#000000\",\"border_bright\":\"#272A31\",\"border_default\":\"#1D1F27\",\"on_primary_high\":\"#ffffff\",\"on_primary_low\":\"#7faaff\",\"on_primary_medium\":\"#cbdaff\",\"on_secondary_high\":\"#FFFFFF\",\"on_secondary_low\":\"#A4ABC0\",\"on_secondary_medium\":\"#D3D9F0\",\"on_surface_high\":\"#EFF0FA\",\"on_surface_low\":\"#8F9099\",\"on_surface_medium\":\"#C5C6D0\",\"primary_bright\":\"#3da6ff\",\"primary_default\":\"#2F80FF\",\"primary_dim\":\"#2059b2\",\"primary_disabled\":\"#338cff\",\"secondary_bright\":\"#70778B\",\"secondary_default\":\"#444954\",\"secondary_dim\":\"#293042\",\"secondary_disabled\":\"#404759\",\"surface_bright\":\"#272A31\",\"surface_brighter\":\"#2E3038\",\"surface_default\":\"#191B23\",\"surface_dim\":\"#11131A\"}" - - return gson.fromJson( - jsonStr, HMSRoomLayout.HMSRoomLayoutData.HMSRoomTheme.HMSColorPalette::class.java - ) - } -} - -internal fun HMSRoomLayout.getPreviewLayout(roleName : String?) : HMSRoomLayout.HMSRoomLayoutData.Screens.Preview? { - return if (roleName.isNullOrEmpty()) - this.data?.getOrNull(0)?.screens?.preview - else - this.data?.find { it?.role == roleName }?.screens?.preview -} - -internal fun HMSRoomLayout.getCurrentRoleData(roleName : String?) : HMSRoomLayout.HMSRoomLayoutData? { - return if (roleName.isNullOrEmpty()) - this.data?.getOrNull(0) - else - this.data?.find { it?.role == roleName } -} - - -internal fun CardView.setBackgroundColor( - backgroundColorStr: String?, - defaultBackgroundColor: String, -) { - this.setCardBackgroundColor(getColorOrDefault(backgroundColorStr, defaultBackgroundColor)) -} - -internal fun View.setBackgroundAndColor( - backgroundColorStr: String?, - defaultBackgroundColor: String, -) { - setBackgroundColor(getColorOrDefault(backgroundColorStr, defaultBackgroundColor)) -} - - -//AppCompatImageView tint -internal fun androidx.appcompat.widget.AppCompatImageView.setIconTintColor( - iconTintColorStr: String?, - defaultIconTintColor: String, -) { - this.imageTintList = - ColorStateList.valueOf(getColorOrDefault(iconTintColorStr, defaultIconTintColor)) -} - -internal fun View.setBackgroundAndColor( - backgroundColorStr: String?, - defaultBackgroundColor: String, - @DrawableRes backGroundDrawableRes: Int? -) { - this.backgroundTintList = - ColorStateList.valueOf(getColorOrDefault(backgroundColorStr, defaultBackgroundColor)) - val normalDrawable: Drawable = if(backGroundDrawableRes != null) - ResourcesCompat.getDrawable(this.context.resources, backGroundDrawableRes, null)!! - else - getShape() - val wrapDrawable: Drawable = DrawableCompat.wrap(normalDrawable) - DrawableCompat.setTint( - wrapDrawable, getColorOrDefault(backgroundColorStr, defaultBackgroundColor) - ) - background = wrapDrawable -} - -fun getColorOrDefault(colorStr: String?, defaultColor: String): Int { - return try { - colorStr!!.toColorInt() - } catch (e: Exception) { - try { - defaultColor.toColorInt() - } catch (e: Exception) { - android.graphics.Color.parseColor("#FFFFFF") - } - } -} - -fun View.backgroundGradientDrawable(@ColorInt startColor: Int, @ColorInt endColor: Int): Unit { - val h = this.height.toFloat() - val shapeDrawable = ShapeDrawable(RectShape()) - shapeDrawable.paint.shader = - LinearGradient(0f, 0f, 0f, h, startColor, endColor, Shader.TileMode.REPEAT) - this.background = shapeDrawable -} - - -internal fun ShapeableImageView.setIconEnabled( - @DrawableRes enabledIconDrawableRes: Int -) { - val radius = resources.getDimension(R.dimen.eight_dp).toInt() - - this.setBackgroundColor(resources.getColor(android.R.color.transparent)) - - shapeAppearanceModel = - shapeAppearanceModel.toBuilder().setAllCorners(CornerFamily.ROUNDED, radius.toFloat()) - .build() - - this.strokeColor = ColorStateList.valueOf( - getColorOrDefault( - HMSPrebuiltTheme.getColours()?.borderBright, - HMSPrebuiltTheme.getDefaults().border_bright - ) - ) - - this.strokeWidth = resources.getDimension(R.dimen.one_dp) - - this.setImageResource(enabledIconDrawableRes) - - drawable.setTint( - getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp - ) - ) - - (drawable as? Animatable)?.start() -} - - -internal fun ImageView.setIconDisabled( - @DrawableRes disabledIconDrawableRes: Int, - @DrawableRes backgroundRes: Int = R.drawable.gray_round_solid_drawable -) { - - this.setImageResource(disabledIconDrawableRes) - this.setBackgroundResource(backgroundRes) - background.setTint( - getColorOrDefault( - HMSPrebuiltTheme.getColours()?.secondaryDim, - HMSPrebuiltTheme.getDefaults().secondary_dim - ) - ) - - drawable.setTint( - getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp - ) - ) - - (drawable as? Animatable)?.start() - -} - -internal fun ShapeableImageView.setIconDisabled( - @DrawableRes disabledIconDrawableRes: Int, - @DimenRes radiusREs: Int = R.dimen.eight_dp, -) { - - val radius = resources.getDimension(radiusREs).toInt() - - this.strokeWidth = 0f - - shapeAppearanceModel = - shapeAppearanceModel.toBuilder().setAllCornerSizes(radius.toFloat()).build() - - this.setBackgroundColor( - getColorOrDefault( - HMSPrebuiltTheme.getColours()?.secondaryDim, - HMSPrebuiltTheme.getDefaults().secondary_dim - ) - ) - this.setImageResource(disabledIconDrawableRes) - - - drawable.setTint( - getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onPrimaryHigh, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp - ) - ) - - (drawable as? Animatable)?.start() - -} - -internal fun TextView.alertButtonEnabled() { - this.isEnabled = true - - this.setTextColor( - getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onPrimaryHigh, - HMSPrebuiltTheme.getDefaults().onprimary_high_emp - ) - ) - - this.setBackgroundAndColor( - HMSPrebuiltTheme.getColours()?.alertErrorDefault, - HMSPrebuiltTheme.getDefaults().error_default, - null - ) - - this.drawableStart?.setTint( - getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onPrimaryHigh, - HMSPrebuiltTheme.getDefaults().onprimary_high_emp - ) - ) -} - -internal fun TextView.buttonStrokeEnabled() { - this.isEnabled = true - this.setBackgroundAndColor( - HMSPrebuiltTheme.getColours()?.alertErrorDefault, - HMSPrebuiltTheme.getDefaults().error_default, - R.drawable.gray_round_stroked_drawable - ) - - this.setTextColor( - getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onPrimaryHigh, - HMSPrebuiltTheme.getDefaults().onprimary_high_emp - ) - ) - -} -internal fun TextView.buttonEnabled() { - this.isEnabled = true - - this.setTextColor( - getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onPrimaryHigh, - HMSPrebuiltTheme.getDefaults().onprimary_high_emp - ) - ) - - this.setBackgroundAndColor( - HMSPrebuiltTheme.getColours()?.primaryDefault, - HMSPrebuiltTheme.getDefaults().primary_default, - null - ) - - this.drawableStart?.setTint( - getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onPrimaryHigh, - HMSPrebuiltTheme.getDefaults().onprimary_high_emp - ) - ) -} - -private fun getBackgroundForColor(color : Int) = getShape().apply { setTint(color) } - -internal fun TextView.buttonDisabled() { - this.isEnabled = false - - - this.setTextColor( - getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onPrimaryLow, - HMSPrebuiltTheme.getDefaults().onprimary_low_emp - ) - ) - - this.setBackgroundAndColor( - HMSPrebuiltTheme.getColours()?.primaryDisabled, - HMSPrebuiltTheme.getDefaults().primary_disabled, - null - ) - - this.drawableStart?.setTint( - getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onPrimaryLow, - HMSPrebuiltTheme.getDefaults().onprimary_low_emp - ) - ) - -} - - -//hex color to int color -private fun String.toColorInt(): Int = android.graphics.Color.parseColor(this) - internal fun FragmentMeetingBinding.applyTheme() { pinMessageTheme(pinCloseButton) userBlockedTheme(userBlocked) - chatPausedTheme(chatPausedContainer, chatPausedTitle,chatPausedBy) + chatPausedTheme(chatPausedContainer, chatPausedTitle, chatPausedBy) configureChatControlsTheme(sendToBackground, sendToChipText, chatOptionsCard, chatOptions) chatUnreadMessagesTheming(unreadMessageCount) chatView.background = getChatBackgroundDrawable() - iconSend.drawable.setTint(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceLow, - HMSPrebuiltTheme.getDefaults().onsurface_low_emp - )) + iconSend.drawable.setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceLow, + HMSPrebuiltTheme.getDefaults().onsurface_low_emp + ) + ) editTextMessage.background = getChatBackgroundDrawable() buttonEndCall.setBackgroundAndColor( HMSPrebuiltTheme.getColours()?.alertErrorDefault, @@ -402,10 +119,12 @@ internal fun FragmentMeetingBinding.applyTheme() { HMSPrebuiltTheme.getDefaults().surface_default ) - progressBar.containerCardProgressBar.setBackgroundColor(getColorOrDefault( - "#40000000", - HMSPrebuiltTheme.getDefaults().surface_default - )) + progressBar.containerCardProgressBar.setBackgroundColor( + getColorOrDefault( + "#40000000", + HMSPrebuiltTheme.getDefaults().surface_default + ) + ) progressBar.containerCardProgressBarCard.setBackgroundAndColor( HMSPrebuiltTheme.getColours()?.surfaceDefault, @@ -508,8 +227,6 @@ internal fun FragmentMeetingBinding.applyTheme() { // ) - - //init should be called once buttonRaiseHand?.setIconEnabled(R.drawable.ic_raise_hand) @@ -561,24 +278,29 @@ fun pinMessageTheme(pinCloseButton: ImageView) { pinCloseButton?.drawable?.setTint( getColorOrDefault( HMSPrebuiltTheme.getColours()?.onSurfaceMedium, - HMSPrebuiltTheme.getDefaults().onsurface_med_emp) + HMSPrebuiltTheme.getDefaults().onsurface_med_emp ) + ) } -private fun chatPausedTheme(chatPausedContainer : LinearLayoutCompat, - chatPausedTitle: TextView, chatPausedBy : TextView) { +private fun chatPausedTheme( + chatPausedContainer: LinearLayoutCompat, + chatPausedTitle: TextView, chatPausedBy: TextView +) { chatPausedContainer.background = getChatBackgroundDrawable() chatPausedTitle.setTextColor( getColorOrDefault( HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp) + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) ) chatPausedBy.setTextColor( getColorOrDefault( HMSPrebuiltTheme.getColours()?.onSurfaceMedium, - HMSPrebuiltTheme.getDefaults().onsurface_med_emp) + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) ) } @@ -587,7 +309,8 @@ private fun userBlockedTheme(userBlocked: TextView) { userBlocked.setTextColor( getColorOrDefault( HMSPrebuiltTheme.getColours()?.onSurfaceMedium, - HMSPrebuiltTheme.getDefaults().onsurface_med_emp) + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) ) } @@ -623,17 +346,19 @@ internal fun ChangeNameFragmentBinding.applyTheme() { ) - standardBottomSheet.background =root.context.resources.getDrawable(R.drawable.gray_shape_round_dialog) - .apply { - val color = getColorOrDefault( - HMSPrebuiltTheme.getColours()?.surfaceDim, - HMSPrebuiltTheme.getDefaults().background_default) - setColorFilter(color, PorterDuff.Mode.ADD); - } + standardBottomSheet.background = + root.context.resources.getDrawable(R.drawable.gray_shape_round_dialog) + .apply { + val color = getColorOrDefault( + HMSPrebuiltTheme.getColours()?.surfaceDim, + HMSPrebuiltTheme.getDefaults().background_default + ) + setColorFilter(color, PorterDuff.Mode.ADD); + } newName.setBackgroundAndColor( - HMSPrebuiltTheme.getColours()?.surfaceDefault, - HMSPrebuiltTheme.getDefaults().surface_default, + HMSPrebuiltTheme.getColours()?.surfaceDefault, + HMSPrebuiltTheme.getDefaults().surface_default, R.drawable.gray_round_drawable ) @@ -689,13 +414,15 @@ internal fun BottomSheetStopRecordingBinding.applyTheme() { ) - standardBottomSheet.background =root.context.resources.getDrawable(R.drawable.gray_shape_round_dialog) - .apply { - val color = getColorOrDefault( - HMSPrebuiltTheme.getColours()?.surfaceDim, - HMSPrebuiltTheme.getDefaults().background_default) - setColorFilter(color, PorterDuff.Mode.ADD); - } + standardBottomSheet.background = + root.context.resources.getDrawable(R.drawable.gray_shape_round_dialog) + .apply { + val color = getColorOrDefault( + HMSPrebuiltTheme.getColours()?.surfaceDim, + HMSPrebuiltTheme.getDefaults().background_default + ) + setColorFilter(color, PorterDuff.Mode.ADD); + } changeNameDec.setTextColor( @@ -719,11 +446,12 @@ internal fun BottomSheetStopRecordingBinding.applyTheme() { ) } + internal fun VideoCardBinding.applyTheme() { sipImageHolder.drawable.setTint( getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceMedium, - HMSPrebuiltTheme.getDefaults().onsurface_med_emp + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp ) ) @@ -939,10 +667,11 @@ internal fun FragmentRolePreviewBinding.applyTheme() { internal fun ItemDiagnosticDetailBinding.applyTheme() { - root.setBackgroundColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.surfaceDefault, - HMSPrebuiltTheme.getDefaults().background_default - ) + root.setBackgroundColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.surfaceDefault, + HMSPrebuiltTheme.getDefaults().background_default + ) ) header.setTextColor( @@ -970,10 +699,11 @@ internal fun ItemDiagnosticDetailBinding.applyTheme() { } internal fun ItemDiagnosticHeaderBinding.applyTheme() { - root.setBackgroundColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.surfaceDefault, - HMSPrebuiltTheme.getDefaults().background_default - ) + root.setBackgroundColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.surfaceDefault, + HMSPrebuiltTheme.getDefaults().background_default + ) ) header.setTextColor( @@ -1002,10 +732,11 @@ internal fun ItemDiagnosticHeaderBinding.applyTheme() { } internal fun FragmentPreCallConnectivityTestBinding.applyTheme() { - root.setBackgroundColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.backgroundDim, - HMSPrebuiltTheme.getDefaults().background_default - ) + root.setBackgroundColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.backgroundDim, + HMSPrebuiltTheme.getDefaults().background_default + ) ) cardContainer.setBackgroundColor( @@ -1021,7 +752,7 @@ internal fun FragmentPreCallConnectivityTestBinding.applyTheme() { ) ) - cardContainer.strokeColor = getColorOrDefault( + cardContainer.strokeColor = getColorOrDefault( HMSPrebuiltTheme.getColours()?.borderBright, HMSPrebuiltTheme.getDefaults().border_bright ) @@ -1077,16 +808,15 @@ internal fun FragmentPreCallConnectivityTestBinding.applyTheme() { ) - - } internal fun FragmentPreCallMicBinding.applyTheme() { - root.setBackgroundColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.backgroundDim, - HMSPrebuiltTheme.getDefaults().background_default - ) + root.setBackgroundColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.backgroundDim, + HMSPrebuiltTheme.getDefaults().background_default + ) ) cardContainer.setBackgroundColor( @@ -1102,7 +832,7 @@ internal fun FragmentPreCallMicBinding.applyTheme() { ) ) - cardContainer.strokeColor = getColorOrDefault( + cardContainer.strokeColor = getColorOrDefault( HMSPrebuiltTheme.getColours()?.borderBright, HMSPrebuiltTheme.getDefaults().border_bright ) @@ -1162,12 +892,14 @@ internal fun FragmentPreCallMicBinding.applyTheme() { } + internal fun FragmentPreCallCameraBinding.applyTheme() { - root.setBackgroundColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.backgroundDim, - HMSPrebuiltTheme.getDefaults().background_default - ) + root.setBackgroundColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.backgroundDim, + HMSPrebuiltTheme.getDefaults().background_default + ) ) cardContainer.setBackgroundColor( @@ -1183,7 +915,7 @@ internal fun FragmentPreCallCameraBinding.applyTheme() { ) ) - cardContainer.strokeColor = getColorOrDefault( + cardContainer.strokeColor = getColorOrDefault( HMSPrebuiltTheme.getColours()?.borderBright, HMSPrebuiltTheme.getDefaults().border_bright ) @@ -1226,11 +958,12 @@ internal fun FragmentPreCallCameraBinding.applyTheme() { } internal fun FragmentPreCallRegionSelectionBinding.applyTheme() { - root.setGradient(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.backgroundDim, - HMSPrebuiltTheme.getDefaults().background_default + root.setGradient( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.backgroundDim, + HMSPrebuiltTheme.getDefaults().background_default + ), Color.TRANSPARENT ) - , Color.TRANSPARENT) @@ -1258,15 +991,16 @@ internal fun FragmentPreCallRegionSelectionBinding.applyTheme() { ) - } + internal fun FragmentPreviewBinding.applyTheme() { - previewGradient.setGradient(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.backgroundDim, - HMSPrebuiltTheme.getDefaults().background_default + previewGradient.setGradient( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.backgroundDim, + HMSPrebuiltTheme.getDefaults().background_default + ), Color.TRANSPARENT ) - , Color.TRANSPARENT) buttonJoinMeeting.setTextColor( getColorOrDefault( @@ -1416,7 +1150,8 @@ internal fun FragmentPreviewBinding.applyTheme() { hlsSessionText.setTextColor( getColorOrDefault( HMSPrebuiltTheme.getColours()?.alertErrorBrighter, - HMSPrebuiltTheme.getDefaults().border_bright) + HMSPrebuiltTheme.getDefaults().border_bright + ) ) @@ -1452,6 +1187,7 @@ internal fun FragmentPreviewBinding.applyTheme() { buttonToggleVideo.setIconDisabled(R.drawable.avd_video_on_to_off) buttonToggleAudio.setIconDisabled(R.drawable.avd_mic_on_to_off) buttonSwitchCamera.setIconEnabled(R.drawable.ic_switch_camera) + previewVirtualBackground.setIconEnabled(R.drawable.preview_vb_button) iconDiagnostic.setIconDisabled(R.drawable.icon) } @@ -1511,14 +1247,19 @@ fun ExitBottomSheetBinding.applyTheme() { fun EndSessionBottomSheetBinding.applyTheme() { - root.background = ResourcesCompat.getDrawable(this.root.resources,R.drawable.gray_shape_round_dialog, null)!! - .apply { - val color = getColorOrDefault( - HMSPrebuiltTheme.getColours()?.surfaceDim, - HMSPrebuiltTheme.getDefaults().background_default) - colorFilter = - BlendModeColorFilterCompat.createBlendModeColorFilterCompat(color, BlendModeCompat.SRC) - } + root.background = + ResourcesCompat.getDrawable(this.root.resources, R.drawable.gray_shape_round_dialog, null)!! + .apply { + val color = getColorOrDefault( + HMSPrebuiltTheme.getColours()?.surfaceDim, + HMSPrebuiltTheme.getDefaults().background_default + ) + colorFilter = + BlendModeColorFilterCompat.createBlendModeColorFilterCompat( + color, + BlendModeCompat.SRC + ) + } endSessionIcon.setIconTintColor( @@ -1563,7 +1304,7 @@ fun FragmentGridVideoBinding.applyTheme() { ) tabLayoutDots.setBackgroundColor(Color.TRANSPARENT) tabLayoutDots.backgroundTintList = ColorStateList.valueOf( - Color.TRANSPARENT + Color.TRANSPARENT ) tabLayoutDotsRemoteScreenShare.setBackgroundColor(Color.TRANSPARENT) @@ -1608,7 +1349,7 @@ fun FragmentGridVideoBinding.applyTheme() { HMSPrebuiltTheme.getColours()?.surfaceDefault?.let { iconOption.setBackgroundColor( getColorOrDefault( - EmailUtils.addAlpha(it, 0.6), + addAlpha(it, 0.6), HMSPrebuiltTheme.getDefaults().surface_default ) ) @@ -1625,7 +1366,10 @@ fun FragmentGridVideoBinding.applyTheme() { minimizedIconAudioOff.setIconDisabled(R.drawable.avd_mic_on_to_off, radiusREs = R.dimen.two_dp) minimizedIconAudioOff.isEnabled = false - minimizedIconVideoOff.setIconDisabled(R.drawable.avd_video_on_to_off, radiusREs = R.dimen.two_dp) + minimizedIconVideoOff.setIconDisabled( + R.drawable.avd_video_on_to_off, + radiusREs = R.dimen.two_dp + ) minimizedIconVideoOff.isEnabled = false maximizedIcon.drawable.setTint( getColorOrDefault( @@ -1808,7 +1552,7 @@ fun NotificationCardBinding.applyTheme() { } internal fun ParticipantHeaderItemBinding.applyTheme() { - with(heading){ + with(heading) { setTextColor( getColorOrDefault( HMSPrebuiltTheme.getColours()?.onSurfaceMedium, @@ -1816,18 +1560,20 @@ internal fun ParticipantHeaderItemBinding.applyTheme() { ) ) } - headerbottom.setBackgroundColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.borderBright, - HMSPrebuiltTheme.getDefaults().border_bright - )) + headerbottom.setBackgroundColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.borderBright, + HMSPrebuiltTheme.getDefaults().border_bright + ) + ) } // ParticipantItem binding internal fun ListItemPeerListBinding.applyTheme() { audioLevelView.setBackgroundAndColor( - HMSPrebuiltTheme.getColours()?.secondaryDim, - HMSPrebuiltTheme.getDefaults().secondary_default, - R.drawable.circle_secondary_32 + HMSPrebuiltTheme.getColours()?.secondaryDim, + HMSPrebuiltTheme.getDefaults().secondary_default, + R.drawable.circle_secondary_32 ) badNetworkIndicator.setBackgroundAndColor( @@ -1852,9 +1598,11 @@ internal fun ListItemPeerListBinding.applyTheme() { ) ) - peerSettings.setColorFilter(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceMedium, - HMSPrebuiltTheme.getDefaults().onsurface_med_emp) + peerSettings.setColorFilter( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) ) sipPeer.setBackgroundAndColor( HMSPrebuiltTheme.getColours()?.secondaryDim, @@ -1864,17 +1612,21 @@ internal fun ListItemPeerListBinding.applyTheme() { } internal fun LayoutViewMoreButtonBinding.applyTheme() { - viewMoreText.drawableStart?.setTint(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSecondaryHigh, - HMSPrebuiltTheme.getDefaults().onsecondary_high_emp - )) - viewMoreText.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSecondaryHigh, - HMSPrebuiltTheme.getDefaults().onsecondary_high_emp - )) + viewMoreText.drawableStart?.setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSecondaryHigh, + HMSPrebuiltTheme.getDefaults().onsecondary_high_emp + ) + ) + viewMoreText.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSecondaryHigh, + HMSPrebuiltTheme.getDefaults().onsecondary_high_emp + ) + ) } -private fun closeButtonTheme(closeCombinedTabButton: AppCompatImageButton, res : Resources) { +private fun closeButtonTheme(closeCombinedTabButton: AppCompatImageButton, res: Resources) { closeCombinedTabButton.setBackgroundDrawable(ResourcesCompat.getDrawable( res, R.drawable.ic_cross, null @@ -1888,30 +1640,39 @@ private fun closeButtonTheme(closeCombinedTabButton: AppCompatImageButton, res : } ) } -internal fun LayoutChatParticipantCombinedBinding.applyTheme(hideParticipantTab : Boolean) { + +internal fun LayoutChatParticipantCombinedBinding.applyTheme(hideParticipantTab: Boolean) { closeButtonTheme(closeCombinedTabButton, this.root.resources) - backingLinearLayout.background = ResourcesCompat.getDrawable(this.root.resources,R.drawable.gray_shape_round_dialog, null)!! - .apply { - val color = getColorOrDefault( - HMSPrebuiltTheme.getColours()?.surfaceDim, - HMSPrebuiltTheme.getDefaults().surface_dim) - colorFilter = - BlendModeColorFilterCompat.createBlendModeColorFilterCompat(color, BlendModeCompat.SRC) - } + backingLinearLayout.background = + ResourcesCompat.getDrawable(this.root.resources, R.drawable.gray_shape_round_dialog, null)!! + .apply { + val color = getColorOrDefault( + HMSPrebuiltTheme.getColours()?.surfaceDim, + HMSPrebuiltTheme.getDefaults().surface_dim + ) + colorFilter = + BlendModeColorFilterCompat.createBlendModeColorFilterCompat( + color, + BlendModeCompat.SRC + ) + } tabLayout.tabTextColors = ColorStateList( arrayOf( - intArrayOf( android.R.attr.state_selected), - intArrayOf( -android.R.attr.state_selected) - ), intArrayOf(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp), + intArrayOf(android.R.attr.state_selected), + intArrayOf(-android.R.attr.state_selected) + ), intArrayOf( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ), getColorOrDefault( HMSPrebuiltTheme.getColours()?.onSurfaceLow, - HMSPrebuiltTheme.getDefaults().onsurface_low_emp) + HMSPrebuiltTheme.getDefaults().onsurface_low_emp + ) ) ) - if(!hideParticipantTab) { + if (!hideParticipantTab) { tabLayout.background = getShape() //ResourcesCompat.getDrawable(this.root.resources,R.drawable.tab_layout_bg, null)!! .apply { @@ -1936,18 +1697,18 @@ internal fun LayoutChatParticipantCombinedBinding.applyTheme(hideParticipantTab } -fun getShape(radiusAt : ApplyRadiusatVertex = ApplyRadiusatVertex.ALL_CORNERS): ShapeDrawable { +fun getShape(radiusAt: ApplyRadiusatVertex = ApplyRadiusatVertex.ALL_CORNERS): ShapeDrawable { val eightDp = 8.dp().toFloat() val lines = floatArrayOf( - if(radiusAt == ApplyRadiusatVertex.TOP || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, - if(radiusAt == ApplyRadiusatVertex.TOP || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, - if(radiusAt == ApplyRadiusatVertex.TOP || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, - if(radiusAt == ApplyRadiusatVertex.TOP || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, - if(radiusAt == ApplyRadiusatVertex.BOTTOM || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, - if(radiusAt == ApplyRadiusatVertex.BOTTOM || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, - if(radiusAt == ApplyRadiusatVertex.BOTTOM || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, - if(radiusAt == ApplyRadiusatVertex.BOTTOM || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f + if (radiusAt == ApplyRadiusatVertex.TOP || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, + if (radiusAt == ApplyRadiusatVertex.TOP || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, + if (radiusAt == ApplyRadiusatVertex.TOP || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, + if (radiusAt == ApplyRadiusatVertex.TOP || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, + if (radiusAt == ApplyRadiusatVertex.BOTTOM || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, + if (radiusAt == ApplyRadiusatVertex.BOTTOM || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, + if (radiusAt == ApplyRadiusatVertex.BOTTOM || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f, + if (radiusAt == ApplyRadiusatVertex.BOTTOM || radiusAt == ApplyRadiusatVertex.ALL_CORNERS) eightDp else 0f ) return ShapeDrawable( @@ -1957,6 +1718,7 @@ fun getShape(radiusAt : ApplyRadiusatVertex = ApplyRadiusatVertex.ALL_CORNERS): ) ) } + fun LayoutChatParticipantCombinedBinding.getTabStateList(): StateListDrawable { val unselectedDrawable = getShape() @@ -1965,18 +1727,20 @@ fun LayoutChatParticipantCombinedBinding.getTabStateList(): StateListDrawable { setTint( getColorOrDefault( HMSPrebuiltTheme.getColours()?.surfaceDefault, - HMSPrebuiltTheme.getDefaults().surface_default) + HMSPrebuiltTheme.getDefaults().surface_default + ) ) } - val d2= getShape() - .apply { - setTint( - getColorOrDefault( - HMSPrebuiltTheme.getColours()?.surfaceBright, - HMSPrebuiltTheme.getDefaults().surface_bright) - ) - } - val selectedInner = InsetDrawable(d2,8) + val d2 = getShape() + .apply { + setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.surfaceBright, + HMSPrebuiltTheme.getDefaults().surface_bright + ) + ) + } + val selectedInner = InsetDrawable(d2, 8) val selectedDrawable = LayerDrawable(listOf(unselectedDrawable, selectedInner).toTypedArray()) val stateList = StateListDrawable() @@ -1986,30 +1750,38 @@ fun LayoutChatParticipantCombinedBinding.getTabStateList(): StateListDrawable { return stateList } -fun getChatBackgroundDrawable(alpha : Double? = null): ShapeDrawable { +fun getChatBackgroundDrawable(alpha: Double? = null): ShapeDrawable { return getShape()//ResourcesCompat.getDrawable(this.root.resources,R.drawable.send_message_background, null)!! .apply { - val initialColor = if(alpha == null) HMSPrebuiltTheme.getColours()?.surfaceDefault + val initialColor = if (alpha == null) HMSPrebuiltTheme.getColours()?.surfaceDefault else HMSPrebuiltTheme.getColours()?.surfaceDefault?.let { addAlpha(it, alpha) } - val defaultColor : String = if(alpha == null) HMSPrebuiltTheme.getDefaults().surface_default - else addAlpha(HMSPrebuiltTheme.getDefaults().surface_default, alpha) + val defaultColor: String = + if (alpha == null) HMSPrebuiltTheme.getDefaults().surface_default + else addAlpha(HMSPrebuiltTheme.getDefaults().surface_default, alpha) val color = getColorOrDefault( initialColor, - defaultColor) + defaultColor + ) colorFilter = - BlendModeColorFilterCompat.createBlendModeColorFilterCompat(color, BlendModeCompat.SRC) + BlendModeColorFilterCompat.createBlendModeColorFilterCompat( + color, + BlendModeCompat.SRC + ) } } + private fun configureChatControlsTheme( sendToBackground: MaterialCardView, sendToChipText: MaterialTextView, - chatOptionsCard : MaterialCardView, - chatOptions : ImageView + chatOptionsCard: MaterialCardView, + chatOptions: ImageView ) { - chatOptions.drawable.setTint(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceLow, - HMSPrebuiltTheme.getDefaults().onsurface_low_emp - )) + chatOptions.drawable.setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceLow, + HMSPrebuiltTheme.getDefaults().onsurface_low_emp + ) + ) chatOptionsCard.strokeColor = getColorOrDefault( HMSPrebuiltTheme.getColours()?.borderBright, @@ -2026,7 +1798,8 @@ private fun configureChatControlsTheme( sendToBackground.background = getShape().apply { val color = getColorOrDefault( HMSPrebuiltTheme.getColours()?.primaryDefault, - HMSPrebuiltTheme.getDefaults().primary_default) + HMSPrebuiltTheme.getDefaults().primary_default + ) colorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(color, BlendModeCompat.SRC) } @@ -2069,21 +1842,30 @@ private fun chatUnreadMessagesTheming(unreadMessageCount: TextView) { internal fun LayoutChatParticipantCombinedTabChatBinding.applyTheme() { pinMessageTheme(pinCloseButton) userBlockedTheme(userBlocked) - chatPausedTheme(chatPausedContainer, chatPausedTitle,chatPausedBy) + chatPausedTheme(chatPausedContainer, chatPausedTitle, chatPausedBy) configureChatControlsTheme(sendToBackground, sendToChipText, chatOptionsCard, chatOptions) // Emptyview - messageEmptyImage.drawable.setTint(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.secondaryDefault, - HMSPrebuiltTheme.getDefaults().secondary_default)) + messageEmptyImage.drawable.setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.secondaryDefault, + HMSPrebuiltTheme.getDefaults().secondary_default + ) + ) - emptyTitle.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp)) + emptyTitle.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) + ) - emptyDescription.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceMedium, - HMSPrebuiltTheme.getDefaults().onsurface_med_emp)) + emptyDescription.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) + ) // Chat chatView.background = getChatBackgroundDrawable() editTextMessage.background = getChatBackgroundDrawable() @@ -2091,69 +1873,96 @@ internal fun LayoutChatParticipantCombinedTabChatBinding.applyTheme() { editTextMessage.setTextColor( getColorOrDefault( HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp) + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) ) - editTextMessage.setHintTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceLow, - HMSPrebuiltTheme.getDefaults().onsurface_low_emp)) - iconSend.drawable.setTint(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceLow, - HMSPrebuiltTheme.getDefaults().onsurface_low_emp - )) + editTextMessage.setHintTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceLow, + HMSPrebuiltTheme.getDefaults().onsurface_low_emp + ) + ) + iconSend.drawable.setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceLow, + HMSPrebuiltTheme.getDefaults().onsurface_low_emp + ) + ) } internal fun ListItemChatBinding.applyTheme() { sentBackground.strokeColor = getColorOrDefault( HMSPrebuiltTheme.getColours()?.borderBright, - HMSPrebuiltTheme.getDefaults().border_bright) + HMSPrebuiltTheme.getDefaults().border_bright + ) - sentBackground.setBackgroundColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.surfaceDefault, - HMSPrebuiltTheme.getDefaults().surface_default)) - name.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp)) - message.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp)) - time.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceLow, - HMSPrebuiltTheme.getDefaults().onsurface_low_emp)) + sentBackground.setBackgroundColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.surfaceDefault, + HMSPrebuiltTheme.getDefaults().surface_default + ) + ) + name.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) + ) + message.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) + ) + time.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceLow, + HMSPrebuiltTheme.getDefaults().onsurface_low_emp + ) + ) - sentTo.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceMedium, - HMSPrebuiltTheme.getDefaults().onsurface_med_emp)) + sentTo.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) + ) } internal fun LayoutChatMergeBinding.applyTheme() { pinMessageTheme(pinCloseButton) userBlockedTheme(userBlocked) - chatPausedTheme(chatPausedContainer, chatPausedTitle,chatPausedBy) + chatPausedTheme(chatPausedContainer, chatPausedTitle, chatPausedBy) configureChatControlsTheme(sendToBackground, sendToChipText, chatOptionsCard, chatOptions) chatViewBackground.background = getChatBackgroundDrawable() handRaise.background = getShape().apply { val color = getColorOrDefault( HMSPrebuiltTheme.getColours()?.surfaceDefault, - HMSPrebuiltTheme.getDefaults().surface_default) + HMSPrebuiltTheme.getDefaults().surface_default + ) colorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(color, BlendModeCompat.SRC) } chatHamburgerMenu.background = getShape().apply { val color = getColorOrDefault( HMSPrebuiltTheme.getColours()?.surfaceDefault, - HMSPrebuiltTheme.getDefaults().surface_default) + HMSPrebuiltTheme.getDefaults().surface_default + ) colorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(color, BlendModeCompat.SRC) } - iconSend.drawable.setTint(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceLow, - HMSPrebuiltTheme.getDefaults().onsurface_low_emp - )) + iconSend.drawable.setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceLow, + HMSPrebuiltTheme.getDefaults().onsurface_low_emp + ) + ) editTextMessage.background = getChatBackgroundDrawable() } + internal fun HlsFragmentLayoutBinding.applyTheme() { // chatMerge.applyTheme() // meetingViewModel.getHmsRoomLayout()?.data?.getOrNull(0)?.logo?.url @@ -2165,18 +1974,22 @@ private fun TextInputLayout.applyTheme() { // background color background = getChatBackgroundDrawable() - defaultHintTextColor = ColorStateList.valueOf(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceLow, - HMSPrebuiltTheme.getDefaults().onsurface_low_emp - )) + defaultHintTextColor = ColorStateList.valueOf( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceLow, + HMSPrebuiltTheme.getDefaults().onsurface_low_emp + ) + ) startIconDrawable = ResourcesCompat.getDrawable(resources, R.drawable.ic_search_24, null) - ?.apply { colorFilter = PorterDuffColorFilter( - getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceLow, - HMSPrebuiltTheme.getDefaults().onsurface_low_emp - ), - PorterDuff.Mode.SRC_IN - ) } + ?.apply { + colorFilter = PorterDuffColorFilter( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceLow, + HMSPrebuiltTheme.getDefaults().onsurface_low_emp + ), + PorterDuff.Mode.SRC_IN + ) + } // boxStrokeColor = getColorOrDefault( // HMSPrebuiltTheme.getColours()?.borderBright, // HMSPrebuiltTheme.getDefaults().border_bright @@ -2184,17 +1997,25 @@ private fun TextInputLayout.applyTheme() { boxStrokeWidth = 0 boxStrokeWidthFocused = 0 } + private fun TextInputEditText.applyTheme() { - setHintTextColor(ColorStateList.valueOf(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceLow, - HMSPrebuiltTheme.getDefaults().onsurface_low_emp - ))) - setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp - )) + setHintTextColor( + ColorStateList.valueOf( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceLow, + HMSPrebuiltTheme.getDefaults().onsurface_low_emp + ) + ) + ) + setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) + ) background = getChatBackgroundDrawable() } + internal fun FragmentParticipantsBinding.applyTheme() { containerSearch.applyTheme() textInputSearch.applyTheme() @@ -2212,18 +2033,28 @@ internal fun FragmentParticipantsBinding.applyTheme() { ) closeButtonTheme(closeButton, this.root.resources) // surfacedim - root.setBackgroundColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.surfaceDim, - HMSPrebuiltTheme.getDefaults().surface_dim)) - participantsNum.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp)) + root.setBackgroundColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.surfaceDim, + HMSPrebuiltTheme.getDefaults().surface_dim + ) + ) + participantsNum.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) + ) } internal fun LayoutParticipantsMergeBinding.applyTheme() { searchViewTheme(containerSearch, textInputSearch) } -private fun backgroundShape(inset: Boolean = false, innerRadii : Float = 8.dp().toFloat()): ShapeDrawable { + +private fun backgroundShape( + inset: Boolean = false, + innerRadii: Float = 8.dp().toFloat() +): ShapeDrawable { val lines = floatArrayOf( innerRadii, innerRadii, @@ -2251,35 +2082,46 @@ private fun backgroundShape(inset: Boolean = false, innerRadii : Float = 8.dp(). ) } } -fun CustomMenuLayoutBinding.applyTheme(options : EnabledMenuOptions) { + +fun CustomMenuLayoutBinding.applyTheme(options: EnabledMenuOptions) { // border bright - toggleAudio.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp)) - toggleVideo.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp)) - with(menuBackingLayout){ - dividerDrawable = ResourcesCompat.getDrawable(resources, R.drawable.menu_item_participants_divider, null) - ?.apply { - setTint( - getColorOrDefault( - HMSPrebuiltTheme.getColours()?.borderBright, - HMSPrebuiltTheme.getDefaults().border_bright) - ) - } + toggleAudio.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) + ) + toggleVideo.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) + ) + with(menuBackingLayout) { + dividerDrawable = + ResourcesCompat.getDrawable(resources, R.drawable.menu_item_participants_divider, null) + ?.apply { + setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.borderBright, + HMSPrebuiltTheme.getDefaults().border_bright + ) + ) + } background = LayerDrawable( arrayOf(backgroundShape() - .apply { - paint.color = getColorOrDefault( - HMSPrebuiltTheme.getColours()?.surfaceDefault, - HMSPrebuiltTheme.getDefaults().surface_default) - }, + .apply { + paint.color = getColorOrDefault( + HMSPrebuiltTheme.getColours()?.surfaceDefault, + HMSPrebuiltTheme.getDefaults().surface_default + ) + }, backgroundShape(true) .apply { paint.color = getColorOrDefault( HMSPrebuiltTheme.getColours()?.borderBright, - HMSPrebuiltTheme.getDefaults().border_bright) + HMSPrebuiltTheme.getDefaults().border_bright + ) } ) ) @@ -2291,10 +2133,12 @@ fun CustomMenuLayoutBinding.applyTheme(options : EnabledMenuOptions) { onStage.setTextColor(textColors) switchRole.setTextColor(textColors) raiseHand.setTextColor(textColors) - removeParticipant.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.alertErrorDefault, - HMSPrebuiltTheme.getDefaults().error_default - )) + removeParticipant.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.alertErrorDefault, + HMSPrebuiltTheme.getDefaults().error_default + ) + ) onStage.drawableStart = ResourcesCompat.getDrawable( this.root.resources, @@ -2307,8 +2151,8 @@ fun CustomMenuLayoutBinding.applyTheme(options : EnabledMenuOptions) { ) ) } - if(options.audioIsOn != null) { - val audioIcon = if(options.audioIsOn) { + if (options.audioIsOn != null) { + val audioIcon = if (options.audioIsOn) { R.drawable.participants_menu_audio_muted } else { R.drawable.participants_menu_audio_unmuted @@ -2325,8 +2169,8 @@ fun CustomMenuLayoutBinding.applyTheme(options : EnabledMenuOptions) { ) } } - if(options.videoIsOn != null) { - val videoIcon = if(options.videoIsOn) { + if (options.videoIsOn != null) { + val videoIcon = if (options.videoIsOn) { R.drawable.participants_menu_video_muteed } else { R.drawable.ic_videocam_24 @@ -2368,19 +2212,23 @@ fun CustomMenuLayoutBinding.applyTheme(options : EnabledMenuOptions) { } } - fun trackTintList() : ColorStateList { - val checkedUncheckedState = arrayOf(intArrayOf(android.R.attr.state_checked), - intArrayOf(-android.R.attr.state_checked)) +fun trackTintList(): ColorStateList { + val checkedUncheckedState = arrayOf( + intArrayOf(android.R.attr.state_checked), + intArrayOf(-android.R.attr.state_checked) + ) return ColorStateList( checkedUncheckedState, intArrayOf( getColorOrDefault( HMSPrebuiltTheme.getColours()?.primaryDefault, - HMSPrebuiltTheme.getDefaults().primary_default), + HMSPrebuiltTheme.getDefaults().primary_default + ), getColorOrDefault( HMSPrebuiltTheme.getColours()?.onSurfaceMedium, - HMSPrebuiltTheme.getDefaults().onsurface_med_emp) + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) ) ) } @@ -2394,22 +2242,29 @@ private fun setSwitchThemes(switchCompat: SwitchMaterial) { switchCompat.setTextColor( getColorOrDefault( HMSPrebuiltTheme.getColours()?.onSurfaceMedium, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp) + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) ) } -private fun thumbTintList() : ColorStateList { - val checkedUncheckedState = arrayOf(intArrayOf(android.R.attr.state_checked), - intArrayOf(-android.R.attr.state_checked)) + +private fun thumbTintList(): ColorStateList { + val checkedUncheckedState = arrayOf( + intArrayOf(android.R.attr.state_checked), + intArrayOf(-android.R.attr.state_checked) + ) return ColorStateList( checkedUncheckedState, - intArrayOf(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onPrimaryHigh, - HMSPrebuiltTheme.getDefaults().onprimary_high_emp), + intArrayOf( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onPrimaryHigh, + HMSPrebuiltTheme.getDefaults().onprimary_high_emp + ), getColorOrDefault( HMSPrebuiltTheme.getColours()?.secondaryDefault, - HMSPrebuiltTheme.getDefaults().secondary_default) + HMSPrebuiltTheme.getDefaults().secondary_default + ) ) ) } @@ -2432,15 +2287,27 @@ fun LayoutPollQuestionCreationBinding.applyTheme() { ) - backButton.drawable.setTint(getColorOrDefault(HMSPrebuiltTheme.getColours()?.onSurfaceMedium, HMSPrebuiltTheme.getDefaults().onsurface_med_emp)) + backButton.drawable.setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) + ) } -fun LayoutPollsCreationBinding.applyTheme() { - backButton.drawable.setTint(getColorOrDefault(HMSPrebuiltTheme.getColours()?.onSurfaceMedium, HMSPrebuiltTheme.getDefaults().onsurface_med_emp)) - root.setBackgroundColor( getColorOrDefault( - HMSPrebuiltTheme.getColours()?.backgroundDefault, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp +fun LayoutPollsCreationBinding.applyTheme() { + backButton.drawable.setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) ) + + root.setBackgroundColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.backgroundDefault, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) ) heading.setTextColor( getColorOrDefault( @@ -2465,14 +2332,16 @@ fun LayoutPollsCreationBinding.applyTheme() { pollIcon.setCardBackgroundColor( getColorOrDefault( - HMSPrebuiltTheme.getColours()?.borderBright, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp) + HMSPrebuiltTheme.getColours()?.borderBright, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) ) quizIcon.setCardBackgroundColor( getColorOrDefault( HMSPrebuiltTheme.getColours()?.borderBright, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp) + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) ) @@ -2491,23 +2360,32 @@ fun LayoutPollsCreationBinding.applyTheme() { ) - pollText.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp - )) + pollText.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) + ) - quizText.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp - )) + quizText.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) + ) - pollTitleEditText.setHintTextColor(ColorStateList( - arrayOf( intArrayOf(android.R.attr.state_selected, -android.R.attr.state_selected)), - intArrayOf( getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceLow, - HMSPrebuiltTheme.getDefaults().onsurface_low_emp)) - )) + pollTitleEditText.setHintTextColor( + ColorStateList( + arrayOf(intArrayOf(android.R.attr.state_selected, -android.R.attr.state_selected)), + intArrayOf( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceLow, + HMSPrebuiltTheme.getDefaults().onsurface_low_emp + ) + ) + ) + ) @@ -2523,21 +2401,26 @@ fun LayoutPollsCreationBinding.applyTheme() { HMSPrebuiltTheme.getDefaults().onsurface_high_emp ) ) - pollTitleEditText.setHintTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceLow, - HMSPrebuiltTheme.getDefaults().onsurface_low_emp)) + pollTitleEditText.setHintTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceLow, + HMSPrebuiltTheme.getDefaults().onsurface_low_emp + ) + ) previousPollsHeading.setTextColor( getColorOrDefault( HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp) + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) ) settingStr.setTextColor( getColorOrDefault( HMSPrebuiltTheme.getColours()?.onSurfaceMedium, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp) + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) ) border.setBackgroundColor( @@ -2564,22 +2447,28 @@ fun Button.voteButtons() { val buttonDisabledBackgroundColor = getColorOrDefault( HMSPrebuiltTheme.getColours()?.primaryDisabled, - HMSPrebuiltTheme.getDefaults().primary_disabled) + HMSPrebuiltTheme.getDefaults().primary_disabled + ) val buttonDisabledTextColor = getColorOrDefault( HMSPrebuiltTheme.getColours()?.onPrimaryLow, - HMSPrebuiltTheme.getDefaults().onprimary_low_emp) + HMSPrebuiltTheme.getDefaults().onprimary_low_emp + ) val buttonEnabledBackgroundColor = getColorOrDefault( HMSPrebuiltTheme.getColours()?.primaryDefault, - HMSPrebuiltTheme.getDefaults().primary_default) + HMSPrebuiltTheme.getDefaults().primary_default + ) val buttonEnabledTextColor = getColorOrDefault( HMSPrebuiltTheme.getColours()?.onPrimaryHigh, - HMSPrebuiltTheme.getDefaults().onprimary_high_emp) + HMSPrebuiltTheme.getDefaults().onprimary_high_emp + ) - val states = arrayOf(intArrayOf(android.R.attr.state_enabled), - intArrayOf(-android.R.attr.state_enabled)) + val states = arrayOf( + intArrayOf(android.R.attr.state_enabled), + intArrayOf(-android.R.attr.state_enabled) + ) val backgroundColors = intArrayOf(buttonEnabledBackgroundColor, buttonDisabledBackgroundColor) val textColors = intArrayOf(buttonEnabledTextColor, buttonDisabledTextColor) @@ -2588,29 +2477,38 @@ fun Button.voteButtons() { backgroundColors ) - setTextColor(ColorStateList( - states, - textColors - )) + setTextColor( + ColorStateList( + states, + textColors + ) + ) } -fun MaterialCardView.isSelectedStroke(isSelected : Boolean) { +fun MaterialCardView.isSelectedStroke(isSelected: Boolean) { if (isSelected.not()) this.strokeColor = getColorOrDefault( HMSPrebuiltTheme.getColours()?.borderBright, - HMSPrebuiltTheme.getDefaults().primary_default) + HMSPrebuiltTheme.getDefaults().primary_default + ) else this.strokeColor = getColorOrDefault( HMSPrebuiltTheme.getColours()?.primaryDefault, - HMSPrebuiltTheme.getDefaults().primary_default) + HMSPrebuiltTheme.getDefaults().primary_default + ) } fun LayoutQuizLeaderboardBinding.applyTheme() { backButton.backgroundTintList = - ColorStateList.valueOf(getColorOrDefault(HMSPrebuiltTheme.getColours()?.onSurfaceMedium, HMSPrebuiltTheme.getDefaults().onsurface_med_emp)) + ColorStateList.valueOf( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) + ) heading.setTextColor( getColorOrDefault( HMSPrebuiltTheme.getColours()?.onSurfaceHigh, @@ -2618,7 +2516,12 @@ fun LayoutQuizLeaderboardBinding.applyTheme() { ) ) closeBtn.backgroundTintList = - ColorStateList.valueOf(getColorOrDefault(HMSPrebuiltTheme.getColours()?.onSurfaceMedium, HMSPrebuiltTheme.getDefaults().onsurface_med_emp)) + ColorStateList.valueOf( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) + ) root.setBackgroundColor( getColorOrDefault( @@ -2626,20 +2529,29 @@ fun LayoutQuizLeaderboardBinding.applyTheme() { HMSPrebuiltTheme.getDefaults().onsurface_high_emp ) ) - pollsLive.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().onprimary_high_emp - )) - pollsLive.setBackgroundColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.surfaceDefault, - HMSPrebuiltTheme.getDefaults().error_default - )) + pollsLive.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onprimary_high_emp + ) + ) + pollsLive.setBackgroundColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.surfaceDefault, + HMSPrebuiltTheme.getDefaults().error_default + ) + ) } fun LayoutPollsDisplayBinding.applyTheme() { backButton.backgroundTintList = - ColorStateList.valueOf(getColorOrDefault(HMSPrebuiltTheme.getColours()?.onSurfaceMedium, HMSPrebuiltTheme.getDefaults().onsurface_med_emp)) + ColorStateList.valueOf( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) + ) heading.setTextColor( getColorOrDefault( HMSPrebuiltTheme.getColours()?.onSurfaceHigh, @@ -2652,14 +2564,18 @@ fun LayoutPollsDisplayBinding.applyTheme() { HMSPrebuiltTheme.getDefaults().onsurface_med_emp ) ) - pollsLive.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onPrimaryHigh, - HMSPrebuiltTheme.getDefaults().onprimary_high_emp - )) - pollsLive.setBackgroundColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.alertErrorDefault, - HMSPrebuiltTheme.getDefaults().error_default - )) + pollsLive.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onPrimaryHigh, + HMSPrebuiltTheme.getDefaults().onprimary_high_emp + ) + ) + pollsLive.setBackgroundColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.alertErrorDefault, + HMSPrebuiltTheme.getDefaults().error_default + ) + ) } fun LayoutHeaderBinding.applyTheme() { @@ -2757,9 +2673,6 @@ fun ItemNameSectionBinding.applyTheme() { ) - - - } fun LayoutPollsDisplayChoicesQuesionBinding.applyTheme() { @@ -2779,6 +2692,7 @@ fun LayoutPollsDisplayChoicesQuesionBinding.applyTheme() { votebutton.voteButtons() } + fun LayoutQuizDisplayShortAnswerBinding.applyTheme() { } @@ -2818,8 +2732,10 @@ fun LayoutPollQuestionCreationItemBinding.applyTheme() { ) spinnerArrow.drawable.setTint( - getColorOrDefault( HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().surface_default,) + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().surface_default, + ) ) @@ -2861,10 +2777,10 @@ fun LayoutPollQuestionCreationItemBinding.applyTheme() { ) addAnOptionTextView.drawableStart?.setTint( - getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceMedium, - HMSPrebuiltTheme.getDefaults().onprimary_high_emp - ) + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onprimary_high_emp + ) ) setSwitchThemes(notRequiredToAnswer) @@ -2922,9 +2838,11 @@ internal fun TextView.saveButtonDisabled() { fun LayoutPollQuizOptionsItemMultiChoiceBinding.applyTheme() { - backingCard.setCardBackgroundColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.surfaceDefault, - HMSPrebuiltTheme.getDefaults().surface_default) + backingCard.setCardBackgroundColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.surfaceDefault, + HMSPrebuiltTheme.getDefaults().surface_default + ) ) deleteOptionTrashButton.drawable.setTint( @@ -2981,37 +2899,47 @@ fun LayoutPollQuizOptionsItemBinding.setTheme() { } fun TextView.pollsStatusLiveDraftEnded(state: HmsPollState) { - text = when(state) { + text = when (state) { HmsPollState.STARTED -> "LIVE" HmsPollState.CREATED -> "DRAFT" HmsPollState.STOPPED -> "ENDED" } - val colorRes = when(state) { + val colorRes = when (state) { HmsPollState.STARTED -> R.drawable.polls_status_background_live HmsPollState.CREATED -> R.drawable.polls_status_background_draft HmsPollState.STOPPED -> R.drawable.polls_status_background_ended } setBackgroundResource(colorRes) } + fun LayoutPollsDisplayResultQuizAnswerItemsBinding.applyTheme() { - optionText.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp - )) - peopleAnswering.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceMedium, - HMSPrebuiltTheme.getDefaults().onsurface_med_emp - )) + optionText.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) + ) + peopleAnswering.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) + ) } + fun LayoutPollsDisplayResultProgressBarsItemBinding.applyTheme() { - answer.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp - )) - totalVotes.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceMedium, - HMSPrebuiltTheme.getDefaults().onsurface_med_emp - )) + answer.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) + ) + totalVotes.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) + ) questionProgressBar.applyProgressbarTheme() } @@ -3021,33 +2949,38 @@ fun LinearProgressIndicator.applyProgressbarTheme() { HMSPrebuiltTheme.getDefaults().primary_default ) - setIndicatorColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.primaryDefault, - HMSPrebuiltTheme.getDefaults().surface_bright - )) + setIndicatorColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.primaryDefault, + HMSPrebuiltTheme.getDefaults().surface_bright + ) + ) } fun LayoutAddMoreBinding.applyTheme() { - addMoreOptions.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceMedium, - HMSPrebuiltTheme.getDefaults().onsurface_med_emp - )) - addMoreOptions.drawableStart = AppCompatResources.getDrawable( - root.context, R.drawable.add_circle_with_plus - )?.apply { setTint( + addMoreOptions.setTextColor( getColorOrDefault( HMSPrebuiltTheme.getColours()?.onSurfaceMedium, HMSPrebuiltTheme.getDefaults().onsurface_med_emp ) ) + addMoreOptions.drawableStart = AppCompatResources.getDrawable( + root.context, R.drawable.add_circle_with_plus + )?.apply { + setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) + ) } } fun PreviousPollsListBinding.applyTheme() { root.setBackgroundColor( - HMSPrebuiltTheme.getColours()?.surfaceBright, - HMSPrebuiltTheme.getDefaults().onsurface_med_emp + HMSPrebuiltTheme.getColours()?.surfaceBright, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp ) viewButton.setBackgroundAndColor( @@ -3075,17 +3008,18 @@ fun PreviousPollsListBinding.applyTheme() { HMSPrebuiltTheme.getDefaults().onsurface_med_emp ) - status.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().onsurface_med_emp - )) - + status.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) + ) } -fun MaterialCardView.highlightCorrectAnswer(isCorrect : Boolean) { - strokeColor = if(isCorrect) { +fun MaterialCardView.highlightCorrectAnswer(isCorrect: Boolean) { + strokeColor = if (isCorrect) { getColorOrDefault( HMSPrebuiltTheme.getColours()?.alertSuccess, HMSPrebuiltTheme.getDefaults().error_default @@ -3109,14 +3043,19 @@ internal fun LayoutMultiChoiceQuestionOptionItemBinding.applyTheme() { } fun LayoutPinnedMessageBinding.applyTheme() { - root.background = getShape()// ResourcesCompat.getDrawable(this.root.resources,R.drawable.gray_shape_round_dialog, null)!! - .apply { - val color = getColorOrDefault( - HMSPrebuiltTheme.getColours()?.surfaceDefault, - HMSPrebuiltTheme.getDefaults().surface_default) - colorFilter = - BlendModeColorFilterCompat.createBlendModeColorFilterCompat(color, BlendModeCompat.SRC) - } + root.background = + getShape()// ResourcesCompat.getDrawable(this.root.resources,R.drawable.gray_shape_round_dialog, null)!! + .apply { + val color = getColorOrDefault( + HMSPrebuiltTheme.getColours()?.surfaceDefault, + HMSPrebuiltTheme.getDefaults().surface_default + ) + colorFilter = + BlendModeColorFilterCompat.createBlendModeColorFilterCompat( + color, + BlendModeCompat.SRC + ) + } pinnedMessage.setTextColor( getColorOrDefault( @@ -3127,7 +3066,7 @@ fun LayoutPinnedMessageBinding.applyTheme() { } private fun dialogBackground(resources: Resources): Drawable = - ResourcesCompat.getDrawable(resources,R.drawable.gray_shape_round_dialog, null)!!.apply { + ResourcesCompat.getDrawable(resources, R.drawable.gray_shape_round_dialog, null)!!.apply { val color = getColorOrDefault( HMSPrebuiltTheme.getColours()?.backgroundDefault, HMSPrebuiltTheme.getDefaults().background_default @@ -3179,12 +3118,15 @@ fun BottomSheetMessageOptionsBinding.applyTheme() { ) } -private fun searchViewTheme(containerSearch : MaterialCardView, textInputSearch : EditText) { - textInputSearch.setTextColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceHigh, - HMSPrebuiltTheme.getDefaults().onsurface_high_emp - )) +private fun searchViewTheme(containerSearch: MaterialCardView, textInputSearch: EditText) { + + textInputSearch.setTextColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceHigh, + HMSPrebuiltTheme.getDefaults().onsurface_high_emp + ) + ) textInputSearch.setHintTextColor( getColorOrDefault( @@ -3192,20 +3134,25 @@ private fun searchViewTheme(containerSearch : MaterialCardView, textInputSearch HMSPrebuiltTheme.getDefaults().onsurface_med_emp ) ) - textInputSearch.setBackgroundColor(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.surfaceDim, - HMSPrebuiltTheme.getDefaults().surface_dim - )) - textInputSearch.drawableStart?.setTint(getColorOrDefault( - HMSPrebuiltTheme.getColours()?.onSurfaceMedium, - HMSPrebuiltTheme.getDefaults().onsurface_med_emp - )) + textInputSearch.setBackgroundColor( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.surfaceDim, + HMSPrebuiltTheme.getDefaults().surface_dim + ) + ) + textInputSearch.drawableStart?.setTint( + getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onSurfaceMedium, + HMSPrebuiltTheme.getDefaults().onsurface_med_emp + ) + ) containerSearch.strokeWidth = 1.dp() containerSearch.strokeColor = getColorOrDefault( HMSPrebuiltTheme.getColours()?.borderBright, HMSPrebuiltTheme.getDefaults().border_bright ) } + fun LayoutRoleBasedChatBottomSheetSelectorBinding.applyTheme() { root.background = dialogBackground(this.root.resources) border5.setBackgroundColor( @@ -3222,6 +3169,7 @@ fun LayoutRoleBasedChatBottomSheetSelectorBinding.applyTheme() { ) searchViewTheme(containerSearch, textInputSearch) } + fun LayoutRoleBasedChatMessageBottomSheetItemHeaderBinding.applyTheme() { name.setTextColor( getColorOrDefault( @@ -3230,6 +3178,7 @@ fun LayoutRoleBasedChatMessageBottomSheetItemHeaderBinding.applyTheme() { ) ) } + fun LayoutRoleBasedChatMessageBottomSheetItemRecipientBinding.applyTheme() { image.drawable.setTint( getColorOrDefault( diff --git a/room-kit/src/main/java/live/hms/roomkit/util/EmailUtils.kt b/room-kit/src/main/java/live/hms/roomkit/util/EmailUtils.kt index e8bfd99f8..d14231a3e 100644 --- a/room-kit/src/main/java/live/hms/roomkit/util/EmailUtils.kt +++ b/room-kit/src/main/java/live/hms/roomkit/util/EmailUtils.kt @@ -14,15 +14,6 @@ object EmailUtils { const val TAG = "EmailUtils" - fun addAlpha(originalColor: String, alpha: Double): String { - - val alphaFixed = (alpha * 255) - var alphaHex = toHexString(alphaFixed) - if (alphaHex.length == 1) { - alphaHex = "0$alphaHex" - } - return originalColor.replace("#", "#$alphaHex") - } fun getNonFatalLogIntent(context: Context, throwable: Throwable? = null): Intent { val logFile = LogUtils.saveLogsToFile(context, "nonfatal-log") val logUri = FileProvider.getUriForFile(context, "live.hms.roomkit.provider", logFile) diff --git a/room-kit/src/main/java/live/hms/roomkit/util/ViewExt.kt b/room-kit/src/main/java/live/hms/roomkit/util/ViewExt.kt index f334b255c..b65fafc44 100644 --- a/room-kit/src/main/java/live/hms/roomkit/util/ViewExt.kt +++ b/room-kit/src/main/java/live/hms/roomkit/util/ViewExt.kt @@ -40,15 +40,10 @@ import java.io.File import java.io.FileOutputStream import kotlin.math.roundToInt - fun View.setOnSingleClickListener(l: View.OnClickListener) { setOnClickListener(OnSingleClickListener(l)) } -private fun getDip(): Float = Resources.getSystem().displayMetrics.density -fun Float.dp() = this * getDip() -fun Int.dp() = (this * getDip()).roundToInt() - // Keep the listener at last such that we can use kotlin lambda fun View.setOnSingleClickListener(waitDelay: Long, l: View.OnClickListener) { setOnClickListener(OnSingleClickListener(l, waitDelay)) diff --git a/room-kit/src/main/res/drawable/preview_vb_button.xml b/room-kit/src/main/res/drawable/preview_vb_button.xml new file mode 100644 index 000000000..d9c1ea777 --- /dev/null +++ b/room-kit/src/main/res/drawable/preview_vb_button.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + diff --git a/room-kit/src/main/res/drawable/vb_session_option_icon.xml b/room-kit/src/main/res/drawable/vb_session_option_icon.xml new file mode 100644 index 000000000..4ef84554a --- /dev/null +++ b/room-kit/src/main/res/drawable/vb_session_option_icon.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + diff --git a/room-kit/src/main/res/font/inter_regular.ttf b/room-kit/src/main/res/font/inter_regular.ttf deleted file mode 100644 index 8d4eebf20..000000000 Binary files a/room-kit/src/main/res/font/inter_regular.ttf and /dev/null differ diff --git a/room-kit/src/main/res/layout/fragment_preview.xml b/room-kit/src/main/res/layout/fragment_preview.xml index 6334e87f0..ae8b9f6e2 100644 --- a/room-kit/src/main/res/layout/fragment_preview.xml +++ b/room-kit/src/main/res/layout/fragment_preview.xml @@ -348,6 +348,22 @@ app:iconSize="24dp" app:layout_constraintStart_toEndOf="@+id/button_toggle_video" app:layout_constraintTop_toTopOf="parent" /> + Use noise cancellation Hello blank fragment + Toggle VB \ No newline at end of file diff --git a/room-kit/src/main/res/values/themes.xml b/room-kit/src/main/res/values/themes.xml index a49d7b2a1..105679656 100644 --- a/room-kit/src/main/res/values/themes.xml +++ b/room-kit/src/main/res/values/themes.xml @@ -12,6 +12,29 @@ @font/clan_pro_news + + + + +