Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2db8548b authored by Carlos Martinez Romero's avatar Carlos Martinez Romero Committed by Android (Google) Code Review
Browse files

Merge "Updated the BufferStreamsDemoApp UI to jetpack compose." into main

parents 81f86d7d 4b01c0ae
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -14,14 +14,33 @@

android_app {
    name: "BufferStreamsDemoApp",
    srcs: ["java/**/*.java"],
    srcs: ["java/**/*.kt"],
    sdk_version: "current",

    jni_uses_platform_apis: true,
    jni_libs: ["libbufferstreamdemoapp"],
    use_embedded_native_libs: true,
    kotlincflags: [
        "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api",
    ],

    resource_dirs: ["res"],

    static_libs: [
        "androidx.activity_activity-compose",
        "androidx.appcompat_appcompat",
        "androidx.compose.foundation_foundation",
        "androidx.compose.material3_material3",
        "androidx.compose.runtime_runtime",
        "androidx.compose.ui_ui",
        "androidx.compose.ui_ui-graphics",
        "androidx.compose.ui_ui-tooling-preview",
        "androidx.core_core-ktx",
        "androidx.lifecycle_lifecycle-runtime-ktx",
        "androidx.navigation_navigation-common-ktx",
        "androidx.navigation_navigation-compose",
        "androidx.navigation_navigation-fragment-ktx",
        "androidx.navigation_navigation-runtime-ktx",
        "androidx.navigation_navigation-ui-ktx",
    ],
}
+4 −3
Original line number Diff line number Diff line
@@ -9,14 +9,15 @@
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppCompat.Light"
        android:theme="@style/Theme.Jetpack"
        tools:targetApi="34">
        <activity
            android:name=".MainActivity"
            android:exported="true">
            android:exported="true"
            android:label="@string/app_name"
            android:theme="@style/Theme.Jetpack">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
+40 −0
Original line number Diff line number Diff line
package com.android.graphics.bufferstreamsdemoapp

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource

@Composable
fun BufferDemosAppBar(
        currentScreen: BufferDemoScreen,
        canNavigateBack: Boolean,
        navigateUp: () -> Unit,
        modifier: Modifier = Modifier
) {
    TopAppBar(
            title = { Text(stringResource(currentScreen.title)) },
            colors =
            TopAppBarDefaults.mediumTopAppBarColors(
                    containerColor = MaterialTheme.colorScheme.primaryContainer
            ),
            modifier = modifier,
            navigationIcon = {
                if (canNavigateBack) {
                    IconButton(onClick = navigateUp) {
                        Icon(
                                imageVector = Icons.AutoMirrored.Filled.ArrowBack,
                                contentDescription = stringResource(R.string.back_button)
                        )
                    }
                }
            }
    )
}
 No newline at end of file
+27 −0
Original line number Diff line number Diff line
package com.android.graphics.bufferstreamsdemoapp

class BufferStreamJNI {
    // Used to load the 'bufferstreamsdemoapp' library on application startup.
    init {
        System.loadLibrary("bufferstreamdemoapp")
    }

    /**
     * A native method that is implemented by the 'bufferstreamsdemoapp' native library, which is
     * packaged with this application.
     */
    external fun stringFromJNI()
    external fun testBufferQueueCreation()

    companion object {
        fun companion_stringFromJNI() {
            val instance = BufferStreamJNI()
            instance.stringFromJNI()
        }

        fun companion_testBufferQueueCreation() {
            val instance = BufferStreamJNI()
            instance.testBufferQueueCreation()
        }
    }
}
 No newline at end of file
+33 −0
Original line number Diff line number Diff line
package com.android.graphics.bufferstreamsdemoapp

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

@Composable
fun DemoScreen1(modifier: Modifier = Modifier) {
    Column(modifier = modifier, verticalArrangement = Arrangement.SpaceBetween) {
        Card(modifier = Modifier.fillMaxWidth().weight(1f, false).padding(16.dp).height(400.dp)) {
            Text("Log output", modifier = Modifier.padding(16.dp))
        }
        Row(modifier = Modifier.weight(1f, false).padding(16.dp)) {
            Column(verticalArrangement = Arrangement.spacedBy(16.dp)) {
                Button(
                        modifier = Modifier.fillMaxWidth(),
                        onClick = { BufferStreamJNI.companion_testBufferQueueCreation() }
                ) { Text("Run") }
                OutlinedButton(modifier = Modifier.fillMaxWidth(), onClick = {}) { Text("Clear") }
            }
        }
    }
}
 No newline at end of file
Loading