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

Commit d5164b3

Browse files
author
Murat Yener
committed
initial code commit
1 parent 1a43b81 commit d5164b3

Some content is hidden

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

47 files changed

+2123
-1
lines changed

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
start/.gradle/5.1.1/gc.properties
2+
start/.gradle/5.1.1/executionHistory/executionHistory.bin
3+
start/.gradle/5.1.1/executionHistory/executionHistory.lock
4+
start/.gradle/5.1.1/fileChanges/last-build.bin
5+
start/.gradle/5.1.1/fileHashes/fileHashes.bin
6+
start/.gradle/5.1.1/fileHashes/fileHashes.lock
7+
start/.gradle/5.4.1/gc.properties
8+
start/.gradle/5.4.1/executionHistory/executionHistory.bin
9+
start/.gradle/5.4.1/executionHistory/executionHistory.lock
10+
start/.gradle/5.4.1/fileChanges/last-build.bin
11+
start/.gradle/5.4.1/fileContent/fileContent.lock
12+
start/.gradle/5.4.1/fileHashes/fileHashes.bin
13+
start/.gradle/5.4.1/fileHashes/fileHashes.lock
14+
start/.gradle/5.4.1/fileHashes/resourceHashesCache.bin
15+
start/.gradle/5.4.1/javaCompile/classAnalysis.bin
16+
start/.gradle/5.4.1/javaCompile/jarAnalysis.bin
17+
start/.gradle/5.4.1/javaCompile/javaCompile.lock
18+
start/.gradle/5.4.1/javaCompile/taskHistory.bin
19+
start/.gradle/buildOutputCleanup/buildOutputCleanup.lock
20+
start/.gradle/buildOutputCleanup/cache.properties
21+
start/.gradle/buildOutputCleanup/outputFiles.bin
22+
start/.gradle/vcs-1/gc.properties

CONTRIBUTING.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# How to become a contributor and submit your own code
2+
3+
## Contributor License Agreements
4+
5+
We'd love to accept your sample apps and patches! Before we can take them, we
6+
have to jump a couple of legal hurdles.
7+
8+
Please fill out either the individual or corporate Contributor License Agreement
9+
(CLA).
10+
11+
* If you are an individual writing original source code and you're sure you
12+
own the intellectual property, then you'll need to sign an [individual CLA]
13+
(https://developers.google.com/open-source/cla/individual).
14+
* If you work for a company that wants to allow you to contribute your work,
15+
then you'll need to sign a [corporate CLA]
16+
(https://developers.google.com/open-source/cla/corporate).
17+
18+
Follow either of the two links above to access the appropriate CLA and
19+
instructions for how to sign and return it. Once we receive it, we'll be able to
20+
accept your pull requests.
21+
22+
## Contributing A Patch
23+
24+
1. Submit an issue describing your proposed change to the repo in question.
25+
1. The repo owner will respond to your issue promptly.
26+
1. If your proposed change is accepted, and you haven't already done so, sign a
27+
Contributor License Agreement (see details above).
28+
1. Fork the desired repo, develop and test your code changes.
29+
1. Ensure that your code adheres to the existing style in the sample to which
30+
you are contributing. Refer to the
31+
[Google Cloud Platform Samples Style Guide]
32+
(https://github.com/GoogleCloudPlatform/Template/wiki/style.html) for the
33+
recommended coding standards for this organization.
34+
1. Ensure that your code has an appropriate set of unit tests which all pass.
35+
1. Submit a pull request.

LICENSE

Lines changed: 613 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,33 @@
1-
# android-kotlin-notifications
1+
EggTimer - Final Code
2+
============================================================================
3+
4+
Solution code for Advanced Android with Kotlin Codelab
5+
6+
Introduction
7+
------------
8+
9+
EggTimer is a timer app for cooking eggs.
10+
You can start and stop the timer, choose different cooking intervals..
11+
12+
In this codelab, working from this starter app, you:
13+
14+
* Add notitications to the eggtimer app.
15+
* Use channels and importance for the app notifications.
16+
* Customize and style the notifications.
17+
18+
19+
Pre-requisites
20+
--------------
21+
22+
You should be familiar with:
23+
24+
* Services, AlarmManager, Broadcast Receivers.
25+
26+
27+
Getting Started
28+
---------------
29+
30+
1. Download
31+
2. Swtich to start branch
32+
3. Run the app.
33+

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright (C) 2019 Google Inc.
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+
* http://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+
apply plugin: 'com.android.application'
18+
apply plugin: 'kotlin-android'
19+
apply plugin: 'kotlin-kapt'
20+
21+
android {
22+
compileSdkVersion 29
23+
defaultConfig {
24+
applicationId "com.example.android.eggtimernotifications"
25+
minSdkVersion 19
26+
targetSdkVersion 29
27+
versionCode 1
28+
versionName "1.0"
29+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
30+
}
31+
buildTypes {
32+
release {
33+
minifyEnabled false
34+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
35+
}
36+
}
37+
38+
// Enables data binding.
39+
dataBinding {
40+
enabled = true
41+
}
42+
}
43+
44+
dependencies {
45+
implementation fileTree(dir: 'libs', include: ['*.jar'])
46+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
47+
implementation 'androidx.appcompat:appcompat:1.0.2'
48+
implementation 'androidx.core:core-ktx:1.0.2'
49+
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
50+
51+
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
52+
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0-rc01'
53+
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0-rc01'
54+
testImplementation 'junit:junit:4.12'
55+
androidTestImplementation 'androidx.test:runner:1.2.0'
56+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
57+
58+
//for fcm
59+
implementation 'com.google.firebase:firebase-core:17.0.0'
60+
implementation 'com.google.firebase:firebase-iid:19.0.1'
61+
implementation 'com.google.firebase:firebase-messaging:19.0.1'
62+
implementation 'android.arch.work:work-runtime:1.0.1'
63+
}

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: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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");
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.android.eggtimernotifications">
20+
21+
<application
22+
android:allowBackup="true"
23+
android:icon="@drawable/egg_icon"
24+
android:label="@string/app_name"
25+
android:roundIcon="@drawable/egg_notification"
26+
android:supportsRtl="true"
27+
android:theme="@style/AppTheme">
28+
29+
<activity android:name=".MainActivity">
30+
<intent-filter>
31+
<action android:name="android.intent.action.MAIN"/>
32+
33+
<category android:name="android.intent.category.LAUNCHER"/>
34+
</intent-filter>
35+
</activity>
36+
37+
<receiver
38+
android:name=".receiver.AlarmReceiver"
39+
android:enabled="true"
40+
android:exported="false">
41+
</receiver>
42+
<receiver
43+
android:name=".receiver.SnoozeReceiver"
44+
android:enabled="true"
45+
android:exported="false">
46+
</receiver>
47+
48+
</application>
49+
50+
</manifest>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (C) 2019 Google Inc.
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+
* http://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.android.eggtimernotifications
18+
19+
import android.os.Bundle
20+
import androidx.appcompat.app.AppCompatActivity
21+
import com.example.android.eggtimernotifications.ui.EggTimerFragment
22+
23+
class MainActivity : AppCompatActivity() {
24+
25+
override fun onCreate(savedInstanceState: Bundle?) {
26+
super.onCreate(savedInstanceState)
27+
28+
setContentView(R.layout.activity_main)
29+
if (savedInstanceState == null) {
30+
supportFragmentManager.beginTransaction()
31+
.replace(R.id.container, EggTimerFragment.newInstance())
32+
.commitNow()
33+
}
34+
}
35+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (C) 2019 Google Inc.
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+
* http://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.android.eggtimernotifications.receiver
18+
19+
import android.app.NotificationManager
20+
import android.content.BroadcastReceiver
21+
import android.content.Context
22+
import android.content.Intent
23+
import android.widget.Toast
24+
import androidx.core.content.ContextCompat
25+
import com.example.android.eggtimernotifications.R
26+
import com.example.android.eggtimernotifications.util.sendNotification
27+
28+
class AlarmReceiver: BroadcastReceiver() {
29+
30+
override fun onReceive(context: Context, intent: Intent) {
31+
// TODO: Step 1.10 [Optional] remove toast
32+
// Toast.makeText(context, context.getText(R.string.eggs_ready), Toast.LENGTH_SHORT).show()
33+
34+
// TODO: Step 1.9 add call to sendNotification
35+
val notificationManager = ContextCompat.getSystemService(
36+
context,
37+
NotificationManager::class.java
38+
) as NotificationManager
39+
40+
notificationManager.sendNotification(
41+
context.getText(R.string.eggs_ready).toString(),
42+
context
43+
)
44+
45+
}
46+
47+
}

0 commit comments

Comments
 (0)