Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Development to Master #44

Merged
merged 17 commits into from
Aug 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ android {

buildTypes {
release {
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
Expand Down Expand Up @@ -51,5 +51,6 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
api "androidx.navigation:navigation-dynamic-features-fragment:2.5.1"
implementation "com.google.android.play:core:1.10.3"
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'

}
85 changes: 84 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,87 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

##---------------Begin: proguard configuration for SQLCipher ----------
#noinspection ShrinkerUnresolvedReference
-keep,includedescriptorclasses class net.sqlcipher.** { *; }
-keep,includedescriptorclasses interface net.sqlcipher.** { *; }


##---------------Begin: proguard configuration for Gson ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { <fields>; }

# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * extends com.google.gson.TypeAdapter
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer


##---------------Begin: proguard configuration for Retrofit ----------
# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
# EnclosingMethod is required to use InnerClasses.
-keepattributes Signature, InnerClasses, EnclosingMethod

# Retrofit does reflection on method and parameter annotations.
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations

# Retain service method parameters when optimizing.
-keepclassmembers, allowshrinking, allowobfuscation interface * {
@retrofit2.http.* <methods>;
}

# Ignore annotation used for build tooling.
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

# Ignore JSR 305 annotations for embedding nullability information.
-dontwarn javax.annotation.**

# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
-dontwarn kotlin.Unit

# Top-level functions that can only be used by Kotlin.
-dontwarn retrofit2.KotlinExtensions
-dontwarn retrofit2.KotlinExtensions$*

# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy
# and replaces all potential values with null. Explicitly keeping the interfaces prevents this.
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>

-dontwarn kotlinx.**

#-------------------------------------------------
# JetPack Navigation
# This fixes: Caused by: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment androidx.navigation.fragment.NavHostFragment: make sure class name exists
#-------------------------------------------------
-keepnames class androidx.navigation.fragment.NavHostFragment
-keepnames class androidx.navigation.dynamicfeatures.fragment.DynamicNavHostFragment
-keepnames class com.google.android.play.core.splitcompat.SplitCompatApplication

##---------------Begin: proguard configuration for Glide ----------
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep class * extends com.bumptech.glide.module.AppGlideModule {
<init>(...);
}
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
-keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder {
*** rewind();
}
10 changes: 9 additions & 1 deletion app/src/main/java/com/mankart/eshop/MyApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ package com.mankart.eshop

import com.google.android.play.core.splitcompat.SplitCompatApplication
import dagger.hilt.android.HiltAndroidApp
import timber.log.Timber

@HiltAndroidApp
class MyApplication: SplitCompatApplication()
class MyApplication: SplitCompatApplication() {
override fun onCreate() {
super.onCreate()
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.mankart.eshop.auth.ui.fragment

import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.util.Patterns
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
Expand All @@ -20,6 +19,7 @@ import com.mankart.eshop.core.data.Resource
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import timber.log.Timber

@AndroidEntryPoint
class LoginFragment : Fragment() {
Expand Down Expand Up @@ -83,12 +83,12 @@ class LoginFragment : Fragment() {
is Resource.Message -> {
setLoading(false)
Toast.makeText(requireActivity(), it.message, Toast.LENGTH_SHORT).show()
Log.e(TAG, it.message.toString())
Timber.i(it.message.toString())
}
is Resource.Error -> {
setLoading(false)
Toast.makeText(requireActivity(), getString(R.string.wrong_email_password), Toast.LENGTH_SHORT).show()
Log.e(TAG, it.message.toString())
Timber.e(it.message.toString())
}
is Resource.Success -> {
setLoading(false)
Expand Down Expand Up @@ -158,7 +158,8 @@ class LoginFragment : Fragment() {
_binding = null
}

companion object {
private const val TAG = "LoginFragment"
override fun onDestroy() {
super.onDestroy()
_binding = null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ class RegisterFragment : Fragment() {
_binding = null
}

override fun onDestroy() {
super.onDestroy()
_binding = null
}

companion object {
private const val TAG = "RegisterFragment"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.mankart.eshop.cart.ui.fragment

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand All @@ -28,6 +27,7 @@ import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.launch
import timber.log.Timber

@AndroidEntryPoint
class CartFragment: Fragment() {
Expand Down Expand Up @@ -126,7 +126,7 @@ class CartFragment: Fragment() {
uiState.value = getCurrentDate()
Toast.makeText(requireActivity(), getString(R.string.item_updated), Toast.LENGTH_SHORT).show()
} else {
Log.e(TAG, it.message.toString())
Timber.e(it.message.toString())
}
}
}
Expand All @@ -139,7 +139,7 @@ class CartFragment: Fragment() {
uiState.value = getCurrentDate()
Toast.makeText(requireActivity(), getString(R.string.item_deleted), Toast.LENGTH_SHORT).show()
} else {
Log.e(TAG, it.message.toString())
Timber.e(it.message.toString())
}
}
}
Expand All @@ -148,25 +148,28 @@ class CartFragment: Fragment() {
private fun getCart() {
lifecycleScope.launchWhenStarted {
cartViewModel.getCarts().collect { resource ->
if (resource is Resource.Success) {
totalPriceState.value = resource.data?.subTotal?:0
val listCart = resource.data?.cart

if (!listCart.isNullOrEmpty()) {
val adapter = ListCartAdapter(
listCart,
onItemClickCallback = { productId -> onItemClickHandler(productId) },
onBtnIncreaseClickCallback = { itemId, qty -> onIncreaseQtyHandler(itemId, qty) },
onBtnDecreaseClickCallback = { itemId, qty -> onDecreaseQtyHandler(itemId, qty) }
)
binding.rvCarts.adapter = adapter
} else {
binding.rvCarts.visibility = View.GONE
binding.tvEmptyCart.visibility = View.VISIBLE
binding.btnCheckout.isEnabled = false
when (resource) {
is Resource.Loading -> isShowProgressBar(true)
is Resource.Success -> {
isShowProgressBar(false)
totalPriceState.value = resource.data?.subTotal?:0
val listCart = resource.data?.cart

if (!listCart.isNullOrEmpty()) {
val adapter = ListCartAdapter(
listCart,
onItemClickCallback = { productId -> onItemClickHandler(productId) },
onBtnIncreaseClickCallback = { itemId, qty -> onIncreaseQtyHandler(itemId, qty) },
onBtnDecreaseClickCallback = { itemId, qty -> onDecreaseQtyHandler(itemId, qty) }
)
binding.rvCarts.adapter = adapter
} else {
binding.rvCarts.visibility = View.GONE
binding.tvEmptyCart.visibility = View.VISIBLE
binding.btnCheckout.isEnabled = false
}
}
} else {
Log.e(TAG, resource.message.toString())
else -> Timber.e(resource.message.toString())
}
}
}
Expand Down Expand Up @@ -216,10 +219,20 @@ class CartFragment: Fragment() {

override fun onDestroyView() {
super.onDestroyView()
binding.rvCarts.adapter = null
_binding = null
}

override fun onDestroy() {
super.onDestroy()
_binding = null
}

companion object {
private const val TAG = "CartFragment"
private fun isShowProgressBar(state: Boolean) {
if (state) {
binding.progressBar.visibility = View.VISIBLE
} else {
binding.progressBar.visibility = View.GONE
}
}
}
Loading