Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from Irineu333/release/v1.0.2
Browse files Browse the repository at this point in the history
Release/v1.0.2

feat: added Neo Utils apps divulgation
fix: correcting BottomSheet expanded bug
feat: create config help
feat: enabled firebase persistence
feat: added force update
  • Loading branch information
Irineu333 authored Jan 7, 2022
2 parents db32837 + 3e4cefa commit dd219e8
Show file tree
Hide file tree
Showing 29 changed files with 487 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .idea/.name

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

4 changes: 2 additions & 2 deletions .idea/deploymentTargetDropDown.xml

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

4 changes: 4 additions & 0 deletions .idea/misc.xml

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

7 changes: 5 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ android {
applicationId "com.neo.fbrules"
minSdk 21
targetSdk 31
versionCode 2
versionName "1.0.1"
versionCode 3
versionName "1.0.2"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -79,6 +79,9 @@ dependencies {
//Highlight library
implementation "com.github.NeoUtils:Highlight:1.0.4"

//Load images
implementation "io.coil-kt:coil:1.4.0"

def lifecycle_version = "2.4.0"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
Expand Down
5 changes: 0 additions & 5 deletions app/src/debug/res/mipmap-anydpi-v26/ic_launcher.xml

This file was deleted.

5 changes: 0 additions & 5 deletions app/src/debug/res/mipmap-anydpi-v26/ic_launcher_round.xml

This file was deleted.

9 changes: 9 additions & 0 deletions app/src/main/java/com/neo/fbrules/App.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
package com.neo.fbrules

import android.app.Application
import com.google.firebase.FirebaseApp
import com.google.firebase.database.FirebaseDatabase
import com.google.firebase.ktx.Firebase
import com.neo.fbrules.util.environment
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class App : Application() {
override fun onCreate() {

FirebaseDatabase
.getInstance()
.setPersistenceEnabled(true)

environment = getString(R.string.environment)

super.onCreate()
}
}
57 changes: 57 additions & 0 deletions app/src/main/java/com/neo/fbrules/core/NeoUtilsAppsManager.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.neo.fbrules.core

import com.google.firebase.crashlytics.ktx.crashlytics
import com.google.firebase.database.DataSnapshot
import com.google.firebase.database.DatabaseError
import com.google.firebase.database.ValueEventListener
import com.google.firebase.ktx.Firebase
import com.neo.fbrules.main.presenter.model.NeoUtilsApp
import com.neo.fbrules.util.firebaseEnvironment


class NeoUtilsAppsManager(
private val appsListener: AppsListener
) : ValueEventListener {

private val fbNeoUtilsAppsManager =
firebaseEnvironment.child("neo_utils_apps")

init {
fbNeoUtilsAppsManager.addValueEventListener(this)
}

interface AppsListener {
fun change(apps: List<NeoUtilsApp>)
}

override fun onDataChange(snapshot: DataSnapshot) {

val neoUtilsApp = mutableListOf<NeoUtilsApp>()

for (child in snapshot.children) {

runCatching {
val name = child.child("name").value as String
val packageName = child.child("package").value as String
val url = child.child("url").value as String
val iconUrl = child.child("icon").value as String

neoUtilsApp.add(
NeoUtilsApp(
name = name,
packageName = packageName,
url = url,
iconUrl = iconUrl
)
)
}.onFailure {
Firebase.crashlytics.recordException(it)
}
}

appsListener.change(neoUtilsApp)

}

override fun onCancelled(error: DatabaseError) = Unit
}
12 changes: 10 additions & 2 deletions app/src/main/java/com/neo/fbrules/core/UpdateManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.google.firebase.database.ValueEventListener
import com.google.firebase.ktx.Firebase
import com.neo.fbrules.BuildConfig
import com.neo.fbrules.util.firebaseEnvironment

class UpdateManager(
private val updateListener: UpdateListener
) : ValueEventListener {
Expand All @@ -27,14 +28,16 @@ class UpdateManager(
val downloadLink = snapshot.child("download_link").value as String
val lastVersionCode = snapshot.child("last_version_code").value as Long
val lastVersionName = snapshot.child("last_version_name").value as String
val forceUpdate = snapshot.child("force").value as? Boolean ?: false

if (versionCode == lastVersionCode.toInt()) {
updateListener.updated()
} else {
updateListener.hasUpdate(
lastVersionCode.toInt(),
lastVersionName,
downloadLink
downloadLink,
forceUpdate
)
}
}
Expand All @@ -47,6 +50,11 @@ class UpdateManager(

interface UpdateListener {
fun updated()
fun hasUpdate(lastVersionCode: Int, lastVersionName: String, downloadLink: String)
fun hasUpdate(
lastVersionCode: Int,
lastVersionName: String,
downloadLink: String,
force: Boolean
)
}
}
Loading

0 comments on commit dd219e8

Please sign in to comment.