Skip to content

Commit

Permalink
Merge pull request #47 from psuzn/develop
Browse files Browse the repository at this point in the history
develop -> main
  • Loading branch information
psuzn authored Nov 26, 2023
2 parents df64226 + f80f36c commit 7d27e81
Show file tree
Hide file tree
Showing 44 changed files with 808 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .run/iosApp.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="iosApp" type="KmmRunConfiguration" factoryName="iOS Application" CONFIG_VERSION="1" EXEC_TARGET_ID="ADE463A4-513B-4388-B613-3ED01A8C7598" XCODE_PROJECT="$PROJECT_DIR$/iosApp/iosApp.xcworkspace" XCODE_CONFIGURATION="Debug" XCODE_SCHEME="iosApp">
<configuration default="false" name="iosApp" type="KmmRunConfiguration" factoryName="iOS Application" CONFIG_VERSION="1" EXEC_TARGET_ID="E03FCF7C-99D3-4C80-8793-0DE2C2CD6295" XCODE_PROJECT="$PROJECT_DIR$/iosApp/iosApp.xcworkspace" XCODE_CONFIGURATION="Debug" XCODE_SCHEME="iosApp">
<method v="2">
<option name="com.jetbrains.kmm.ios.BuildIOSAppTask" enabled="true" />
</method>
</configuration>
</component>
</component>
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# Play Deals
[![Static Badge](https://img.shields.io/badge/Android-black?logo=android&logoColor=white&color=%234889f5)](https://play.google.com/store/apps/details?id=me.sujanpoudel.playdeals) &nbsp;
[![Static Badge](https://img.shields.io/badge/IOS-grey?logo=apple)](https://github.com/psuzn/app-deals/releases/latest) &nbsp;&nbsp;
[![Static Badge](https://img.shields.io/badge/macOS-black?logo=apple)](https://github.com/psuzn/app-deals/releases/latest) &nbsp;
[![Static Badge](https://img.shields.io/badge/Windows-green?logo=windows&color=blue)](https://github.com/psuzn/app-deals/releases/latest) &nbsp;
[![Static Badge](https://img.shields.io/badge/Linux-white?logo=linux&logoColor=white&color=grey)](https://github.com/psuzn/app-deals/releases/latest) &nbsp;

[![Static Badge](https://img.shields.io/badge/Android-black?logo=android&logoColor=white&color=%234889f5)](https://play.google.com/store/apps/details?id=me.sujanpoudel.playdeals)
&nbsp;
[![Static Badge](https://img.shields.io/badge/IOS-grey?logo=apple)](https://github.com/psuzn/app-deals/releases/latest)
&nbsp;&nbsp;
[![Static Badge](https://img.shields.io/badge/macOS-black?logo=apple)](https://github.com/psuzn/app-deals/releases/latest)
&nbsp;
[![Static Badge](https://img.shields.io/badge/Windows-green?logo=windows&color=blue)](https://github.com/psuzn/app-deals/releases/latest)
&nbsp;
[![Static Badge](https://img.shields.io/badge/Linux-white?logo=linux&logoColor=white&color=grey)](https://github.com/psuzn/app-deals/releases/latest)
&nbsp;

![Static Badge](https://img.shields.io/badge/License-GPL--v3-brightgreen)
[![Lint and verify](https://github.com/psuzn/App-deals/actions/workflows/lint.yaml/badge.svg?branch=develop)](https://github.com/psuzn/App-deals/actions/workflows/lint.yaml)
Expand All @@ -16,6 +22,9 @@
Play deals is a simple app that aggregates the paid apps that have ongoing deals and discounts, aka you can get the
paid apps free or with discount.

| <img src="media/screenshot-black.jpg" width="95%" > | <img src="media/screenshot-light.jpg" width="95%" > |
|-----------------------------------------------------|:----------------------------------------------------:|

## Download

You can download the app from [play store](https://play.google.com/store/apps/details?id=me.sujanpoudel.playdeals) or
Expand Down Expand Up @@ -44,7 +53,8 @@ It shares same business logic and UI across all the platform.
- [Compose Multiplatform UI](https://www.jetbrains.com/lp/compose-multiplatform/) to build the cross platform UI.
- [Ktor](https://www.jetbrains.com/lp/compose-multiplatform/) for the http/api calls.
- [Kamel](https://github.com/Kamel-Media/Kamel) for loading images.
- [Kodein](https://www.google.com/search?q=kodein&sourceid=chrome&ie=UTF-8) for dependency injection.
- [Kodein](https://github.com/kosi-libs/Kodein) for dependency injection.
- [SQLDelight](https://github.com/cashapp/sqldelight) to offline cache using sqlite.

### UI Navigation

Expand All @@ -60,7 +70,7 @@ This loosely follows mvvm architecture inspired from android's view model.

**In Priority order** :

- [ ] Add Offline Caches for the apps
- [x] Add Offline Caches for the apps
- [ ] Push Notifications
- [ ] Add ability to add/request new app deal from app

Expand Down
24 changes: 21 additions & 3 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
kotlin("multiplatform")
id("com.android.application")
id("org.jetbrains.compose")
id("com.google.gms.google-services")
}

kotlin {
Expand All @@ -10,8 +11,12 @@ kotlin {
val androidMain by getting {
dependencies {
implementation(project(":shared"))
api("androidx.activity:activity-compose:1.7.2")
api("androidx.core:core-ktx:1.12.0")
implementation("androidx.activity:activity-compose:1.8.1")
implementation("androidx.core:core-ktx:1.12.0")

implementation(platform("com.google.firebase:firebase-bom:${Versions.FIREBASE_BOM}"))
implementation("com.google.firebase:firebase-analytics-ktx")
implementation("com.google.firebase:firebase-messaging-ktx")
}
}
}
Expand All @@ -38,13 +43,26 @@ android {
targetCompatibility = JavaVersion.VERSION_17
}


signingConfigs {
getByName("debug") {
storeFile = file("./key.debug.jks")
storePassword = "play-deals"
keyAlias = "key0"
keyPassword = "play-deals"
}
}

buildTypes {
getByName("release") {
release {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
}
debug {
isMinifyEnabled = false
}
}
}
Binary file added androidApp/key.debug.jks
Binary file not shown.
23 changes: 23 additions & 0 deletions androidApp/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/PlayDealsTheme">

<activity
android:name=".MainActivity"
android:exported="true"
Expand All @@ -18,5 +21,25 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>


<service
android:name=".FcmService"
android:exported="false">

<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>

</service>

<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_notification" />

<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorPrimary" />

</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package me.sujanpoudel.playdeals

import android.annotation.SuppressLint
import android.app.NotificationManager
import android.content.Context
import android.content.pm.PackageManager
import com.google.firebase.messaging.CommonNotificationBuilder
import com.google.firebase.messaging.Constants.MessageNotificationKeys
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.ImageDownload
import com.google.firebase.messaging.NotificationParams
import com.google.firebase.messaging.RemoteMessage
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withTimeoutOrNull
import kotlin.time.Duration.Companion.seconds

@SuppressLint("MissingFirebaseInstanceTokenRefresh")
class FcmService : FirebaseMessagingService() {

override fun onMessageReceived(message: RemoteMessage) {
val data = message.toIntent().extras

if (!NotificationParams.isNotification(data)) {
return super.onMessageReceived(message)
}

showNotification(NotificationParams(data!!))
}
}

private fun Context.manifestMetadata() = try {
applicationContext.packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA)
.metaData
} catch (e: PackageManager.NameNotFoundException) {
null
}

@SuppressLint("VisibleForTests")
private fun Context.showNotification(notificationParams: NotificationParams) {
val manifestMetadata = manifestMetadata()
val channel = CommonNotificationBuilder.getOrCreateChannel(
this,
notificationParams.notificationChannelId,
manifestMetadata,
)

val info = CommonNotificationBuilder.createNotificationInfo(
this,
this,
notificationParams,
channel,
manifestMetadata,
)

val url = notificationParams.getString(MessageNotificationKeys.IMAGE_URL)

CoroutineScope(Dispatchers.IO).launch {
if (url != null) {
val image = withTimeoutOrNull(10.seconds) {
try {
ImageDownload.create(url)?.blockingDownload()
} catch (_: Exception) {
null
}
}
info.notificationBuilder.setLargeIcon(image)
}

val notificationManager = getSystemService(FirebaseMessagingService.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.notify(info.tag, info.id, info.notificationBuilder.build())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ import me.sujanpoudel.playdeals.common.navigation.BackPressConsumer
import me.sujanpoudel.playdeals.common.navigation.LocalBackPressConsumer

class MainActivity : ComponentActivity() {
private val callBack =
object : OnBackPressedCallback(false) {
override fun handleOnBackPressed() {
backPressConsumer.onBackPress()
}
private val callBack = object : OnBackPressedCallback(false) {
override fun handleOnBackPressed() {
backPressConsumer.onBackPress()
}
}

private val backPressConsumer: BackPressConsumer =
BackPressConsumer {
Expand Down
21 changes: 21 additions & 0 deletions androidApp/src/androidMain/res/drawable-anydpi/ic_notification.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="226"
android:viewportHeight="226"
android:tint="#FFFFFF">
<group android:scaleX="0.6104844"
android:scaleY="0.6104844"
android:translateX="44.015263"
android:translateY="44.015263">
<path
android:pathData="M209.65,16.25L209.65,16.25A22.98,22.98 45.26,0 1,209.65 48.74L48.74,209.65A22.98,22.98 45.26,0 1,16.25 209.65L16.25,209.65A22.98,22.98 45.26,0 1,16.25 177.16L177.16,16.25A22.98,22.98 45.26,0 1,209.65 16.25z"
android:fillColor="#ffffff"/>
<path
android:pathData="M53.03,49.42m-36.18,0a36.18,36.18 0,1 1,72.36 0a36.18,36.18 0,1 1,-72.36 0"
android:fillColor="#ffffff"/>
<path
android:pathData="M173.15,179.66m-36.18,0a36.18,36.18 0,1 1,72.36 0a36.18,36.18 0,1 1,-72.36 0"
android:fillColor="#ffffff"/>
</group>
</vector>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion androidApp/src/androidMain/res/values-night/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">false</item>
</style>

</resources>
</resources>
4 changes: 4 additions & 0 deletions androidApp/src/androidMain/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#7477CC</color>
</resources>
2 changes: 1 addition & 1 deletion androidApp/src/androidMain/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item>
</style>
</resources>
</resources>
40 changes: 40 additions & 0 deletions androidApp/src/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"project_info": {
"project_number": "408920570359",
"firebase_url": "https://play-deals.firebaseio.com",
"project_id": "play-deals",
"storage_bucket": "play-deals.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:408920570359:android:73507efea95268337b16f2",
"android_client_info": {
"package_name": "me.sujanpoudel.playdeals"
}
},
"oauth_client": [
{
"client_id": "408920570359-vcp440gf1q7gm4ae8mnv9k0v1hsoqfcj.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyAc5FcH3QJ3tlgqwXJDHrApEegd-CzB654"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "408920570359-i6c0bhijsqshb1ok3d9v6ucvpj0p44vq.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ plugins {
id("org.jlleitschuh.gradle.ktlint") version "11.5.0" apply true
id("com.codingfeline.buildkonfig") version "0.14.0" apply false
id("app.cash.sqldelight") version Versions.SQLDELIGHT apply false
id("com.google.gms.google-services") version "4.3.15" apply false
}

allprojects {
Expand Down
3 changes: 2 additions & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ object Versions {
const val COMPOSE = "1.5.1"
const val SETTINGS = "1.0.0"
const val SQLDELIGHT = "2.0.0"
const val FIREBASE_BOM = "32.3.1"

const val KTOR = "2.3.4"
const val KTOR = "2.3.5"
const val KODE_IN = "7.20.2"
const val COROUTINE = "1.7.3"
const val KOTLINX_DATE_TIME = "0.4.0"
Expand Down
Loading

0 comments on commit 7d27e81

Please sign in to comment.