Skip to content

Commit da8787c

Browse files
committed
Added Notification project
1 parent 4d63a77 commit da8787c

Some content is hidden

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

50 files changed

+184
-213
lines changed
File renamed without changes.

Notifications/.idea/codeStyles/Project.xml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Notifications/.idea/encodings.xml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

android-launcher/app/build.gradle renamed to Notifications/app/build.gradle

+3-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ apply plugin: 'kotlin-android-extensions'
77
android {
88
compileSdkVersion 28
99
defaultConfig {
10-
applicationId "com.example.androidlauncher"
10+
applicationId "com.example.notifications"
1111
minSdkVersion 15
1212
targetSdkVersion 28
1313
versionCode 1
@@ -24,14 +24,12 @@ android {
2424

2525
dependencies {
2626
implementation fileTree(dir: 'libs', include: ['*.jar'])
27-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
27+
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
2828
implementation 'com.android.support:appcompat-v7:28.0.0'
2929
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
3030
testImplementation 'junit:junit:4.12'
3131
androidTestImplementation 'com.android.support.test:runner:1.0.2'
3232
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
33+
implementation "com.android.support:support-compat:28.0.0"
3334

34-
implementation 'com.xwray:groupie:2.1.0'
35-
implementation 'com.xwray:groupie-kotlin-android-extensions:2.3.0'
36-
implementation 'com.android.support:recyclerview-v7:28.0.0'
3735
}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.androidlauncher
1+
package com.example.notifications
22

33
import android.support.test.InstrumentationRegistry
44
import android.support.test.runner.AndroidJUnit4
@@ -19,6 +19,6 @@ class ExampleInstrumentedTest {
1919
fun useAppContext() {
2020
// Context of the app under test.
2121
val appContext = InstrumentationRegistry.getTargetContext()
22-
assertEquals("com.example.androidlauncher", appContext.packageName)
22+
assertEquals("com.example.notifications", appContext.packageName)
2323
}
2424
}

android-launcher/app/src/main/AndroidManifest.xml renamed to Notifications/app/src/main/AndroidManifest.xml

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
4-
package="com.example.androidlauncher">
3+
package="com.example.notifications">
54

65
<application
76
android:allowBackup="true"
87
android:icon="@mipmap/ic_launcher"
98
android:label="@string/app_name"
109
android:roundIcon="@mipmap/ic_launcher_round"
1110
android:supportsRtl="true"
12-
android:theme="@style/AppTheme"
13-
tools:ignore="GoogleAppIndexingWarning">
14-
<activity android:name=".AppDrawer">
15-
</activity>
11+
android:theme="@style/AppTheme">
1612
<activity android:name=".MainActivity">
1713
<intent-filter>
1814
<action android:name="android.intent.action.MAIN"/>
1915

20-
<!--<category android:name="android.intent.category.HOME"/>
21-
<category android:name="android.intent.category.DEFAULT"/>-->
2216
<category android:name="android.intent.category.LAUNCHER"/>
2317
</intent-filter>
2418
</activity>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
package com.example.notifications
2+
3+
import android.app.Notification.VISIBILITY_PUBLIC
4+
import android.os.Build
5+
import android.support.v7.app.AppCompatActivity
6+
import android.os.Bundle
7+
import android.support.v4.app.NotificationCompat
8+
import android.support.v4.app.NotificationManagerCompat
9+
import kotlinx.android.synthetic.main.activity_main.*
10+
import android.R.attr.name
11+
import android.annotation.SuppressLint
12+
import android.annotation.TargetApi
13+
import android.app.Notification.VISIBILITY_PRIVATE
14+
import android.app.NotificationChannel
15+
import android.app.NotificationManager
16+
import android.content.Context
17+
import android.support.annotation.RequiresApi
18+
19+
20+
class MainActivity : AppCompatActivity() {
21+
22+
val CHANNEL_ID = "CHANNEL_ID"
23+
24+
25+
@SuppressLint("NewApi")
26+
override fun onCreate(savedInstanceState: Bundle?) {
27+
super.onCreate(savedInstanceState)
28+
setContentView(R.layout.activity_main)
29+
30+
createNotificationChannel()
31+
32+
default_notification_btn.setOnClickListener {
33+
createNormalNotification()
34+
}
35+
36+
head_up_notification_btn.setOnClickListener {
37+
createHeadsUpNotification()
38+
}
39+
40+
lock_screen_notification_btn.setOnClickListener {
41+
createLockScreenNotification()
42+
}
43+
}
44+
45+
fun createNormalNotification(){
46+
val builder = NotificationCompat.Builder(this, CHANNEL_ID)
47+
.setSmallIcon(R.drawable.notification_icon)
48+
.setContentTitle("Normal Notification")
49+
.setContentText("Really great content for this notification")
50+
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
51+
52+
createNotification(0, builder)
53+
}
54+
55+
fun createHeadsUpNotification(){
56+
val builder = NotificationCompat.Builder(this, CHANNEL_ID)
57+
.setSmallIcon(R.drawable.notification_icon)
58+
.setContentTitle("Heads up notification")
59+
.setContentText("Really great content for this notification")
60+
.setPriority(NotificationCompat.PRIORITY_HIGH)
61+
62+
if (Build.VERSION.SDK_INT >= 21) builder.setVibrate(LongArray(0))
63+
64+
createNotification(1, builder)
65+
}
66+
67+
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
68+
fun createLockScreenNotification(){
69+
val publicBuilder = NotificationCompat.Builder(this, CHANNEL_ID)
70+
.setSmallIcon(R.drawable.notification_icon)
71+
.setContentTitle("Alternative notification")
72+
.setPriority(NotificationCompat.PRIORITY_HIGH)
73+
.setVisibility(VISIBILITY_PUBLIC)
74+
75+
val builder = NotificationCompat.Builder(this, CHANNEL_ID)
76+
.setSmallIcon(R.drawable.notification_icon)
77+
.setContentTitle("Lock screen Notification")
78+
.setContentText("Really great content for this notification")
79+
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
80+
.setVisibility(VISIBILITY_PRIVATE)
81+
.setPublicVersion(publicBuilder.build())
82+
83+
createNotification(0, builder)
84+
}
85+
86+
fun createNotification(id: Int, builder: NotificationCompat.Builder){
87+
with(NotificationManagerCompat.from(this)) {
88+
notify(0, builder.build())
89+
}
90+
}
91+
92+
private fun createNotificationChannel() {
93+
// Create the NotificationChannel, but only on API 26+ because
94+
// the NotificationChannel class is new and not in the support library
95+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
96+
val name = "Channel"
97+
val descriptionText = "Simple channel example"
98+
val importance = NotificationManager.IMPORTANCE_DEFAULT
99+
val channel = NotificationChannel(CHANNEL_ID, name, importance).apply {
100+
description = descriptionText
101+
}
102+
// Register the channel with the system
103+
val notificationManager: NotificationManager =
104+
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
105+
notificationManager.createNotificationChannel(channel)
106+
}
107+
}
108+
109+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24.0"
5+
android:viewportHeight="24.0">
6+
<path
7+
android:fillColor="#FF000000"
8+
android:pathData="M6,18c0,0.55 0.45,1 1,1h1v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L11,19h2v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L16,19h1c0.55,0 1,-0.45 1,-1L18,8L6,8v10zM3.5,8C2.67,8 2,8.67 2,9.5v7c0,0.83 0.67,1.5 1.5,1.5S5,17.33 5,16.5v-7C5,8.67 4.33,8 3.5,8zM20.5,8c-0.83,0 -1.5,0.67 -1.5,1.5v7c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5v-7c0,-0.83 -0.67,-1.5 -1.5,-1.5zM15.53,2.16l1.3,-1.3c0.2,-0.2 0.2,-0.51 0,-0.71 -0.2,-0.2 -0.51,-0.2 -0.71,0l-1.48,1.48C13.85,1.23 12.95,1 12,1c-0.96,0 -1.86,0.23 -2.66,0.63L7.85,0.15c-0.2,-0.2 -0.51,-0.2 -0.71,0 -0.2,0.2 -0.2,0.51 0,0.71l1.31,1.31C6.97,3.26 6,5.01 6,7h12c0,-1.99 -0.97,-3.75 -2.47,-4.84zM10,5L9,5L9,4h1v1zM15,5h-1L14,4h1v1z"/>
9+
</vector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<android.support.constraint.ConstraintLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
xmlns:app="http://schemas.android.com/apk/res-auto"
6+
android:layout_width="match_parent"
7+
android:layout_height="match_parent"
8+
tools:context=".MainActivity">
9+
10+
<Button
11+
android:layout_width="wrap_content"
12+
android:layout_height="wrap_content"
13+
android:id="@+id/default_notification_btn" app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp"
14+
android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
15+
android:layout_marginRight="8dp" android:layout_marginTop="8dp" app:layout_constraintTop_toTopOf="parent"
16+
android:text="default notification"/>
17+
<Button
18+
android:text="Head up"
19+
android:layout_width="wrap_content"
20+
android:layout_height="wrap_content"
21+
android:id="@+id/head_up_notification_btn" app:layout_constraintEnd_toEndOf="parent"
22+
android:layout_marginEnd="8dp"
23+
android:layout_marginRight="8dp" app:layout_constraintStart_toStartOf="parent"
24+
android:layout_marginLeft="8dp" android:layout_marginStart="8dp" android:layout_marginTop="60dp"
25+
app:layout_constraintTop_toBottomOf="@+id/default_notification_btn"
26+
app:layout_constraintHorizontal_bias="0.498"/>
27+
<Button
28+
android:text="Lockscreen"
29+
android:layout_width="wrap_content"
30+
android:layout_height="wrap_content"
31+
android:id="@+id/lock_screen_notification_btn" app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp"
32+
android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
33+
android:layout_marginRight="8dp" android:layout_marginTop="68dp"
34+
app:layout_constraintTop_toBottomOf="@+id/head_up_notification_btn"
35+
app:layout_constraintHorizontal_bias="0.498"/>
36+
37+
</android.support.constraint.ConstraintLayout>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<resources>
2+
<string name="app_name">Notifications</string>
3+
</resources>
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
<resources>
22

33
<!-- Base application theme. -->
4-
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
4+
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
55
<!-- Customize your theme here. -->
66
<item name="colorPrimary">@color/colorPrimary</item>
77
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
88
<item name="colorAccent">@color/colorAccent</item>
9-
<item name="android:windowShowWallpaper">true</item>
10-
<item name="android:windowBackground">@android:color/transparent</item>
119
</style>
1210

1311
</resources>

android-launcher/app/src/test/java/com/example/androidlauncher/ExampleUnitTest.kt renamed to Notifications/app/src/test/java/com/example/notifications/ExampleUnitTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.androidlauncher
1+
package com.example.notifications
22

33
import org.junit.Test
44

android-launcher/build.gradle renamed to Notifications/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88

99
}
1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:3.3.2'
11+
classpath 'com.android.tools.build:gradle:3.4.0'
1212
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1313
// NOTE: Do not place your application dependencies here; they belong
1414
// in the individual module build.gradle files
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Mon Mar 18 22:18:00 CET 2019
1+
#Sat Apr 20 11:00:18 CEST 2019
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
File renamed without changes.
File renamed without changes.
File renamed without changes.

android-launcher/.idea/codeStyles/Project.xml

-35
This file was deleted.

android-launcher/app/src/main/java/com/example/androidlauncher/AppDrawer.kt

-45
This file was deleted.

android-launcher/app/src/main/java/com/example/androidlauncher/AppInformations.kt

-5
This file was deleted.

0 commit comments

Comments
 (0)