Skip to content

Commit

Permalink
Small project update
Browse files Browse the repository at this point in the history
  • Loading branch information
D4rK7355608 committed Jul 14, 2024
1 parent 95e443a commit a077e5c
Show file tree
Hide file tree
Showing 35 changed files with 632 additions and 329 deletions.
8 changes: 4 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId = "com.d4rk.cartcalculator"
minSdk = 26
targetSdk = 34
versionCode = 54
versionName = "1.0.6"
versionCode = 56
versionName = "1.0.7"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
resourceConfigurations += listOf(
"en",
Expand All @@ -35,6 +35,7 @@ android {
"bg",
"pl",
"uk",
"pt-rBR",
)
vectorDrawables {
useSupportLibrary = true
Expand All @@ -47,7 +48,6 @@ android {
isMinifyEnabled = true
isShrinkResources = true
isDebuggable = false
versionNameSuffix = "-release"
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
)
Expand All @@ -56,7 +56,6 @@ android {
debug {
multiDexEnabled = true
isDebuggable = true
versionNameSuffix = "-debug"
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
)
Expand Down Expand Up @@ -91,6 +90,7 @@ android {
}
}
}

dependencies {
// Firebase
implementation(platform(libs.firebase.bom))
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/kotlin/com/d4rk/cartcalculator/MainComposable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import com.d4rk.cartcalculator.ui.help.HelpActivity
import com.d4rk.cartcalculator.ui.home.HomeComposable
import com.d4rk.cartcalculator.ui.settings.SettingsActivity
import com.d4rk.cartcalculator.ui.support.SupportActivity
import com.d4rk.cartcalculator.utils.Utils
import com.d4rk.cartcalculator.utils.IntentUtils
import kotlinx.coroutines.launch

@OptIn(ExperimentalMaterial3Api::class)
Expand Down Expand Up @@ -77,26 +77,26 @@ fun MainComposable() {
when (item.title) {

R.string.settings -> {
Utils.openActivity(
IntentUtils.openActivity(
context, SettingsActivity::class.java
)
}

R.string.help_and_feedback -> {
Utils.openActivity(
IntentUtils.openActivity(
context, HelpActivity::class.java
)
}

R.string.updates -> {
Utils.openUrl(
IntentUtils.openUrl(
context,
"https://github.com/D4rK7355608/${context.packageName}/blob/master/CHANGELOG.md"
)
}

R.string.share -> {
Utils.shareApp(context)
IntentUtils.shareApp(context)
}
}
scope.launch {
Expand Down Expand Up @@ -137,7 +137,7 @@ fun MainComposable() {
}
}, actions = {
IconButton(onClick = {
Utils.openActivity(context, SupportActivity::class.java)
IntentUtils.openActivity(context, SupportActivity::class.java)
}) {
Icon(
Icons.Outlined.VolunteerActivism, contentDescription = "Support"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.d4rk.cartcalculator.constants.permissions

object PermissionsConstants {
const val REQUEST_CODE_NOTIFICATION_PERMISSION = 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.d4rk.cartcalculator.data.model.ui.button

enum class ButtonState { Pressed , Idle }
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import com.d4rk.cartcalculator.data.database.table.ShoppingCartItemsTable
import com.d4rk.cartcalculator.data.datastore.DataStore
import com.d4rk.cartcalculator.ui.dialogs.DeleteCartItemDialog
import com.d4rk.cartcalculator.ui.dialogs.NewCartItemDialog
import com.d4rk.cartcalculator.utils.bounceClick
import com.d4rk.cartcalculator.utils.compose.bounceClick
import java.util.Locale

@OptIn(ExperimentalMaterial3Api::class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
package com.d4rk.cartcalculator.ui.dialogs

import android.content.res.Resources
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.drawable.AdaptiveIconDrawable
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand All @@ -25,6 +19,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.d4rk.cartcalculator.BuildConfig
import com.d4rk.cartcalculator.R
import com.d4rk.cartcalculator.utils.drawable.toBitmapDrawable

@Composable
fun VersionInfoDialog(onDismiss: () -> Unit) {
Expand Down Expand Up @@ -73,20 +68,4 @@ fun VersionInfoContent() {
)
}
}
}

fun Drawable.toBitmapDrawable(): BitmapDrawable {
return when (this) {
is BitmapDrawable -> this
is AdaptiveIconDrawable -> {
val bitmap =
Bitmap.createBitmap(intrinsicWidth, intrinsicHeight, Bitmap.Config.ARGB_8888)
val canvas = Canvas(bitmap)
setBounds(0, 0, canvas.width, canvas.height)
draw(canvas)
BitmapDrawable(Resources.getSystem(), bitmap)
}

else -> throw IllegalArgumentException("Unsupported drawable type: ${this::class.java.name}")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,27 @@ package com.d4rk.cartcalculator.ui.help
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.ui.Modifier
import com.d4rk.cartcalculator.ui.settings.display.theme.style.AppTheme
import com.d4rk.cartcalculator.utils.Utils
import com.google.android.play.core.review.ReviewManager
import com.google.android.play.core.review.ReviewManagerFactory

class HelpActivity : AppCompatActivity() {
private lateinit var reviewManager: ReviewManager
override fun onCreate(savedInstanceState: Bundle?) {
private val viewModel: HelpViewModel by viewModels()
override fun onCreate(savedInstanceState : Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
AppTheme {
Surface(
modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background
modifier = Modifier.fillMaxSize() , color = MaterialTheme.colorScheme.background
) {
HelpComposable(this@HelpActivity)
HelpComposable(this@HelpActivity, viewModel)
}
}
}

}

/**
* Initiates the feedback process for the app.
*
* This function uses the Google Play In-App Review API to prompt the user for feedback.
* If the request to launch the in-app review flow is successful, the review dialog is displayed.
* If the request fails, it opens the Google Play Store page for the app's reviews.
*
* @see com.google.android.play.core.review.ReviewManagerFactory
* @see com.google.android.play.core.review.ReviewManager
* @param context The context used to create the ReviewManager instance and launch review flows.
*/
fun feedback() {
reviewManager = ReviewManagerFactory.create(this)
val task = reviewManager.requestReviewFlow()
task.addOnSuccessListener { reviewInfo ->
reviewManager.launchReviewFlow(this, reviewInfo)
}.addOnFailureListener {
Utils.openUrl(
this,
"https://play.google.com/store/apps/details?id=${this.packageName}&showAllReviews=true"
)
}.addOnFailureListener {
Utils.sendEmailToDeveloper(this)
}
}
}
Loading

0 comments on commit a077e5c

Please sign in to comment.