Skip to content

Commit

Permalink
"Emergency" update - disabled some dynamic features
Browse files Browse the repository at this point in the history
  • Loading branch information
Javinator9889 committed Apr 22, 2020
1 parent a4a5f41 commit 8578cac
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG
@@ -1,5 +1,5 @@
## v1.1.1
+ New notifications handler - now they must notify when expected
+ New notifications handler - now you must get notified when expected

## v1.1.0
+ NEW: OkHttp for handling file downloading.
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Expand Up @@ -42,7 +42,7 @@ android {
applicationId "com.javinator9889.handwashingreminder"
minSdkVersion 17
targetSdkVersion 29
versionCode 105
versionCode 106
versionName "1.1.1-${gitCommitHash}"
multiDexEnabled true
resConfigs "en", "es"
Expand Down
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 @@ -189,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 @@ -40,6 +40,7 @@ class BootCompletedJob : BroadcastReceiver() {
else
app.activityHandler.disableActivityTracker()
try {
Timber.d("Enqueuing notifications as the device has rebooted")
with(WorkHandler(requireNotNull(context))) {
enqueuePeriodicNotificationsWorker()
}
Expand Down
Expand Up @@ -18,20 +18,18 @@
*/
package com.javinator9889.handwashingreminder.network

import com.javinator9889.handwashingreminder.utils.AndroidVersion
import com.javinator9889.handwashingreminder.utils.OkHttp
import com.javinator9889.handwashingreminder.utils.OkHttpLegacy
import com.javinator9889.handwashingreminder.utils.isAtLeast
import com.javinator9889.handwashingreminder.network.okhttp.OkHttpDownloader as Downloader

object HttpDownloader {
fun newInstance(): OkHttpDownloader {
val className = if (isAtLeast(AndroidVersion.LOLLIPOP))
/*val className = if (isAtLeast(AndroidVersion.LOLLIPOP))
"${OkHttp.PACKAGE_NAME}.${OkHttp.CLASS_NAME}\$${OkHttp.PROVIDER_NAME}"
else
"${OkHttpLegacy.PACKAGE_NAME}.${OkHttpLegacy
.CLASS_NAME}\$${OkHttpLegacy.PROVIDER_NAME}"
val okHttpProvider = Class.forName(className).kotlin.objectInstance
as OkHttpDownloader.Provider
return okHttpProvider.newInstance()
return okHttpProvider.newInstance()*/
return Downloader.newInstance()
}
}
@@ -0,0 +1,49 @@
/*
* Copyright © 2020 - present | Handwashing reminder by Javinator9889
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*
* Created by Javinator9889 on 21/04/20 - Handwashing reminder.
*/
package com.javinator9889.handwashingreminder.network.okhttp

import com.javinator9889.handwashingreminder.network.OkHttpDownloader
import okhttp3.CacheControl
import okhttp3.OkHttpClient
import okhttp3.Request
import okio.BufferedSource
import java.io.IOException

class OkHttpDownloader : OkHttpDownloader {
private val client = OkHttpClient()

companion object Provider : OkHttpDownloader.Provider {
override fun newInstance(): OkHttpDownloader = OkHttpDownloader()
}

override fun downloadFile(url: String): BufferedSource {
val request = with(Request.Builder()) {
url(url)
cacheControl(CacheControl.FORCE_NETWORK)
build()
}
with(client.newCall(request).execute()) {
if (!isSuccessful) {
close()
throw IOException("Unexpected code $this")
}
return body()!!.source()
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/values-es/strings.xml
Expand Up @@ -53,7 +53,7 @@
contenido a la aplicación para que funcione correctamente. Por favor,
espera un minuto - este proceso no debería durar mucho.</string>
<string name="dynamic_module_loading_error">¡Vaya! Algo ha ido
mal 😥 - intenta el proceso de nuevo</string>
mal 😥 - intenta el proceso de nuevo | código de error: %1$d</string>
<string name="done">Hecho</string>
<string name="preparing">Preparando…</string>
<string name="installing">Instalando…</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Expand Up @@ -52,7 +52,7 @@
content to the app so it works correctly. Please, wait a minute
- this process should not last long.</string>
<string name="dynamic_module_loading_error">Oops! Something went
wrong 😥 - please retry the process</string>
wrong 😥 - please retry the process | error code: %1$d</string>
<string name="done">Done</string>
<string name="preparing">Preparing…</string>
<string name="installing">Installing…</string>
Expand Down
Expand Up @@ -73,7 +73,7 @@ class IntroActivity : AppIntro2(),

override fun attachBaseContext(base: Context?) {
super.attachBaseContext(base)
SplitCompat.installActivity(base)
SplitCompat.installActivity(this)
}

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down

0 comments on commit 8578cac

Please sign in to comment.