Skip to content
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
25 changes: 13 additions & 12 deletions app/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import java.util.Properties

plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
alias(libs.plugins.kotlin.serialization)
id("org.jetbrains.kotlin.plugin.parcelize")
id("com.google.dagger.hilt.android")
Expand Down Expand Up @@ -38,6 +37,8 @@ ktfmt {

kotlin { jvmToolchain(11) }

room { schemaDirectory("$projectDir/schemas") }

android {
namespace = "com.github.livingwithhippos.unchained"
compileSdk = 37
Expand All @@ -46,14 +47,12 @@ android {
applicationId = "com.github.livingwithhippos.unchained"
minSdk = 27
targetSdk = 37
versionCode = 59
versionName = "1.7.0"
versionCode = 60
versionName = "1.7.1"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

room { schemaDirectory("$projectDir/schemas") }

packaging {
jniLibs { excludes.addAll(listOf("META-INF/proguard/*")) }
resources {
Expand Down Expand Up @@ -89,12 +88,6 @@ android {
}

buildTypes {
applicationVariants.forEach { variant ->
variant.outputs
.map { it as com.android.build.gradle.internal.api.BaseVariantOutputImpl }
.forEach { it.outputFileName = "${variant.name}-${variant.versionName}.apk" }
}

debug {
versionNameSuffix = "-dev"
applicationIdSuffix = ".debug"
Expand Down Expand Up @@ -226,7 +219,15 @@ dependencies {
androidTestImplementation(libs.test.rules)
androidTestImplementation(libs.test.junit)
androidTestImplementation(libs.test.truth)
testImplementation(libs.test.core)
testImplementation(libs.junit)
testImplementation(libs.robolectric)
}

androidComponents {
onVariants(selector().all()) { variant ->
variant.outputs.forEach { output ->
val versionName = output.versionName.orNull ?: "unspecified"
output.outputFileName.set("${variant.name}-$versionName.apk")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import javax.inject.Inject
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import kotlin.time.Duration.Companion.milliseconds

/**
* A [ViewModel] subclass. It offers LiveData to be observed during the authentication process and
Expand Down Expand Up @@ -55,7 +56,7 @@ constructor(
val secretData = authRepository.getSecrets(credentials.deviceCode)
if (secretData != null) secretLiveData.postEvent(SecretResult.Retrieved(secretData))
else {
delay(SECRET_CALLS_DELAY)
delay(SECRET_CALLS_DELAY.milliseconds)
secretLiveData.postEvent(SecretResult.Empty)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.github.livingwithhippos.unchained.base

import android.app.Dialog
import android.os.Bundle
import androidx.core.os.bundleOf
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.setFragmentResult
import com.github.livingwithhippos.unchained.R
Expand All @@ -19,7 +18,11 @@ class DeleteDialogFragment : DialogFragment() {
.setMessage(R.string.confirm_item_removal_description)
.setTitle(title)
.setPositiveButton(R.string.delete) { _, _ ->
setFragmentResult("deleteActionKey", bundleOf("deleteConfirmation" to true))

val bundle = Bundle().apply {
putBoolean("deleteConfirmation", true)
}
setFragmentResult("deleteActionKey", bundle)
}
.setNegativeButton(R.string.close) { dialog, _ -> dialog.cancel() }
builder.create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import android.net.ConnectivityManager
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.Parcelable
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
Expand Down Expand Up @@ -60,6 +59,7 @@ import com.github.livingwithhippos.unchained.utilities.SIGNATURE
import com.github.livingwithhippos.unchained.utilities.TelemetryManager
import com.github.livingwithhippos.unchained.utilities.extension.downloadFileInStandardFolder
import com.github.livingwithhippos.unchained.utilities.extension.openExternalWebPage
import com.github.livingwithhippos.unchained.utilities.extension.parcelable
import com.github.livingwithhippos.unchained.utilities.extension.showToast
import com.github.livingwithhippos.unchained.utilities.extension.toHex
import com.google.android.material.bottomnavigation.BottomNavigationView
Expand All @@ -72,6 +72,7 @@ import javax.inject.Inject
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import timber.log.Timber
import kotlin.time.Duration.Companion.milliseconds

/** A [AppCompatActivity] subclass. Shared between all the fragments except for the preferences. */
@AndroidEntryPoint
Expand Down Expand Up @@ -385,10 +386,8 @@ class MainActivity : AppCompatActivity() {
},
)

// monitor if the torrent notification service needs to be started. It monitor the
// preference
// change itself
// for the shutting down part
// monitor if the torrent notification service needs to be started. It monitors the
// preference change itself for the shutting down part
preferences.registerOnSharedPreferenceChangeListener { sharedPreferences, key ->
if (key == KEY_TORRENT_NOTIFICATIONS) {
val enableTorrentNotifications = sharedPreferences.getBoolean(key, false)
Expand Down Expand Up @@ -485,7 +484,7 @@ class MainActivity : AppCompatActivity() {
when (viewModel.getDownloadManagerPreference()) {
PreferenceKeys.DownloadManager.SYSTEM -> {
val manager =
applicationContext.getSystemService(Context.DOWNLOAD_SERVICE)
applicationContext.getSystemService(DOWNLOAD_SERVICE)
as DownloadManager
var downloadsStarted = 0
content.downloads.forEach { download ->
Expand Down Expand Up @@ -525,7 +524,7 @@ class MainActivity : AppCompatActivity() {
if (viewModel.getDownloadOnUnmeteredOnlyPreference()) {
val connectivityManager =
applicationContext.getSystemService(
Context.CONNECTIVITY_SERVICE
CONNECTIVITY_SERVICE
) as ConnectivityManager
if (connectivityManager.isActiveNetworkMetered) {
applicationContext.showToast(
Expand Down Expand Up @@ -558,7 +557,7 @@ class MainActivity : AppCompatActivity() {
PreferenceKeys.DownloadManager.SYSTEM -> {

val manager =
applicationContext.getSystemService(Context.DOWNLOAD_SERVICE)
applicationContext.getSystemService(DOWNLOAD_SERVICE)
as DownloadManager

val queuedDownload =
Expand Down Expand Up @@ -592,7 +591,7 @@ class MainActivity : AppCompatActivity() {
if (viewModel.getDownloadOnUnmeteredOnlyPreference()) {
val connectivityManager =
applicationContext.getSystemService(
Context.CONNECTIVITY_SERVICE
CONNECTIVITY_SERVICE
) as ConnectivityManager
if (connectivityManager.isActiveNetworkMetered) {
applicationContext.showToast(
Expand Down Expand Up @@ -671,9 +670,8 @@ class MainActivity : AppCompatActivity() {
}

"*/*" -> {
// replace with intent.getParcelableExtra(Intent.EXTRA_STREAM,
// Uri::class.java) when stabilized
(intent.getParcelableExtra<Parcelable>(Intent.EXTRA_STREAM) as? Uri)?.let {
val data: Uri? = intent.parcelable(Intent.EXTRA_STREAM)
data?.let {
if (
it.lastPathSegment?.endsWith(TYPE_UNCHAINED, ignoreCase = true) ==
true
Expand Down Expand Up @@ -759,7 +757,7 @@ class MainActivity : AppCompatActivity() {

CurrentFSMAuthentication.Waiting -> {
// auth may become ok, delay and continue loop
delay(100)
delay(100.milliseconds)
}
}
}
Expand Down Expand Up @@ -798,13 +796,12 @@ class MainActivity : AppCompatActivity() {
private suspend fun doubleClickBottomItem(destinationID: Int) {
val bottomNav = findViewById<BottomNavigationView>(R.id.bottom_nav_view)

// if the tab was already selected, a single tap will bring us back to the first fragment of
// its
// navigation xml. Otherwise, simulate another click after a delay
// if the tab was already selected, a single tap will bring us back to the first fragment
// of its navigation XML. Otherwise, simulate another click after a delay
if (bottomNav.selectedItemId != destinationID) {
bottomNav.selectedItemId = destinationID
}
delay(100)
delay(100.milliseconds)
bottomNav.selectedItemId = destinationID
}

Expand Down Expand Up @@ -844,7 +841,7 @@ class MainActivity : AppCompatActivity() {

binding.bottomNavView.setupWithNavController(navController)

// Setup the ActionBar with navController and 3 top level destinations
// Set up the ActionBar with navController and 3 top level destinations
// these won't show a back/up arrow
appBarConfiguration =
AppBarConfiguration(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
adapter = StatAdapter(showLabel, showCaption, showIcon)
recyclerView.adapter = adapter

val layoutManager: FlexboxLayoutManager = FlexboxLayoutManager(context)
val layoutManager = FlexboxLayoutManager(context)
layoutManager.flexDirection =
if (direction == 1) FlexDirection.COLUMN else FlexDirection.ROW
layoutManager.justifyContent = JustifyContent.CENTER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import javax.inject.Inject

class AuthenticationRepository
@Inject
constructor(private val protoStore: ProtoStore, private val apiHelper: AuthApiHelper) :
constructor(protoStore: ProtoStore, private val apiHelper: AuthApiHelper) :
BaseRepository(protoStore) {

suspend fun getVerificationCode(): Authentication? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import kotlinx.coroutines.delay
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import kotlin.time.Duration.Companion.milliseconds

@Singleton
class UnrestrictRepository
Expand Down Expand Up @@ -72,7 +73,7 @@ constructor(protoStore: ProtoStore, private val unrestrictApiHelper: UnrestrictA
linksList.forEach {
unrestrictedLinks.add(getEitherUnrestrictedLink(it, password, remote))
// just to be on the safe side...
delay(callDelay)
delay(callDelay.milliseconds)
}
return unrestrictedLinks
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import javax.inject.Inject
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import timber.log.Timber
import kotlin.time.Duration.Companion.milliseconds

const val MAX_SERVICE_DURATION = 5 * 60 * 60 * 1000
const val MIN_SERVICE_DURATION = 20 * 60 * 1000
Expand Down Expand Up @@ -189,7 +190,7 @@ class ForegroundTorrentService : LifecycleService() {
// no valid token ready, retry later
}
// update notifications every 5 seconds
delay(updateTiming)
delay(updateTiming.milliseconds)
}
stopTorrentService()
}
Expand Down Expand Up @@ -293,7 +294,7 @@ class ForegroundTorrentService : LifecycleService() {
private fun stopTorrentService() {
lifecycleScope.launch {
// delay used to let the notification finish
delay(1000)
delay(1000.milliseconds)
notificationManager.cancel(SUMMARY_ID)
// this will avoid removing the notifications, so the user can see what happened in the
// meanwhile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,8 @@ class DownloadDetailsFragment : UnchainedFragment(), DownloadDetailsListener {
browserLayout.visibility = View.GONE
} else {
browserLayout.setOnClickListener {
{
context?.openExternalWebPage(RD_STREAMING_URL + args.details.id)
if (popup.isShowing) popup.dismiss()
}
context?.openExternalWebPage(RD_STREAMING_URL + args.details.id)
if (popup.isShowing) popup.dismiss()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlin.time.Duration.Companion.milliseconds

@HiltViewModel
class FolderListViewModel
Expand Down Expand Up @@ -109,7 +110,7 @@ constructor(
queryJob?.cancel()

queryJob = viewModelScope.launch {
delay(500)
delay(500.milliseconds)
if (isActive) queryLiveData.postValue(query?.trim() ?: "")
}
}
Expand Down
Loading