Skip to content

Commit

Permalink
Improved the project structure for a better organization
Browse files Browse the repository at this point in the history
  • Loading branch information
D4rK7355608 committed Jul 13, 2024
1 parent 5bb704d commit 66c087c
Show file tree
Hide file tree
Showing 34 changed files with 503 additions and 404 deletions.
4 changes: 0 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ plugins {
alias(libs.plugins.googlePlayServices)
alias(libs.plugins.googleOssServices)
alias(libs.plugins.googleFirebase)
alias(libs.plugins.googleDaggerHilt)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.devToolsKsp)
}
Expand Down Expand Up @@ -144,9 +143,6 @@ dependencies {
ksp(libs.androidx.room.compiler)
implementation(libs.androidx.room.ktx)
implementation(libs.androidx.room.runtime)
ksp(libs.hilt.android.compiler)
implementation(libs.hilt.android)
implementation("androidx.hilt:hilt-navigation-compose:1.2.0")

// Kotlin
implementation(libs.kotlinx.coroutines.android)
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
<uses-permission android:name="com.android.vending.CHECK_LICENSE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />

<queries>
<intent>
Expand Down Expand Up @@ -139,7 +140,7 @@

<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-5294151573817700~1050558256" />
android:value="ca-app-pub-5294151573817700~8003610653" />

<property
android:name="android.adservices.AD_SERVICES_CONFIG"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import com.d4rk.englishwithlidia.plus.ui.help.HelpActivity
import com.d4rk.englishwithlidia.plus.ui.home.HomeComposable
import com.d4rk.englishwithlidia.plus.ui.settings.SettingsActivity
import com.d4rk.englishwithlidia.plus.ui.support.SupportActivity
import com.d4rk.englishwithlidia.plus.utils.Utils
import com.d4rk.englishwithlidia.plus.utils.IntentUtils
import kotlinx.coroutines.launch

@OptIn(ExperimentalMaterial3Api::class)
Expand Down Expand Up @@ -78,26 +78,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 @@ -147,7 +147,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
Expand Up @@ -8,13 +8,13 @@ object AdsConstants {
get() = if (BuildConfig.DEBUG) {
"ca-app-pub-3940256099942544/6300978111"
} else {
"ca-app-pub-5294151573817700/8040893463"
"ca-app-pub-5294151573817700/8479403125"
}

val APP_OPEN_UNIT_ID: String
get() = if (BuildConfig.DEBUG) {
"ca-app-pub-3940256099942544/9257395921"
} else {
"ca-app-pub-5294151573817700/9208287867"
"ca-app-pub-5294151573817700/2885662643"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.d4rk.englishwithlidia.plus.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.englishwithlidia.plus.data.model.ui.button

enum class ButtonState { Pressed , Idle }
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
package com.d4rk.englishwithlidia.plus.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.englishwithlidia.plus.BuildConfig
import com.d4rk.englishwithlidia.plus.R
import com.d4rk.englishwithlidia.plus.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.englishwithlidia.plus.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.englishwithlidia.plus.ui.settings.display.theme.style.AppTheme
import com.d4rk.englishwithlidia.plus.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 66c087c

Please sign in to comment.