Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update stuff #205

Merged
1 commit merged into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("com.android.application")
Expand All @@ -23,7 +24,7 @@ android {
applicationId = "de.dertyp7214.rboardthememanager"
minSdk = 23
targetSdk = 33
versionCode = 376000
versionCode = 376100
versionName = "3.7.6"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -59,7 +60,7 @@ android {
jvmTarget = JvmTarget.JVM_17.description
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = JvmTarget.JVM_17.description
}
Expand Down Expand Up @@ -103,7 +104,7 @@ dependencies {
implementation("com.google.android.material:material:1.8.0-rc01")
implementation("androidx.constraintlayout:constraintlayout:2.2.0-alpha05")
implementation("androidx.preference:preference-ktx:1.2.0")
implementation("androidx.activity:activity-ktx:1.7.0-alpha02")
implementation("androidx.activity:activity-ktx:1.7.0-alpha03")
implementation("androidx.fragment:fragment-ktx:1.6.0-alpha04")
implementation("com.jaredrummler:android-shell:1.0.0")
implementation("com.google.firebase:firebase-analytics:21.2.0")
Expand All @@ -122,6 +123,6 @@ dependencies {
implementation("com.github.murgupluoglu:flagkit-android:1.0.2")
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar", "*.aar"))))

debugImplementation("androidx.compose.ui:ui-tooling:1.4.0-alpha03")
debugImplementation("androidx.compose.ui:ui-tooling:1.4.0-alpha04")
implementation("org.jetbrains.kotlin:kotlin-reflect:1.8.0")
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import com.skydoves.balloon.BalloonSizeSpec
import com.skydoves.balloon.createBalloon
import com.topjohnwu.superuser.io.SuFile
import de.dertyp7214.rboardcomponents.utils.asyncInto
import de.dertyp7214.rboardcomponents.utils.doAsync
import de.dertyp7214.rboardthememanager.BuildConfig
import de.dertyp7214.rboardthememanager.Config
import de.dertyp7214.rboardthememanager.Config.MODULE_META
Expand Down Expand Up @@ -699,8 +700,8 @@ class MainActivity : AppCompatActivity() {
}
Config.useMagisk = false
ThemeUtils::loadThemes asyncInto mainViewModel::setThemes
}, onMagisk = {
it.dismiss()
}, onMagisk = { dialogFragment ->
dialogFragment.dismiss()
preferenceManager.edit {
putBoolean("useMagisk", true)
putBoolean("usageSet", true)
Expand Down Expand Up @@ -743,52 +744,54 @@ class MainActivity : AppCompatActivity() {
notify(this, notificationId, builder.build())
}
var finished = false
val url =
doAsync({
if (URL(Config.GITHUB_REPO_PREFIX).isReachable()) updateUrl(versionName) else updateUrlGitlab
UpdateHelper(url, this).apply {
addOnProgressListener { progress, bytes, total ->
if (!finished) {
builder
.setContentText(
getString(
R.string.download_update_progress,
"${bytes.toHumanReadableBytes(this@MainActivity)}/${
total.toHumanReadableBytes(this@MainActivity)
}"
}) { url ->
UpdateHelper(url, this).apply {
addOnProgressListener { progress, bytes, total ->
if (!finished) {
builder
.setContentText(
getString(
R.string.download_update_progress,
"${bytes.toHumanReadableBytes(this@MainActivity)}/${
total.toHumanReadableBytes(this@MainActivity)
}"
)
)
)
.setProgress(maxProgress, progress.toInt(), false)
notify(manager, notificationId, builder.build())
}
}
setFinishListener { path, _ ->
finished = true
manager.cancel(notificationId)
if (enableBlur) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
content.setRenderEffect(
RenderEffect.createBlurEffect(
10F,
10F,
Shader.TileMode.REPEAT
)
)
.setProgress(maxProgress, progress.toInt(), false)
notify(manager, notificationId, builder.build())
}
}
PackageUtils.install(this@MainActivity, File(path), downloadResultLauncher) {
setFinishListener { path, _ ->
finished = true
manager.cancel(notificationId)
if (enableBlur) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
content.setRenderEffect(null)
content.setRenderEffect(
RenderEffect.createBlurEffect(
10F,
10F,
Shader.TileMode.REPEAT
)
)
}
PackageUtils.install(this@MainActivity, File(path), downloadResultLauncher) {
if (enableBlur) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
content.setRenderEffect(null)
}
Toast.makeText(this@MainActivity, R.string.error, Toast.LENGTH_LONG).show()
}
Toast.makeText(this@MainActivity, R.string.error, Toast.LENGTH_LONG).show()
}
}
setErrorListener {
finished = true
builder.setContentText(getString(R.string.download_error))
.setProgress(0, 0, false)
notify(manager, notificationId, builder.build())
it?.connectionException?.printStackTrace()
Log.d("ERROR", it?.serverErrorMessage ?: "NOO")
}
}.start()
setErrorListener {
finished = true
builder.setContentText(getString(R.string.download_error))
.setProgress(0, 0, false)
notify(manager, notificationId, builder.build())
it?.connectionException?.printStackTrace()
Log.d("ERROR", it?.serverErrorMessage ?: "NOO")
}
}.start()
}
}

override fun onDestroy() {
Expand Down