Skip to content

Commit eb242ce

Browse files
committedJul 29, 2020
[Rally] Migrates Rally from aosp to samples repo
Snapshot: 6710852 Change-Id: I445b328ed216be0f014b6e729c1464921f5ec8f8
1 parent 2781212 commit eb242ce

40 files changed

+2217
-0
lines changed
 

‎Rally/.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

‎Rally/ASSETS_LICENSE

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
All font files are licensed under the SIL OPEN FONT LICENSE license. All other files are licensed under the Apache 2 license.
2+
3+
4+
SIL OPEN FONT LICENSE
5+
Version 1.1 - 26 February 2007
6+
7+
PREAMBLE
8+
The goals of the Open Font License (OFL) are to stimulate worldwide
9+
development of collaborative font projects, to support the font creation
10+
efforts of academic and linguistic communities, and to provide a free and
11+
open framework in which fonts may be shared and improved in partnership
12+
with others.
13+
14+
The OFL allows the licensed fonts to be used, studied, modified and
15+
redistributed freely as long as they are not sold by themselves. The
16+
fonts, including any derivative works, can be bundled, embedded,
17+
redistributed and/or sold with any software provided that any reserved
18+
names are not used by derivative works. The fonts and derivatives,
19+
however, cannot be released under any other type of license. The
20+
requirement for fonts to remain under this license does not apply
21+
to any document created using the fonts or their derivatives.
22+
23+
DEFINITIONS
24+
"Font Software" refers to the set of files released by the Copyright
25+
Holder(s) under this license and clearly marked as such. This may
26+
include source files, build scripts and documentation.
27+
28+
"Reserved Font Name" refers to any names specified as such after the
29+
copyright statement(s).
30+
31+
"Original Version" refers to the collection of Font Software components as
32+
distributed by the Copyright Holder(s).
33+
34+
"Modified Version" refers to any derivative made by adding to, deleting,
35+
or substituting — in part or in whole — any of the components of the
36+
Original Version, by changing formats or by porting the Font Software to a
37+
new environment.
38+
39+
"Author" refers to any designer, engineer, programmer, technical
40+
writer or other person who contributed to the Font Software.
41+
42+
PERMISSION & CONDITIONS
43+
Permission is hereby granted, free of charge, to any person obtaining
44+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
45+
redistribute, and sell modified and unmodified copies of the Font
46+
Software, subject to the following conditions:
47+
48+
1) Neither the Font Software nor any of its individual components,
49+
in Original or Modified Versions, may be sold by itself.
50+
51+
2) Original or Modified Versions of the Font Software may be bundled,
52+
redistributed and/or sold with any software, provided that each copy
53+
contains the above copyright notice and this license. These can be
54+
included either as stand-alone text files, human-readable headers or
55+
in the appropriate machine-readable metadata fields within text or
56+
binary files as long as those fields can be easily viewed by the user.
57+
58+
3) No Modified Version of the Font Software may use the Reserved Font
59+
Name(s) unless explicit written permission is granted by the corresponding
60+
Copyright Holder. This restriction only applies to the primary font name as
61+
presented to the users.
62+
63+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
64+
Software shall not be used to promote, endorse or advertise any
65+
Modified Version, except to acknowledge the contribution(s) of the
66+
Copyright Holder(s) and the Author(s) or with their explicit written
67+
permission.
68+
69+
5) The Font Software, modified or unmodified, in part or in whole,
70+
must be distributed entirely under this license, and must not be
71+
distributed under any other license. The requirement for fonts to
72+
remain under this license does not apply to any document created
73+
using the Font Software.
74+
75+
TERMINATION
76+
This license becomes null and void if any of the above conditions are
77+
not met.
78+
79+
DISCLAIMER
80+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
81+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
82+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
83+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
84+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
85+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
86+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
87+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
88+
OTHER DEALINGS IN THE FONT SOFTWARE.

‎Rally/app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

‎Rally/app/build.gradle

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
* Copyright 2020 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import com.example.compose.rally.buildsrc.Libs
18+
19+
plugins {
20+
id 'com.android.application'
21+
id 'kotlin-android'
22+
}
23+
24+
android {
25+
compileSdkVersion 30
26+
27+
defaultConfig {
28+
applicationId "com.example.compose.rally"
29+
minSdkVersion 21
30+
targetSdkVersion 30
31+
versionCode 1
32+
versionName '1.0'
33+
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
34+
35+
vectorDrawables.useSupportLibrary = true
36+
}
37+
38+
buildTypes {
39+
release {
40+
minifyEnabled false
41+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
42+
}
43+
}
44+
45+
compileOptions {
46+
sourceCompatibility JavaVersion.VERSION_1_8
47+
targetCompatibility JavaVersion.VERSION_1_8
48+
}
49+
50+
kotlinOptions {
51+
jvmTarget = '1.8'
52+
}
53+
54+
buildFeatures {
55+
compose true
56+
}
57+
58+
composeOptions {
59+
kotlinCompilerVersion Libs.AndroidX.Compose.kotlinCompilerVersion
60+
kotlinCompilerExtensionVersion Libs.AndroidX.Compose.version
61+
}
62+
63+
}
64+
65+
dependencies {
66+
implementation Libs.Kotlin.stdlib
67+
implementation Libs.Coroutines.android
68+
69+
implementation Libs.AndroidX.coreKtx
70+
implementation Libs.AndroidX.appcompat
71+
implementation Libs.AndroidX.Navigation.fragment
72+
implementation Libs.AndroidX.Navigation.uiKtx
73+
implementation Libs.material
74+
75+
implementation Libs.AndroidX.Compose.layout
76+
implementation Libs.AndroidX.Compose.material
77+
implementation Libs.AndroidX.Compose.materialIconsExtended
78+
implementation Libs.AndroidX.Compose.tooling
79+
implementation Libs.AndroidX.Compose.runtime
80+
implementation Libs.AndroidX.Compose.runtimeLivedata
81+
82+
androidTestImplementation Libs.junit
83+
androidTestImplementation Libs.AndroidX.Test.core
84+
androidTestImplementation Libs.AndroidX.Test.espressoCore
85+
androidTestImplementation Libs.AndroidX.Test.rules
86+
androidTestImplementation Libs.AndroidX.Test.Ext.junit
87+
androidTestImplementation Libs.AndroidX.Compose.uiTest
88+
}
89+
90+
configurations.configureEach() {
91+
resolutionStrategy {
92+
eachDependency { DependencyResolveDetails details ->
93+
if (details.requested.group == 'org.jetbrains.kotlin') {
94+
details.useVersion Libs.Kotlin.version
95+
}
96+
}
97+
}
98+
}

‎Rally/app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright 2020 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
19+
package="com.example.compose.rally">
20+
21+
<application
22+
android:allowBackup="true"
23+
android:icon="@mipmap/ic_launcher"
24+
android:label="@string/app_name"
25+
android:supportsRtl="true"
26+
android:theme="@style/Theme.Rally">
27+
<activity
28+
android:name=".RallyActivity"
29+
android:windowSoftInputMode="adjustResize"
30+
android:label="@string/app_name">
31+
<intent-filter>
32+
<action android:name="android.intent.action.MAIN" />
33+
34+
<category android:name="android.intent.category.LAUNCHER" />
35+
</intent-filter>
36+
</activity>
37+
</application>
38+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright 2020 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.compose.rally
18+
19+
import android.os.Bundle
20+
import androidx.activity.ComponentActivity
21+
import androidx.compose.foundation.Box
22+
import androidx.compose.foundation.layout.padding
23+
import androidx.compose.material.Scaffold
24+
import androidx.compose.runtime.Composable
25+
import androidx.compose.runtime.getValue
26+
import androidx.compose.runtime.savedinstancestate.savedInstanceState
27+
import androidx.compose.runtime.setValue
28+
import androidx.compose.ui.Modifier
29+
import androidx.compose.ui.platform.setContent
30+
import com.example.compose.rally.ui.components.RallyTopAppBar
31+
import com.example.compose.rally.ui.theme.RallyTheme
32+
33+
/**
34+
* This Activity recreates part of the Rally Material Study from
35+
* https://material.io/design/material-studies/rally.html
36+
*/
37+
class RallyActivity : ComponentActivity() {
38+
override fun onCreate(savedInstanceState: Bundle?) {
39+
super.onCreate(savedInstanceState)
40+
setContent {
41+
RallyApp()
42+
}
43+
}
44+
}
45+
46+
@Composable
47+
fun RallyApp() {
48+
RallyTheme {
49+
val allScreens = RallyScreen.values().toList()
50+
var currentScreen by savedInstanceState { RallyScreen.Overview }
51+
Scaffold(
52+
topBar = {
53+
RallyTopAppBar(
54+
allScreens = allScreens,
55+
onTabSelected = { screen -> currentScreen = screen },
56+
currentScreen = currentScreen
57+
)
58+
}
59+
) { innerPadding ->
60+
Box(Modifier.padding(innerPadding)) {
61+
currentScreen.content(onScreenChange = { screen -> currentScreen = screen })
62+
}
63+
}
64+
}
65+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2020 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.compose.rally
18+
19+
import androidx.compose.material.icons.Icons
20+
import androidx.compose.material.icons.filled.AttachMoney
21+
import androidx.compose.material.icons.filled.MoneyOff
22+
import androidx.compose.material.icons.filled.PieChart
23+
import androidx.compose.runtime.Composable
24+
import androidx.compose.ui.graphics.vector.VectorAsset
25+
import com.example.compose.rally.data.UserData
26+
import com.example.compose.rally.ui.accounts.AccountsBody
27+
import com.example.compose.rally.ui.bills.BillsBody
28+
import com.example.compose.rally.ui.overview.OverviewBody
29+
30+
/**
31+
* Screen state for Rally. Navigation is kept simple until a proper mechanism is available. Back
32+
* navigation is not supported.
33+
*/
34+
enum class RallyScreen(
35+
val icon: VectorAsset,
36+
private val body: @Composable ((RallyScreen) -> Unit) -> Unit
37+
) {
38+
Overview(
39+
icon = Icons.Filled.PieChart,
40+
body = { onScreenChange -> OverviewBody(onScreenChange) }
41+
),
42+
Accounts(
43+
icon = Icons.Filled.AttachMoney,
44+
body = { AccountsBody(UserData.accounts) }
45+
),
46+
Bills(
47+
icon = Icons.Filled.MoneyOff,
48+
body = { BillsBody(UserData.bills) }
49+
);
50+
51+
@Composable
52+
fun content(onScreenChange: (RallyScreen) -> Unit) {
53+
body(onScreenChange)
54+
}
55+
}

0 commit comments

Comments
 (0)