Skip to content

Commit

Permalink
Merge branch 'development' into 'master'
Browse files Browse the repository at this point in the history
WorkManager

See merge request Javinator9889/handwashing-reminder!5
  • Loading branch information
Javinator9889 committed Apr 23, 2020
2 parents 5d2d0a0 + a4f834b commit 8e6dd92
Show file tree
Hide file tree
Showing 38 changed files with 551 additions and 276 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -17,3 +17,4 @@ secrets.properties
api-5245190277294621651-718463-f914fb7573c6.json
*.jks
google-services.json
services.xml
3 changes: 3 additions & 0 deletions CHANGELOG
@@ -1,3 +1,6 @@
## v1.1.1
+ New notifications handler - now you must get notified when expected

## v1.1.0
+ NEW: OkHttp for handling file downloading.
+ Corrected a minor bug while displaying images.
Expand Down
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -66,6 +66,9 @@ will try to implement classic APK version.

[Download from Play Store](https://play.google.com/store/apps/details?id=com.javinator9889.handwashingreminder)

<a href='https://play.google.com/store/apps/details?id=com.javinator9889.handwashingreminder&pcampaignid=pcampaignidMKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1'>
<img alt='Get it on Google Play' src='https://play.google.com/intl/en_gb/badges/static/images/badges/en_badge_web_generic.png'/></a>

## Contributing
If you want to contribute:

Expand Down
2 changes: 1 addition & 1 deletion ads/build.gradle
Expand Up @@ -33,7 +33,7 @@ dependencies {
// https://developer.android.com/kotlin/ktx#play-core
implementation 'com.google.android.play:core-ktx:1.7.0'
// https://firebase.google.com/docs/admob/android/quick-start#import_the_mobile_ads_sdk
implementation 'com.google.firebase:firebase-ads:19.0.1'
implementation 'com.google.firebase:firebase-ads:19.1.0'
// https://developer.android.com/studio/build/multidex
implementation 'androidx.multidex:multidex:2.0.1'
// https://github.com/JakeWharton/timber
Expand Down
11 changes: 5 additions & 6 deletions app/build.gradle
Expand Up @@ -3,9 +3,8 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.mikepenz.aboutlibraries.plugin'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'com.google.firebase.crashlytics'


def secretsPropertiesFile = rootProject.file("secrets.properties")
Expand Down Expand Up @@ -43,8 +42,8 @@ android {
applicationId "com.javinator9889.handwashingreminder"
minSdkVersion 17
targetSdkVersion 29
versionCode 103
versionName "1.1.0-${gitCommitHash}"
versionCode 107
versionName "1.1.1-${gitCommitHash}"
multiDexEnabled true
resConfigs "en", "es"

Expand Down Expand Up @@ -143,7 +142,6 @@ dependencies {
// https://kotlinlang.org/docs/reference/reflection.html
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
// https://firebase.google.com/docs/android/setup#add-sdks
implementation 'com.google.firebase:firebase-core:17.3.0'
implementation 'com.google.firebase:firebase-common-ktx:19.3.0'
implementation 'com.google.firebase:firebase-analytics:17.3.0'
implementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta04'
Expand All @@ -152,6 +150,7 @@ dependencies {
implementation "com.airbnb.android:lottie:3.4.0"
// https://firebase.google.com/docs/remote-config/use-config-android
implementation 'com.google.firebase:firebase-config:19.1.3'
implementation 'com.google.firebase:firebase-config-ktx:19.1.3'
// https://developer.android.com/jetpack/androidx/releases/work#declaring_dependencies
implementation 'androidx.work:work-runtime-ktx:2.3.4'
// https://mvnrepository.com/artifact/androidx.emoji/emoji/1.0.0
Expand All @@ -172,7 +171,7 @@ dependencies {
// https://developer.android.com/jetpack/androidx/releases/lifecycle#declaring_dependencies
implementation 'androidx.lifecycle:lifecycle-viewmodel-savedstate:2.2.0'
// https://developer.android.com/reference/kotlin/androidx/preference/package-summary
implementation 'androidx.preference:preference:1.1.0'
implementation 'androidx.preference:preference:1.1.1'
// https://github.com/bumptech/glide
implementation 'com.github.bumptech.glide:glide:4.11.0'
kapt 'com.github.bumptech.glide:compiler:4.11.0'
Expand Down
5 changes: 5 additions & 0 deletions app/proguard-rules.pro
Expand Up @@ -14,6 +14,7 @@

# Uncomment this to preserve the line number information for
# debugging stack traces.
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
Expand Down Expand Up @@ -78,3 +79,7 @@

#data models
-keep class com.javinator9889.handwashingreminder.collections.** { *;}

# prevent Crashlytics obfuscation
-keep class com.google.firebase.crashlytics.** { *; }
-dontwarn com.google.firebase.crashlytics.**
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Expand Up @@ -8,6 +8,7 @@
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- Required for 29+. -->
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.INTERNET" />
Expand Down Expand Up @@ -75,6 +76,10 @@
</intent-filter>
</receiver>
<meta-data android:name="firebase_analytics_collection_enabled" android:value="false" />
<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="${applicationId}.firebaseinitprovider"
tools:node="remove" />
</application>

</manifest>
Expand Up @@ -116,9 +116,8 @@ class DynamicFeatureProgress : SplitCompatBaseActivity(),
SplitInstallSessionStatus.FAILED -> {
Toast.makeText(
this, getString(
R.string
.dynamic_module_loading_error
), Toast.LENGTH_LONG
R.string.dynamic_module_loading_error, state.errorCode),
Toast.LENGTH_LONG
).show()
Timber.e(
"Installation failed - error code: ${state.errorCode}"
Expand Down
Expand Up @@ -32,15 +32,17 @@ import com.google.android.gms.common.GoogleApiAvailability
import com.google.android.play.core.splitcompat.SplitCompat
import com.google.android.play.core.splitinstall.SplitInstallManagerFactory
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.ktx.Firebase
import com.google.firebase.perf.FirebasePerformance
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings
import com.google.firebase.remoteconfig.ktx.remoteConfig
import com.javinator9889.handwashingreminder.R
import com.javinator9889.handwashingreminder.application.HandwashingApplication
import com.javinator9889.handwashingreminder.emoji.EmojiLoader
import com.javinator9889.handwashingreminder.gms.ads.AdLoader
import com.javinator9889.handwashingreminder.gms.ads.AdsEnabler
import com.javinator9889.handwashingreminder.gms.vendor.BillingService
import com.javinator9889.handwashingreminder.jobs.workers.WorkHandler
import com.javinator9889.handwashingreminder.utils.*
import com.javinator9889.handwashingreminder.utils.Preferences.Companion.ADS_ENABLED
import com.javinator9889.handwashingreminder.utils.Preferences.Companion.APP_INIT_KEY
Expand All @@ -54,6 +56,7 @@ import timber.log.Timber
import java.security.Security
import java.util.*
import kotlin.collections.ArrayList
import com.javinator9889.handwashingreminder.utils.Firebase as FirebaseConf

internal const val FAST_START_KEY = "intent:fast_start"
internal const val PENDING_INTENT_CODE = 201
Expand Down Expand Up @@ -94,7 +97,8 @@ class LauncherActivity : AppCompatActivity() {
}

private suspend fun displayWelcomeScreen() {
val isThereAnySpecialEvent = with(FirebaseRemoteConfig.getInstance()) {
app.firebaseInitDeferred.await()
val isThereAnySpecialEvent = with(Firebase.remoteConfig) {
getBoolean(SPECIAL_EVENT) && !launchFromNotification
}
var sleepDuration = 0L
Expand Down Expand Up @@ -185,10 +189,10 @@ class LauncherActivity : AppCompatActivity() {
modules += AppIntro.MODULE_NAME
launchOnInstall = true
}
modules += if (isAtLeast(AndroidVersion.LOLLIPOP))
/*modules += if (isAtLeast(AndroidVersion.LOLLIPOP))
OkHttp.MODULE_NAME
else
OkHttpLegacy.MODULE_NAME
OkHttpLegacy.MODULE_NAME*/
if (googleApi.isGooglePlayServicesAvailable(
this,
GOOGLE_PLAY_SERVICES_MIN_VERSION
Expand Down Expand Up @@ -235,7 +239,9 @@ class LauncherActivity : AppCompatActivity() {
it.putExtra(DynamicFeatureProgress.PACKAGE_NAME, packageName)
}

private fun initVariables() {
private suspend fun initVariables() {
app.firebaseInitDeferred.await()
Timber.d("Firebase initialized correctly")
Timber.d("Initializing Iconics")
Iconics.init(this)
Timber.d("Setting-up security providers")
Expand All @@ -254,19 +260,17 @@ class LauncherActivity : AppCompatActivity() {
}
Timber.d("Initializing Billing Service")
app.billingService = BillingService(this)
try {
app.workHandler.enqueuePeriodicNotificationsWorker()
Timber.d("Adding periodic notifications if not enqueued yet")
} catch (_: UninitializedPropertyAccessException) {
Timber.i("Scheduler times have not been initialized")
with(WorkHandler(this)) {
enqueuePeriodicNotificationsWorker()
}
Timber.d("Adding periodic notifications if not enqueued yet")
Timber.d("Setting-up Firebase custom properties")
setupFirebaseProperties()
}

private fun setupFirebaseProperties() {
val firebaseAnalytics = FirebaseAnalytics.getInstance(this)
val firebaseRemoteConfig = FirebaseRemoteConfig.getInstance()
val firebaseRemoteConfig = Firebase.remoteConfig
val firebasePerformance = FirebasePerformance.getInstance()
val config = with(FirebaseRemoteConfigSettings.Builder()) {
minimumFetchIntervalInSeconds = 10
Expand All @@ -280,14 +284,14 @@ class LauncherActivity : AppCompatActivity() {
when (Locale.getDefault().language) {
Locale(LanguagesSupport.Language.SPANISH).language -> {
firebaseAnalytics.setUserProperty(
Firebase.Properties.LANGUAGE,
FirebaseConf.Properties.LANGUAGE,
LanguagesSupport.Language.SPANISH
)
R.xml.remote_config_defaults_es
}
else -> {
firebaseAnalytics.setUserProperty(
Firebase.Properties.LANGUAGE,
FirebaseConf.Properties.LANGUAGE,
LanguagesSupport.Language.ENGLISH
)
R.xml.remote_config_defaults
Expand Down
Expand Up @@ -29,8 +29,9 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.ktx.Firebase
import com.google.firebase.perf.metrics.AddTrace
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
import com.google.firebase.remoteconfig.ktx.remoteConfig
import com.javinator9889.handwashingreminder.R
import com.javinator9889.handwashingreminder.activities.support.ActionBarBase
import com.javinator9889.handwashingreminder.activities.views.fragments.diseases.DiseasesFragment
Expand Down Expand Up @@ -61,7 +62,7 @@ class MainActivity : ActionBarBase(),
with(FirebaseAnalytics.getInstance(this)) {
setCurrentScreen(this@MainActivity, "Main view", null)
}
with(FirebaseRemoteConfig.getInstance()) {
with(Firebase.remoteConfig) {
fetchAndActivate()
}
delegateMenuIcons(menu)
Expand Down
Expand Up @@ -21,7 +21,8 @@ package com.javinator9889.handwashingreminder.activities.views.fragments.news
import android.os.Bundle
import android.view.View
import androidx.annotation.LayoutRes
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
import com.google.firebase.ktx.Firebase
import com.google.firebase.remoteconfig.ktx.remoteConfig
import com.javinator9889.handwashingreminder.R
import com.javinator9889.handwashingreminder.activities.base.BaseFragmentView
import com.javinator9889.handwashingreminder.utils.RemoteConfig
Expand All @@ -40,7 +41,7 @@ class NewsFragment : BaseFragmentView() {
ARG_UNDER_CONSTRUCTION_TEXT
)
} else {
with(FirebaseRemoteConfig.getInstance()) {
with(Firebase.remoteConfig) {
underConstructionText.text =
getString(RemoteConfig.WORK_IN_PROGRESS)
}
Expand Down
Expand Up @@ -45,6 +45,8 @@ class ActivityCheckbox : CheckBoxPreference {
defStyleRes: Int
) : super(context, attrs, defStyleAttr, defStyleRes)

private var firstCheck = true

init {
var isViewDisabled = false
with(GoogleApiAvailability.getInstance()) {
Expand Down Expand Up @@ -83,6 +85,10 @@ class ActivityCheckbox : CheckBoxPreference {

override fun setChecked(checked: Boolean) {
super.setChecked(checked)
if (firstCheck) {
firstCheck = false
return
}
with(HandwashingApplication.getInstance()) {
if (checked) {
activityHandler.startTrackingActivity()
Expand Down
Expand Up @@ -29,6 +29,7 @@ import com.mikepenz.iconics.utils.sizeDp
import java.util.*

class ActivityMultiSelectList : MultiSelectListPreference {
private var isFirstCall = true
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) :
Expand All @@ -48,7 +49,10 @@ class ActivityMultiSelectList : MultiSelectListPreference {
override fun notifyChanged() {
super.notifyChanged()
loadSummary()
reloadActivityHandler()
if (!isFirstCall)
reloadActivityHandler()
else
isFirstCall = false
}

private fun loadSummary() {
Expand Down
Expand Up @@ -27,7 +27,8 @@ import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.liveData
import com.beust.klaxon.Klaxon
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
import com.google.firebase.ktx.Firebase
import com.google.firebase.remoteconfig.ktx.remoteConfig
import com.javinator9889.handwashingreminder.collections.DiseasesInformation
import com.javinator9889.handwashingreminder.collections.DiseasesList
import com.javinator9889.handwashingreminder.collections.DiseasesListWrapper
Expand Down Expand Up @@ -55,7 +56,7 @@ class DiseaseInformationViewModel(
state.get<List<DiseasesInformation>>(PARSED_JSON_KEY)!!
)
val diseasesString =
with(FirebaseRemoteConfig.getInstance()) {
with(Firebase.remoteConfig) {
getString(DISEASES_JSON)
}
Klaxon().parse<DiseasesList>(diseasesString)
Expand Down
Expand Up @@ -42,7 +42,6 @@ import java.io.FileInputStream
import java.io.InputStream
import java.math.BigInteger
import java.security.MessageDigest
import javax.inject.Inject

private const val LIVEDATA_KEY = "videomodel:livedata"

Expand Down Expand Up @@ -128,7 +127,7 @@ class VideoModel(
}
}

class VideoModelFactory @Inject constructor(private val position: Int) :
class VideoModelFactory constructor(private val position: Int) :
ViewModelAssistedFactory<VideoModel> {
override fun create(handle: SavedStateHandle) = VideoModel(handle, position)
}
Expand Up @@ -27,7 +27,6 @@ import androidx.lifecycle.liveData
import com.javinator9889.handwashingreminder.R
import com.javinator9889.handwashingreminder.application.HandwashingApplication
import com.javinator9889.handwashingreminder.emoji.EmojiLoader
import javax.inject.Inject

internal data class Measurements(var width: Int, var height: Int)

Expand Down Expand Up @@ -102,7 +101,7 @@ class WashingHandsModel(
}
}

class WashingHandsModelFactory @Inject constructor(
class WashingHandsModelFactory constructor(
private val position: Int
) : ViewModelAssistedFactory<WashingHandsModel> {
override fun create(handle: SavedStateHandle) =
Expand Down

0 comments on commit 8e6dd92

Please sign in to comment.