Skip to content

Commit

Permalink
Verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesa2 committed Dec 12, 2022
1 parent 0aafd61 commit 544259b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}

Expand Down
1 change: 1 addition & 0 deletions githubAppUpdate/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'com.google.code.gson:gson:2.10'
implementation "androidx.work:work-runtime-ktx:2.7.1"
implementation 'com.github.AppDevNext.Logcat:LogcatCoreLib:2.12'

implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "androidx.appcompat:appcompat:1.5.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Build
import android.util.Log
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.coroutineScope
Expand All @@ -22,6 +21,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Response
import timber.log.Timber
import java.util.concurrent.TimeUnit


Expand Down Expand Up @@ -69,7 +69,7 @@ object AppUpdateHelper {
versionList.body()?.firstOrNull()?.let { release ->
val assetApk = release.assets.find { it.name.endsWith("release.apk") }

Log.d("AppUpdateHelper", release.tagName + " > " + currentVersionName + " " + (release.tagName > currentVersionName))
Timber.d(release.tagName + " > " + currentVersionName + " " + (release.tagName > currentVersionName))
callback?.invoke(release.tagName)
if (release.tagName > currentVersionName) {
askUser(activity, currentVersionName, release, assetApk)
Expand All @@ -78,7 +78,7 @@ object AppUpdateHelper {
}
}
} catch (e: Exception) {
Log.e("AppUpdateHelper", "git check deliver: ${e.message}")
Timber.e("git check deliver: ${e.message}")
Toast.makeText(activity, "git check delivers: ${e.message}", Toast.LENGTH_LONG).show()
}
}
Expand All @@ -91,19 +91,20 @@ object AppUpdateHelper {
){
try {
val versionList = requestVersionsSync(gitRepoUrl)

Timber.e("currentVersionName ${currentVersionName}")
versionList.body()?.firstOrNull()?.let { release ->
val assetApk = release.assets.find { it.name.endsWith("release.apk") }

Log.d("AppUpdateHelper", release.tagName + " > " + currentVersionName + " " + (release.tagName > currentVersionName))
Timber.d(release.tagName + " > " + currentVersionName + " " + (release.tagName > currentVersionName))
val text = "You use version $currentVersionName\n" +
"and there is a new version ${release.tagName}\n"
if (release.tagName > currentVersionName) {
Timber.w(text)
Notify.notification(appContext, text, "New version for '${getAppName(appContext)}'", assetApk, release)
}
}
} catch (e: Exception) {
Log.e("AppUpdateHelper", "git check deliver: ${e.message}")
Timber.e("git check deliver: ${e.message}")
}
}

Expand Down Expand Up @@ -143,15 +144,15 @@ object AppUpdateHelper {
}
.setPositiveButton(activity.getString(R.string.showRelease)) { dialog, _ ->
val uriUrl = Uri.parse(release.htmlUrl)
Log.d("open", uriUrl.toString())
Timber.d("open $uriUrl")
activity.startActivity(Intent(Intent.ACTION_VIEW, uriUrl))
dialog.dismiss()
}

assetApk?.let {
dialog.setNeutralButton(activity.getString(R.string.directDownload)) { dialog, _ ->
val uriUrl = Uri.parse(it.browserDownloadUrl)
Log.d("open", uriUrl.toString())
Timber.d("open $uriUrl")
activity.startActivity(Intent(Intent.ACTION_VIEW, uriUrl))
dialog.dismiss()
}
Expand Down

0 comments on commit 544259b

Please sign in to comment.