Skip to content
This repository was archived by the owner on Nov 21, 2024. It is now read-only.

Commit 83da7f4

Browse files
committed
Initial commit.
Change-Id: I9ecd81923cdc2918a1134fc564cdeb9a8be95f74
1 parent 141ad6a commit 83da7f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2290
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
build
2+
captures
3+
*.iml
4+
out
5+
.idea
6+
prebuilts
7+
.DS_Store
8+
local.properties
9+
.gradle

app/build.gradle

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright (c) 2019 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software distributed under the License
9+
*
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
15+
apply plugin: 'com.android.application'
16+
apply plugin: 'kotlin-android'
17+
apply plugin: 'kotlin-kapt'
18+
19+
android {
20+
compileSdkVersion 29
21+
buildToolsVersion "29.0.0"
22+
defaultConfig {
23+
applicationId "com.materialstudies.owl"
24+
minSdkVersion 23
25+
targetSdkVersion 29
26+
versionCode 1
27+
versionName "1.0"
28+
vectorDrawables.useSupportLibrary = true
29+
}
30+
dataBinding {
31+
enabled true
32+
}
33+
buildTypes {
34+
release {
35+
minifyEnabled false
36+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
37+
}
38+
}
39+
}
40+
41+
ext {
42+
navigation_version = "2.1.0-alpha05"
43+
}
44+
45+
dependencies {
46+
implementation 'androidx.appcompat:appcompat:1.1.0-beta01'
47+
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
48+
implementation 'androidx.core:core-ktx:1.0.2'
49+
implementation 'com.google.android.material:material:1.1.0-alpha07'
50+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
51+
52+
implementation "androidx.navigation:navigation-runtime:$navigation_version"
53+
implementation "androidx.navigation:navigation-runtime-ktx:$navigation_version"
54+
implementation "androidx.navigation:navigation-fragment:$navigation_version"
55+
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
56+
implementation "androidx.navigation:navigation-ui:$navigation_version"
57+
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
58+
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
59+
60+
implementation 'com.github.bumptech.glide:glide:4.9.0'
61+
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
62+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
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

app/src/main/AndroidManifest.xml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright (c) 2019 Google Inc.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6+
in compliance with the License. You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software distributed under the License
11+
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12+
or implied. See the License for the specific language governing permissions and limitations under
13+
the License.
14+
-->
15+
<manifest
16+
xmlns:android="http://schemas.android.com/apk/res/android"
17+
xmlns:tools="http://schemas.android.com/tools"
18+
package="com.materialstudies.owl">
19+
20+
<!--Load images from Unsplash-->
21+
<uses-permission android:name="android.permission.INTERNET"/>
22+
23+
<application
24+
android:allowBackup="true"
25+
android:icon="@mipmap/ic_launcher"
26+
android:label="@string/app_name"
27+
android:name="OwlApplication"
28+
android:roundIcon="@mipmap/ic_launcher_round"
29+
android:supportsRtl="true"
30+
android:theme="@style/Owl"
31+
tools:ignore="GoogleAppIndexingWarning">
32+
33+
<activity
34+
android:name=".ui.MainActivity"
35+
android:theme="@style/Owl.Theme2">
36+
<intent-filter>
37+
<action android:name="android.intent.action.MAIN"/>
38+
<category android:name="android.intent.category.LAUNCHER"/>
39+
</intent-filter>
40+
</activity>
41+
42+
<!--Preload custom fonts-->
43+
<meta-data
44+
android:name="preloaded_fonts"
45+
android:resource="@array/preloaded_fonts"/>
46+
<meta-data
47+
android:name="fontProviderRequests"
48+
android:value="Rubik"/>
49+
50+
</application>
51+
52+
</manifest>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2019 Google LLC
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.materialstudies.owl
18+
19+
import android.app.Application
20+
import android.os.Build.VERSION.SDK_INT
21+
import android.os.Build.VERSION_CODES.Q
22+
import androidx.appcompat.app.AppCompatDelegate
23+
24+
class OwlApplication : Application() {
25+
26+
override fun onCreate() {
27+
super.onCreate()
28+
val nightMode = if (SDK_INT >= Q) {
29+
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
30+
} else {
31+
AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY
32+
}
33+
AppCompatDelegate.setDefaultNightMode(nightMode)
34+
}
35+
36+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2019 Google LLC
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.materialstudies.owl.ui
18+
19+
import android.os.Bundle
20+
import androidx.appcompat.app.AppCompatActivity
21+
import androidx.navigation.Navigation
22+
import androidx.navigation.ui.setupWithNavController
23+
import com.materialstudies.owl.R
24+
import com.materialstudies.owl.databinding.ActivityMainBinding
25+
import com.materialstudies.owl.util.contentView
26+
27+
class MainActivity : AppCompatActivity() {
28+
29+
private val binding: ActivityMainBinding by contentView(R.layout.activity_main)
30+
31+
override fun onCreate(savedInstanceState: Bundle?) {
32+
super.onCreate(savedInstanceState)
33+
binding.apply {
34+
val navController = Navigation.findNavController(this@MainActivity, R.id.nav_host)
35+
bottomNav.setupWithNavController(navController)
36+
}
37+
}
38+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2019 Google LLC
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.materialstudies.owl.ui.featured
18+
19+
import android.os.Bundle
20+
import android.view.LayoutInflater
21+
import android.view.View
22+
import android.view.ViewGroup
23+
import androidx.fragment.app.Fragment
24+
import com.materialstudies.owl.R
25+
26+
class FeaturedFragment : Fragment() {
27+
override fun onCreate(savedInstanceState: Bundle?) {
28+
super.onCreate(savedInstanceState)
29+
}
30+
31+
override fun onCreateView(
32+
inflater: LayoutInflater,
33+
container: ViewGroup?,
34+
savedInstanceState: Bundle?
35+
): View? {
36+
// Inflate the layout for this fragment
37+
return inflater.inflate(R.layout.fragment_featured, container, false)
38+
}
39+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright (c) 2019 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software distributed under the License
9+
*
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
package com.materialstudies.owl.ui.mycourses
15+
16+
data class Course(
17+
val id: Long,
18+
val name: String,
19+
val thumb: String,
20+
val thumbContentDesc: String,
21+
val steps: Int,
22+
val step: Int,
23+
val instructor: String
24+
)
25+
26+
val courses = listOf(
27+
Course(
28+
id = 0,
29+
name = "Basic Blocks and Woodturning",
30+
thumb = "",
31+
thumbContentDesc = "",
32+
steps = 7,
33+
step = 1,
34+
instructor = ""),
35+
Course(
36+
id = 1,
37+
name = "Foos and Bars",
38+
thumb = "",
39+
thumbContentDesc = "",
40+
steps = 7,
41+
step = 1,
42+
instructor = ""),
43+
Course(
44+
id = 2,
45+
name = "Bazs and baxs",
46+
thumb = "",
47+
thumbContentDesc = "",
48+
steps = 7,
49+
step = 1,
50+
instructor = "")
51+
)
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright (c) 2019 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software distributed under the License
9+
*
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
15+
package com.materialstudies.owl.ui.mycourses
16+
17+
import android.view.LayoutInflater
18+
import android.view.ViewGroup
19+
import androidx.lifecycle.LifecycleOwner
20+
import androidx.recyclerview.widget.DiffUtil
21+
import androidx.recyclerview.widget.ListAdapter
22+
import androidx.recyclerview.widget.RecyclerView
23+
import com.bumptech.glide.Glide
24+
import com.materialstudies.owl.R
25+
import com.materialstudies.owl.databinding.CourseItemBinding
26+
import com.materialstudies.owl.util.ShapeAppearanceTransformation
27+
28+
class MyCourseViewHolder(
29+
private val binding: CourseItemBinding
30+
) : RecyclerView.ViewHolder(binding.root) {
31+
32+
fun bind(course: Course, imageTransform: ShapeAppearanceTransformation) {
33+
binding.course = course
34+
Glide.with(binding.courseImage)
35+
.load("https://source.unsplash.com/random/200x200")
36+
.transform(imageTransform)
37+
.into(binding.courseImage)
38+
Glide.with(binding.courseInstructor)
39+
.load("https://i.pravatar.cc/56")
40+
.circleCrop()
41+
.into(binding.courseInstructor)
42+
binding.executePendingBindings()
43+
}
44+
}
45+
46+
class MyCoursesAdapter(private val lifecycle: LifecycleOwner) :
47+
ListAdapter<Course, MyCourseViewHolder>(CourseDiff) {
48+
49+
private val shapeTransform =
50+
ShapeAppearanceTransformation(R.style.ShapeAppearance_Owl_SmallComponent)
51+
52+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyCourseViewHolder {
53+
val binding =
54+
CourseItemBinding.inflate(LayoutInflater.from(parent.context), parent, false).apply {
55+
lifecycleOwner = lifecycle
56+
}
57+
return MyCourseViewHolder(binding)
58+
}
59+
60+
override fun onBindViewHolder(holder: MyCourseViewHolder, position: Int) {
61+
holder.bind(getItem(position), shapeTransform)
62+
}
63+
64+
object CourseDiff : DiffUtil.ItemCallback<Course>() {
65+
override fun areItemsTheSame(oldItem: Course, newItem: Course) = oldItem.id == newItem.id
66+
override fun areContentsTheSame(oldItem: Course, newItem: Course) = oldItem == newItem
67+
}
68+
}

0 commit comments

Comments
 (0)