-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
811 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,4 +41,8 @@ local.properties | |
|
||
app/src/main/obj/ | ||
|
||
buildSrc/build | ||
buildSrc/build | ||
|
||
xcuserdata | ||
|
||
Pods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
object Metadata { | ||
const val groupId = "io.github.merseyside" | ||
const val version = "1.4.8" | ||
const val version = "1.4.9" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="com.merseyside.merseyLib.sample" /> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.merseyside.sample"> | ||
|
||
<application | ||
android:name=".MainApplication" | ||
android:allowBackup="false" | ||
android:label="MerseyKmm"> | ||
|
||
<activity | ||
android:name=".view.MainActivity" | ||
android:exported="true" | ||
android:windowSoftInputMode="adjustResize" | ||
android:theme="@style/Theme.Sample"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
</application> | ||
|
||
</manifest> |
19 changes: 19 additions & 0 deletions
19
sample/androidApp/src/main/kotlin/com/merseyside/sample/MainApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.merseyside.sample | ||
|
||
import com.merseyside.archy.BaseApplication | ||
import com.merseyside.merseyLib.utils.core.notification.NotificationBuilder | ||
import com.merseyside.sample.di.androidModule | ||
import com.merseyside.sample.di.initKoin | ||
import org.koin.android.ext.koin.androidContext | ||
|
||
class MainApplication : BaseApplication() { | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
|
||
val koin = initKoin(androidModule) { | ||
androidContext(this@MainApplication) | ||
}.koin | ||
koin.get<NotificationBuilder>() | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
sample/androidApp/src/main/kotlin/com/merseyside/sample/di/AndroidModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.merseyside.sample.di | ||
|
||
import com.merseyside.merseyLib.utils.core.notification.Notification | ||
import com.merseyside.merseyLib.utils.core.notification.NotificationAdapter | ||
import com.merseyside.merseyLib.utils.core.notification.NotificationInterceptor | ||
import com.merseyside.sample.utils.notification.AppNotificationAdapter | ||
import org.koin.core.module.dsl.singleOf | ||
import org.koin.dsl.bind | ||
import org.koin.dsl.module | ||
|
||
val androidModule = module { | ||
single<NotificationInterceptor> { | ||
object : NotificationInterceptor() { | ||
override fun intercept(notification: Notification) { | ||
|
||
} | ||
} | ||
} | ||
|
||
singleOf(::AppNotificationAdapter) bind NotificationAdapter::class | ||
} |
77 changes: 77 additions & 0 deletions
77
...oidApp/src/main/kotlin/com/merseyside/sample/utils/notification/AppNotificationAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.merseyside.sample.utils.notification | ||
|
||
import android.app.Notification | ||
import android.app.NotificationChannel | ||
import android.app.NotificationManager | ||
import android.app.PendingIntent | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.graphics.Color | ||
import android.os.Build | ||
import androidx.annotation.RequiresApi | ||
import androidx.core.app.NotificationCompat | ||
import androidx.core.app.NotificationManagerCompat | ||
import com.merseyside.merseyLib.utils.core.notification.NotificationAdapter | ||
import com.merseyside.merseyLib.utils.core.notification.NotificationDefinition | ||
import com.merseyside.sample.R | ||
import com.merseyside.sample.view.MainActivity | ||
|
||
class AppNotificationAdapter( | ||
context: Context | ||
): NotificationAdapter(context, CHANNEL_ID) { | ||
|
||
override fun defaultDefinition(context: Context): NotificationDefinition = { | ||
priority = NotificationCompat.PRIORITY_DEFAULT | ||
setVibrate(longArrayOf(200, 50, 200)) | ||
setContentIntent(getPendingIntent(context)) | ||
setSmallIcon(R.drawable.ic_notification) | ||
setChannelId(CHANNEL_ID) | ||
} | ||
|
||
@RequiresApi(Build.VERSION_CODES.O) | ||
override fun createNotificationChannel(): NotificationChannel { | ||
val name: CharSequence = VERBOSE_NOTIFICATION_CHANNEL_NAME | ||
val description: String = VERBOSE_NOTIFICATION_CHANNEL_DESCRIPTION | ||
val importance: Int = NotificationManager.IMPORTANCE_HIGH | ||
|
||
return NotificationChannel(CHANNEL_ID, name, importance).apply { | ||
this.description = description | ||
enableLights(true) | ||
lightColor = Color.GREEN | ||
} | ||
} | ||
|
||
override fun show( | ||
context: Context, | ||
tag: String, | ||
builder: NotificationCompat.Builder | ||
): Boolean { | ||
val notification: Notification = builder.build() | ||
notification.flags = notification.flags or Notification.FLAG_AUTO_CANCEL | ||
|
||
// Show the notification | ||
NotificationManagerCompat.from(context).notify(NOTIFICATION_ID, notification) | ||
|
||
return true | ||
} | ||
|
||
private fun getPendingIntent(context: Context): PendingIntent { | ||
val notificationIntent = Intent(context, MainActivity::class.java) | ||
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP) | ||
|
||
notificationIntent.flags = (Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP) | ||
|
||
return PendingIntent.getActivity( | ||
context, 0, | ||
notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT | ||
) | ||
} | ||
|
||
companion object { | ||
private const val VERBOSE_NOTIFICATION_CHANNEL_NAME = "Verbose notification channel name" | ||
private const val VERBOSE_NOTIFICATION_CHANNEL_DESCRIPTION = "Verbose notification channel description" | ||
private const val CHANNEL_ID = "342" | ||
private val NOTIFICATION_ID = 112 | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
sample/androidApp/src/main/kotlin/com/merseyside/sample/view/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.merseyside.sample.view | ||
|
||
import android.os.Bundle | ||
import androidx.appcompat.widget.Toolbar | ||
import com.merseyside.archy.presentation.activity.BaseBindingActivity | ||
import com.merseyside.sample.R | ||
import com.merseyside.sample.databinding.ActivityMainBinding | ||
import com.merseyside.sample.notifications.NotificationTest | ||
import com.merseyside.utils.view.ext.onClick | ||
import org.koin.android.ext.android.inject | ||
|
||
class MainActivity : BaseBindingActivity<ActivityMainBinding>() { | ||
|
||
private val test by inject<NotificationTest>() | ||
|
||
override fun getFragmentContainer(): Int? { | ||
return null | ||
} | ||
|
||
override fun getLayoutId(): Int { | ||
return R.layout.activity_main | ||
} | ||
|
||
override fun getToolbar(): Toolbar? { | ||
return null | ||
} | ||
|
||
override fun performInjection(bundle: Bundle?, vararg params: Any) {} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
requireBinding().showNotification.onClick { test.showNotification() } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:height="24dp" android:tint="#00B9C7" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM19,18H6c-2.21,0 -4,-1.79 -4,-4 0,-2.05 1.53,-3.76 3.56,-3.97l1.07,-0.11 0.5,-0.95C8.08,7.14 9.94,6 12,6c2.62,0 4.88,1.86 5.39,4.43l0.3,1.5 1.53,0.11c1.56,0.1 2.78,1.41 2.78,2.96 0,1.65 -1.35,3 -3,3zM8,13h2.55v3h2.9v-3H16l-4,-4z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<Button | ||
android:id="@+id/show_notification" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
android:text="Show notification"/> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<resources> | ||
<color name="transparent">#00000000</color> | ||
<color name="white">#FFFFFF</color> | ||
<color name="light_dark">#C6C6C6</color> | ||
<color name="black">#000000</color> | ||
|
||
<color name="grey">#bdbdbd</color> | ||
<color name="grey_light">#efefef</color> | ||
<color name="grey_dark">#8d8d8d</color> | ||
|
||
<color name="night">#1F222C</color> | ||
<color name="night_dark">#191C25</color> | ||
|
||
|
||
<color name="blue_primary">#03A9F4</color> | ||
<color name="blue_primary_variant">#C1E7F8</color> | ||
|
||
<color name="green">#087f23</color> | ||
<color name="red">#f44336</color> | ||
<color name="cyan">#00bcd4</color> | ||
<color name="pink">#D81B60</color> | ||
|
||
<color name="transparent_white">#34ffffff</color> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<!-- Light application theme. --> | ||
<style name="Theme.Sample" parent="Theme.MaterialComponents.Light.NoActionBar"> | ||
|
||
<item name="colorPrimary">@color/white</item> | ||
<item name="colorPrimaryDark">@color/light_dark</item> | ||
<item name="colorOnPrimary">@color/black</item> | ||
|
||
<item name="colorSecondary">@color/blue_primary</item> | ||
<item name="colorSecondaryVariant">@color/blue_primary_variant</item> | ||
<item name="colorOnSecondary">@color/white</item> | ||
|
||
<item name="colorError">@color/pink</item> | ||
<item name="colorOnError">@color/white</item> | ||
|
||
<item name="colorSurface">@color/white</item> | ||
<item name="colorOnSurface">@color/black</item> | ||
|
||
<item name="android:colorBackground">@color/white</item> | ||
<item name="colorOnBackground">@color/black</item> | ||
|
||
<item name="android:textColor">@color/black</item> | ||
<item name="android:textColorSecondary">@color/grey</item> | ||
</style> | ||
|
||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.MaterialComponents.Light" /> | ||
</resources> |
Oops, something went wrong.