Skip to content
Permalink
Browse files

Merge branch 'development' into 'master'

Development

See merge request Javinator9889/handwashing-reminder!2
  • Loading branch information
Javinator9889 committed Apr 21, 2020
2 parents d39bb8f + 0b41adc commit ab93543930827cc796d372c132bdbceeb9d325ac
Showing with 239 additions and 138 deletions.
  1. +2 −2 app/build.gradle
  2. +11 −1 app/src/main/AndroidManifest.xml
  3. +3 −3 app/src/main/java/com/javinator9889/handwashingreminder/activities/DynamicFeatureProgress.kt
  4. +47 −15 app/src/main/java/com/javinator9889/handwashingreminder/activities/LauncherActivity.kt
  5. +11 −4 app/src/main/java/com/javinator9889/handwashingreminder/activities/MainActivity.kt
  6. +2 −5 app/src/main/java/com/javinator9889/handwashingreminder/activities/PrivacyTermsActivity.kt
  7. +0 −1 ...ain/java/com/javinator9889/handwashingreminder/activities/views/fragments/diseases/adapter/Ads.kt
  8. +3 −1 ...ava/com/javinator9889/handwashingreminder/activities/views/fragments/settings/ActivityCheckbox.kt
  9. +18 −16 ...in/java/com/javinator9889/handwashingreminder/activities/views/fragments/settings/SettingsView.kt
  10. +0 −5 ...com/javinator9889/handwashingreminder/activities/views/fragments/settings/TimePickerPreference.kt
  11. +38 −12 .../java/com/javinator9889/handwashingreminder/activities/views/fragments/washinghands/SliderView.kt
  12. +4 −1 ...javinator9889/handwashingreminder/activities/views/fragments/washinghands/WashingHandsFragment.kt
  13. +2 −2 .../com/javinator9889/handwashingreminder/activities/views/viewmodels/DiseaseInformationViewModel.kt
  14. +2 −34 app/src/main/java/com/javinator9889/handwashingreminder/application/HandwashingApplication.kt
  15. +32 −0 app/src/main/java/com/javinator9889/handwashingreminder/jobs/UpdateReceiver.kt
  16. +14 −6 app/src/main/java/com/javinator9889/handwashingreminder/jobs/workers/NotificationsWorker.kt
  17. +4 −4 app/src/main/java/com/javinator9889/handwashingreminder/jobs/workers/WorkHandler.kt
  18. +23 −15 appintro/src/main/java/com/javinator9889/handwashingreminder/appintro/IntroActivity.kt
  19. +11 −5 appintro/src/main/java/com/javinator9889/handwashingreminder/appintro/config/TimeConfigActivity.kt
  20. +11 −5 ...o/src/main/java/com/javinator9889/handwashingreminder/appintro/timeconfig/TimeConfigViewHolder.kt
  21. +1 −1 tgs
@@ -43,8 +43,8 @@ android {
applicationId "com.javinator9889.handwashingreminder"
minSdkVersion 17
targetSdkVersion 29
versionCode 91
versionName "1.0-${gitCommitHash}"
versionCode 94
versionName "1.0.1-${gitCommitHash}"
multiDexEnabled true

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -58,7 +58,17 @@
android:exported="true">
</receiver>

<receiver android:name=".jobs.BootCompletedJob"
<receiver
android:name=".jobs.UpdateReceiver"
android:enabled="true">
<intent-filter>
<action
android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter>
</receiver>

<receiver
android:name=".jobs.BootCompletedJob"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
@@ -31,10 +31,10 @@ import com.google.android.play.core.splitinstall.SplitInstallRequest
import com.google.android.play.core.splitinstall.SplitInstallSessionState
import com.google.android.play.core.splitinstall.SplitInstallStateUpdatedListener
import com.google.android.play.core.splitinstall.model.SplitInstallSessionStatus
import com.google.firebase.analytics.FirebaseAnalytics
import com.javinator9889.handwashingreminder.BuildConfig
import com.javinator9889.handwashingreminder.R
import com.javinator9889.handwashingreminder.activities.base.SplitCompatBaseActivity
import com.javinator9889.handwashingreminder.application.HandwashingApplication
import com.javinator9889.handwashingreminder.utils.AndroidVersion
import com.javinator9889.handwashingreminder.utils.CONFIRMATION_REQUEST_CODE
import com.javinator9889.handwashingreminder.utils.filterNotEmpty
@@ -60,8 +60,8 @@ class DynamicFeatureProgress : SplitCompatBaseActivity(),
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
splitInstallManager.registerListener(this)
with(HandwashingApplication.getInstance()) {
firebaseAnalytics.setCurrentScreen(
with(FirebaseAnalytics.getInstance(this)) {
setCurrentScreen(
this@DynamicFeatureProgress, "Dynamic module", null
)
}
@@ -31,6 +31,9 @@ import com.google.android.gms.common.ConnectionResult
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.perf.FirebasePerformance
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings
import com.javinator9889.handwashingreminder.R
import com.javinator9889.handwashingreminder.application.HandwashingApplication
@@ -43,16 +46,20 @@ import com.javinator9889.handwashingreminder.utils.Preferences.Companion.ADS_ENA
import com.javinator9889.handwashingreminder.utils.Preferences.Companion.APP_INIT_KEY
import com.javinator9889.handwashingreminder.utils.RemoteConfig.Keys.SPECIAL_EVENT
import com.mikepenz.iconics.Iconics
import javinator9889.localemanager.utils.languagesupport.LanguagesSupport
import kotlinx.android.synthetic.main.splash_screen.*
import kotlinx.coroutines.*
import timber.log.Timber
import java.util.*
import kotlin.collections.ArrayList

internal const val FAST_START_KEY = "intent:fast_start"
internal const val PENDING_INTENT_CODE = 201

class LauncherActivity : AppCompatActivity() {
private var launchOnInstall = false
private var launchFromNotification = false
private var canFinishActivity = false
private lateinit var app: HandwashingApplication
private lateinit var initDeferred: Deferred<Unit>

@@ -85,9 +92,9 @@ class LauncherActivity : AppCompatActivity() {
}

private suspend fun displayWelcomeScreen() {
val isThereAnySpecialEvent =
app.remoteConfig.getBoolean(SPECIAL_EVENT) &&
!launchFromNotification
val isThereAnySpecialEvent = with(FirebaseRemoteConfig.getInstance()) {
getBoolean(SPECIAL_EVENT) && !launchFromNotification
}
var sleepDuration = 0L
var animationLoaded = false
val fadeInAnimation =
@@ -161,13 +168,16 @@ class LauncherActivity : AppCompatActivity() {
overridePendingTransition(0, android.R.anim.fade_out)
}
}
finish()
if (canFinishActivity)
finish()
else
canFinishActivity = true
}
}

override fun finish() {
Timber.d("Calling finish")
super.finish()
overridePendingTransition(0, android.R.anim.fade_out)
}

private fun installRequiredModules() {
@@ -216,6 +226,8 @@ class LauncherActivity : AppCompatActivity() {
}

private fun initVariables() {
Timber.d("Initializing Iconics")
Iconics.init(this)
if (app.sharedPreferences.getBoolean(
Preferences.ACTIVITY_TRACKING_ENABLED, false
) && with(GoogleApiAvailability.getInstance()) {
@@ -227,42 +239,62 @@ class LauncherActivity : AppCompatActivity() {
} else {
app.activityHandler.disableActivityTracker()
}

setupFirebaseProperties()
app.billingService = BillingService(this)
Timber.d("Initializing Iconics")
Iconics.init(this)
try {
app.workHandler.enqueuePeriodicNotificationsWorker()
Timber.d("Adding periodic notifications if not enqueued yet")
} catch (_: UninitializedPropertyAccessException) {
Timber.i("Scheduler times have not been initialized")
}
setupFirebaseProperties()
}

private fun setupFirebaseProperties() {
val firebaseAnalytics = FirebaseAnalytics.getInstance(this)
val firebaseRemoteConfig = FirebaseRemoteConfig.getInstance()
val firebasePerformance = FirebasePerformance.getInstance()
val config = with(FirebaseRemoteConfigSettings.Builder()) {
minimumFetchIntervalInSeconds = 10
fetchTimeoutInSeconds = 5
build()
}
with(app.remoteConfig) {
with(firebaseRemoteConfig) {
Timber.d("Initializing Firebase Remote Config")
setConfigSettingsAsync(config)
setDefaultsAsync(app.remoteConfigSettings)
fetchAndActivate()
setDefaultsAsync(when (Locale.getDefault().language) {
Locale(LanguagesSupport.Language.SPANISH).language -> {
firebaseAnalytics.setUserProperty(
Firebase.Properties.LANGUAGE,
LanguagesSupport.Language.SPANISH
)
R.xml.remote_config_defaults_es
}
else -> {
firebaseAnalytics.setUserProperty(
Firebase.Properties.LANGUAGE,
LanguagesSupport.Language.ENGLISH
)
R.xml.remote_config_defaults
}
})
fetchAndActivate().addOnSuccessListener {
if (canFinishActivity)
finish()
else
canFinishActivity = true
}
}
app.firebaseAnalytics.setAnalyticsCollectionEnabled(
firebaseAnalytics.setAnalyticsCollectionEnabled(
app.sharedPreferences.getBoolean(
Preferences.ANALYTICS_ENABLED,
true
)
)
app.firebasePerformance.isPerformanceCollectionEnabled =
firebasePerformance.isPerformanceCollectionEnabled =
app.sharedPreferences.getBoolean(
Preferences.PERFORMANCE_ENABLED,
true
)
Timber.d("Performance enabled: ${app.firebasePerformance.isPerformanceCollectionEnabled}")
Timber.d("Performance enabled: ${firebasePerformance.isPerformanceCollectionEnabled}")
}
}
@@ -28,7 +28,9 @@ import androidx.core.view.forEach
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.perf.metrics.AddTrace
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
import com.javinator9889.handwashingreminder.R
import com.javinator9889.handwashingreminder.activities.support.ActionBarBase
import com.javinator9889.handwashingreminder.activities.views.fragments.diseases.DiseasesFragment
@@ -56,9 +58,12 @@ class MainActivity : ActionBarBase(),
@AddTrace(name = "onCreateMainView")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
app = HandwashingApplication.getInstance()
app.firebaseAnalytics.setCurrentScreen(this, "Main view", null)
app.remoteConfig.fetchAndActivate()
with(FirebaseAnalytics.getInstance(this)) {
setCurrentScreen(this@MainActivity, "Main view", null)
}
with(FirebaseRemoteConfig.getInstance()) {
fetchAndActivate()
}
delegateMenuIcons(menu)
val ids =
arrayOf(R.id.diseases, R.id.handwashing, R.id.news, R.id.settings)
@@ -123,7 +128,9 @@ class MainActivity : ActionBarBase(),
R.id.settings -> "settings"
else -> "Main view"
}
app.firebaseAnalytics.setCurrentScreen(this, screenTitle, null)
with(FirebaseAnalytics.getInstance(this)) {
setCurrentScreen(this@MainActivity, screenTitle, null)
}
return onItemSelected(item.itemId)
}

@@ -25,7 +25,6 @@ import com.google.android.material.tabs.TabLayoutMediator
import com.google.firebase.analytics.FirebaseAnalytics
import com.javinator9889.handwashingreminder.R
import com.javinator9889.handwashingreminder.activities.support.ActionBarBase
import com.javinator9889.handwashingreminder.application.HandwashingApplication
import com.javinator9889.handwashingreminder.collections.PrivacyTermsCollectionAdapter
import kotlinx.android.synthetic.main.disease_view_expanded.*

@@ -39,11 +38,9 @@ class PrivacyTermsActivity : ActionBarBase() {
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowTitleEnabled(true)

with(HandwashingApplication.getInstance()) {
with(FirebaseAnalytics.getInstance(this)) {
val bundle = Bundle(1).apply { putString("view", "privacy") }
firebaseAnalytics.logEvent(
FirebaseAnalytics.Event.VIEW_ITEM, bundle
)
logEvent(FirebaseAnalytics.Event.VIEW_ITEM, bundle)
}

val adapter = PrivacyTermsCollectionAdapter(this)
@@ -47,6 +47,5 @@ class Ads : AbstractItem<Ads.ViewHolder>() {
it.destroy()
}
}

}
}
@@ -28,6 +28,8 @@ import com.google.android.gms.common.ConnectionResult
import com.google.android.gms.common.GoogleApiAvailability
import com.javinator9889.handwashingreminder.R
import com.javinator9889.handwashingreminder.application.HandwashingApplication
import com.javinator9889.handwashingreminder.utils.AndroidVersion
import com.javinator9889.handwashingreminder.utils.isAtLeast
import com.mikepenz.iconics.IconicsDrawable
import com.mikepenz.iconics.typeface.library.ionicons.Ionicons
import com.mikepenz.iconics.utils.sizeDp
@@ -57,7 +59,7 @@ class ActivityCheckbox : CheckBoxPreference {
if (!isViewDisabled) {
if (ContextCompat.checkSelfPermission(
context, Manifest.permission.ACTIVITY_RECOGNITION
) == PERMISSION_DENIED
) == PERMISSION_DENIED && isAtLeast(AndroidVersion.Q)
) {
isViewDisabled = true
summaryOff =
@@ -34,6 +34,7 @@ import androidx.preference.SwitchPreference
import com.afollestad.materialdialogs.MaterialDialog
import com.android.billingclient.api.BillingClient.BillingResponseCode
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.perf.FirebasePerformance
import com.javinator9889.handwashingreminder.R
import com.javinator9889.handwashingreminder.activities.PrivacyTermsActivity
import com.javinator9889.handwashingreminder.application.HandwashingApplication
@@ -109,9 +110,9 @@ class SettingsView : PreferenceFragmentCompat(),
share?.let {
it.icon = icon(Ionicons.Icon.ion_android_share)
it.setOnPreferenceClickListener {
app.firebaseAnalytics.logEvent(
FirebaseAnalytics.Event.SHARE, null
)
with(FirebaseAnalytics.getInstance(requireContext())) {
logEvent(FirebaseAnalytics.Event.SHARE, null)
}
with(Intent.createChooser(Intent().apply {
action = Intent.ACTION_SEND
putExtra(
@@ -251,9 +252,9 @@ class SettingsView : PreferenceFragmentCompat(),
val bundle = Bundle(1).apply {
putString("view", "libs")
}
app.firebaseAnalytics.logEvent(
FirebaseAnalytics.Event.VIEW_ITEM, bundle
)
with(FirebaseAnalytics.getInstance(requireContext())) {
logEvent(FirebaseAnalytics.Event.VIEW_ITEM, bundle)
}
LibsBuilder()
.withAutoDetect(true)
.withFields(R.string::class.java.fields)
@@ -335,17 +336,19 @@ class SettingsView : PreferenceFragmentCompat(),
::firebaseAnalyticsPreference.isInitialized &&
preference == firebaseAnalyticsPreference.get() -> {
val enabled = newValue as Boolean
app.firebaseAnalytics.setAnalyticsCollectionEnabled(enabled)
if (!enabled)
app.firebaseAnalytics.setCurrentScreen(
requireActivity(), null, null
)
with(FirebaseAnalytics.getInstance(requireContext())) {
setAnalyticsCollectionEnabled(enabled)
if (!enabled)
setCurrentScreen(requireActivity(), null, null)
}
true
}
::firebasePerformancePreference.isInitialized &&
preference == firebasePerformancePreference.get() -> {
val enabled = newValue as Boolean
app.firebasePerformance.isPerformanceCollectionEnabled = enabled
with(FirebasePerformance.getInstance()) {
isPerformanceCollectionEnabled = enabled
}
true
}
::adsPreference.isInitialized &&
@@ -483,10 +486,9 @@ class SettingsView : PreferenceFragmentCompat(),
return
val website = Uri.parse(url)
val bundle = Bundle(1).apply { putString("url", url) }
app.firebaseAnalytics.logEvent(
FirebaseAnalytics.Event.VIEW_ITEM,
bundle
)
with(FirebaseAnalytics.getInstance(requireContext())) {
logEvent(FirebaseAnalytics.Event.VIEW_ITEM, bundle)
}
with(Intent(Intent.ACTION_VIEW, website)) {
if (resolveActivity(requireContext().packageManager) !=
null
@@ -57,11 +57,6 @@ class TimePickerPreference : EditTextPreference,
setSummary(time ?: text)
}

/*override fun onSetInitialValue(defaultValue: Any?) {
text = getPersistedString("00:00")
setSummary(text)
}*/

override fun onClick() {
val time = text.split(":")
val tpHour = Integer.parseInt(time[0])

0 comments on commit ab93543

Please sign in to comment.