From 7ae4607931d219b8b5f523f5ef480fcc0abc02e1 Mon Sep 17 00:00:00 2001 From: dgngulcan Date: Fri, 22 Feb 2019 09:00:46 -0500 Subject: [PATCH 1/4] fix null url illegalArgumentException --- .../java/com/droidfeed/ui/binding/CommonBindingAdapters.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/droidfeed/ui/binding/CommonBindingAdapters.kt b/app/src/main/java/com/droidfeed/ui/binding/CommonBindingAdapters.kt index b3d1d59..6d0910d 100644 --- a/app/src/main/java/com/droidfeed/ui/binding/CommonBindingAdapters.kt +++ b/app/src/main/java/com/droidfeed/ui/binding/CommonBindingAdapters.kt @@ -80,9 +80,9 @@ fun loadImage( @BindingAdapter("app:displayUrl") fun displayUrl( webView: WebView, - url: String + url: String? ) { - webView.loadUrl(url) + url?.let { webView.loadUrl(it) } } @BindingAdapter("app:relativeTimestamp") From 6008376a6542ce070bd35b4b2a42a0e4d9dd3c1c Mon Sep 17 00:00:00 2001 From: dgngulcan Date: Mon, 4 Mar 2019 22:05:15 -0500 Subject: [PATCH 2/4] add viewModelFactory for MainViewModel --- app/src/main/java/com/droidfeed/ui/module/feed/FeedFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/droidfeed/ui/module/feed/FeedFragment.kt b/app/src/main/java/com/droidfeed/ui/module/feed/FeedFragment.kt index 0f8e90e..25f7e74 100644 --- a/app/src/main/java/com/droidfeed/ui/module/feed/FeedFragment.kt +++ b/app/src/main/java/com/droidfeed/ui/module/feed/FeedFragment.kt @@ -50,7 +50,7 @@ class FeedFragment : BaseFragment("feed"), Scrollable { .get(FeedViewModel::class.java) mainViewModel = ViewModelProviders - .of(activity!!) + .of(activity!!, viewModelFactory) .get(MainViewModel::class.java) } From 3c2403da27d54771fd91212d317ace0c29e9ef06 Mon Sep 17 00:00:00 2001 From: dgngulcan Date: Mon, 4 Mar 2019 22:25:54 -0500 Subject: [PATCH 3/4] add @keep for models increment app version code-style updates --- app/build.gradle | 26 ++++--------------- app/proguard-rules.pro | 1 - .../data/api/mailchimp/ErrorAdapter.kt | 9 ++++++- .../api/mailchimp/{ => model}/ErrorJson.kt | 5 +++- .../api/mailchimp/{ => model}/ErrorType.kt | 5 +++- .../mailchimp/{ => model}/MailchimpError.kt | 5 +++- .../api/mailchimp/{ => model}/Subscriber.kt | 4 ++- .../{ => model}/SubscriptionStatus.kt | 4 ++- .../api/mailchimp/{ => model}/UserResponse.kt | 4 ++- .../mailchimp/service/NewsletterService.kt | 4 +-- .../com/droidfeed/data/repo/NewsletterRepo.kt | 5 ++-- .../viewholder/ConferenceViewHolder.kt | 1 - .../module/newsletter/NewsletterViewModel.kt | 11 +++++--- .../java/com/droidfeed/util/DebugUtils.kt | 4 +-- .../main/res/layout/fragment_newsletter.xml | 2 +- .../com/droidfeed/OnBoardViewModelTest.kt | 3 --- build.gradle | 2 +- dependencies.gradle | 2 +- gradle.properties | 1 + 19 files changed, 52 insertions(+), 46 deletions(-) rename app/src/main/java/com/droidfeed/data/api/mailchimp/{ => model}/ErrorJson.kt (51%) rename app/src/main/java/com/droidfeed/data/api/mailchimp/{ => model}/ErrorType.kt (57%) rename app/src/main/java/com/droidfeed/data/api/mailchimp/{ => model}/MailchimpError.kt (66%) rename app/src/main/java/com/droidfeed/data/api/mailchimp/{ => model}/Subscriber.kt (64%) rename app/src/main/java/com/droidfeed/data/api/mailchimp/{ => model}/SubscriptionStatus.kt (75%) rename app/src/main/java/com/droidfeed/data/api/mailchimp/{ => model}/UserResponse.kt (73%) diff --git a/app/build.gradle b/app/build.gradle index 4db72e6..ad40126 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,8 +5,8 @@ apply plugin: 'kotlin-kapt' apply plugin: 'io.fabric' ext.app = [ - 'version' : '2.1.1', - 'version_code' : 16, + 'version' : '2.1.5', + 'version_code' : 21, 'compile_sdk_version': 28, 'min_sdk_version' : 21, 'target_sdk_version' : 28 @@ -44,8 +44,8 @@ android { } release { - shrinkResources false - minifyEnabled false + shrinkResources true + minifyEnabled true } } @@ -76,58 +76,43 @@ androidExtensions { } dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - + implementation fileTree(include: ['*.jar'], dir: 'libs') implementation deps.kotlin.stdlib implementation deps.kotlin.coroutines - implementation deps.material_design - implementation deps.androidx.core_ktx implementation deps.androidx.fragment implementation deps.androidx.browser implementation deps.androidx.lifecycle kapt deps.androidx.lifecycle_compiler implementation deps.androidx.paging - implementation deps.androidx.constraint_layout - implementation deps.room.runtime kapt deps.room.compiler - implementation deps.dagger.core implementation deps.dagger.android implementation deps.dagger.android_support kapt deps.dagger.compiler kapt deps.dagger.processor - implementation deps.glide.core kapt deps.glide.compiler - implementation deps.retrofit.core implementation deps.retrofit.moshi_converter - implementation deps.okhttp.core implementation deps.okhttp.logging_interceptor - implementation deps.crashlytics - implementation deps.lottie - implementation deps.firebase.core implementation deps.firebase.config implementation deps.firebase.firestore - implementation deps.jsoup implementation deps.gson // quick fix for version conflict between room and firestore - testImplementation deps.mockito.core testImplementation deps.mockito.inline testImplementation deps.junit testImplementation deps.kotlin.coroutines_test testImplementation deps.testx.core testImplementation deps.arch_testing - androidTestImplementation deps.arch_testing androidTestImplementation deps.testx.core androidTestImplementation deps.testx.runner @@ -136,7 +121,6 @@ dependencies { androidTestImplementation deps.testx.monitor androidTestImplementation deps.testx.ext androidTestImplementation deps.room.testing - detektPlugins deps.detekt_formatting } diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index c1c6136..09d1e6f 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -13,7 +13,6 @@ -keepattributes SourceFile,LineNumberTable -repackageclasses '' - -keep class com.crashlytics.** { *; } -keepattributes *Annotation*,Signature,Exceptions diff --git a/app/src/main/java/com/droidfeed/data/api/mailchimp/ErrorAdapter.kt b/app/src/main/java/com/droidfeed/data/api/mailchimp/ErrorAdapter.kt index e43601c..b013757 100644 --- a/app/src/main/java/com/droidfeed/data/api/mailchimp/ErrorAdapter.kt +++ b/app/src/main/java/com/droidfeed/data/api/mailchimp/ErrorAdapter.kt @@ -1,6 +1,9 @@ package com.droidfeed.data.api.mailchimp import androidx.annotation.Keep +import com.droidfeed.data.api.mailchimp.model.ErrorJson +import com.droidfeed.data.api.mailchimp.model.ErrorType +import com.droidfeed.data.api.mailchimp.model.MailchimpError import com.droidfeed.util.logThrowable import com.squareup.moshi.FromJson import com.squareup.moshi.JsonDataException @@ -21,6 +24,10 @@ internal class ErrorAdapter { } } - return MailchimpError(errorType, errorJson.status, errorJson.detail) + return MailchimpError( + errorType, + errorJson.status, + errorJson.detail + ) } } \ No newline at end of file diff --git a/app/src/main/java/com/droidfeed/data/api/mailchimp/ErrorJson.kt b/app/src/main/java/com/droidfeed/data/api/mailchimp/model/ErrorJson.kt similarity index 51% rename from app/src/main/java/com/droidfeed/data/api/mailchimp/ErrorJson.kt rename to app/src/main/java/com/droidfeed/data/api/mailchimp/model/ErrorJson.kt index d87fdd3..e11eb59 100644 --- a/app/src/main/java/com/droidfeed/data/api/mailchimp/ErrorJson.kt +++ b/app/src/main/java/com/droidfeed/data/api/mailchimp/model/ErrorJson.kt @@ -1,5 +1,8 @@ -package com.droidfeed.data.api.mailchimp +package com.droidfeed.data.api.mailchimp.model +import androidx.annotation.Keep + +@Keep data class ErrorJson( val title: String, val status: Int, diff --git a/app/src/main/java/com/droidfeed/data/api/mailchimp/ErrorType.kt b/app/src/main/java/com/droidfeed/data/api/mailchimp/model/ErrorType.kt similarity index 57% rename from app/src/main/java/com/droidfeed/data/api/mailchimp/ErrorType.kt rename to app/src/main/java/com/droidfeed/data/api/mailchimp/model/ErrorType.kt index eeb2f08..eb38efb 100644 --- a/app/src/main/java/com/droidfeed/data/api/mailchimp/ErrorType.kt +++ b/app/src/main/java/com/droidfeed/data/api/mailchimp/model/ErrorType.kt @@ -1,5 +1,8 @@ -package com.droidfeed.data.api.mailchimp +package com.droidfeed.data.api.mailchimp.model +import androidx.annotation.Keep + +@Keep enum class ErrorType { MEMBER_ALREADY_EXIST, INVALID_RESOURCE, diff --git a/app/src/main/java/com/droidfeed/data/api/mailchimp/MailchimpError.kt b/app/src/main/java/com/droidfeed/data/api/mailchimp/model/MailchimpError.kt similarity index 66% rename from app/src/main/java/com/droidfeed/data/api/mailchimp/MailchimpError.kt rename to app/src/main/java/com/droidfeed/data/api/mailchimp/model/MailchimpError.kt index 0f29898..cb97f7a 100644 --- a/app/src/main/java/com/droidfeed/data/api/mailchimp/MailchimpError.kt +++ b/app/src/main/java/com/droidfeed/data/api/mailchimp/model/MailchimpError.kt @@ -1,8 +1,11 @@ -package com.droidfeed.data.api.mailchimp +package com.droidfeed.data.api.mailchimp.model + +import androidx.annotation.Keep /** * Defines base error response for Mailchimp API. */ +@Keep data class MailchimpError( val type: ErrorType, val code: Int, diff --git a/app/src/main/java/com/droidfeed/data/api/mailchimp/Subscriber.kt b/app/src/main/java/com/droidfeed/data/api/mailchimp/model/Subscriber.kt similarity index 64% rename from app/src/main/java/com/droidfeed/data/api/mailchimp/Subscriber.kt rename to app/src/main/java/com/droidfeed/data/api/mailchimp/model/Subscriber.kt index 34bf130..130c090 100644 --- a/app/src/main/java/com/droidfeed/data/api/mailchimp/Subscriber.kt +++ b/app/src/main/java/com/droidfeed/data/api/mailchimp/model/Subscriber.kt @@ -1,7 +1,9 @@ -package com.droidfeed.data.api.mailchimp +package com.droidfeed.data.api.mailchimp.model +import androidx.annotation.Keep import com.squareup.moshi.Json +@Keep data class Subscriber( @field:Json(name = "email_address") var email: String, diff --git a/app/src/main/java/com/droidfeed/data/api/mailchimp/SubscriptionStatus.kt b/app/src/main/java/com/droidfeed/data/api/mailchimp/model/SubscriptionStatus.kt similarity index 75% rename from app/src/main/java/com/droidfeed/data/api/mailchimp/SubscriptionStatus.kt rename to app/src/main/java/com/droidfeed/data/api/mailchimp/model/SubscriptionStatus.kt index e800b88..bb42ba2 100644 --- a/app/src/main/java/com/droidfeed/data/api/mailchimp/SubscriptionStatus.kt +++ b/app/src/main/java/com/droidfeed/data/api/mailchimp/model/SubscriptionStatus.kt @@ -1,7 +1,9 @@ -package com.droidfeed.data.api.mailchimp +package com.droidfeed.data.api.mailchimp.model +import androidx.annotation.Keep import com.squareup.moshi.Json +@Keep enum class SubscriptionStatus(private val status: String) { @Json(name = "subscribed") SUBSCRIBED("subscribed"), diff --git a/app/src/main/java/com/droidfeed/data/api/mailchimp/UserResponse.kt b/app/src/main/java/com/droidfeed/data/api/mailchimp/model/UserResponse.kt similarity index 73% rename from app/src/main/java/com/droidfeed/data/api/mailchimp/UserResponse.kt rename to app/src/main/java/com/droidfeed/data/api/mailchimp/model/UserResponse.kt index 371995b..6718c21 100644 --- a/app/src/main/java/com/droidfeed/data/api/mailchimp/UserResponse.kt +++ b/app/src/main/java/com/droidfeed/data/api/mailchimp/model/UserResponse.kt @@ -1,7 +1,9 @@ -package com.droidfeed.data.api.mailchimp +package com.droidfeed.data.api.mailchimp.model +import androidx.annotation.Keep import com.squareup.moshi.Json +@Keep data class UserResponse( val id: String, diff --git a/app/src/main/java/com/droidfeed/data/api/mailchimp/service/NewsletterService.kt b/app/src/main/java/com/droidfeed/data/api/mailchimp/service/NewsletterService.kt index cb3e77d..c95ea00 100644 --- a/app/src/main/java/com/droidfeed/data/api/mailchimp/service/NewsletterService.kt +++ b/app/src/main/java/com/droidfeed/data/api/mailchimp/service/NewsletterService.kt @@ -1,7 +1,7 @@ package com.droidfeed.data.api.mailchimp.service -import com.droidfeed.data.api.mailchimp.Subscriber -import com.droidfeed.data.api.mailchimp.UserResponse +import com.droidfeed.data.api.mailchimp.model.Subscriber +import com.droidfeed.data.api.mailchimp.model.UserResponse import retrofit2.Call import retrofit2.http.Body import retrofit2.http.POST diff --git a/app/src/main/java/com/droidfeed/data/repo/NewsletterRepo.kt b/app/src/main/java/com/droidfeed/data/repo/NewsletterRepo.kt index d588e97..1e11244 100644 --- a/app/src/main/java/com/droidfeed/data/repo/NewsletterRepo.kt +++ b/app/src/main/java/com/droidfeed/data/repo/NewsletterRepo.kt @@ -2,8 +2,8 @@ package com.droidfeed.data.repo import com.droidfeed.data.DataStatus import com.droidfeed.data.api.mailchimp.ErrorAdapter -import com.droidfeed.data.api.mailchimp.MailchimpError -import com.droidfeed.data.api.mailchimp.Subscriber +import com.droidfeed.data.api.mailchimp.model.MailchimpError +import com.droidfeed.data.api.mailchimp.model.Subscriber import com.droidfeed.data.api.mailchimp.service.NewsletterService import com.droidfeed.util.extention.suspendingEnqueue import com.google.firebase.remoteconfig.FirebaseRemoteConfig @@ -28,6 +28,7 @@ class NewsletterRepo @Inject constructor( try { val listId = remoteConfig.getString("mc_newsletter_list_id") newsletterService.addSubscriber(listId, subscriber).suspendingEnqueue() + DataStatus.Successful() } catch (e: HttpException) { when (e.code()) { diff --git a/app/src/main/java/com/droidfeed/ui/adapter/viewholder/ConferenceViewHolder.kt b/app/src/main/java/com/droidfeed/ui/adapter/viewholder/ConferenceViewHolder.kt index eb4a09b..4494e60 100644 --- a/app/src/main/java/com/droidfeed/ui/adapter/viewholder/ConferenceViewHolder.kt +++ b/app/src/main/java/com/droidfeed/ui/adapter/viewholder/ConferenceViewHolder.kt @@ -18,7 +18,6 @@ open class ConferenceViewHolder( itemCard.setOnClickListener { onItemClick(conference) } - } } } \ No newline at end of file diff --git a/app/src/main/java/com/droidfeed/ui/module/newsletter/NewsletterViewModel.kt b/app/src/main/java/com/droidfeed/ui/module/newsletter/NewsletterViewModel.kt index 4d411ce..4753654 100644 --- a/app/src/main/java/com/droidfeed/ui/module/newsletter/NewsletterViewModel.kt +++ b/app/src/main/java/com/droidfeed/ui/module/newsletter/NewsletterViewModel.kt @@ -1,15 +1,16 @@ package com.droidfeed.ui.module.newsletter +import android.util.Log import android.util.Patterns import androidx.annotation.StringRes import androidx.lifecycle.MutableLiveData import com.droidfeed.BuildConfig import com.droidfeed.R import com.droidfeed.data.DataStatus -import com.droidfeed.data.api.mailchimp.ErrorType -import com.droidfeed.data.api.mailchimp.MailchimpError -import com.droidfeed.data.api.mailchimp.Subscriber -import com.droidfeed.data.api.mailchimp.SubscriptionStatus +import com.droidfeed.data.api.mailchimp.model.ErrorType +import com.droidfeed.data.api.mailchimp.model.MailchimpError +import com.droidfeed.data.api.mailchimp.model.Subscriber +import com.droidfeed.data.api.mailchimp.model.SubscriptionStatus import com.droidfeed.data.repo.NewsletterRepo import com.droidfeed.ui.common.BaseViewModel import com.droidfeed.util.AnalyticsUtil @@ -74,6 +75,8 @@ class NewsletterViewModel @Inject constructor( } private fun handleSignUpResponse(dataStatus: DataStatus) { + Log.e("JAMIRYO", "5---- $dataStatus") + when (dataStatus) { is DataStatus.Successful -> { isEmailInputVisible.postValue(false) diff --git a/app/src/main/java/com/droidfeed/util/DebugUtils.kt b/app/src/main/java/com/droidfeed/util/DebugUtils.kt index 5b7d53d..266155c 100644 --- a/app/src/main/java/com/droidfeed/util/DebugUtils.kt +++ b/app/src/main/java/com/droidfeed/util/DebugUtils.kt @@ -11,9 +11,9 @@ private const val TAG = "DroidFeed" * * @param throwable */ -fun logThrowable(throwable: Throwable) { +fun logThrowable(throwable: Throwable?) { if (BuildConfig.DEBUG) { - throwable.printStackTrace() + throwable?.printStackTrace() } else { Crashlytics.logException(throwable) } diff --git a/app/src/main/res/layout/fragment_newsletter.xml b/app/src/main/res/layout/fragment_newsletter.xml index 3569a35..880845b 100644 --- a/app/src/main/res/layout/fragment_newsletter.xml +++ b/app/src/main/res/layout/fragment_newsletter.xml @@ -117,7 +117,7 @@ android:layout_marginTop="@dimen/spacing_small" android:layout_marginEnd="@dimen/spacing_xlarge" android:backgroundTint="@color/colorAccent" - android:onClick="@{(v)->viewModel.signUp(edtEmail.getText().toString)}" + android:onClick="@{(v)->viewModel.signUp(edtEmail.getText().toString())}" android:text="@string/sign_me_up" app:isVisible="@{viewModel.isSignButtonVisible}" app:layout_constraintEnd_toEndOf="parent" diff --git a/app/src/test/java/com/droidfeed/OnBoardViewModelTest.kt b/app/src/test/java/com/droidfeed/OnBoardViewModelTest.kt index 4633752..463887e 100644 --- a/app/src/test/java/com/droidfeed/OnBoardViewModelTest.kt +++ b/app/src/test/java/com/droidfeed/OnBoardViewModelTest.kt @@ -16,7 +16,6 @@ import org.junit.runners.JUnit4 import org.mockito.ArgumentMatchers import org.mockito.Mockito.* - @Suppress("TestFunctionName") @RunWith(JUnit4::class) class OnBoardViewModelTest { @@ -80,7 +79,6 @@ class OnBoardViewModelTest { verify(observer).onChanged(false) } - @Test fun WHEN_continue_button_is_clicked_THEN_open_main_activity() { runBlocking { @@ -95,5 +93,4 @@ class OnBoardViewModelTest { verify(observer, only()).onChanged(ArgumentMatchers.any()) } - } \ No newline at end of file diff --git a/build.gradle b/build.gradle index b04c584..f6f5e3b 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.3.1' + classpath 'com.android.tools.build:gradle:3.3.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin" classpath "org.jetbrains.kotlin:kotlin-android-extensions:$versions.kotlin" classpath "io.fabric.tools:gradle:$versions.fabric_gradle" diff --git a/dependencies.gradle b/dependencies.gradle index 7439bc2..994d415 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -17,7 +17,7 @@ ext.versions = [ crashlytics : '2.9.9', detekt_ktlint : '1.0.0-RC14', firebase_core : '16.0.7', - firebase_config : '16.3.0', + firebase_config : '16.1.3', firebase_firestore : '18.0.1', okHttp : '3.13.1', jSoup : '1.11.3', diff --git a/gradle.properties b/gradle.properties index 2448eb5..0e07386 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,6 +13,7 @@ android.enableJetifier=true android.useAndroidX=true org.gradle.jvmargs=-Xmx4096M android.databinding.enableV2=true +android.enableR8 = true # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects From 9efaf365d53291db9bdd1a0040319604db4388c3 Mon Sep 17 00:00:00 2001 From: dgngulcan Date: Mon, 4 Mar 2019 22:35:21 -0500 Subject: [PATCH 4/4] increment release version --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index ad40126..075c606 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,7 +6,7 @@ apply plugin: 'io.fabric' ext.app = [ 'version' : '2.1.5', - 'version_code' : 21, + 'version_code' : 22, 'compile_sdk_version': 28, 'min_sdk_version' : 21, 'target_sdk_version' : 28