Merge all the project into one and clean up the repo(#11)

* Set up samples project

* Add CompanionPane

* Update the pipeline to include ComposeSamples

* Add DualView

* Add ExtendedCanvas

* Add ComposeGallery

* Remove the duplicate projects

* Update pipeline

* Fix the pipeline issue

* Add missing files

* Add copyright
This commit is contained in:
Joy Liu 2021-03-02 12:13:35 -08:00 коммит произвёл GitHub
Родитель e9afeae473
Коммит cef6cd5340
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
293 изменённых файлов: 1066 добавлений и 2682 удалений

19
.github/workflows/app-samples-CI.yml поставляемый
Просмотреть файл

@ -1,7 +1,7 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: App samples CI
name: Compose samples CI
on:
push:
@ -17,14 +17,8 @@ on:
required: false
jobs:
build:
build-test-and-check:
runs-on: ubuntu-latest
strategy:
matrix:
projects: [CompanionPane, ComposeGallery, ExtendedCanvas, ListDetail, DualView]
fail-fast: false
steps:
- uses: actions/checkout@v2
@ -36,34 +30,29 @@ jobs:
- name: Cache gradle packages
uses: actions/cache@v2
with:
path: ${{matrix.projects}}/.gradle/caches
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Grant execute permission for gradlew
run: chmod +x ${{matrix.projects}}/gradlew
run: chmod +x gradlew
- name: clean
run: |
cd ${{matrix.projects}}
./gradlew clean --info
- name: assemble debug
run: |
cd ${{matrix.projects}}
./gradlew assembleDebug --info
- name: unit tests
run: |
cd ${{matrix.projects}}
./gradlew testDebugUnitTest --info
- name: lint
run: |
cd ${{matrix.projects}}
./gradlew lintDebug --info
- name: ktlint
run: |
cd ${{matrix.projects}}
./gradlew ktlint --info

48
.gitignore поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
### Android template
# Built application files
*.apk
*.aar
*.ap_
*.aab
@ -14,8 +14,7 @@
bin/
gen/
out/
# Uncomment the following line in case you need and you don't have the release build type files in your app
# release/
release/
# Gradle files
.gradle/
@ -38,48 +37,9 @@ captures/
# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
.idea/
# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
.cxx/
# Google Services (e.g. APIs or Firebase)
# google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
# Version control
vcs.xml
# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
#*.keystore

46
CompanionPane/.gitignore поставляемый
Просмотреть файл

@ -1,45 +1 @@
### Android template
# Built application files
*.apk
*.ap_
*.aab
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
release/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/
# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore
/build

1
CompanionPane/app/.gitignore поставляемый
Просмотреть файл

@ -1 +0,0 @@
/build

Просмотреть файл

@ -1,50 +0,0 @@
/*
*
* * Copyright (c) Microsoft Corporation. All rights reserved.
* * Licensed under the MIT License.
*
*/
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.microsoft.device.display.samples.companionpane"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerVersion "$kotlinVersion"
kotlinCompilerExtensionVersion "$composeVersion"
}
}
dependencies {
implementation kotlinDependencies.kotlinStdlib
implementation androidxDependencies.ktxCore
implementation androidxDependencies.appCompat
implementation androidxDependencies.window
implementation androidxDependencies.compose
implementation androidxDependencies.composeRuntime
implementation androidxDependencies.composeMaterial
implementation androidxDependencies.composeUITooling
implementation googleDependencies.material
}

Двоичные данные
CompanionPane/app/src/main/java/com/microsoft/device/display/samples/.DS_Store поставляемый

Двоичный файл не отображается.

Двоичные данные
CompanionPane/app/src/main/res/.DS_Store поставляемый

Двоичный файл не отображается.

Двоичные данные
CompanionPane/app/src/main/res/drawable/.DS_Store поставляемый

Двоичный файл не отображается.

Просмотреть файл

@ -1,3 +0,0 @@
<resources>
<string name="app_name">Companion Pane-Compose</string>
</resources>

Просмотреть файл

@ -1,34 +1,49 @@
/*
*
* * Copyright (c) Microsoft Corporation. All rights reserved.
* * Licensed under the MIT License.
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
apply from: 'dependencies.gradle'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
repositories {
google()
jcenter()
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.microsoft.device.display.samples.companionpane"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
}
dependencies {
classpath config.gradlePlugin
classpath config.kotlinGradlePlugin
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion "$composeVersion"
}
}
allprojects {
repositories {
google()
jcenter()
}
apply from: "$rootDir/ktlint.gradle"
dependencies {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
implementation kotlinDependencies.kotlinStdlib
implementation androidxDependencies.ktxCore
implementation androidxDependencies.appCompat
implementation androidxDependencies.window
implementation androidxDependencies.composeUI
implementation androidxDependencies.composeRuntime
implementation androidxDependencies.composeMaterial
implementation androidxDependencies.composeUITooling
implementation androidxDependencies.activityCompose
implementation googleDependencies.material
}

Просмотреть файл

@ -1,54 +0,0 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*
*/
ext {
gradlePluginVersion = '7.0.0-alpha05'
kotlinVersion = "1.4.21-2"
compileSdkVersion = 29
targetSdkVersion = compileSdkVersion
minSdkVersion = 21
config = [
gradlePlugin : "com.android.tools.build:gradle:$gradlePluginVersion",
kotlinGradlePlugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion",
testInstrumentationRunner: "androidx.test.runner.AndroidJUnitRunner"
]
kotlinDependencies = [
kotlinStdlib: "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
]
//AndroidX versions
appCompatVersion = "1.1.0"
ktxCoreVersion = "1.3.0"
constraintLayoutVersion = "1.1.3"
recyclerViewVersion = "1.1.0"
cardViewVersion = "1.0.0"
ktxFragmentVersion = "1.2.4"
viewPager2Version = "1.0.0"
localBroadcastManagerVersion = "1.0.0"
preferenceVersion = "1.1.1"
composeVersion = "1.0.0-alpha11"
windowVersion = "1.0.0-alpha02"
androidxDependencies = [
appCompat : "androidx.appcompat:appcompat:$appCompatVersion",
ktxCore : "androidx.core:core-ktx:$ktxCoreVersion",
window : "androidx.window:window:$windowVersion",
compose : "androidx.compose.ui:ui:$composeVersion",
composeRuntime : "androidx.compose.runtime:runtime-livedata:$composeVersion",
composeMaterial : "androidx.compose.material:material:$composeVersion",
composeUI : "androidx.compose.ui:ui:$composeVersion",
composeUITooling : "androidx.compose.ui:ui-tooling:$composeVersion",
]
//Google dependencies
materialVersion = "1.1.0"
googleDependencies = [
material: "com.google.android.material:material:$materialVersion"
]
}

Просмотреть файл

@ -1,16 +0,0 @@
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Mon Aug 31 14:15:30 PDT 2020
android.useAndroidX=true
android.enableJetifier=true
org.gradle.jvmargs=-Xmx1536m

Двоичные данные
CompanionPane/gradle/wrapper/gradle-wrapper.jar поставляемый

Двоичный файл не отображается.

Просмотреть файл

@ -1,5 +0,0 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-6.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

185
CompanionPane/gradlew поставляемый
Просмотреть файл

@ -1,185 +0,0 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"

104
CompanionPane/gradlew.bat поставляемый
Просмотреть файл

@ -1,104 +0,0 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

Просмотреть файл

@ -1,34 +0,0 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*
*/
repositories {
jcenter()
}
configurations {
ktlint
}
dependencies {
ktlint "com.pinterest:ktlint:0.40.0"
}
task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "src/**/*.kt"
// to generate report in checkstyle format prepend following args:
// "--reporter=plain", "--reporter=checkstyle,output=${buildDir}/ktlint.xml"
// see https://github.com/pinterest/ktlint#usage for more
}
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "-F", "src/**/*.kt"
}

Просмотреть файл

@ -1,3 +0,0 @@
rootProject.name = "CompanionPane"
include ':app'

Просмотреть файл

@ -1,4 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) Microsoft Corporation. All rights reserved.
~ Licensed under the MIT License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.microsoft.device.display.samples.companionpane">

Просмотреть файл

@ -1,9 +1,6 @@
/*
*
* * Copyright (c) Microsoft Corporation. All rights reserved.
* * Licensed under the MIT License.
* *
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
package com.microsoft.device.display.samples.companionpane
@ -12,11 +9,11 @@ import android.content.res.Configuration
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.text.BasicText
import androidx.compose.material.Scaffold
import androidx.compose.material.TopAppBar
import androidx.compose.ui.platform.setContent
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
@ -60,7 +57,7 @@ class MainActivity : AppCompatActivity() {
},
)
},
bodyContent = {
content = {
SetupUI(viewModel = appStateViewModel)
}
)

Просмотреть файл

@ -1,9 +1,6 @@
/*
*
* * Copyright (c) Microsoft Corporation. All rights reserved.
* * Licensed under the MIT License.
* *
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
package com.microsoft.device.display.samples.companionpane
@ -16,8 +13,6 @@ import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.preferredHeight
import androidx.compose.foundation.layout.preferredWidth
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.runtime.Composable
@ -73,9 +68,9 @@ fun LandscapeSpannedLayout() { // dual portrait mode
modifier = Modifier.fillMaxHeight().weight(1f),
verticalArrangement = Arrangement.Center
) {
Spacer(Modifier.preferredHeight(20.dp))
Spacer(Modifier.height(20.dp))
ImagePanel(Modifier.height(380.dp).fillMaxWidth())
Spacer(Modifier.preferredHeight(25.dp))
Spacer(Modifier.height(25.dp))
EffectPanel()
}
Column(
@ -89,7 +84,7 @@ fun LandscapeSpannedLayout() { // dual portrait mode
VignettePanel(modifier = Modifier.width(longSlideWidth))
BrightnessPanel(modifier = Modifier.width(longSlideWidth))
}
Spacer(Modifier.preferredHeight(80.dp))
Spacer(Modifier.height(80.dp))
ShortFilterControl()
}
}
@ -98,7 +93,7 @@ fun LandscapeSpannedLayout() { // dual portrait mode
@Composable
fun PortraitSpannedLayout() { // dual landscape mode
Column(modifier = Modifier.fillMaxSize()) {
Spacer(Modifier.preferredHeight(40.dp))
Spacer(Modifier.height(40.dp))
Row(
modifier = Modifier.fillMaxWidth().weight(1f),
horizontalArrangement = Arrangement.Center
@ -109,21 +104,21 @@ fun PortraitSpannedLayout() { // dual landscape mode
modifier = Modifier.fillMaxWidth().weight(1f)
) {
EffectPanel()
Spacer(Modifier.preferredHeight(60.dp))
Spacer(Modifier.height(60.dp))
Row(horizontalArrangement = Arrangement.spacedBy(40.dp)) {
Spacer(Modifier.preferredWidth(20.dp))
Spacer(Modifier.width(20.dp))
Column(modifier = Modifier.wrapContentWidth()) {
MagicWandPanel(modifier = Modifier.width(shortSlideWidth))
Spacer(Modifier.preferredHeight(20.dp))
Spacer(Modifier.height(20.dp))
DefinitionPanel(modifier = Modifier.width(shortSlideWidth))
}
Column(modifier = Modifier.wrapContentWidth()) {
VignettePanel(modifier = Modifier.width(shortSlideWidth))
Spacer(Modifier.preferredHeight(20.dp))
Spacer(Modifier.height(20.dp))
BrightnessPanel(modifier = Modifier.width(shortSlideWidth))
}
}
Spacer(Modifier.preferredHeight(60.dp))
Spacer(Modifier.height(60.dp))
ShortFilterControl()
}
}
@ -135,7 +130,7 @@ fun PortraitLayout() {
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.spacedBy(15.dp)
) {
Spacer(Modifier.preferredHeight(8.dp))
Spacer(Modifier.height(8.dp))
ImagePanel(Modifier.height(350.dp).fillMaxWidth())
EffectPanel()
FullFilterControl()
@ -145,11 +140,11 @@ fun PortraitLayout() {
@Composable
fun LandscapeLayout() {
Column(modifier = Modifier.fillMaxSize()) {
Spacer(Modifier.preferredHeight(40.dp))
Spacer(Modifier.height(40.dp))
Row(modifier = Modifier.wrapContentWidth()) {
Spacer(Modifier.preferredWidth(20.dp))
Spacer(Modifier.width(20.dp))
ImagePanel(Modifier.width(360.dp))
Spacer(Modifier.preferredWidth(20.dp))
Spacer(Modifier.width(20.dp))
Column(
modifier = Modifier.wrapContentWidth(),
verticalArrangement = Arrangement.spacedBy(20.dp)
@ -159,9 +154,9 @@ fun LandscapeLayout() {
VignettePanel(modifier = Modifier.width(shortSlideWidth))
BrightnessPanel(modifier = Modifier.width(shortSlideWidth))
}
Spacer(Modifier.preferredWidth(20.dp))
Spacer(Modifier.width(20.dp))
}
Spacer(Modifier.preferredHeight(30.dp))
Spacer(Modifier.height(30.dp))
ShortFilterControl()
}
}

Просмотреть файл

@ -1,3 +1,8 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
package com.microsoft.device.display.samples.companionpane.ui
import androidx.compose.ui.graphics.Color

Просмотреть файл

@ -1,3 +1,8 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
package com.microsoft.device.display.samples.companionpane.ui
import androidx.compose.foundation.shape.RoundedCornerShape

Просмотреть файл

@ -1,3 +1,8 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
package com.microsoft.device.display.samples.companionpane.ui
import androidx.compose.foundation.isSystemInDarkTheme

Просмотреть файл

@ -1,3 +1,8 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
package com.microsoft.device.display.samples.companionpane.ui
import androidx.compose.material.Typography

Просмотреть файл

@ -1,9 +1,6 @@
/*
*
* * Copyright (c) Microsoft Corporation. All rights reserved.
* * Licensed under the MIT License.
* *
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
package com.microsoft.device.display.samples.companionpane.uicomponent

Просмотреть файл

@ -1,9 +1,6 @@
/*
*
* * Copyright (c) Microsoft Corporation. All rights reserved.
* * Licensed under the MIT License.
* *
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
package com.microsoft.device.display.samples.companionpane.uicomponent
@ -14,9 +11,10 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.preferredWidth
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.text.BasicText
import androidx.compose.material.Slider
import androidx.compose.material.SliderDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@ -26,7 +24,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.imageResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
@ -43,9 +41,11 @@ fun SliderControl(modifier: Modifier) {
value = sliderPosition,
onValueChange = { sliderPosition = it },
valueRange = 0f..100f,
thumbColor = Color.White,
activeTrackColor = Color.White,
inactiveTrackColor = Gray,
colors = SliderDefaults.colors(
thumbColor = Color.White,
activeTrackColor = Color.White,
inactiveTrackColor = Gray
),
modifier = modifier
)
}
@ -56,7 +56,7 @@ fun LeftAlignText(title: String) {
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.Start
) {
Spacer(Modifier.preferredWidth(30.dp))
Spacer(Modifier.width(30.dp))
BasicText(
text = title,
style = TextStyle(
@ -71,13 +71,13 @@ fun LeftAlignText(title: String) {
@Composable
fun ImageWithText(id: Int, text: String, imageWidth: Dp, width: Dp) {
Column(
modifier = Modifier.preferredWidth(width),
modifier = Modifier.width(width),
verticalArrangement = Arrangement.spacedBy(5.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Image(
bitmap = imageResource(id = id),
modifier = Modifier.preferredWidth(imageWidth),
painter = painterResource(id = id),
modifier = Modifier.width(imageWidth),
alignment = Alignment.Center,
contentDescription = null
)
@ -96,7 +96,7 @@ fun ImageWithText(id: Int, text: String, imageWidth: Dp, width: Dp) {
@Composable
fun ImagePanel(modifier: Modifier) {
Image(
bitmap = imageResource(R.drawable.full_image),
painter = painterResource(R.drawable.full_image),
modifier = modifier,
contentScale = ContentScale.Inside,
alignment = Alignment.Center,

Просмотреть файл

@ -1,3 +1,8 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
package com.microsoft.device.display.samples.companionpane.uicomponent
import androidx.compose.foundation.Image
@ -7,14 +12,13 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.preferredHeight
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.imageResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.microsoft.device.display.samples.companionpane.R
@ -24,7 +28,7 @@ fun EffectPanel() {
val imageWidth = 80.dp
val controlWidth = 100.dp
LeftAlignText(title = "Filters")
Spacer(Modifier.preferredHeight(10.dp))
Spacer(Modifier.height(10.dp))
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceEvenly) {
ImageWithText(R.drawable.gingham, "Gingham", imageWidth, controlWidth)
ImageWithText(R.drawable.orignal, "Original", imageWidth, controlWidth)
@ -69,14 +73,14 @@ fun AdjustScale() {
verticalArrangement = Arrangement.spacedBy(5.dp)
) {
Image(
bitmap = imageResource(R.drawable.dot),
painter = painterResource(R.drawable.dot),
modifier = Modifier.fillMaxWidth().height(5.dp),
contentScale = ContentScale.Inside,
alignment = Alignment.Center,
contentDescription = null
)
Image(
bitmap = imageResource(R.drawable.scale_icon),
painter = painterResource(R.drawable.scale_icon),
modifier = Modifier.fillMaxWidth().height(25.dp),
contentScale = ContentScale.Inside,
alignment = Alignment.Center,
@ -92,31 +96,31 @@ fun FullIconsPanel() {
horizontalArrangement = Arrangement.SpaceEvenly
) {
Image(
bitmap = imageResource(id = R.drawable.filter_icon),
painter = painterResource(id = R.drawable.filter_icon),
contentDescription = null
)
Image(
bitmap = imageResource(id = R.drawable.hdr_icon),
painter = painterResource(id = R.drawable.hdr_icon),
contentDescription = null
)
Image(
bitmap = imageResource(id = R.drawable.ecllipse_icon),
painter = painterResource(id = R.drawable.ecllipse_icon),
contentDescription = null
)
Image(
bitmap = imageResource(id = R.drawable.vertical_icon),
painter = painterResource(id = R.drawable.vertical_icon),
contentDescription = null
)
Image(
bitmap = imageResource(id = R.drawable.horizontal_icon),
painter = painterResource(id = R.drawable.horizontal_icon),
contentDescription = null
)
Image(
bitmap = imageResource(id = R.drawable.zoom_icon),
painter = painterResource(id = R.drawable.zoom_icon),
contentDescription = null
)
Image(
bitmap = imageResource(id = R.drawable.brightness_icon),
painter = painterResource(id = R.drawable.brightness_icon),
contentDescription = null
)
}
@ -129,15 +133,15 @@ fun ShortIconsPanel() {
horizontalArrangement = Arrangement.SpaceEvenly
) {
Image(
bitmap = imageResource(id = R.drawable.ecllipse_icon),
painter = painterResource(id = R.drawable.ecllipse_icon),
contentDescription = null
)
Image(
bitmap = imageResource(id = R.drawable.vertical_icon),
painter = painterResource(id = R.drawable.vertical_icon),
contentDescription = null
)
Image(
bitmap = imageResource(id = R.drawable.horizontal_icon),
painter = painterResource(id = R.drawable.horizontal_icon),
contentDescription = null
)
}

Просмотреть файл

@ -1,9 +1,6 @@
/*
*
* * Copyright (c) Microsoft Corporation. All rights reserved.
* * Licensed under the MIT License.
* *
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
package com.microsoft.device.display.samples.companionpane.viewModels

Просмотреть файл

@ -1,3 +1,8 @@
<!--
~ Copyright (c) Microsoft Corporation. All rights reserved.
~ Licensed under the MIT License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 504 B

После

Ширина:  |  Высота:  |  Размер: 504 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 460 B

После

Ширина:  |  Высота:  |  Размер: 460 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.7 KiB

После

Ширина:  |  Высота:  |  Размер: 1.7 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 315 B

После

Ширина:  |  Высота:  |  Размер: 315 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 2.4 KiB

После

Ширина:  |  Высота:  |  Размер: 2.4 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 978 B

После

Ширина:  |  Высота:  |  Размер: 978 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 2.9 MiB

После

Ширина:  |  Высота:  |  Размер: 2.9 MiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 126 KiB

После

Ширина:  |  Высота:  |  Размер: 126 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.6 KiB

После

Ширина:  |  Высота:  |  Размер: 1.6 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 2.3 KiB

После

Ширина:  |  Высота:  |  Размер: 2.3 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 259 B

После

Ширина:  |  Высота:  |  Размер: 259 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 839 B

После

Ширина:  |  Высота:  |  Размер: 839 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 270 B

После

Ширина:  |  Высота:  |  Размер: 270 B

Просмотреть файл

@ -1,4 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) Microsoft Corporation. All rights reserved.
~ Licensed under the MIT License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"

Просмотреть файл

@ -1,8 +1,6 @@
<!--
~
~ Copyright (c) Microsoft Corporation. All rights reserved.
~ Licensed under the MIT License.
~
~ Copyright (c) Microsoft Corporation. All rights reserved.
~ Licensed under the MIT License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 276 B

После

Ширина:  |  Высота:  |  Размер: 276 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 136 KiB

После

Ширина:  |  Высота:  |  Размер: 136 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 137 KiB

После

Ширина:  |  Высота:  |  Размер: 137 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 133 KiB

После

Ширина:  |  Высота:  |  Размер: 133 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 138 KiB

После

Ширина:  |  Высота:  |  Размер: 138 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 741 B

После

Ширина:  |  Высота:  |  Размер: 741 B

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.8 KiB

После

Ширина:  |  Высота:  |  Размер: 1.8 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.2 KiB

После

Ширина:  |  Высота:  |  Размер: 1.2 KiB

Просмотреть файл

@ -1,4 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) Microsoft Corporation. All rights reserved.
~ Licensed under the MIT License.
-->
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />

Просмотреть файл

@ -1,4 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) Microsoft Corporation. All rights reserved.
~ Licensed under the MIT License.
-->
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 3.5 KiB

После

Ширина:  |  Высота:  |  Размер: 3.5 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 5.2 KiB

После

Ширина:  |  Высота:  |  Размер: 5.2 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 2.6 KiB

После

Ширина:  |  Высота:  |  Размер: 2.6 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 3.3 KiB

После

Ширина:  |  Высота:  |  Размер: 3.3 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 4.8 KiB

После

Ширина:  |  Высота:  |  Размер: 4.8 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 7.3 KiB

После

Ширина:  |  Высота:  |  Размер: 7.3 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 7.7 KiB

После

Ширина:  |  Высота:  |  Размер: 7.7 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 12 KiB

После

Ширина:  |  Высота:  |  Размер: 12 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 10 KiB

После

Ширина:  |  Высота:  |  Размер: 10 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 16 KiB

После

Ширина:  |  Высота:  |  Размер: 16 KiB

Просмотреть файл

@ -1,3 +1,8 @@
<!--
~ Copyright (c) Microsoft Corporation. All rights reserved.
~ Licensed under the MIT License.
-->
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.CompanionPaneApps" parent="Theme.MaterialComponents.DayNight.DarkActionBar">

Просмотреть файл

@ -1,4 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) Microsoft Corporation. All rights reserved.
~ Licensed under the MIT License.
-->
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>

Просмотреть файл

@ -0,0 +1,8 @@
<!--
~ Copyright (c) Microsoft Corporation. All rights reserved.
~ Licensed under the MIT License.
-->
<resources>
<string name="app_name">Companion Pane-Compose</string>
</resources>

Просмотреть файл

@ -1,3 +1,8 @@
<!--
~ Copyright (c) Microsoft Corporation. All rights reserved.
~ Licensed under the MIT License.
-->
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.CompanionPaneApps" parent="Theme.MaterialComponents.DayNight.DarkActionBar">

Просмотреть файл

@ -1,52 +0,0 @@
/*
*
* * Copyright (c) Microsoft Corporation. All rights reserved.
* * Licensed under the MIT License.
*
*/
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.microsoft.device.display.samples.composegallery"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerVersion "$kotlinVersion"
kotlinCompilerExtensionVersion "$composeVersion"
}
}
dependencies {
implementation kotlinDependencies.kotlinStdlib
implementation androidxDependencies.ktxCore
implementation androidxDependencies.appCompat
implementation androidxDependencies.window
implementation androidxDependencies.compose
implementation androidxDependencies.composeRuntime
implementation androidxDependencies.composeMaterial
implementation androidxDependencies.composeUI
implementation androidxDependencies.composeUITooling
implementation googleDependencies.material
}

Двоичные данные
ComposeGallery/app/src/main/res/.DS_Store поставляемый

Двоичный файл не отображается.

Просмотреть файл

@ -1,3 +0,0 @@
<resources>
<string name="app_name">Compose Gallery</string>
</resources>

Просмотреть файл

@ -1,38 +1,45 @@
/*
*
* * Copyright (c) Microsoft Corporation. All rights reserved.
* * Licensed under the MIT License.
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
apply from: 'dependencies.gradle'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
repositories {
google()
jcenter()
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.microsoft.device.display.samples.composegallery"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
}
dependencies {
classpath config.gradlePlugin
classpath config.kotlinGradlePlugin
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
allprojects {
repositories {
google()
jcenter()
}
apply from: "$rootDir/ktlint.gradle"
}
task clean(type: Delete) {
delete rootProject.buildDir
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = '1.8'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion composeVersion
}
}
dependencies {
implementation kotlinDependencies.kotlinStdlib
implementation androidxDependencies.ktxCore
implementation androidxDependencies.appCompat
implementation androidxDependencies.window
implementation androidxDependencies.composeUI
implementation androidxDependencies.composeRuntime
implementation androidxDependencies.composeMaterial
implementation androidxDependencies.composeUITooling
implementation androidxDependencies.activityCompose
implementation googleDependencies.material
}

Просмотреть файл

@ -1,54 +0,0 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*
*/
ext {
gradlePluginVersion = '7.0.0-alpha05'
kotlinVersion = "1.4.21-2"
compileSdkVersion = 29
targetSdkVersion = compileSdkVersion
minSdkVersion = 21
config = [
gradlePlugin : "com.android.tools.build:gradle:$gradlePluginVersion",
kotlinGradlePlugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion",
]
kotlinDependencies = [
kotlinStdlib: "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
]
//AndroidX versions
appCompatVersion = "1.1.0"
ktxCoreVersion = "1.3.0"
constraintLayoutVersion = "1.1.3"
recyclerViewVersion = "1.1.0"
cardViewVersion = "1.0.0"
ktxFragmentVersion = "1.2.4"
viewPager2Version = "1.0.0"
localBroadcastManagerVersion = "1.0.0"
preferenceVersion = "1.1.1"
composeVersion = "1.0.0-alpha11"
windowVersion = "1.0.0-alpha02"
androidxDependencies = [
appCompat : "androidx.appcompat:appcompat:$appCompatVersion",
ktxCore : "androidx.core:core-ktx:$ktxCoreVersion",
window : "androidx.window:window:$windowVersion",
compose : "androidx.compose.ui:ui:$composeVersion",
composeRuntime : "androidx.compose.runtime:runtime-livedata:$composeVersion",
composeMaterial : "androidx.compose.material:material:$composeVersion",
composeUI : "androidx.compose.ui:ui:$composeVersion",
composeUITooling : "androidx.compose.ui:ui-tooling:$composeVersion",
]
//Google dependencies
materialVersion = "1.1.0"
googleDependencies = [
material: "com.google.android.material:material:$materialVersion"
]
}

Просмотреть файл

@ -1,16 +0,0 @@
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Mon Aug 31 14:15:30 PDT 2020
android.useAndroidX=true
android.enableJetifier=true
org.gradle.jvmargs=-Xmx1536m

Просмотреть файл

@ -1,8 +0,0 @@
#Fri Oct 23 16:36:46 PDT 2020
distributionBase=GRADLE_USER_HOME
distributionUrl=https://services.gradle.org/distributions/gradle-6.8-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
android.useAndroidX=true
android.enableJetifier=true

172
ComposeGallery/gradlew поставляемый
Просмотреть файл

@ -1,172 +0,0 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

84
ComposeGallery/gradlew.bat поставляемый
Просмотреть файл

@ -1,84 +0,0 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

Просмотреть файл

@ -1,34 +0,0 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*
*/
repositories {
jcenter()
}
configurations {
ktlint
}
dependencies {
ktlint "com.pinterest:ktlint:0.37.2"
}
task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "src/**/*.kt"
// to generate report in checkstyle format prepend following args:
// "--reporter=plain", "--reporter=checkstyle,output=${buildDir}/ktlint.xml"
// see https://github.com/pinterest/ktlint#usage for more
}
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "-F", "src/**/*.kt"
}

Просмотреть файл

@ -1,2 +0,0 @@
rootProject.name = "ComposeGallery"
include ':app'

Просмотреть файл

@ -1,4 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) Microsoft Corporation. All rights reserved.
~ Licensed under the MIT License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.microsoft.device.display.samples.composegallery">

Просмотреть файл

@ -1,23 +1,21 @@
/*
*
* * Copyright (c) Microsoft Corporation. All rights reserved.
* * Licensed under the MIT License.
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
package com.microsoft.device.display.samples.composegallery
import android.util.Log
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.preferredHeight
import androidx.compose.foundation.layout.preferredWidth
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
@ -29,7 +27,7 @@ import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.loadImageResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
@ -40,7 +38,6 @@ import com.microsoft.device.display.samples.composegallery.models.ImageModel
import com.microsoft.device.display.samples.composegallery.viewModels.AppStateViewModel
private lateinit var appStateViewModel: AppStateViewModel
private val DEBUG_TAG = "ComposeGallery"
@Preview
@Composable
@ -60,8 +57,6 @@ fun SetupUI() {
val isScreenSpannedLiveData = appStateViewModel.getIsScreenSpannedLiveData()
val isScreenSpanned = isScreenSpannedLiveData.observeAsState(initial = false).value
Log.i(DEBUG_TAG, "SetupUI isScreenSpanned: $isScreenSpanned")
if (isScreenSpanned) {
ShowDetailWithList(models)
} else {
@ -92,19 +87,20 @@ private fun ShowListColumn(models: List<ImageModel>, modifier: Modifier) {
) then Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically
) {
val image = loadImageResource(id = item.image)
image.resource.resource?.let {
Image(
bitmap = it,
modifier = Modifier.preferredHeight(100.dp).preferredWidth(150.dp),
contentDescription = null
)
}
Spacer(Modifier.preferredWidth(16.dp))
Image(
painter = painterResource(id = item.image),
modifier = Modifier
.height(100.dp)
.width(150.dp),
contentDescription = null
)
Spacer(Modifier.width(16.dp))
Column(modifier = Modifier.fillMaxHeight() then Modifier.padding(16.dp)) {
BasicText(
text = item.id,
modifier = Modifier.fillMaxHeight().wrapContentSize(Alignment.Center),
modifier = Modifier
.fillMaxHeight()
.wrapContentSize(Alignment.Center),
style = TextStyle(
fontSize = 20.sp,
fontWeight = FontWeight.Bold
@ -112,7 +108,9 @@ private fun ShowListColumn(models: List<ImageModel>, modifier: Modifier) {
)
BasicText(
text = item.title,
modifier = Modifier.fillMaxHeight().wrapContentSize(Alignment.Center)
modifier = Modifier
.fillMaxHeight()
.wrapContentSize(Alignment.Center)
)
}
}
@ -128,14 +126,22 @@ fun ShowDetailWithList(models: List<ImageModel>) {
val selectedImageModel = models[selectedIndex]
Row(
modifier = Modifier.fillMaxHeight().wrapContentSize(Alignment.Center)
then Modifier.fillMaxWidth().wrapContentSize(Alignment.Center)
modifier = Modifier
.fillMaxSize()
.wrapContentSize(Alignment.Center)
) {
ShowListColumn(
models, Modifier.fillMaxHeight().wrapContentSize(Alignment.Center).weight(1f)
models,
Modifier
.fillMaxHeight()
.wrapContentSize(Alignment.Center)
.weight(1f)
)
Column(
modifier = Modifier.fillMaxHeight().wrapContentSize(Alignment.Center).weight(1f),
modifier = Modifier
.fillMaxHeight()
.wrapContentSize(Alignment.Center)
.weight(1f),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(space = 20.dp)
) {
@ -143,13 +149,10 @@ fun ShowDetailWithList(models: List<ImageModel>) {
text = selectedImageModel.id,
style = TextStyle(fontSize = 50.sp)
)
val image = loadImageResource(id = selectedImageModel.image)
image.resource.resource?.let {
Image(
bitmap = it,
contentDescription = null
)
}
Image(
painter = painterResource(id = selectedImageModel.image),
contentDescription = null
)
}
}
}

Просмотреть файл

@ -1,8 +1,6 @@
/*
*
* * Copyright (c) Microsoft Corporation. All rights reserved.
* * Licensed under the MIT License.
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
package com.microsoft.device.display.samples.composegallery
@ -10,10 +8,10 @@ package com.microsoft.device.display.samples.composegallery
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.ui.platform.setContent
import androidx.core.util.Consumer
import androidx.lifecycle.ViewModelProvider
import androidx.window.WindowLayoutInfo

Просмотреть файл

@ -1,8 +1,6 @@
/*
*
* * Copyright (c) Microsoft Corporation. All rights reserved.
* * Licensed under the MIT License.
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
package com.microsoft.device.display.samples.composegallery.models

Просмотреть файл

@ -1,8 +1,6 @@
/*
*
* * Copyright (c) Microsoft Corporation. All rights reserved.
* * Licensed under the MIT License.
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
package com.microsoft.device.display.samples.composegallery.models

Просмотреть файл

@ -1,8 +1,6 @@
/*
*
* * Copyright (c) Microsoft Corporation. All rights reserved.
* * Licensed under the MIT License.
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
package com.microsoft.device.display.samples.composegallery.ui

Просмотреть файл

@ -1,8 +1,6 @@
/*
*
* * Copyright (c) Microsoft Corporation. All rights reserved.
* * Licensed under the MIT License.
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
package com.microsoft.device.display.samples.composegallery.ui

Просмотреть файл

@ -1,8 +1,6 @@
/*
*
* * Copyright (c) Microsoft Corporation. All rights reserved.
* * Licensed under the MIT License.
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
package com.microsoft.device.display.samples.composegallery.ui

Просмотреть файл

@ -1,8 +1,6 @@
/*
*
* * Copyright (c) Microsoft Corporation. All rights reserved.
* * Licensed under the MIT License.
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
package com.microsoft.device.display.samples.composegallery.ui

Просмотреть файл

@ -1,8 +1,6 @@
/*
*
* * Copyright (c) Microsoft Corporation. All rights reserved.
* * Licensed under the MIT License.
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
package com.microsoft.device.display.samples.composegallery.viewModels

Просмотреть файл

@ -1,3 +1,8 @@
<!--
~ Copyright (c) Microsoft Corporation. All rights reserved.
~ Licensed under the MIT License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"

Просмотреть файл

@ -1,4 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) Microsoft Corporation. All rights reserved.
~ Licensed under the MIT License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 728 KiB

После

Ширина:  |  Высота:  |  Размер: 728 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 553 KiB

После

Ширина:  |  Высота:  |  Размер: 553 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 432 KiB

После

Ширина:  |  Высота:  |  Размер: 432 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 837 KiB

После

Ширина:  |  Высота:  |  Размер: 837 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 466 KiB

После

Ширина:  |  Высота:  |  Размер: 466 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 519 KiB

После

Ширина:  |  Высота:  |  Размер: 519 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 798 KiB

После

Ширина:  |  Высота:  |  Размер: 798 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 660 KiB

После

Ширина:  |  Высота:  |  Размер: 660 KiB

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше